akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int n = Integer.parseInt(str[0]);
            int k = Integer.parseInt(str[1]);
            str = br.readLine().split(" ");
            Map<Integer, Integer> map = new TreeMap<Integer, Integer>();
            for (int i = 0; i < n; i++) {
                int tmp = Integer.parseInt(str[i]);
                if (map.containsKey(tmp)) {
                    int val = map.get(tmp) + 1;
                    map.put(tmp, val);
                } else {
                    map.put(tmp, 1);
                }
            }
            List<Entry<Integer, Integer>> list_entries = new ArrayList<Entry<Integer, Integer>>(map.entrySet());

            Collections.sort(list_entries, new Comparator<Entry<Integer, Integer>>() {
                public int compare(Entry<Integer, Integer> obj1, Entry<Integer, Integer> obj2) {
                    return obj1.getValue().compareTo(obj2.getValue());
                }
            });

            if (map.size() > k) {
                int ans = 0;
                int count = map.size() - k;
                int i = 0;
                    for (Entry<Integer, Integer> entry : list_entries) {
                        int val = entry.getValue();
                        ans += val;
                        i++;
                        if (count <= i) {
                            break;
                        }
                    }
                System.out.println(ans);
            } else {
                System.out.println(0);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

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

	ll A[N];
	rep(i, N) cin >> A[i];

	// 各ビットごとの1の個数を調べる
	ll b[61] = {};
	for(int i = 60; i >= 0; i--){
		ll y = 1LL << i;
		int cnt = 0;
		rep(i, N){
			if(A[i] & y) cnt++;
		}
		b[i] = cnt;
	}

	// for(int i = 60; i >= 0; i--) cout << b[i];
	// cout << endl;

	// Xを探す
	// XとKとで初めてビットが異なる箇所で場合分け
	// X <= K なので、初めてビットが異なればその箇所ではXのビットは0、Kのビットは1
	// それ以降は何でもよいので貪欲
	ll ans = 0;
	for(int i = 60; i >= -1; i--){
		ll t = 0;
		if(i != -1 && !(K & (1LL << i))) continue;
		for(int j = 60; j >= 0; j--){
			ll y = 1LL << j;
			if(j > i){
				if(K & y) t += (N - b[j]) * y;
				else t += b[j] * y;
			}else if(j == i){
				t += b[j] * y; // (N - b[j]) * y;
			}else{
				t += max(b[j] * y, (N - b[j]) * y);
			}
		}
		// cout << i << " " << t << endl;
		ans = max(ans, t);
	}

	cout << ans << endl;
}


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

int main(){
    int N, X;
    cin >> N >> X;
    int D = 0;
    int cnt = 1;
    for (int i=2;i<=N+1;i++){
        int L;
        cin >> L;
        D += L;
        if (D <= X) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        boolean[] d = new boolean[10];
        for(int i = 0; i < k; i++){
            d[sc.nextInt()] = true;
        }
        Deque<String> q = new ArrayDeque<String>();
        q.add("");
        while(q.size() > 0){
            String s = q.poll();
            int a = !s.isEmpty() ? 0 : 1;
            for(int i = a; i < 10; i++){
                if(d[i]) continue;
                String tmp = s+i;
                if(Integer.parseInt(tmp) >= n){
                    System.out.println(tmp);
                    return;
                }else{
                    q.add(tmp);
                }
            }
        }
    }
    public static int nCk(int n,int k,int M) {
        long ret = 1;
        if(n < k)return 0;
        int min = Math.min(k, n-k);
        for(int i=1;i<=min;i++) {
            ret = (ret * pow(i,M-2,M)) % M;
        }
        for(int i=n-min+1;i<=n;i++) {
            ret = (ret * i) % M;
        }
        return (int)ret;
    }

    public static long pow(long a,long b,int M) {
        long ret = 1;
        long tmp = a;
        while(b>0) {
            if((b&1)==1){
                ret = (ret * tmp) % M;
            }
            tmp = (tmp * tmp) % M;
            b = b>>1;
        }
        return ret;
    }
}


