akhauriyash/Code-Regression huggingface dataset:
/*{{{*/
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <stdlib.h>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
#include <complex>

using namespace             std;
typedef long long           ll;
typedef unsigned long long  ull;
typedef pair<ll, ll>        P;
const double                PIE = 3.141592;

#define rep_n(i, a, b)  for (int i=a; i<b; i++)
#define rep(i, n)       rep_n(i, 0, n)
#define all(v)          (v).begin(), (v).end()
#define item(v)         sizeof(v)/sizeof(v[0])
#define tov(v)          v, v+item(v)
#define mp(x, y)        make_pair(x, y)
#define mset(x, y)      memset(x, y, sizeof(x))
#define chmin(x,y)      (x=min(x, y))
#define chmax(x,y)      (x=max(x, y))
#define SORTI(v)        sort(v, v+item(v))
#define SORT(v)         sort(d.begin(), d.end());
#define UNIQUE(x)       x.erase(unique(all(x)), x.end())
#define ins(x, y, z)    x.insert(x.begin()+y, z)
#define era(x, y)       x.erase(x.begin()+y)
#define era1(x, y, z)   x.erase(x.begin()+y, x.begin()+z)
#define COUNT(x, y)     count(all(x), y)
#define FIND(x, y)      find(all(x), y) - x.begin()
#define ASSIGN(x, y)    x.assign(&a[0], &a[item(a)-1])

#define ci1(a)          cin>>a 
#define ci2(a, b)       cin>>a>>b
#define ci3(a, b, c)    cin>>a>>b>>c
#define ci4(a, b, c, d) cin>>a>>b>>c>>d
#define co1(a)          cout<<a<<endl;
#define co2(a, b)       cout<<a<<" "<<b<<endl;
#define co3(a, b, c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define co4(a, b, c, d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
/*}}}*/

ll x, y, z, ans;
vector<ll> v;

int main() {
    ci3(x, y, z);

    if ((z-y-1)%2==1) co1("Alice");
    if ((z-y-1)%2==0) co1("Borys");

}

///*debug*/co1();


Measured memory_bytes: 256
N, K = map(int,input().split())
A = list(map(int,input().split()))

ans = 0

for i in range(min(N,K)+1):
  for j in range(min(N,K)+1-i):
    if j == 0:
      st = A[:i]
    else:
      st = A[:i]+ A[-j:]
    st.sort(reverse = 1)
    for suteru in range(K - i - j+1):
      ans = max(ans, sum(st[:i+j-suteru]))
    
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

struct UnionFind{
  vector<int> par; //親
  vector<int> size; //集合の大きさ

  UnionFind(int n){
    par.resize(n); size.resize(n, 1);
    for(int i = 0; i < n; i++){
      par[i] = i;
    }
  }

  //木の根を求める
  int root(int x){
    if(par[x] == x){
      return x;
    }else{
      return par[x] = root(par[x]);
    }
  }

  //xとyの属する集合を併合
  void unite(int x,int y){
    x = root(x), y = root(y);
    if(x == y) return;
    if(size[x] < size[y]) swap(x,y);
    par[y] = x;
    size[x] += size[y];
  }

  bool same(int x, int y){
    return root(x) == root(y);
  }
};

