akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

int main() {
	int N; cin >> N;
	V<ll> A(N); rep(i, N) cin >> A[i];
	V<ll> ac(N + 1);
	rep(i, N) ac[i+1] = ac[i] + A[i];

	ll ans = TEN(18);

	rep(i, N-1) {
		ll x = abs(ac[i+1] - (ac[N] - ac[i+1]));
		chmin(ans, x);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
str = input()
L = list(str)
l = []
if L.count('K') == L.count('U') == L.count('P') == L.count('C'):
    print(L.count('K'))
elif L.count('K') == 0 :
    print(0)
elif L.count('U') == 0 :
    print(0)
elif L.count('P') == 0 :
    print(0)
elif L.count('C') == 0 :
    print(0)
else:
    k = L.count('K')
    u = L.count('U')
    p = L.count('P')
    c = L.count('C')
    l.append(k)
    l.append(u)
    l.append(p)
    l.append(c)
    ls = sorted(l)
#    print(l)
    print(ls[len(ls) - 4])
#    print(( L.count('K') + L.count('U') + L.count('P') + L.count('C') )//4)
#    l = []
#    l.append(L.count('K'))
#    l.append(L.count('U'))
#    l.append(L.count('P'))
#    l.append(L.count('C'))
#    print(l[len(l) - 4]) 


Measured memory_bytes: 5564
#include <stdio.h>

int main(void){
  int N, D, X;
  int A[100];
  
  scanf("%d%d%d", &N, &D, &X);
  int i;
  for(i=0;i<N;i++)	scanf("%d", &A[i]);
  
  int ans = 0;
  for(i=0;i<N;i++){
    int j=0;
    while( j*A[i]+1 <= D ){
      ans++;
      j++;
    }
  }
  
  printf("%d\n", ans + X );
  
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanNumber = new Scanner(System.in);

        int num1 = Integer.parseInt(scanNumber.next());

        int num2 = Integer.parseInt(scanNumber.next());

        int num3 = Integer.parseInt(scanNumber.next());

        int answer = 0;

        if(num1 < num2){
            if(num2 < num3){
                answer = num3 - num1;
            }
            else{
                if(num1 < num3){
                    answer = num2 - num1;
                }
                else{
                    answer = num2 - num3;
                }
            }
        }
        else if(num1 < num3){
            answer = num3 - num2;
        }
        else{
            if(num2 < num3){
                answer = num1 - num2;
            }
            else{
                answer = num1 - num3;
            }
        }

        System.out.print(answer);

    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    int a[1000] = {0};

    cin >> N;
    for( int i=0; i<N; i++ )
        cin >> a[i];
    
    std::sort(a, a+N);

    cout << a[N-1]-a[0] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 	long long int n,d;
  	cin>>n>>d;
  	long long int ans = 0;
  	for(long long int i=0,a,b;i<n;i++){
     	cin>>a>>b;
      	long long int dis = a*a+b*b;
      	if(dis<=d*d)
          ans++;
    }
  	cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3620
import sys
sys.setrecursionlimit(10**9)
N = int(input())

M = [set() for _ in range(N)]

A = [[] for _ in range(N)]
ans = [0] * (N - 1)
for i in range(N - 1):
    a, b = map(int, input().split())
    A[a - 1].append((b - 1, i))
    A[b - 1].append((a - 1, i))

def dfs(x, p, pre):
    cnt = 1
    for a in A[x]:
        if a[0] == pre:
            continue

        if cnt == p:
            cnt += 1
        ans[a[1]] = cnt
        cnt += 1

        dfs(a[0], ans[a[1]], x)

dfs(0, -1, -1)

print(max(ans))
for a in ans:
    print(a)


Measured memory_bytes: 102300
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t H, W, K;
  cin >> H >> W >> K;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<vector<int64_t>> A(H, vector<int64_t>(W, false));
  vector<bool> filled_row(H, false);
  vector<vector<int64_t>> result(H, vector<int64_t>(W, INT64_MIN));
  for (int64_t row = 0; row < H; ++row) {
    string s;
    cin >> s;
    int64_t count_per_row = 0;
    for (int64_t column = 0; column < W; ++column) {
      const char ch = s.c_str()[column];
      if (ch == '#') {
        A[row][column] = true;
        ++count_per_row;
        filled_row[row] = true;
      }
    }
  }

  int64_t last_filled_row = H - 1;
  while (last_filled_row >= 0) {
    if (filled_row[last_filled_row]) {
      break;
    }
    --last_filled_row;
  }

  int64_t start_row = 0;
  int64_t index = 1;
  while (true) {
    int64_t end_row = start_row;
    while (!filled_row[end_row]) {
      ++end_row;
      if (end_row == H - 1) {
        break;
      }
    }
    if (end_row == last_filled_row) {
      end_row = H - 1;
    }

    int64_t last_filled_col = W - 1;
    while (last_filled_col >= 0) {
      int64_t count = 0;
      for (int64_t row = start_row; row <= end_row; ++row) {
        if (A[row][last_filled_col])
          ++count;
      }
      if (count > 0) {
        break;
      }
      --last_filled_col;
    }

    int64_t start_col = 0;
    int64_t end_col;
    while (true) {
      end_col = start_col;
      while (end_col < W) {
        int64_t count = 0;
        for (int64_t r = start_row; r <= end_row; ++r) {
          if (A[r][end_col]) {
            ++count;
          }
        }
        if (count > 0) {
          break;
        }
        ++end_col;
      }
      if (end_col == last_filled_col) {
        end_col = W - 1;
      }

      for (int64_t row = start_row; row <= end_row; ++row) {
        for (int64_t col = start_col; col <= end_col; ++col) {
          result[row][col] = index;
        }
      }
      ++index;

      if (end_col == W - 1) {
        break;
      }
      start_col = end_col + 1;
    }

    if (end_row == H - 1) {
      break;
    }
    start_row = end_row + 1;
  }

  for (int64_t i = 0; i < H; ++i) {
    for (int64_t j = 0; j < W; ++j) {
      if (j != 0) {
        cout << " ";
      }
      cout << result[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <queue>
#include <functional> 

using namespace std;
typedef long long ll;

ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}

int main(){

    ll N, K;
    cin >> N >> K;


    vector<ll > V(N, 0);
    for(ll i = 0; i < N; i++){
        cin >> V[i];
    }

    sort(V.rbegin(), V.rend());

    //入力の最大値が求めるK未満のとき成り立たない
    if(V[0] < K ){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    ll n_gcd = V[0];
    for(ll i = 1; i < N; i++){
        if(i == 1){
            n_gcd = gcd(V[i-1], V[i]);
        }else{
            n_gcd = gcd(n_gcd , V[i]);
        }
    }  

    if(K % n_gcd == 0){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }

} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define M 998244353
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	n=n%1000;
	if(n==0)
    {
      cout<<0;
    }
  	else
    {
      cout<<1000-n;
    }
	return 0;
}

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

int main() {
  while (true) {
    int a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) break;

    for (int i = 0; i < a; i ++) {
      for (int j = 0; j < b; j ++) {
        if (i == 0 || i == a-1) {
          cout << "#";
        } else if (j == 0 || j == b-1) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}



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

using namespace std;

int main(void) {
    int n, k;
    cin >> n >> k;
    set<int> s;
    for (int i = 0; i < k; ++i) {
        int d;
        cin >> d;
        for (int j = 0; j < d; ++j) {
            int t;
            cin >> t;
            s.insert(t);
        }
    }
    cout << n - s.size() << endl;
}

Measured memory_bytes: 3652
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	public static void main(String[] args) {
		int N=sc.nextInt();
		int i=sc.nextInt();
		
		p(N-i+1);
	}
	
	
	
	
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  int count=0;
  bool flag=true;
  for(int i=0;;i++){
    for(int j=0;j<N;j++){
      if(A.at(j)%2 != 0)  flag=false;
      A.at(j)/=2;
    }
    if(!flag) break;
    count++;
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <climits>
#include <bitset>
#include <cassert>
#include <random>
#include <complex>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

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

const int N = 2e5 + 10;
vector<int> divisor[N];

double dp[25][N];
double a[25];

double rec(int i, int val){
	if (i == 0) return abs(val - a[i]) / a[i];

	double &res = dp[i][val];
	if (res > -.5) return res;

	res = 1e9;
	for (auto d : divisor[val]){
		res = min(res, rec(i - 1, val / d));
	}
	res = max(res, abs(val - a[i]) / a[i]);

	return res;
}

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

	FOR(i, 1, N) for (int j = i; j < N; j += i) divisor[j].push_back(i);

	int n;
	cin >> n;
	rep(i, n) cin >> a[i];

	rep(i, 25) rep(j, N) dp[i][j] = -1;
	double ans = 1e9;
	FOR(i, 1, N){
		//cout << i << ' ' << rec(n - 1, 36) << endl;
		ans = min(ans, rec(n - 1, i));
	}
	cout.setf(ios::fixed);
	cout.precision(12);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 61760
#include <iostream>
#include <algorithm>
#include <vector>
// #include <bits/stdc++.h>
using namespace std;

int main()
{
  int snkNum = 0;
  int oksNum = 0;

  cin >> snkNum >> oksNum;

  vector<int> haveOksVec(snkNum+1, 0);
  vector<int> oksVec(oksNum+1, 0);

  for (int i = 1; i <= oksNum; i++)
  {
    int temp;
    cin >> temp;

    for (int i = 1; i <= temp; i++)
    {
      int temp2;
      cin >> temp2;
      haveOksVec[temp2] = 1;
    }

  }

  int ans = 0;

  for(int i = 1; i <= snkNum; i++)
  {
    if(haveOksVec[i] == 0)
    {
      ans++;
    } 
  }


  cout << ans << endl;
}

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

int main(){
	
	long long int N, K, res = -1000000009;
	vector<long long int> P, C, score;
	cin >> N >> K ;

	P.resize(N+1);
	C.resize(N+1);
	score.resize(N+1);

	for(int i = 1; i<N+1; i++){
		cin >> P[i];
	}
	for(int i = 1; i<N+1; i++){
		cin >> C[i];
	}

	for(int i = 1; i<N+1; i++){
		int tmpIdx = i, loopL = 0;
		long long int loopS = 0, score = 0;

		do{
			loopL++;
			tmpIdx = P[tmpIdx];
			loopS += C[tmpIdx];
			score += C[tmpIdx];

			if(loopL <= K){
				res = max(res, score);
			}
		}while(tmpIdx != i);
		// loop部分を使わない場合はこのループで網羅

		// tmpIdx は i
		score = 0;
		if(K >= loopL && loopS > 0){
			for(int j=1; j<loopL+1; j++){
				tmpIdx = P[tmpIdx];
				score += C[tmpIdx];
				res = max(res, score + loopS*((K-j)/loopL));
			}
		}

	}
	
	
	cout << res;

	return 0;
}

Measured memory_bytes: 3720
import java.io.*;
import java.util.*;

class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int deg=0;
        int d_deg=0;
        double x=0;
        double y=0;
        int length=0;
        while(true){
            deg+=d_deg;
            StringTokenizer st=new StringTokenizer(br.readLine(),",");
            length=Integer.parseInt(st.nextToken());
            d_deg=Integer.parseInt(st.nextToken());
            if(d_deg==0&&length==0) break;
            x+=length*Math.cos(Math.toRadians(deg));
            y+=length*Math.sin(Math.toRadians(deg));
            
        }System.out.println((int)y);
        System.out.println((int)x);
    }
}

Measured memory_bytes: 24040
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define int ll

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


//std::ios::sync_with_stdio(false);

main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	int x,y;
	cin>>x>>y;
	if(y%2==0 && (y/2-x)>=0 && (2*x-y/2)>=0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
} 


Measured memory_bytes: 3640
#include<cstdio>
int main(){
int n;
scanf("%d",&n);
int a[n]={};
int b[n]={};
for(int i=0;i<n;i++){
scanf("%d %d",&a[i],&b[i]);
}
int x=0;
int y=0;
for(int i=0;i<n;i++){
if(a[i]>x){
x=a[i];
y=i;
}
}
printf("%d\n",a[y]+b[y]);
return 0;
}

Measured memory_bytes: 1024
n = int(input())
cards = {} #空の辞書
for i in range(n):
    card = input()
    cards[card] = 1
for c in ['S', 'H', 'C', 'D']:
    for n in range(1,14):
        key = c + ' ' + str(n)
        if not key in cards:
            print(key)


Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

long long int nCr(int n, int r){
    long long int num = 1;
    for(int i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}

int main() {
    int N;
    cin >> N;
    map<string, int> mp;
    for (int i=0; i<N; i++) {
        string str;
        cin >> str;
        sort(str.begin(), str.end());
        auto itr = mp.find(str);
        if( itr != mp.end() ) {
            int n = mp[str]; n++; mp[str] = n;
        } else {
            mp[str] = 1;
        }
    }

    long long int cnt = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if (itr->second > 1) {
            cnt += nCr(itr->second, 2);
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
			int N =sc.nextInt();
			int[] A=new int[N];			
			int ans=40;
			int tmp=0;
						
			for(int i=0;i<N;i++){
				A[i]=sc.nextInt();
			}
			for(int i=0;i<N;i++){
				tmp=0;
				for(;A[i]%2==0;){
					tmp++;		
					A[i]=A[i]/2;
				}
				if(tmp<ans){
					ans=tmp;
				}
			}
			System.out.println(ans);
		}
}

Measured memory_bytes: 22740
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
ll f(ll n) {
	ll p = n / 4 * 4;

	ll x = 0;
	for (ll i = p; i <= n; ++i) {
		x ^= i;
	}
	return x;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;
	cin >> a >> b;
	cout << (f(b) ^ f(a - 1)) << endl;

}

Measured memory_bytes: 256
#include <iostream>

int arr[110][110];

int main() {
	int r, c;
	std::cin >> r >> c;
	for(int i = 1; i <= r; i++) {
		int sum = 0;
		for(int j = 1; j <= c; j++) std::cin >> arr[i][j], sum += arr[i][j];
		arr[i][c + 1] = sum;
	}
	for(int j = 1; j <= c; j++) {
		int sum = 0;
		for(int i = 1; i <= r; i++) sum += arr[i][j];
		arr[r + 1][j] = sum;
	}
	for(int i = 1; i <= r; i++) arr[r + 1][c + 1] += arr[i][c + 1];
	for(int i = 1; i <= r + 1; i++) {
		bool f = 1;
		for(int j = 1; j <= c + 1; j++) {
			if(f) f = 0;
			else std::cout << ' ';
			std::cout << arr[i][j];
		}
		std::cout << '\n';
	}
	return 0;
}


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

int M = 1e9 + 7;
struct Mat {
    vector<long> a;
    int s;
    Mat(int s) : s(s), a(s * s) {}
    const Mat &operator=(long x) {
        for(int i = 0; i < s; i++)
            for(int j = 0; j < s; j++)
                (*this)(i, j) = i == j ? x : 0;
        return *this;
    }
    long &operator()(int i, int j) { return a[i * s + j]; }
    const long &operator()(int i, int j) const { return a[i * s + j]; }
    const Mat &operator()(const Mat &m, const Mat &n) {
        for(int i = 0; i < s; i++)
            for(int j = 0; j < s; j++)
                for(int k = 0; k < s; k++)
                    ((*this)(i, k) += m(i, j) * n(j, k)) %= M;
        return *this;
    }
    const Mat &operator*=(const Mat &m) {
        Mat t(s);
        return *this = t(*this, m);
    }
};
int a[] = {-11,   50,  -110, 65,   253, -648, 440,  610, -1430, 780, 780,
           -1430, 610, 440,  -648, 253, 65,   -110, 50,  -11,   1};
int main() {
    int t;
    cin >> t;
    for(int i = 0; i < t; i++) {
        int n;
        cin >> n;
        if(n < 5) {
            cout << "0\n";
            continue;
        }
        n -= 5;
        Mat m(21), k(21);
        k = 1;
        for(int j = 0; j < 21; j++)
            m(0, j) = (-a[j] + M) % M;
        for(int j = 1; j < 21; j++)
            m(j, j - 1) = 1;
        for(; n; n >>= 1) {
            if(n & 1)
                k *= m;
            m *= m;
        }
        cout << k(0, 0) << '\n';
    }
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

#define rep(i, s, n) for(int i = s;i<n;i++)
#define repe(i, s, n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<int> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
static const ll maxLL = (ll) 1 << 62;
const ll MOD = 1000000007, INF = 1e18;
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1, 0, -1};

template<typename T1, typename T2>
bool pairCompare(const pair<T1, T2> &firstElof, const pair<T1, T2> &secondElof) {
    return firstElof.second > secondElof.second;
}

int mapMaxValue(std::map<ll, int> m) {
    int max = 0;
    for (std::map<ll, int>::iterator it = m.begin(); it != m.end(); it++) {
        if (max < it->second) max = it->second;
    }
    return max;
}

int main(void) {
    int n;
    cin >> n;
    vi d(n);

    for (int i = 0; i < n; ++i) {
        cin >> d[i];
    }

    sort(d.begin(), d.end());

    cout << d[n / 2] - d[n / 2 - 1] << endl;
}

Measured memory_bytes: 640
<?php
$n = trim(fgets(STDIN));
$x = explode(" ", trim(fgets(STDIN)));
$y = explode(" ", trim(fgets(STDIN)));

$a = array();
for ($i = 0; $i < $n; $i++)
  $a[$i] = abs($x[$i] - $y[$i]);

$p1 = 0;
$p2 = 0;
$p3 = 0;
$p4 = 0;

foreach ($a as $ai) {
  $p1 += $ai;
  $p2 += $ai * $ai;
  $p3 += $ai * $ai * $ai;
  if ($p4 < $ai) $p4 = $ai;
}
$p2 = sqrt($p2);
$p3 = pow($p3, 1 / 3);

echo sprintf("%.10f\n%.10f\n%.10f\n%.10f\n", $p1, $p2, $p3, $p4);



Measured memory_bytes: 9388
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  string S;
  cin >> S;
  int flag=0;
  while(S!=""){
    int N = S.size();
    if(N>=7){
      if(S.substr(N-7,7)=="dreamer"){
        S=S.substr(0,N-7);
      }else if(S.substr(N-6,6)=="eraser"){
        S=S.substr(0,N-6);
      }else if(S.substr(N-5,5)=="erase"){
        S=S.substr(0,N-5);
      }else if(S.substr(N-5,5)=="dream"){
        S=S.substr(0,N-5);
      }else{
        flag=1;
        break;
      }
    }else if(N==6){
      if(S.substr(N-6,6)=="eraser"){
        S=S.substr(0,N-6);
      }else if(S.substr(N-5,5)=="erase"){
        S=S.substr(0,N-5);
      }else if(S.substr(N-5,5)=="dream"){
        S=S.substr(0,N-5);
      }else{
        flag=1;
        break;
      }
    }else if(N==5){
      if(S.substr(N-5,5)=="erase"){
        S=S.substr(0,N-5);
      }else if(S.substr(N-5,5)=="dream"){
        S=S.substr(0,N-5);
      }else{
        flag=1;
        break;
      }
    }else{
      flag=1;
      break;
    }
  }

  if(flag==1){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
}

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

int main() {
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	}
    else if(a>b){
		cout<<"a > b"<<endl;
	}
	else if(a==b){
		cout<<"a == b"<<endl;
	}	
}



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

int main(){
  int a,b,c;
  int k;
  cin >> a >> b >> c;
  cin >> k;
  
  while(k > 0){
    if(a >= b){
      b*=2;
      k--;
    }
    else if(b >= c){
      c*=2;
      k--;
    }
    else{
      c*=2;
      k--;
    }
  }
  
  if(b > a){
   if(c > b){
    cout << "Yes" << endl;
   }
   else{
    cout << "No" << endl;
 	}
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3612
import sys
N = int(input())
A = []
x = []
y = []

for i in range(N):
    a1 = int(input())
    A.append(a1)
    x1 = []
    y1 = []
    for j in range(a1):        
        x2, y2 = map(int,input().split())
        x1.append(x2)
        y1.append(y2)
    x.append(x1)
    y.append(y1)

ans = []
c = 0
for i in range(1 << N):
    c = 0
    s = 0
    for j in range(N):
        if (i >> j) & 1 == 1:
            for k in range(A[j]):
                if (i >> (x[j][k] - 1)) & 1 != y[j][k]:
                    s = 1
                    break
        if s == 1:
            break
    if s != 1:
        for j in range(N):
            if (i >> j) & 1 == 1:
                c += 1
        ans.append(c)
        
print(max(ans))   

Measured memory_bytes: 3480
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
 
#include <bits/stdc++.h>
using namespace std;

#define    int                      long long int

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    ppi                      pair <int , pii>               
#define    sp(x)                    setprecision(x)

int32_t main()
{
    speed upp
    string s;
    cin>>s;
    if(s[0]==s[1] && s[1]==s[2])
        cout<<"No";
    else
        cout<<"Yes";
}

Measured memory_bytes: 256
s = input()
def kai(s):
    if s[0] == "A":
        if "C" in s[2:-1]:
            if s.count("C") == 1:
                s = s.replace("A", "")
                s = s.replace("C", "")
                if s.islower():
                    print("AC")
                else:
                    print("WA")
            else:
                print("WA")
        else:
            print("WA")
    else:
        print("WA")
 
kai(s)

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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

int _runtimeTerror_()
{
    int x;
    cin>>x;
    cout<<(x^1)<<"\n";
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

Measured memory_bytes: 3644
a, b, m = gets.split.map(&:to_i)

as = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)

mn = as.min + bs.min

m.times do
  x, y, c = gets.split.map(&:to_i)

  discounted_price = as[x - 1] + bs[y - 1] - c

  mn = [discounted_price, mn].min
end

p mn


Measured memory_bytes: 18700
#include <stdio.h>
#include <stdlib.h>
int main(){
  long int N,K,a,b;
  scanf("%ld %ld",&N,&K);
  a=N%K;
  b=K-a;
  if(a<b) printf("%ld",a);
  else printf("%ld",b);
  return 0;
}

Measured memory_bytes: 128
class Card():

    def bubble_sort(self):
        bubble_card = [i for i in self]
        for i in range(len(bubble_card)):
            for j in range(len(self)-1, i, -1):
                if bubble_card[j].strip('SHCD') < bubble_card[j-1].strip('SHCD'):
                    bubble_card[j], bubble_card[j-1] = bubble_card[j-1], bubble_card[j]
        return bubble_card


    def selection_sort(self):
        select_card = [i for i in self]
        for i in range(len(select_card)):
            minj = i
            change = False
            for j in range(i + 1, len(select_card)):
                if select_card[minj].strip('SHCD') > select_card[j].strip('SHCD'):
                    minj = j
                    change = True
            if change:
                select_card[i], select_card[minj] = select_card[minj], select_card[i]
        return select_card


    def stable_sort(self):
        sort_card = [i for i in self]
        sort = []
        for i in range(len(sort_card)-1):
            min = i
            for j in range(i+1, len(sort_card)):
                if int(sort_card[min].strip('SHCD')) > int(sort_card[j].strip('SHCD')):
                    min = j
            min_card = sort_card[min]
            sort_card.pop(min)
            sort_card.insert(i,min_card)
        sort = sort_card
        return sort





def main():
    n = int(input())
    cards = [i for i in input().split()]
    bubble = Card.bubble_sort(cards)
    select = Card.selection_sort(cards)
    stable = Card.stable_sort(cards)

    for i in range(len(bubble)):
        print(bubble[i]) if i == len(bubble)-1 else print(str(bubble[i])+' ',end='')
    print('Stable') if bubble == stable else print('Not stable')

    for i in range(len(select)):
        print(select[i]) if i == len(select)-1 else print(str(select[i])+' ',end='')
    print('Stable') if select == stable else print('Not stable')


if __name__ == '__main__':
    main()

Measured memory_bytes: 7776
a,b,c=map(int,input().split())
if a==5 and c==5:
    if b==7:
        print("YES")
    else:
        print("NO")
else:
    if a==5 and b==5 or b==5 and c==5:
        if c==7 or a==7:
            print("YES")
        else:
            print("NO")
    else:
        print("NO")

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)


int main(){
    int a,b;
    cin>>a>>b;
    char c;
    if(a*b==15) c='*';
    else if(a+b==15) c='+';
    else c='x';
    cout<<c<<endl;
}



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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if ( (a == b && b == c) || (a != b && b != c && a != c) ){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(In));
        }

        public T Min<T>(params T[] a)
        {
            if (a.Length == 0) return default(T);

            T min = a[0];
            for (int i = 1; i < a.Length; i++)
            {
                if ((dynamic)min > (dynamic)a[i]) min = a[i];
            }
            return min;
        }

        public T Max<T>(params T[] a)
        {
            if (a.Length == 0) return default(T);

            T max = a[0];
            for (int i = 1; i < a.Length; i++)
            {
                if ((dynamic)max < (dynamic)a[i]) max = a[i];
            }
            return max;
        }

        public void Solve(ConsoleInput input)
        {
            var a = input.ReadInt;
            var b = input.ReadInt;

            if (b % a == 0)
            {
                WriteLine($"{a + b}");
            }
            else
            {
                WriteLine($"{b - a}");
            }


            //Solve(input);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private readonly char _separator;
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            _separator = separator;
            _stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13268
s = input()
a = [s[i] for i in range(len(s)) if (i + 1) % 2 == 1]
b = [s[i] for i in range(len(s)) if (i + 1) % 2 == 0]
a = list(set(a))
b = list(set(b))
a.sort()
ans = ''
for e in a:
  if ans == '':
    if e == 'R' or e == 'U' or e == 'D':
      next
    else:
      ans = 'No'
if ans == '':
  for e in b:
    if ans == '':
      if e == 'L' or e == 'U' or e == 'D':
        next
      else:
        ans = 'No'
if ans == '':
  ans = 'Yes'
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cassert>
#include <numeric>
#include <queue>
#include <unordered_set>

using namespace std;

bool solve(std::string s, std::string t) {
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());

    return s < t;
}

int main() {
     string s, t;
    cin >> s >> t;

    cout << (solve(s, t) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int n;
  cin >> n;
  vint hat(3);
  bool flag = true;
  int ans = 1;
  rep(i,n){
    int count = 0;
    int a;
    cin >> a;
    flag = true;
    rep(j,3){
      if(hat[j] == a){
        count++;
        if(flag){
          hat[j]++;
          flag = false;
        }
      }
    }
    ans *= count;
    ans %= MOD;
  }
  cout << ans << endl;
}

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

int N,M;

int par[101010];

void init(const int n){ 
  for(int i = 0; i < n; i++){ par[i] = i;}
}

int root(int a){ 
  if( a == par[a]){ return a;}
  else{ return par[a] = root(par[a]);}
}

bool issame(int a, int b){
  return root(a) == root(b);
}

void unite(int a, int b){ 
  if( issame(a,b) ){ return ;}
  else{
    par[root(a)] = root(b);
  }
}

struct edge{int u,v,val;};

bool comp(edge a, edge b){
  return a.val < b.val;
}

edge E[101010];

int Kruscal(){ 
  
  int sum = 0;
  
  sort(E,E+M,comp);
  
  for(int i = 0; i < M; i++){ 
    int a = E[i].u; int b = E[i].v;
    
    if( issame(a,b) ){ continue;}
    
    unite(a,b);
    
    sum += E[i].val;
    
  }
  
  return sum;
}
  
      

signed main(void){
  
  cin >> N >> M;
  init(N);
  
  for(int i = 0; i < M; i++){
    cin >> E[i].u >> E[i].v >> E[i].val;
  }
  
  cout << Kruscal() << endl;
  
  return 0;
}


Measured memory_bytes: 5520
N,L=map(int,input().split())
a=[int(i) for i in input().split()]
Longest_pair=0
p=0
for i in range(N-1):
  if a[i]+a[i+1]>Longest_pair:
    Longest_pair=a[i]+a[i+1]
    p=i+1
if Longest_pair<L:
  print("Impossible")
  exit()
else:
  print("Possible")
for i in range(1,p):
  print(i)
for i in range(p+1,N)[::-1]:
  print(i)
print(p)


Measured memory_bytes: 63984
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        int E = sc.nextInt();
        int N = 5;

        //注文してから届くまでの時間
        int[] time = {A, B, C, D, E};
        //注文してから次に注文できるまでの時間
        int[] nextTime = new int[N];

        for (int i = 0; i < N; i++) {
            if (time[i] % 10 == 0) {
                nextTime[i] = time[i];
            } else {
                nextTime[i] = time[i] - time[i] % 10 + 10;
            }
        }

        int ans = 999999999;

        for (int i = 0; i < N; i++) {
            int sumTime = 0;
            for (int j = 0; j < N; j++) {
                if (i == j) {
                    //最後の処理
                    sumTime += time[j];
                } else {
                    sumTime += nextTime[j];
                }
            }
            ans = Math.min(ans, sumTime);
        }

        System.out.println(ans);


    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <cstdint>
#include <cassert>
#include <cstring>

uint32_t N, RK;
uint32_t C[300][300];
uint64_t pows[301];
bool zero[300];
const uint64_t MOD = 1000000007;

uint64_t memo[301][301];

uint64_t solve(int r, int rank) {
  if (memo[r][rank] != -1) {
    return memo[r][rank];
  }

  if (r == N) {
    uint64_t ans = 1;
    for (int i = rank + 1; i <= N; ++i) {
      ans = (ans * pows[N]) % MOD;
    }
    return memo[r][rank] = ans;
  } else {
    uint64_t a = (pows[N] - pows[rank] + MOD) % MOD;

    uint64_t indep = (a * solve(r + 1, rank + 1)) % MOD;
    uint64_t depen = 0;

    int nz = 0;
    if (zero[r]) {
      for (int i = 0; i < r; ++i) {
        if (zero[i]) {
          ++nz;
        }
      }
      depen = pows[nz - r + rank] * solve(r + 1, rank) % MOD;
    }

#ifdef DEBUG
    std::cout << "f(" << r << ", " << rank << ") = " << (indep + depen) << " = " << a << " * f(" << (r + 1) << ", " << (rank + 1) << ")";
    if (zero[r]) {
      std::cout << " + " << pows[nz] << " * f(" << (r + 1) << ", " << rank << ")" << std::endl;
    } else {
      std::cout << std::endl;
    }
#endif

    return memo[r][rank] = (indep + depen) % MOD;
  }
}

int main() {
  memset(memo, -1, sizeof memo);

  std::cin >> N;
  RK = N;

  pows[0] = 1;
  for (int i = 0; i <= N; ++i) {
    pows[i + 1] = (2 * pows[i]) % MOD;
  }

  for (int r = 0; r < N; ++r) {
    for (int c = 0; c < N; ++c) {
      std::cin >> C[r][c];
    }
  }

  for (int c = 0; c < N; ++c) {
    int r = 0;
    for (; r < N; ++r) {
      int t = 0;
      for (; t < c && C[r][t] == 0; ++t);
      if (t == c && C[r][t] == 1) {
        break;
      }
    }
    if (r == N) {
      zero[c] = 1;
      --RK;
    } else {
      std::swap(C[r], C[c]);
      for (int r2 = c + 1; r2 < N; ++r2) {
        if (C[r2][c] == 1) {
          for (int c2 = 0; c2 < N; ++c2) {
            if (c2 < c) {
              assert(C[r2][c2] == 0);
            } else {
              C[r2][c2] ^= C[c][c2];
            }
          }
        }
      }
    }
  }

  std::cout << solve(0, 0) << std::endl;
}


Measured memory_bytes: 1280
#include<stdio.h>
#include<string.h>

int main(){
  char line[128];
  char *pre_contest[] = {};
  char *contest[] ={"ABC","ARC"};
  fgets(line,sizeof(line),stdin);
  pre_contest[0] = line;

  if(strncmp(contest[0],pre_contest[0],3)==0){
    printf("%s",contest[1]);
  }
  if(strncmp(contest[1],pre_contest[0],3)==0){
    printf("%s",contest[0]);
  }

  return 0;

}

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

typedef long long ll;

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

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

ll gcm(ll a, ll b) {
  ll c = a % b;
  a = b;
  b = c;
  while(c != 0) {
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

ll lcm(ll a, ll b) {
  ll g = gcm(a, b);
  return ((a / g) * (b / g)) * g;
}  

int main() {
 ll n, t[101];
 cin >> n;
 rep(i, 0, n) cin >> t[i];
 rep(i, 1, n) {
   t[i] = lcm(t[i - 1], t[i]);
 }

 cout << t[n - 1] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define mod 1000000007
#define inf 9999999999999999ll
vi sieve()
{
    vi pr;
    ll n=500000;
    vb prime(n+1,true);
    prime[0]=prime[1]=false;
    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i])
        {
            for(ll j=2*i;j<=n;j+=i)
                prime[j]=false;
        }
    }
    for(ll i=2;i<=n;i++)
    {
        if(prime[i])
            pr.pb(i);
    }
    return pr;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vi p=sieve();
    cout<<*lower_bound(p.begin(),p.end(),n)<<endl;
}


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

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

  int a, b, c;
  cin >> a >> b >> c;
  int tmpa = 0;
  int tmpb = 0;
  int i;
  for (i = 0; i < 500000000 ; i++) {
    if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
      break;
    }
    tmpa = a;
    tmpb = b;
    a = (b+c) / 2;
    b = (tmpa + c) / 2;
    c = (tmpa + tmpb) / 2;
  }
  if (i == 500000000) {
    cout << -1 << '\n';
  }
  else {
    cout << i << '\n';
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

const int INF = 1<<30;

int n, m, data[16], dp[2][256], in;

main(){
  while(cin >> n >> m && (n|m)){
    for(int i=0;i<m;i++) cin >> data[i];
    fill(dp[0], dp[2], INF);
    dp[0][128] = 0;
    for(int i=0;i<n;i++){
      cin >> in;
      for(int j=0;j<256;j++) dp[(i+1)%2][j] = INF;
      for(int j=0;j<256;j++){
        if(dp[i%2][j] == INF) continue;
        for(int k=0;k<m;k++){
          int next = j + data[k];
          if(next < 0) next = 0;
          if(next > 255) next = 255;
          dp[(i+1)%2][next] = min(dp[(i+1)%2][next], abs(in-(next)) * abs(in-(next)) + dp[i%2][j]);
        }
      }
    }
    int ans = INF;
    for(int i=0;i<256;i++) ans = min(ans, dp[n%2][i]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
#include<iostream>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1)a += 13;
	if (b == 1)b += 13;
	if (a > b)cout << "Alice" << endl;
	else if (a < b)cout << "Bob" << endl;
	else cout << "Draw" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  ull a, b, c;
  cin >> a >> b >> c;
  
  if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
    cout << 0 << endl;
  } else {
    cout << min(a*b, min(b*c, a*c)) << endl;
  }
  return 0;
}

Measured memory_bytes: 3576
n = gets.to_i
ss = gets.split.map(&:to_i)
loop do
  m = ss.inject(:+).to_f / n

  sum = 0.0

  ss.each do |s|
    sum += (s - m) **2
  end

  puts "%0.8f" % Math.sqrt(sum / n)

  n = gets.to_i
  break if n==0
  ss = gets.split.map(&:to_i)
end

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

int main(){
    int N;
    cin >> N;
    int a[N-1];
    int temp;
    int result = 0;

    for(int i=0; i<N; ++i){
        cin >> a[i];
    }

    for(int i=0; i<N; ++i){
        for(int j=N-1; j>i; --j){
            if(a[j] < a[j-1]){
                temp = a[j];
                a[j] = a[j-1];
                a[j-1] = temp;
            }
        }
    }

    for(int i=N-1; i>0; --i){
        result += a[i] - a[i-1];
    }
    cout << result << endl;
}

/*
ソートしてダブリを削除して差を計算
*/


Measured memory_bytes: 256