class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <time.h>  
#define f first
#define s second
#define rep(i, l, r) for (long long i = (l); i < (r); i++)
#define repb(i, r, l) for (long long i = (r); i > (l); i--)
#define pb push_back
 
using namespace std;
typedef vector<long long> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef deque <long long> dq;
typedef long long int lli;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull; 
const int MAX_CHAR=256;
 
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 
 
const ll mod = 1e9 + 7;
 
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
} 
 
ll nCrModp(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
    for (ll i = 1; i <= n; i++) 
    { 
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
}
 
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true;  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 

bool sortinrev(const pair<ll,string> &a,  
               const pair<ll,string> &b) 
{ 
       return (a.first > b.first); 
}
 
vl countFreq(ll arr[], ll n) 
{ 
    unordered_map<ll, ll> mp; 
    vector <ll> v;
    
    for (ll i = 0; i < n; i++) 
        mp[arr[i]]++; 
   
    for (auto x : mp) 
        v.pb(x.second);
    
    return v;
}
 
bool sortbysec(const pair<ll, ll>& a, 
               const pair<ll, ll>& b) 
{ 
    return (a.second < b.second); 
} 

ll binarySearch(ll arr[], ll l, ll r, ll x) 
{ 
    while (l <= r) 
    { 
        ll m = l + (r - l) / 2; 
        if (arr[m] == x) 
            return m; 
        if (arr[m] < x) 
            l = m + 1; 
        else
            r = m - 1; 
    }
    return -1; 
}

const ll MAXSIEVE=(1e3);
ll spf[MAXSIEVE];
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXSIEVE; i++) 
        spf[i] = i; 

    for (ll i=4; i<MAXSIEVE; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXSIEVE; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXSIEVE; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}

int main()
{
    
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    
    while(t--)
    {
        string str;
        cin >> str;
        
        bool flag=false;
        rep(i,0,str.length())
            if(str[i]=='7')
                flag=true;
        
        if(flag==true)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}


Measured memory_bytes: 3640
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-3;
const double PI  = acos(-1.0);

double p(vector<double>& xs, vector<double>& ys, double x){
  double y = 0;
  REP(i,SZ(xs)){
	double tmp = 1.;
	REP(j,SZ(xs))
	  if(i != j)
		tmp *= (x - xs[j]) / (xs[i] - xs[j]);
	y += tmp * ys[i];
  }
  return y;
}


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

  int d;
  while(cin>>d,d){
	int N = d+3, ans = -1;
	vector<double> xs(N), ys(N);
	REP(i,N) cin >> ys[i], xs[i] = i;

	REP(i,N){
	  vector<double> y_ = ys, x_ = xs;
	  y_.erase(y_.begin()+i);
	  x_.erase(x_.begin()+i);
	  bool ok = true;
	  REP(j,SZ(y_)){
		vector<double> x = x_, y = y_;
		y.erase(y.begin()+j);
		x.erase(x.begin()+j);
		if(abs(p(x,y,x_[j]) - y_[j]) > EPS)
		  ok = false;
	  }

	  if(ok) ans = i;
	}

	cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  string s,t;
  cin>>s>>t;
  ll count = 0;
  t.pb('1');
  for (ll i = n; i > 0; i--){
    string a = s.substr(n - i);
    string b = t;
    b.erase(b.begin() + i,b.begin()+n+1);
    if (a == b)
    {
      count = i;
      break;
    }
  }
  print(2 * n - count);
}

Measured memory_bytes: 3584
#include<stdio.h>
 
int A[100][100];
 
int main(void){
  int n,u,l,i,j,k;
 
  scanf("%d",&n);
   
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&l);
    for(j=0;j<l;j++){
      scanf("%d",&k);
      A[i][k-1]=1;
    }
  }
   
  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
      printf("%d ",A[i][j]);
    }
      printf("%d\n",A[i][j]);
 
  }
  return 0;
}

Measured memory_bytes: 628
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(m)]
c=[0]*n
for i in range(m):
    c[ab[i][0]-1]+=1
    c[ab[i][1]-1]+=1