signed main(){

  int n, m, k; cin >> n >> m >> k;
  UnionFind uf(n);
  vector<int> g(n);
  vector<vector<int>> ok(n), ng(n);
  for(int i = 0; i < m; i++){
    int a, b; cin >> a >> b;
    a--, b--;
    uf.unite(a, b);
    g[a] = g[b] = uf.root(a);
    ok[a].push_back(b);
    ok[b].push_back(a);
  }

  for(int i = 0; i < k; i++){
    int c, d; cin >> c >> d;
    c--, d--;
    if(uf.same(c, d)){
      ng[c].push_back(d);
      ng[d].push_back(c);
    }
  }

  for(int i = 0; i < n; i++){
    int ans = uf.size[uf.root(i)];
    ans -= ok[i].size();
    ans -= ng[i].size();
    cout << ans - 1 << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 15348
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, M; cin >> N >> M;
    vector<int> A(N, 0), B(N, 0);
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
    vector<int> C(M, 0), D(M, 0), I(M, 0);
    for (int i = 0; i < M; i++) {
        cin >> C[i] >> D[i]; I[i] = i + 1;
    }
    for (int i = 0; i < M; i++) for (int j = i + 1; j < M; j++) if (C[i] == C[j] && D[i] == D[j]) C.erase(C.begin() + j), D.erase(D.begin() + j), I.erase(I.begin() + j);
    for (int i = 0; i < N; i++) {
        long long int mini = 0, ans = 0;
        for (int j = 0; j < C.size(); j++) {
            int tmp = abs(A[i] - C[j]) + abs(B[i] - D[j]);
            if (j == 0) mini = tmp, ans = I[j];
            else if (mini > tmp) mini = tmp, ans = I[j];
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3576
let () =
  let n1 = read_int () and
      n2 = read_int () and
      n3 = read_int () and
      n4 = read_int () in
  let sum = n1+n2+n3+n4 in
  Printf.printf "%d\n%d\n" (sum/60) (sum mod 60)
;;

Measured memory_bytes: 2300
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int test[213456][2];
int ok[213456];
signed main() {
	int n, m; string s, t; char a; cin >> s >> t;
	for (int h = 0; h < s.size(); h++) {
		a = s[s.size() - 1];
		for (int i = s.size() - 1; i > 0; i--) {
			s[i] = s[i - 1];
		}
		s[0] = a;
		if (s == t) { cout << "Yes" << endl; return 0; }
	}
	cout << "No" << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>

using namespace std;
typedef struct{
  int up;
  int down;
  int right;
  int left;
}ze;
ze z[200];

void print(int i){
  cout <<z[i].up<<" "<<z[i].down<<" "<<z[i].left<<" "<<z[i].right<<" "<<endl;

}
int main(){
  int n=0,n1,d;
  int rm;
  int lm;
  int um;
  int dm;
  while(true){
    rm=1;
    lm=0;
    um=1;
    dm=0;
    for(int i =0;i<n;i++){
      z[i].up=1;
      z[i].down=0;
      z[i].right=1;
      z[i].left=0;
    }
    cin>>n;
    if(n==0)break;
    for(int i = 1;i<n;i++){
      cin>>n1>>d;
      z[i]=z[n1];
      if(d==0){
	z[i].left++;
	//	print(i);
	if(lm<z[i].left+1-z[i].right)lm=1+z[i].left-z[i].right;
      }
      else if(d==1){
	z[i].down++;
	//	print(i);
 	if(dm<z[i].down+1-z[i].up)dm=1+z[i].down-z[i].up;
     }
      else if(d==2){
	z[i].right++;
	//	print(i);
       	if(rm<z[i].right-z[i].left)rm=z[i].right-z[i].left;
      }
      else {
	z[i].up++;
	//	print(i);
	if(um<z[i].up-z[i].down)um=z[i].up-z[i].down;
     }
    }
    cout<<rm+lm<<" "<<um+dm<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <stdlib.h>
#include <limits.h>
#include <unordered_map>
#include <string>
#include <map>
using namespace std;

#define INF (INT_MAX/2)

typedef struct{
  int vno;   // vertex No.
  int dist;  // accumulated distance fromt start vertex
} v_t;

typedef struct{
  vector<v_t>            vertex;
  vector< vector<int> >  adj;
} g_t;

bool cmpD(const vector<v_t>::iterator &lhs, const vector<v_t>::iterator &rhs){
  return (*lhs).dist < (*rhs).dist;
};

bool cmpVno(const vector<v_t>::iterator &lhs, const vector<v_t>::iterator &rhs){
  return (*lhs).vno < (*rhs).vno;
};

int main(){ // Dijkstra P.254
  g_t G;  // graph : index is each vertex
  unordered_map< string, int > W; // Weight between Source and Target
  string sv; // "Source,Target"
  multimap< int, vector<v_t>::iterator > Q; // Key: dist 
  int vmax; int emax; int start;

  scanf("%d %d %d" ,&vmax ,&emax ,&start);
  // initialize G
  for( int i=0 ; i < vmax ; i++ ){
    v_t v = { i, INF + i };
    vector<int> a;
    G.vertex.push_back(v);
    G.adj.push_back(a);
  }
  v_t vs = { start, 0 };
  G.vertex.at(start) = vs;
  // initialize Adj
  for( int cnt=0 ; cnt<emax ; cnt++ ){
    int s, t, w; // source, target, weight
    scanf("%d %d %d" ,&s ,&t, &w);
    G.adj[s].push_back(t);
    sv = to_string(s) + "," + to_string(t);
    W[sv] = w;
  }

  for( auto itr = G.vertex.begin() ; itr != G.vertex.end() ; ++itr ){
    Q.insert( make_pair((*itr).dist, itr) );
  }

  while(!Q.empty()){
    auto u_itit = Q.begin();
    int uno = (*(u_itit->second)).vno;
    Q.erase(u_itit);
    for( auto v_it = G.adj[uno].begin() ; v_it != G.adj[uno].end() ; ++v_it ){
      // relax
      int w_uv = -1; // when no adj
      sv = to_string(uno) + "," + to_string(*v_it);
      auto w_it = W.find(sv);
      if( w_it != W.end() ){
        w_uv = w_it->second;
      }
      if( w_uv != -1 && G.vertex[(*v_it)].dist > ( G.vertex[uno].dist + w_uv ) ){
        int old_dist = G.vertex[(*v_it)].dist;
        int old_vno  = *v_it;
        for( auto it = Q.find(old_dist) ; it != Q.end() ; ++it ){
          if( (*(it->second)).vno == old_vno ){
            auto up_vit = it->second;
            Q.erase(it);
            Q.insert( make_pair( G.vertex[uno].dist + w_uv ,up_vit ) );
            break;
          }
        }
        G.vertex[(*v_it)].dist = G.vertex[uno].dist + w_uv;
      }
    }
  }

  for( auto itr = G.vertex.begin() ; itr != G.vertex.end() ; ++itr ){
    if( (*itr).dist < INF ){
      printf("%d\n" ,(*itr).dist );
    }else{
      printf("INF\n");
    }
  }

  return 0;
}




Measured memory_bytes: 72620
import math
N = int(input())
A = [0]*N
B = [0]*N
for i in range(N):
  A[i]= int(input())
B = sorted(A,reverse=True)
for j in range(N):
  if(A[j]==B[0]):
    print(B[1])
  else:
    print(B[0])


Measured memory_bytes: 20508
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := 5
	ml := make([]int, n+1)
	mln := make([]int, n+1)

	for i := 1; i < n+1; i++ {
		ml[i] = nextInt()
		mln[i] = kiriageX(ml[i], 10)
	}

	var tl []int = []int{1, 2, 3, 4, 5}
	pall := permutations(tl)

	mint := 130 * 6
	for i := 0; i < len(pall); i++ {
		nowtime := 0
		for j := 0; j <= 3; j++ {
			nowtime += mln[pall[i][j]]
		}
		nowtime += ml[pall[i][5-1]] //最後だけ切り上げしない

		mint = min(nowtime, mint)
	}

	fmt.Println(mint)

}

// aをbの倍数に切り上げ
func kiriageX(a, b int) int {
	return (a + (b - 1)) / b * b
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}
func pow(a, b int) int {
	var ret int = 1
	for b > 0 {
		if (b & 1) == 1 {
			ret *= a
		}
		a *= a
		b >>= 1
	}
	return ret
}

// 順列
// 順列作成 (ランダム順)
// var tl []int = []int{1, 2, 3, 4, 5, 6, 7, 8}
// pall := permutations(tl)
//   -> [[],[],[]]
// 数値リスト化 例
//	pallnum := make([]int, len(pall))
//	for i := 0; i < len(pall); i++ {
//		tmp := 0
//		for j := 0; j < n; j++ {
//			tmp += pall[i][j] * pow(10, n-j-1)
//		}
//		pallnum[i] = tmp
//	}
func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1828
#include<cstdio>

#define mo 1000000007
#define ran 101101

int n, m;
int forbid[ran], s[ran];

int main() {
	scanf("%d%d", &n, &m);
	for(int i=0;i<m;i++) {
		int x; scanf("%d", &x);
		forbid[x] = true;
	}
	
	s[0] = 1;
	for(int i=1;i<=n;i++) {
		if (forbid[i]) s[i] = 0;
		else 
		if (i==1) s[i] = 1;
		else {
			s[i] = s[i-1] + s[i-2];
			if (s[i]>=mo) s[i] -= mo;
		}
	}
	printf("%d\n", s[n]);
	
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

int n;
int a[3001];
int main() {
    cin>>n;
    REP(i, 0, n) cin>>a[i];

    ll sum=0;
    REP(i, 0, n) sum+=a[i];
    cout<<sum-n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll m = 1e9 + 7;
ll powm(ll b, ll p)
{
    if (p == 0)
        return 1;
    if (p % 2 == 1)
        return b * powm(b, p - 1) % m;
    else
    {
        ll t = powm(b, p / 2);
        return t * t % m;
    }
}
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> flcm;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
    {
        int t = a[i];
        for (ll j = 2; j * j <= t; j++)
        {
            int fac = 0;
            while (t % j == 0)
            {
                fac += 1;
                t /= j;
            }
            if (fac > flcm[j])
                flcm[j] = fac;
        }
        if (t != 1)
            if (flcm[t] == 0)
                flcm[t] = 1;
    }
    ll ans = 0;
    ll lcm = 1;
    for (auto x : flcm)
    {
        lcm = lcm * powm(x.first, x.second) % m;
    }
    for (int i = 0; i < n; i++)
        ans += lcm * powm(a[i], m - 2) % m;
    cout << ans % m << endl;
}


Measured memory_bytes: 4008
#include<iostream>
using namespace std;
int main()
{
  int h;
  for(;cin>>h,h;)
    {
      int board[h][5];
      for(int i=0;i<h;i++)
	for(int j=0;j<5;j++)
	  cin>>board[i][j];
      int ans=0;
      while(true)
	{
	  int add=0;
	  for(int i=0;i<h;i++)
	    {
	      for(int j=0;j<3;j++)
		if(board[i][j]==board[i][j+1]&&
		   board[i][j+1]==board[i][j+2] )
		  {
		    int jj = j;
		    while(jj < 5 &&board[i][j]==board[i][jj])
		      jj++;
		    for(int x=j;x<jj;x++)
		      {
			add+=board[i][x];
			board[i][x]=0;
		      }

		  }
	    }
	  ans+=add;
	  if(add==0)
	    break;

	for(int i=h-1;i>0;i--)
	  {
	    for(int j=0;j<5;j++)
	      {
		if(board[i][j]==0)
		  {
		    for(int ii=i-1;ii>=0;ii--)
		      if(board[ii][j]!=0)
			{
			  board[i][j]=board[ii][j];
			  board[ii][j]=0;
			  break;
			}
		  }
	      }
	  }
	/*
	cerr<<endl;
	for(int i=0;i<h;i++,cerr<<endl)
	  for(int j=0;j<5;j++)
	    cerr<<board[i][j]<<" ";
	cerr<<endl;
	*/
	}

      cout<<ans<<endl;
    }

}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<cctype>
using namespace std;

int main(){
int h=0,t=0,n;
string hs,ts;
cin >>n;
for(int i=0;i<n;i++){
cin >>hs >>ts;
if(ts==hs){
h++;
t++;
}
else if(ts>hs) t=t+3;
else h=h+3;
}
cout <<h <<" " <<t <<endl;
return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>

using namespace std;

int main()
{
    char a;
    cin>>a;
    if(a=='A'){
        cout<<"T\n";
    }
    if(a=='C'){
        cout<<"G\n";
    }if(a=='T'){
        cout<<"A\n";
    }if(a=='G'){
        cout<<"C\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)


int main(){
   int k;
  cin >>k;
  ll sum=0;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
        int Gcd;
        Gcd=__gcd(i,j);
        sum+=__gcd(Gcd,l);
      }
    }
  }
  cout << sum << endl;
 
}
  

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/*Question
/?´???°??? 1 ??¨????????°??????????????§????????????????????¶??°????´???°??¨?¨?????????????
/????????°????????????8 ???????´???°???2, 3, 5, 7, 11, 13, 17, 19 ??¨???????????????1 ????´???°??§?????????????????????
/n ????????´??°???????????????????????????????????????????´???°?????°???????????????????????°???????????????????????????????????? 
*/

/*Input
/??????????????? n ?????????????????????????¶???? n ?????? n ????????´??°???????????????????????? 
*/

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		//????????¨
		boolean b;
		int count = 0;
		/*??\???
		/??????????´???°?????\???????¬??????°????????\???
		*/
		int n = Integer.parseInt(sc.readLine());
		int[] a = new int[n];
		for(int i = 0;i < n;i++){
			a[i] = Integer.parseInt(sc.readLine());
		}
		/*??°??????????????\???Prime???????????????
		/true??????count?????°???1?¢???????
		*/
		for (int s:a) {
			b = Prime(s);
			if (b) count++;
		}
		System.out.println(count);
	}

	/*Prime????????????
	/??????????????????????´???°???????????????????????????????????????
	/??????1?????????????¬????2??¨??¶??°?????????
	/??\??????3??????2??\????¢??????????????????§?????£????????????????????????
	*/

	public static boolean Prime(int s) {
		if (s < 2) return false;
		else if (s == 2) return true;
		else if (s % 2 == 0) return false;
		double sqrts = Math.sqrt(s);
		for (int i = 3; i <= sqrts; i += 2) {
		if (s % i == 0) {
			return false;
			}
		}
		return true;
	}
}

Measured memory_bytes: 29772
/* Author : tushar3105 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef pair<long long int,long long int> ii;					// Pair of integers
typedef vector<long long int> vi;                   				// Vector of integers
typedef vector<vector<long long int>> vvi;                 			// Vector of vi
typedef vector<pair<long long int, long long int>> vii;				// Vector of ii

#define pb push_back								// Push back to vectors
#define mp make_pair								// For pairs
#define ff first								// For pairs
#define ss second								// For pairs
#define all(c) (c).begin(),(c).end()						// Use in sorting
#define sz(a) ((long long int)(a).size())
#define lli long long int
#define ull unsigned long long int
#define ld long double
#define ref(i,x,y) for(long long int i=(x);i<=(y);++i)				// Loop to go forward
#define reb(i,x,y) for(long long int i=(x);i>=(y);--i)				// Loop to go backward
#define trf(c,it) for(auto it = (c).begin(); it != (c).end(); it++)		// Remember it is an iterator
#define trb(c,it) for(auto it = (c).end()-1; it != (c).begin()-1; it--)		// Remember it is an iterator
#define tc(t) long long int (t); cin>>(t);while((t)--)				// Test cases
//fill (dist,dist+110000,pinf);							// For setting default

const long long int mod = 1e9+7;
const long long int pinf = 9223372036854775807;
const long long int ninf = -9223372036854775807;

/*-----------------------------Code begins----------------------------------*/

lli n, k, a[210000];

int main (void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	cin>>n>>k;
    
    ref(i,1,n)
        cin>>a[i];
    
    ref(i, k + 1, n)
    {
        if (a[i] > a[i - k])
            cout << "Yes" << endl;
    
        else
            cout << "No" << endl;
    }

	return 0;
}


Measured memory_bytes: 5152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	int N, L;
	cin >> N >> L;

	int sum = 0;
	int absMin = 1000;
	for(int i=0; i<N; i++) {
		sum += L + i;
		if(abs(absMin) > abs(L + i)) {
			absMin = L + i;
		}
	}

	cout << sum - absMin;
	// cout << "[deb: val ]" << val <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
/*
int swap(){
}*/

int main (){
    int N = 0;
    int A[100] = {0};
    int tmp, flag, j, i, k=0;

    scanf("%d", &N);
    for(i=0; i<N; i++){
        scanf("%d", &A[i]);
    }
    
    
    flag = 1; // 逆の隣接要素が存在する
    while(flag){
        flag = 0;
        for(j=N-1; j>=1; j--){
            if(A[j] < A[j-1]){
                tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                k++;
                flag = 1;
                
                
/*                
                for(i=0; i<N-1; i++){
                    printf("%d ", A[i]);
                }printf("%d\n%d\n", A[N-1], k);
*/
            }
        }
    }
    
    for(i=0; i<N-1; i++){
        printf("%d ", A[i]);
    }printf("%d\n%d\n", A[N-1], k);
    
    
return 0;
}





Measured memory_bytes: 2092
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

signed main(){
  int n,k;
  cin>>n>>k;
  if(n%k==0){
    cout<<0<<en;
  }else cout<<1<<en;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <utility>
#include <stdio.h>
#include <stdlib.h>

int depth;
std::string data;
std::vector< std::vector< int > > vv;

int max( int p, int q ) {
	if( p > q ) return p;
	return q;
}

/*
	探索
	引数は　現在の階層の深さ、各選挙区における最小得票数のvector
*/
void search( int dep ) {

	if( dep >= depth ) return;
	using namespace std;

	/*
		k段階の最小得票数を求める
		k段階の選挙区はいくつ存在し、
		k-1段階の選挙区をいくつずつ含むか？
	*/

	int currentDepth = depth;
	int blockNum = 0;

	vector< int > vec;

	for( int i = 0; i < data.length(); i++ ) {
		if( data[i] == '[' ) {
			currentDepth --;
			if( currentDepth == dep - 1 ) {
				blockNum ++;
			}
		} else if( data[i] == ']' ) {
			currentDepth ++;
			if( currentDepth == dep + 1 ) {
				vec.push_back( blockNum );
				blockNum = 0;
			}
		}
	}

	int k = 0;
	for( int i = 0; i < vec.size(); i++ ) {
		vector< int > tv;
		int sum = 0;
		for( int j = 0; j < vec[i]; j++ ) {
			tv.push_back( vv[ dep - 1 ][ k ] );
			k ++;
		}
		sort( tv.begin(), tv.end() );
		for( int j = 0; j < vec[i] / 2 + 1; j++ ) {
			sum += tv[ j ];
		}
		vv[ dep ].push_back( sum );
	}

	search( dep + 1 );

}

int main( void ) {

	using namespace std;

	int n;
	cin >> n;

	for( int i = 0; i < n; i++ ) {

		int currentDepth = 0;			//階層の深さ
		depth = 0;
		vv.clear();
		cin >> data;	//データ取得

		//階層の深さを調べる
		for( int j = 0; j < data.length(); j++ ) {
			if( data[j] == '[' ) {
				currentDepth ++;
			} else if( data[j] == ']' ) {
				currentDepth --;
			}
			depth = max( depth, currentDepth );
		}
		
		vv = vector< vector< int > >( depth, vector< int >() );

		//第0段階の最小得票数をpush_backする
		currentDepth = 0;
		int back;
		for( int j = 0; j < data.length(); j++ ) {
			if( data[j] == '[' ) {
				currentDepth ++;
				if( currentDepth == depth ) {
					back = j;
				}
			} else if( data[j] == ']' ) {
				if( currentDepth == depth ) {
					vv[0].push_back( atoi( data.substr( back + 1, j - back - 1 ).c_str() ) / 2 + 1 );
				}
				currentDepth --;
			}
		}

		search( 1 );
		cout << vv[ depth - 1 ][ 0 ] << endl;

	}

	return 0;

}

Measured memory_bytes: 3200
var
 n,m,i,j,x:longint;
 a:array[0..1000,0..1000] of char;
 s:string;
begin
 readln(n,m);
 for i:=1 to n do
  begin
   readln(s);
   for j:=1 to m do
    a[i,j]:=s[j];
  end;
 for i:=1 to n do
  begin
   for j:=1 to m do
    begin
     x:=0;
     if a[i,j]<>'#' then begin
       if a[i+1,j]='#' then inc(x);
       if a[i,j+1]='#' then inc(x);
       if a[i-1,j]='#' then inc(x);
       if a[i,j-1]='#' then inc(x);
       if a[i-1,j-1]='#' then inc(x);
       if a[i-1,j+1]='#' then inc(x);
       if a[i+1,j-1]='#' then inc(x);
       if a[i+1,j+1]='#' then inc(x);
      end;
     if a[i,j]='#' then write('#')
                   else write(x);
    end;
   writeln;
  end;
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
#define all(obj) obj.begin(), obj.end()
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

using namespace std;

typedef unsigned long long ull;
typedef int long long ll;
constexpr ll bigNum = 1000000007;

signed main()
{
    fast;
    string s, t;
    int count = 0;
    cin >> s >> t;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == t[i])
        {
            count++;
        }
    }
    cout << count;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
long long N;
cin>>N;
long long M; cin>>M;
long long counter=0;
long long ac[100010]={};
long long wa[100010]={};
long long counterw=0;
long long r;
string t;
for(long long i=0; i<M;i++){
cin>>r>>t;
if(t.at(0)=='A'){
ac[r]++;}
else{
if(ac[r]==0){
wa[r]++;}}}
for(long long i=0; i<N+1;i++){
if(ac[i]>0){
counter++;
counterw+=wa[i];}}
cout<<counter<<" "<<counterw<<endl;}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a,b;
    while(true){
        cin>>a>>b;
        if(a==0&&b==0){
            break;
        }
        if(a>b){
            swap(a,b);
        }
        cout<<a<<" "<<b<<endl;
    }
    return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
int main(){
    double a,b,S,L,h,rad;
    int c;
    double PI = acos(-1);
    cin>>a>>b>>c;
    rad = c*PI/180;
    S = a*b*sin(rad)/2;
    L = a+b+sqrt(a*a+b*b-2*a*b*cos(rad));
    h = 2*S/a;
    printf("%.8lf\n", S);
    printf("%.8lf\n", L);
    printf("%.8lf\n", h);
return 0;
}


Measured memory_bytes: 3412
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 123456789
//0x3f3f3f3f
#define INFL 10000000000000000
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<int,pii> pdii;
long long int MOD = 1000000007;


int main(void){
	int N,M;
	cin>>N>>M;
	int a[114514]={0};
	for(int i=0;i<M;i++){
		int p,q;
		cin>>p>>q;p--;q--;
		a[p]++;a[q]++;
	}
	bool flag=true;
	for(int i=0;i<N;i++){
		if(a[i]%2==1)flag=false;
	}
	if(flag)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
using ll = long long;
using ull = unsigned long long;
using namespace std;

void solve()
{
    char a;
    cin >> a;
    if (isupper(a)) {
        cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }
}

int main(){cin.tie(0);ios_base::sync_with_stdio(false);solve();return 0;}

Measured memory_bytes: 3656
import math
n=int(input())
x=list(map(float,input().split()))
y=list(map(float,input().split()))
M=0
Y=0
T=0
Cn=[]

for i in range(n):
  z=abs(x[i]-y[i])
  M+=z
  Y+=z**2
  T+=z**3
  Cn.append(z)
  
Y=math.sqrt(Y)
T=T**(1/3)
C=max(Cn)

print(f"{M:.6f}")
print(f"{Y:.6f}")
print(f"{T:.6f}")
print(f"{C:.6f}")


Measured memory_bytes: 5736
var
    n,i,ans:longint;
    a,b:array[1..1000]of longint;
begin
    readln(n);
    for i:=1 to n do
    begin
        readln(a[i],b[i]);
        inc(ans,b[i]-a[i]+1);//相加
    end;
    writeln(ans);
end.

Measured memory_bytes: 128
#include<iostream>
using namespace std;

int start(int i,int x){
  double a = i*100.0/(100+x);
  if((int)a == a) return (int)a;
  else return (int)a+1;
}

int goal(int i,int x){
  return (int)((i+1)*100.0/(100+x));
}


int main(){
  int before=0,after=1,sum=2;
  int max = 0;
  while(cin>>before>>after>>sum){
    if(before == 0 && after == 0 && sum == 0) break;
    for(int i=1;i<sum;i++){
      int j=sum-i;
      if(i<=j){
	for(int n1 = start(i,before);n1 <= goal(i,before);n1++){
	  for(int n2 = start(j,before);n2 <= goal(j,before);n2++){
	    if((int)(n1*(100.0+before)/100) + (int)(n2*(100.0+before)/100) !=sum ) continue;
	    int s = (int)(n1*(100.0+after)/100) + (int)(n2*(100.0+after)/100);
	    max = (max < s ) ? s : max;
	  }
	}
      }else
	break;
    }
    cout<<max<<endl;
    max = 0;
  }
  return 0;
}

Measured memory_bytes: 1160
def gcd(m,n):
    while (m % n != 0):
        n,m = m%n,n
    return(n)

def lcm(m,n):
    return(m * n // gcd(m,n))

n,m = map(int,input().split())

s = input()
t = input()


g = gcd(m,n)

if(g in [n,m]):
    print(-1)
else:
    x = lcm(m,n)
    a = x // n
    b = x // m
    for i in range(n//b):
        ai = b * i
        bi = a * i
        if(s[ai] != t[bi]):
            print(-1)
            exit()
    print(lcm(m,n))

Measured memory_bytes: 3316
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
enum Query
{
    push = 0,
    top = 1,
    pop = 2,
};
std::istream &operator>>(std::istream &is, Query &i)
{
    int tmp;
    if (is >> tmp)
        i = static_cast<Query>(tmp);
    return is;
} //オペレーターオーバーロード
int main()
{
    int n, q;
    cin >> n >> q;
    typedef std::stack<int> stk;
    vector<stk> S(n);

    while (q)
    {
        int query;
        cin >> query;
        int t;
        cin >> t;
        stk &s = S.at(t);
        if (query == push)
        {
            //push(t,x)
            int x;
            cin >> x;
            s.push(x);
        }
        if (query == top)
        {
            //top(t)
            if (!s.empty())
            {
                cout << s.top() << endl;
            }
        }
        if (query == pop)
        {
            //pop(t)
            if (!s.empty())
            {
                s.pop();
            }
        }
        q--;
    }
}


Measured memory_bytes: 4356
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

static const double eps = 1e-8;

int moveTo[][2] = {{-1,0},{1,0},{0,-1},{0,1}};

int stage[100][100];

void paint(int c,int d,int x,int y){
	//c:1~5 d: 0:horizonal 1:vertical
	if(d==0){
		for(int i=x;i<x+4;i++){
			for(int j=y;j<y+2;j++){
				stage[j][i] = c;
			}
		}
	}
	else{
		for(int i=x;i<x+2;i++){
			for(int j=y;j<y+4;j++){
				stage[j][i] = c;
			}
		}
	}
}

bool bfs(int w, int h, int xs, int ys, int xg, int yg){
	int cs = stage[ys][xs];
	int cg = stage[yg][xg];
	if(cs != cg) return false;

	queue<P> que;
	que.push(P(xs,ys));

	while(!que.empty()){
		int sx = que.front().first;
		int sy = que.front().second;
		
		if(sx == xg && sy == yg) return true;
		que.pop();

		stage[sy][sx] = -1;

		for(int i=0;i<4;i++){
			int dx = sx + moveTo[i][0];
			int dy = sy + moveTo[i][1];

			if(dx < 0 || dx >= w || dy < 0 || dy >= h) continue;
			if(stage[dy][dx] != cs || stage[dy][dx] == -1) continue;
			que.push(P(dx,dy));

		}

	}
	return false;
}

int main(){
	int w,h;
	while(~scanf("%d %d",&w,&h)){
		if(w==h && h==0) break;
		memset(stage,-1,sizeof(stage));
		int xs,ys;
		scanf("%d %d",&xs,&ys);

		int xg,yg;
		scanf("%d %d",&xg,&yg);

		int n;
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			int c,d,x,y;
			//c:1~5 d: 0:horizonal 1:vertical
			scanf("%d %d %d %d",&c,&d,&x,&y);
			paint(c,d,x-1,y-1);
		}

		printf("%s\n",bfs(w,h,xs-1,ys-1,xg-1,yg-1) ? "OK" : "NG");
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;

#define LL long long

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n; cin >> n;
    string s = "";
    while(1) {
        if(n == 0) break;
        int t = n % (-2);
        if(t == -1) t = 1;
        s += char(48 + t);
        n -= t;
        n /= -2;
    }    
    reverse(s.begin(), s.end());
    if(s.length() == 0) s += '0';

    cout << s;
}

Measured memory_bytes: 3616
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    map<ll, vector<ll>> G;
    rep (i, N) {
        G[i + 1];
    }
    rep (i, M) {
        ll a, b;
        cin >> a >> b;
        G[a].pb(b);
        G[b].pb(a);
    }
    for (auto v1 : G[1]) {
        for (auto v2 : G[v1]) {
            if (v2 == N) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 23656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ll a, b, c, d;
    
    cin >> a >> b >> c >> d;
    
    if(a*b>=c*d){
        cout << a*b << endl;
    }else{
        cout << c*d << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef vector<vector<int>> Graph;
void add_edge(Graph& g, int from, int to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } else return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	ll n; cin >> n;

	cout << (!n) << endl;
}



Measured memory_bytes: 3644
import numpy as np,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
H,W = LI()
a = np.array([[s for s in S()] for _ in range(H)])
a = a[(a=='#').any(axis=1)]
a = a.T
a = a[(a=='#').any(axis=1)]
a = a.T.tolist()
for x in a:
    print(*x,sep='')


Measured memory_bytes: 20888
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n;
    cin >> n;
    cout << (n-30)/2 << endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  for (int i = a; i <= min(b, a + k - 1); i++) cout << i << endl;
  for (int i = max(b - k + 1, a + k); i <= b; i++) cout << i << endl;
  return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
int main() 
{ 
   //  freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
ll n;
cin>>n;
map<ll,ll> m;
ll sum=0;
for(ll i=0;i<n;i++){
    ll x;
    cin>>x;
    sum += x;
    m[x]++;
  }
  ll q;
  cin>>q;
  while(q--){
    ll a,b;
    cin>>a>>b;
    ll x = b-a;
    ll count = m[a];
    if(m[a]!=0){
      m[b] += m[a];
      m[a] = 0;
      sum += (x*count);
    }
    cout<<sum<<"\n";

  }
	return 0; 
}
 

Measured memory_bytes: 9252
#include <bits/stdc++.h>
#define r(i,n) for(long long i = 0; i<n; i++)
typedef long long ll;
using namespace std;


int main() {
  ll h,w;
  cin >> h >> w;
  if(h==1||w==1)cout<<1<<endl;
  else cout<<(h*w+1)/2<<endl;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
L,R={},{}
for i,a in enumerate(A):
  l,r = i-a,i+a
  if l not in L: L[l]=0
  if r not in R: R[r]=0
  L[l]+=1
  R[r]+=1

count = 0
for x in L:
  if x not in R: continue
  count += L[x]*R[x]
print(count)

Measured memory_bytes: 57344
#include <stdio.h>

#define rep(i, n) for(i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(i = f; i < (int)l; ++i)

char fld[1001][1001];
int J[1001][1001];
int O[1001][1001];
int I[1001][1001];

int main(void){
    int m, n, k;
    register int i, j;
    scanf("%d%d%d", &m, &n, &k);
    getchar();
    rep(i, m){
        rep(j, n) fld[i][j] = getchar();
        getchar();
    }

#define FOR_EACH(F) {F(J, 'J'); F(O, 'O');} // F(I, 'I');}
#define PSUM(ARR, SYM)                        \
    repf(i, 1, m + 1){                        \
        int __c = 0;                          \
        repf(j, 1, n + 1){                    \
            __c += (fld[i-1][j-1] == SYM);    \
            ARR[i][j] = ARR[i - 1][j] + __c;  \
        }                                     \
    }                                         
    FOR_EACH(PSUM);

    /*
    rep(i, m + 1){
        rep(j, n + 1)
            printf("%3d", J[i][j]);
        printf("\n");
    }
    */

    while(k --> 0){
        int a, b, c, d;
        scanf("%d%d%d%d", &a, &b, &c, &d);
        a--; b--;
        int jsum, osum;
        jsum = osum = 0;
        jsum = J[c][d] - J[c][b] - J[a][d] + J[a][b];
        osum = O[c][d] - O[c][b] - O[a][d] + O[a][b];
        printf("%d %d %d\n", jsum, osum, (c - a) * (d - b) - jsum - osum);
    }

    return 0;
}

Measured memory_bytes: 10836
#include <bits/stdc++.h>
using namespace std;    

int main() {
  int64_t a,b,k;
  cin >> a >> b >> k;
  if(a >= k) cout << a-k << ' ' << b << endl;
  else if(b >= k - a) cout << 0 << ' ' << b + a - k << endl;
  else cout << 0 << ' ' << 0 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *args[])
{
	int h,w;
	int i,j;

	while(1) {

		scanf("%d %d", &h, &w);

		if( h==0 && w==0 ) break;

		for( i=0; i < h; i++ ) {

			for( j=0;  j < w; j++ ) {
				printf("#");
			}
			printf("\n");

		}
		printf("\n");
	}

	return 0;

}

Measured memory_bytes: 572
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var array = Console.ReadLine().Split(' ');

        var aHp = int.Parse(array[0]);
        var aPower = int.Parse(array[1]);
        var bHp = int.Parse(array[2]);
        var bPower = int.Parse(array[3]);

        while (true)
        {
            bHp -= aPower;
            if(bHp <= 0)
            {
                Console.WriteLine("Yes");
                break;
            }

            aHp -= bPower;
            if(aHp <= 0)
            {
                Console.WriteLine("No");
                break;
            }
        }



        Console.Read();


    }
}


Measured memory_bytes: 17864
S = list(input())
#2パターン考える
ans1 = 0#0101010101010101
ans2 = 0#1010101010101010
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "0":#ans1の方は直さなくていいans2を直す
            ans2 += 1
        elif S[i] == "1":#ans2の方は直さなくていいans1を直す
            ans1 += 1
    else:
        if S[i] == "1":#ans1の方は直さなくていいans2を直す
            ans2 += 1
        elif S[i] == "0":#ans2の方は直さなくていいans1を直す
            ans1 += 1

print(min(ans1, ans2))

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;
	vll a(n + 1), b(n);
	for (ll i = 0; i < n + 1; i++) cin >> a[i];
	for (ll i = 0; i < n; i++) cin >> b[i];

	ll ans = 0;
	for (ll i = 0; i < n / 2; i++) {
		if (b[i] >= a[i]) {
			ans += a[i];
			b[i] -= a[i];
			a[i] = 0;
		}
		else {
			ans += b[i];
			a[i] -= b[i];
			b[i] = 0;
		}
		if (b[i] >= a[i + 1]) {
			ans += a[i + 1];
			b[i] -= a[i + 1];
			a[i + 1] = 0;
		}
		else {
			ans += b[i];
			a[i + 1] -= b[i];
			b[i] = 0;
		}
		if (b[n - 1 - i] >= a[n - i]) {
			ans += a[n - i];
			b[n - 1 - i] -= a[n - i];
			a[n - i] = 0;
		}
		else {
			ans += b[n - 1 - i];
			a[n - i] -= b[n - 1 - i];
			b[n - 1 - i] = 0;
		}
		if (b[n - 1 - i] >= a[n - 1 - i]) {
			ans += a[n - 1 - i];
			b[n - 1 - i] -= a[n - 1 - i];
			a[n - 1 - i] = 0;
		}
		else {
			ans += b[n - 1 - i];
			a[n - 1 - i] -= b[n - 1 - i];
			b[n - 1 - i] = 0;
		}
	}
	if (n % 2) {
		ll i = n / 2;
		if (b[i] >= a[i]) {
			ans += a[i];
			b[i] -= a[i];
			a[i] = 0;
		}
		else {
			ans += b[i];
			a[i] -= b[i];
			b[i] = 0;
		}
		if (b[i] >= a[i + 1]) {
			ans += a[i + 1];
			b[i] -= a[i + 1];
			a[i + 1] = 0;
		}
		else {
			ans += b[i];
			a[i + 1] -= b[i];
			b[i] = 0;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(void){
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  //ABピザ2枚組を何セット買うか
  int ab_num;
  //セットを最大で何セット買えるか  
  int set_max = max(X, Y);
 
  //ABセットを何セット買うかで総当たり的に確かめる
  //各場面でA, Bのピザを何枚買うか                                      
  int a_num, b_num;
  //priceの最大値は5000*10^5
  int price, price_min = 1000000000;
  for(ab_num=0; ab_num<=set_max; ab_num++){
    a_num = 0; b_num = 0;
    if(ab_num < X)
      a_num = X - ab_num;
    if(ab_num < Y)
      b_num = Y - ab_num;
    price = A*a_num + B*b_num + 2*C*ab_num;
    //cout<<"ab_num = "<<ab_num<<", "<<"price = "<<price<<endl;
    if(price < price_min)
      price_min = price;
  }

  cout << price_min << endl;
    
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
using ll=long long;

ll gcd(ll a,ll b) {
    if (b==0) {
        return a;
    }
    return gcd(b,a%b);
}
ll lcm(ll a,ll b) {
    return a/gcd(a,b)*b;
}
int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N;
    cin>>N;
    ll ans=1;
    for (int i=0; i<N; i++) {
        ll T;
        cin>>T;
        ans=lcm(ans,T);   
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, n, a) for(int i = (a); i >= (n); i--)
#define mod 1e9+7
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int a[4] = {};
  rep(i, 0, 3) cin >> a[i];
  rep(i, 0, 3) rep(j, 0, 3) {
    if(i == j) continue;
    if(a[i] * a[j] % 2) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
n = list(map(int, input().split()))

rmax = int(n[3] / n[0])
ans = 0
k = n[3] % n[2]

for i in range(0, rmax+1):
  sum = i * n[0]
  while sum <= n[3]:
    if sum % n[2] == k:
      ans += 1
    sum += n[1]

print(ans)



Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int i;
	
	i = 0;
	
	for (;;){
		scanf ("%d %d", &a, &b);
		c = 0;
		if (a == 0 && b == 0){
			break;
		}
		else{
			if (i != 0){
				puts("");
			}
		}
		i++;
	
		while (a <= b){
			
			if (a % 4 == 0 && a % 100 != 0 || a % 400 == 0){
				printf("%d\n", a);
				c = 1;	
			}
			a++;
		}
		if (c != 1){
			printf("NA\n");
		}
		
	}
	return (0);
}

Measured memory_bytes: 612
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int32_t main() {
    //ios::sync_with_stdio(false); cin.tie(nullptr);
    
    string s;
    cin >> s;
    
    int sum = 0;
    for (char c: s) {
        sum += c - '0';
    }
    
    cout << (sum % 9 == 0 ? "Yes" : "No");
}



Measured memory_bytes: 3748
N, A = map(int, input().split())
x = list(map(int, input().split()))

#dp[j][k][s] = (x0...xj からk枚選んでxiの合計をsにするような選び方の総数)
dp = [[[0] * (A * N + 1) for k in range(N + 1)] for j in range(N)]

dp[0][0][0] = 1
if x[0] <= A * N:
    dp[0][1][x[0]] = 1

for j in range(N - 1):
    for k in range(N + 1):
        for s in range(A * N + 1):
            if k == 0 and s == 0:
                dp[j + 1][k][s] = 1
            elif k > j + 2:
                dp[j + 1][k][s] = 0
            elif s >= x[j + 1] and k >= 1:
                dp[j + 1][k][s] = dp[j][k][s] + dp[j][k - 1][s - x[j + 1]]
            else:
                dp[j + 1][k][s] = dp[j][k][s]

res = 0
for i in range(1, N + 1):
    res += dp[N - 1][i][A * i]

print(res)

Measured memory_bytes: 93148