for i in range(n):
    print(c[i])

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

using namespace std;
using ll = long long;
using P = pair<int ,int>;
using  vi = vector<int>;
using vii = vector<P>;

const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

#define INF 1LL << 62
#define MOD (int)1e9 + 7
#define rep(i,n) for(int i = 0;i<n;i++)
#define all(x) x.begin(),x.end()
#define pb push_back

int main() {

	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	cout <<s1[0] << s2[0] << s3[0]<< endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>

#define mod 1000000007
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG

using namespace std;
using ll = long long;
using lli = long long int;
using pii = pair<int, int>;
 
 int main(){
	 int N, n, digit = 0;
	 cin >> N;
	 n = N;
	 int a = 0;
	while(n > 0){
		a += n%10;
		n /= 10;
	 }
	 if(N%a == 0) cout << "Yes";
	 else cout << "No";
	 return 0;
 }

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

int main() {
	int d;
	cin >> d;
	const int n = 26;
	vector<int> c(n);
	vector<vector<int>> s(d, vector<int>(n));
	rep(i, n) cin >> c[i];
	rep(i, d) rep(j, n) cin >> s[i][j];
	vector<int> t(d), last(n);
	
	// 貪欲
	ll ans = 0;
	rep(i, d) {
		ll mx = -1001001001;
		int now = 0;
		
		rep(j, n) {
			ll tmp = ans;
			tmp += s[i][j];
			rep(k, n) {
				if(j == k) continue;
				tmp -= c[k] * (i+1-last[k]);
			}
			if(mx < tmp) {
				mx = tmp;
				now = j;
			}
		}
		ans = mx;
		last[now] = i+1;
		t[i] = now+1;
	}
	int cnt = 0;
	while(1) {
		// 局所探索法
		cnt++;
		if(cnt > 100000) break;
		int nd = rand()%d;
		int nq = rand()%n + 1;
		int old = t[nd];
		t[nd] = nq;
		
		// 点数のシミュレーション
		vector<int> nlast(n);
		ll now = 0;
		rep(i, d) {
			now += s[i][t[i]];
			nlast[t[i]-1] = i+1;
			rep(j, n) {
				now -= c[j] * (i+1-nlast[j-1]);
			}
		}
		
		// 良くなれば更新
		if(now > ans) {
			ans = now;
		} else {
			t[nd] = old;
		}
	}
	
	rep(i, d) printf("%d\n", t[i]);
	return 0;
}

Measured memory_bytes: 3744
// Ivan Zanov
// Template
#include <chrono>
#include <iostream>
#include <utility>
#include <bitset>
#include <vector>
#include <set>
#include <unordered_map>
#include <map>
#include <assert.h>
#include <cmath>
#include <algorithm>
#include <complex>
#include <deque>
#include <iomanip>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <memory>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <sstream>
#include <exception>
#include <functional>
#include <cstring>
#include <cstdlib>
using namespace std;
using namespace std :: chrono;
#define lowbit(x) ((x)&((x)^((x)-1)))
#define max(a,b) (a<b?b:a)
#define IOS ios_base::sync_with_stdio(0);
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define INF (int)1e9
#define EPS (int)1e-9
#define bit_count __builtin_popcount
#define gcd __gcd
#define max3(a, b, c) max(a, max(b,c))
#define min3(a, b, c) min(a, min(b,c))
#define abs(x) (x < 0 ? (-x) : x)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
inline void set_bit(int & n, int b) { n |= (1 << (int) b); }
inline void unset_bit(int & n, int b) { n &= ~(1 << (int) b); }
inline bool check_bit(int n, int pos) { return ( n & (1 << (pos))); }
inline ll lcm(ll a, ll b){ return (a * b / gcd(a,b));}
inline ll square(ll a){return (a * a);}
int main() {
	string a, b;
	cin>>a>>b;
	string str = b + a;
	cout<<str<<endl;
	/*auto start = high_resolution_clock::now();
	auto end = high_resolution_clock::now();
	auto duration = duration_cast<microseconds>(stop - start);
	cout<<fixed<<setprecision(3)<<duration.count() * 1e-6<<endl;*/
    return 0;
}

Measured memory_bytes: 256
n=int(input())
k=0
w=[input() for _ in range(n)]
if len(set(w))!=n:print('No')
else:
    for i in range(n-1):
        if w[i][-1]==w[i+1][0]:k+=1
    if k==n-1:print('Yes')
    else:print('No')

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

//        int n = sc.nextInt();

        int d[]=sc.nextIntArray(5);
        int s=0;
        for (int i = 0; i < d.length; i++) {
			s+=d[i];
			if(d[i]%10!=0)d[i]=10-d[i]%10;
			else d[i]=0;
		}
        sort(d);
        db(d);
        for (int i = 0; i < d.length-1; i++) {
			s+=d[i];
		}
        
       
        out.println(s);
        out.flush();
    }



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int id,T;
//    P(int id, int T) {
//        this.id=id;
//        this.T=T;
//    }
//    public int compareTo(P p){
//        return id-p.id; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 21972
n = int(input())

A = []
for i in range(n):
    A.append(int(input()))
total = sum(A)

if total % 10 != 0:
    print(total)
else:
    A = sorted(A)
    for i in range(n):
        if A[i] % 10 != 0:
            total -=A[i]
            break
    if total % 10 == 0:
        print(0)
    else:
        print(total)

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

int main() {
	int a, b, n;
	bool square = false;
	cin >> a >> b;
	if (b < 10) n = a * 10 + b;
	else if (b < 100) n = a * 100 + b;
	else n = a * 1000 + b;
	
	for (int i = 1; i < 400; i++) {
	    if (n / i == i && n % i == 0) square++;
	}
	
	if (square) cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_BALL_MAX		200005									// 最大ボール数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1Cond[D_BALL_MAX];									// 条件
static int siBCnt;												// ボール数
static int si1Exist[D_BALL_MAX];								// ボール有無
static char sc1Out[D_BALL_MAX * 7];								// 出力内容

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// 出力
int
fOut(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i, j;
	char lc1Buf[1024];

	// ボール数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siBCnt);

	// 条件 - 取得
	for (i = 1; i <= siBCnt; i++) {
		fscanf(szpFpI, "%d", &si1Cond[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// ボール有無 - セット
	for (i = siBCnt; i >= 1; i--) {

		// ボール合計
		int liCnt = 0;
		for (j = 2; ; j++) {
			int liNo = i * j;
			if (liNo > siBCnt) {
				break;
			}
			liCnt += si1Exist[liNo];
		}

		// 条件 - 加算
		liCnt += si1Cond[i];

		// ボール有無 - セット
		si1Exist[i] = liCnt % 2;
	}

	// 出力内容 - セット
	int liOCnt = 0;
	char *lcpOut = sc1Out;
	for (i = 1; i <= siBCnt; i++) {
		if (si1Exist[i] == 1) {
			liOCnt++;
			sprintf(lc1Buf, "%d ", i);
			int liLen = strlen(lc1Buf);
			strncpy(lcpOut, lc1Buf, liLen);
			lcpOut += liLen;
		}
	}

	// 出力 - ボール数
	sprintf(lc1Buf, "%d\n", liOCnt);
	fOut(lc1Buf);

	// 出力 - ボール位置
	if (liOCnt > 0) {
		lcpOut[0] = '\0';
		lcpOut--;
		lcpOut[0] = '\n';
		fOut(sc1Out);
	}

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 3200
#include "bits/stdc++.h"
 
using namespace std;
 
using ll = long long;
 
template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;
 
template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;
 
template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;
 
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()
 
const double PI = acos(-1);
const ll MOD = 1e9+7;
 
int n, m, a, b, q;
string s;
 
int main() {
    cin >> a >> b >> q;
 
    Vl s(a), t(b);
    REP(i, a) cin >> s[i];
    REP(i, b) cin >> t[i];
 
    sort(ALL(s));
    sort(ALL(t));
 
    REP(i, q) {
        ll x;
        cin >> x;
        ll mini = 1e18;
 
        auto sr = lower_bound(ALL(s), x);
        if (sr != s.end()) {
            auto srtr = lower_bound(ALL(t), *sr);
            if (srtr != s.end()) {
                mini = min(mini, abs(x - *sr) + abs(*sr - *srtr));
            }
            if (srtr != t.begin()) {
                mini = min(mini, abs(x - *sr) + abs(*sr - *(srtr-1)));
            }
        }
        if (sr != s.begin()) {
            auto sl = sr-1;
            auto sltr = lower_bound(ALL(t), *sl);
            if (sltr != t.end()) {
                mini = min(mini, abs(x - *sl) + abs(*sl - *sltr));
            }
            if (sltr != t.begin()) {
                mini = min(mini, abs(x - *sl) + abs(*sl - *(sltr-1)));
            }
        }
 
        auto tr = lower_bound(ALL(t), x);
        if (tr != t.end()) {
            auto trsr = lower_bound(ALL(s), *tr);
            if (trsr != s.end()) {
                mini = min(mini, abs(x - *tr) + abs(*tr - *trsr));
            }
            if (trsr != s.begin()) {
                mini = min(mini, abs(x - *tr) + abs(*tr - *(trsr-1)));
            }
        }
        if (tr != t.begin()) {
            auto tl = tr-1;
            auto tlsr = lower_bound(ALL(s), *tl);
            if (tlsr != s.end()) {
                mini = min(mini, abs(x - *tl) + abs(*tl - *tlsr));
            }
            if (tlsr != s.begin()) {
                mini = min(mini, abs(x - *tl) + abs(*tl - *(tlsr-1)));
            }
        }
 
        std::cout << mini << '\n';
    }
 
 
    return 0;
}

Measured memory_bytes: 2944
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

int n,k[200010],l[200010],r[200010];
vector<int> v1[200010],v2[200010];

signed main()
{
	ios::sync_with_stdio(false);
	int t;
	cin>>t;
	while(t--){
		cin>>n;
		long long ans=0ll;
		int cnt1=0,cnt2=0;
		for(int i=1;i<=n;i++){
			cin>>k[i]>>l[i]>>r[i];
			ans+=(long long)min(l[i],r[i]);
			if(l[i]>r[i]) cnt1++;
			else cnt2++;
		}
		for(int i=1;i<=cnt1;i++) v1[i].clear();
		for(int i=1;i<=cnt2;i++) v2[i].clear();
		for(int i=1;i<=n;i++){
			if(l[i]>r[i]){
				v1[min(k[i],cnt1)].push_back(l[i]-r[i]);
			}
			else{
				if(n-k[i]>0) v2[min(n-k[i],cnt2)].push_back(r[i]-l[i]);
			}
		}
		priority_queue<int> q1,q2;
		for(int i=1;i<=cnt1;i++){
			for(int j=0;j<v1[i].size();j++){
				q1.push(-v1[i][j]);
			}
			while(q1.size()>i){
				q1.pop();
			}
		}
		while(!q1.empty()){
			int x=q1.top();ans-=(long long)x;
			q1.pop();
		}
		for(int i=1;i<=cnt2;i++){
			for(int j=0;j<v2[i].size();j++){
				q2.push(-v2[i][j]);
			}
			while(q2.size()>i){
				q2.pop(); 
			}
		}
		while(!q2.empty()){
			int x=q2.top();ans-=(long long)x;
			q2.pop();
		}
		cout<<ans<<'\n';
	}
	return 0;
}

Measured memory_bytes: 18556
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <queue>
#include <set>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n,m; cin >> n >> m;
	vector<ll> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	vector<ll> cnt(n+1,0);
	for(int i=0;i<n;i++){
		cnt[i+1]=a[i]+cnt[i];
	}
	ll ret=0,cn=0;
	ll left=0,right=1e12;
	while(right-left>1){
		ll mid=(left+right)/2;
		ret=0,cn=0;
		for(ll b:a){
			auto itr=lower_bound(a.begin(),a.end(),mid-b);
			int i=itr-a.begin();
			cn+=a.end()-itr;
			ret+=cnt[n]-cnt[i]+(a.end()-itr)*b;
		}
		if(cn<m){
			right=mid;
		}
		else{
			left=mid;
		}
	}
	cout << ret-(cn-m)*left << endl;
}

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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


int main() {
    int x; cin >> x;
    prt(360 / gcd(x, 360));

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int x,a,b;
  cin >> x >> a >> b;
  cout <<(x-a)%b << endl;
}


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

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

using namespace std;

const int INF=1<<29;

int main(){
	int m,n; scanf("%d%d",&m,&n);
	int lo[100][100],up[100][100]; // lower, upper
	rep(u,m){
		rep(i,n){
			lo[u][i]=-INF;
			up[u][i]=+INF;
		}
		int k; scanf("%d",&k);
		while(k--){
			int skill;
			char c;
			int val; scanf("%d %c%*c%d",&skill,&c,&val); skill--;
			if(c=='<'){
				up[u][skill]=min(up[u][skill],val);
			}
			else{
				lo[u][skill]=max(lo[u][skill],val);
			}
		}
	}

	bool G[100][100]={};
	rep(u,m) rep(v,m) rep(i,n) if(up[u][i]<lo[v][i]) G[u][v]=true;

	// Warshall-Floyd
	rep(w,m) rep(u,m) rep(v,m) G[u][v]|=G[u][w]&G[w][v];

	rep(u,m) if(G[u][u]) return puts("No"),0;
	puts("Yes");

	return 0;
}

Measured memory_bytes: 1108
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<iomanip>
#include<map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[8] = { 1,0,-1,0,1,1,-1,-1 };
int dy[8] = { 0,1,0,-1,1,-1,1,-1 };





int main() { 	


	int r;
	cin >> r;

	cout << 3 * r * r << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const ll MOD = (ll)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1], inv[1];
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

priority_queue<int, vector<int>, greater<int>> pq;
vector<int> v;

int vec[200000];
int n;

ll cal(int mid) {
    ll ret = 0;
    for (int i = 0; i < n; i++)
        ret += abs(vec[i] - (mid + i));

    return ret;
}

int main() {
    scanf("%d", &n);

    for (int i = 0; i < n; i++)
        scanf("%d", &vec[i]);

    int le = -200001, ri = 1000000000, mid;

    ll ans = 1e18;
    while (le <= ri) {
        mid = (le + ri) / 2;
        ll aa = cal(mid);
        ll bb = cal(mid + 1);

        ans = min(ans, aa);
        ans = min(ans, bb);
        if (aa < bb) ri = mid - 1;
        else le = mid + 1;
    }

    printf("%lld", ans);
}

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

int a[150] = {};

int main()
{
    string s;
    cin >> s;
    string ans = {};
    for (int i = 0; i < s.size(); ++i)
    {
        if (s[i] == '0')
        {
            ans.push_back('0');
        }
        else if (s[i] == '1')
        {
            ans.push_back('1');
        }
        else
        {
            if (!ans.empty())
            {
                ans.pop_back();
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    for(ll i = k; i <= n+1; i++){
        ll maxi = (n-i+1+n)*i/2;
        ll mini = (i-1)*i/2;
        (ans += maxi - mini +1) %= mod;
    }
    cout << fixed << ans%mod << endl;
    return 0;
}

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

int main(void)
{
	char str[21];
	char swap;
	int len;
	int i;
	
	scanf("%s", str);
	
	len = strlen(str);
	for (i = 1; i <= (len / 2); i++){
		swap = str[i - 1];
		str[i - 1] = str[len - i];
		str[len - i] = swap;
	}
	
	printf("%s\n", str);
	
	return (0);
}

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

class Program
{
	static void Main(string[] args)
	{
		while (true)
		{
			var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
			var n = input[0];
			var x = input[1];

			if (n == 0 && x == 0) break;

			var ans = 0;
			for (var i = 1; i <= n; i++)
			{
				for (var j = i + 1; j <= n; j++)
				{
					for (var k = j + 1; k <= n; k++)
					{
						if (i + j + k == x)
						{
							ans++;
						}
					}
				}
			}

			System.Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 18396
#include<stdio.h>

int main()
{
    char buffer[32];
    int r, c;
    int sheet[100][100];
    int i, j;
    int sumRow=0, sumCol[101]={0};
    
    fgets(buffer, 32, stdin);
    sscanf(buffer, "%d %d", &r, &c);
    for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
        {
            scanf(" %d", &sheet[i][j]);
        }
    }
    
    for(i=0;i<r;i++)
    {
        sumRow=0;
        for(j=0;j<c;j++)
        {
            printf("%d ", sheet[i][j]);
            sumRow += sheet[i][j];
            sumCol[j] += sheet[i][j];
        }
        printf("%d\n", sumRow);
        sumCol[j] += sumRow;
    }
    
    for(j=0;j<c;j++)
    {
        printf("%d ", sumCol[j]);
    }
    printf("%d\n", sumCol[j]);

    
    return(0);
}


Measured memory_bytes: 2056
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
 
int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    set <int> s;
    int a;
    for (int i = 0 ; i < n ; i++) {
    	cin >> a;
    	if (s.count(a) == 0) s.insert(a);
    	else s.erase(a);
	}
	cout << s.size();
}

Measured memory_bytes: 8152
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char c[1001][1001];
int main()
    {
    int a,b;
    cin>>a>>b;
    for(int i=0;i<a;i++)
        for(int j=0;j<b;j++)
        {
        cin>>c[i][j];
        }
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++)
            {
            int sum=0;
            if(c[i][j]=='#') cout<<'#';
            else        
                {
                if(c[i-1][j+1]=='#') sum++;
                if(c[i][j+1]=='#') sum++;
                if(c[i+1][j+1]=='#') sum++;
                if(c[i-1][j]=='#') sum++;
                if(c[i+1][j]=='#') sum++;
                if(c[i-1][j-1]=='#') sum++;
                if(c[i][j-1]=='#') sum++;
                if(c[i+1][j-1]=='#') sum++;
                cout<<sum;
            }
            }  
		 cout<<endl; 
    }
    cout<<endl;
    return 0;     
}

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

const int MAX = 5000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int ways(int x,int y){
  if (x==0&&y==0){
    return 1;
  }else if ( x<0 || y < 0 || x<y/2 || y<x/2 || (x+y)%3!=0){
    return 0;
  }else{
    return ways(x-1,y-2)+ways(x-2,y-1);
  }
}

int main(){
  int X,Y;
  cin >> X >> Y;
  if ((X+Y)%3!=0){
    cout << 0;
    return 0;
  }
  int r=(X+Y)/3;
  X-=r;
  Y-=r;
  COMinit();
  if(X<0&&Y<0){
    cout << 0;
  }else if(X==0||Y==0){
    cout << 1;
  }else {
    cout << COM(X+Y,Y)%1000000007;
  }
}


Measured memory_bytes: 117376
#include<bits/stdc++.h>
#define N 100100
using namespace std;
int n,k,ans;
int fa[N],rd[N];
int zx[N];
bool done[N];
void dfs(int p){
	done[p]=1;
	if(p!=1){
		zx[p]++;
		if(zx[p]==k&&fa[p]!=1) ans++,zx[p]=0;
		zx[fa[p]]=max(zx[fa[p]],zx[p]);
		rd[fa[p]]--;
		if(rd[fa[p]]==0) dfs(fa[p]);
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&fa[i]);
		if(i!=1) rd[fa[i]]++;
	}
	if(fa[1]!=1) ans++;
	for(int i=2;i<=n;i++){
		if(!rd[i]&&!done[i]){
			dfs(i);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1664
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a % b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }
// 桁和
LL Ketawa_s(string s) { LL a = 0; FOR(i, 0, s.length())a += s[i] - '0'; return a; }

//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p % i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % p) % p; }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// -------------------------------------------------------------------------------

#define MAX 1000

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL R;
	cin >> R;

	if (R < 1200) {
		O("ABC");
	}
	else if (R < 2800) {
		O("ARC");
	}
	else {
		O("AGC");
	}

	return 0;
}

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

int select_sort(int A[],int n){
    int sum=0;
    int j,minj;
    for(int i=0;i<n;i++){
        minj=i;
        for(j=i;j<n;j++){
            minj=(A[minj]>A[j])?j:minj;
        }
        if(i!=minj){
        swap(A[i],A[minj]);sum++;
        }
    }
    return sum;
}

int main(){
    int n;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++)scanf("%d",&A[i]);
    int sum=select_sort(A,n);
    for(int i=0;i<n;i++){
        if(i!=0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n%d\n",sum);

}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX  1510000
int hww[2][MAX] = {};
signed main(){
	while(1){
		int count = 0;
		int H, W, h[2000]={}, w[2000]={};
		cin>>H>>W;
		if(!H&&!W)break;
		for(int i = 1; i <= H; i++){//cout<<i<<"----"<<endl;
			cin>>h[i];
			h[i] += h[i-1];
			for(int j = 0; j < i; j++){//cout<<h[i]<<" "<<h[j]<<endl;
				hww[0][h[i]-h[j]]++;
			}
		}
		for(int i = 1; i <= W; i++){//cout<<i<<"----"<<endl;
			cin>>w[i];
			w[i] += w[i-1];
			for(int j = 0; j < i; j++){//cout<<w[i]<<" "<<w[j]<<endl;
				hww[1][w[i]-w[j]]++;
			}
		}
		for(int i = 1; i < MAX; i++){//cout<<hw[0][i]<<" "<<hw[1][i]<<endl;
			count += hww[0][i]*hww[1][i];
			hww[0][i] = hww[1][i] =0;
		}
		cout<<count<<endl;
	}
	return 0;
}


Measured memory_bytes: 26744
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int[][] arr = new int[3][3];
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				arr[i][j] = sc.nextInt();
			}
		}
		if(arr[0][0]-arr[0][1] == arr[1][0]-arr[1][1] && arr[1][0]-arr[1][1] == arr[2][0]-arr[2][1]) {
			if(arr[0][1]-arr[0][2] == arr[1][1]-arr[1][2] && arr[1][1]-arr[1][2] == arr[2][1]-arr[2][2]) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) cin >> s.at(i);

  int M;
  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) cin >> t.at(i);

  int yen = 0;
  for (int i = 0; i < N; i++) {
    int x = 0;
    string A = s.at(i);
    for (int j = 0; j < N; j++) {
      if (s.at(j) == A) x++;
    }
    for (int j = 0; j < M; j++) {
      if (t.at(j) == A) x--;
    }
    if (x > yen) yen = x;
  }

  cout << yen << endl;
}

Measured memory_bytes: 256
import itertools
import numpy as np
n,d = map(int,input().split())
x = [np.array(input().split(), dtype=np.int64)for _ in range(n)]


ans = 0
for u,v in itertools.combinations(x,2):
    d = ((u-v) * (u-v)).sum()
    if int(d**0.5) == d ** 0.5:
        ans += 1
print(ans)

Measured memory_bytes: 12424
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int a[2][2];
    rep(i,2)rep(j,2)cin >> a[i][j];
    int now = 1;
    while(1){
        a[now][0] -= a[1-now][1];
        if(a[now][0] <= 0){
            if(now)cout << "Yes" << endl;
            else cout << "No" << endl;
            return 0;
        }
        now = 1 - now;
    }
}


Measured memory_bytes: 3624
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    ll n, a, b; cin>>n>>a>>b;

    if((b - a) % 2 == 0){
        cout << (b - a) / 2 << endl;
    }
    else{
        ll ans = min(b - 1, n - a);
        // A が卓 1 に行く
        ll Aleft = a;
        ll Bleft = b - Aleft;
        chmin(ans, Aleft + (Bleft - 1) / 2);

        // B が卓 N に行く
        ll Bright = (n - b + 1);
        ll Aright = a + Bright;
        chmin(ans, Bright + (n - Aright) / 2);
        
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256