akhauriyash/Code-Regression huggingface dataset:
#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 INF 999999999
typedef long long ll;
using namespace std;
int main() {
    string S;
    cin >> S;
    map<char, int> check;
    char alpha[26];
    REP(i, 26) alpha[i] = 'a'+i;
    REP(i, S.length()) {
        check[S[i]] = 1;
    }
    REP(i, 26) {
        if(check[alpha[i]] != 1) {
            cout << alpha[i] << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}


Measured memory_bytes: 512
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 x = sc.nextInt();
		int y = 0;
		for(int i = 0; i <= a; i++) {
			for(int j = 0; j <= b; j++) {
				for(int k = 0; k <= c; k++) {
					if(500 * i + 100 * j + 50 * k == x){
						y++;
					}
				}
			}
		}
		System.out.println(y);
	}
 
}

Measured memory_bytes: 21844
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
// #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = (int)1e9;

bool G[101][51][51];

int main() {
  int n, m;
  vi steps(3);
  cin >> n >> m >> steps[0] >> steps[1] >> steps[2];
  REP(i, m){
    int from, to;
    cin >> from >> to;
    G[0][from][to] = true;
  }

  FOR(c, 1, 101){
    FOR(j, 1, n + 1) FOR(i, 1, n + 1){
      FOR(k, 1, n + 1){
        G[c][j][i] |= G[c - 1][j][k] && G[0][k][i];
      }
    }
  }
  // REP(c,  5){
  //   FOR(j, 1, n + 1){
  //     FOR(i, 1, n + 1){
  //       LOG("%d ", G[c][j][i] ? 1 : 0);
  //     }
  //     LOG("\n");
  //   }
  //   LOG("--------------------\n");
  // }

  vvi taketurn(n + 1, vi(4, INF));
  taketurn[n][3] = 0;
  queue<int> que;
  que.push(n);
  while(!que.empty()) {
    int to = que.front(); que.pop();
    FOR(from, 1, n){
      REP(i, steps.size()){
        int step = steps[i];
        if(G[step - 1][from][to]) {
          // LOG("--->> %d -> %d step %d\n", from, to, step);
          taketurn[from][i] = min(taketurn[from][i], taketurn[to][3] + 1);
        }
      }
      int res = min(taketurn[from][3], max(taketurn[from][0], max(taketurn[from][1], taketurn[from][2])));
      if (taketurn[from][3] > res) {
        taketurn[from][3] = res;
        if(from == 1) {
          cout << taketurn[from][3] << endl;
          goto END;
        }
        que.push(from);
      }
    }
  }


  cout << "IMPOSSIBLE" << endl;

END:
  {}
  // FOR(i, 1, n + 1){
  //   LOG("%d ", taketurn[i][3]);
  // }
  // LOG("\n");
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; cin >> s;
	for (char &c: s) if (c == '?') c = 'D';
	cout << s << endl;
}



Measured memory_bytes: 3744
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int r = sc.nextInt();
        int s = sc.nextInt();
        int p = sc.nextInt();
        char[] t = sc.next().toCharArray();

        int q = n / k + 1;

        int point = 0;

        int g = 2;
        for (int i = 0 ; i < k ; i++) {
            char c = t[i];
            for (int j = 0 ; (j + 1) * k + i < n ; j++) {
                if (t[j * k + i] == t[(j + 1) * k + i]) {
                    g++;
                } else {
                    if (c == 'r') {
                        point += (g / 2) * p;
                    } else if (c == 's') {
                        point += (g / 2) * r;
                    } else {
                        point += (g / 2) * s;
                    }

                    g = 2;
                    c = t[(j + 1) * k + i];
                }
            }
            if (c == 'r') {
                point += (g / 2) * p;
            } else if (c == 's') {
                point += (g / 2) * r;
            } else {
                point += (g / 2) * s;
            }
            g = 2;
        }

        System.out.println(point);

    }

}

Measured memory_bytes: 27576
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
#define int ll

/*int f(int a, int b, int c) {
	if (b < a) {
		swap(a, b);
	}
	if (c < b) {
		swap(b, c);
		if (b < a) {
			swap(a, b);
		}
	}
	return b;
}

int get(vector<int> kek) {
	while (SZ(kek) > 1) {
		vector<int> kek2;
		for (int i = 1; i + 1 < SZ(kek); i++) {
			kek2.pb(f(kek[i - 1], kek[i], kek[i + 1]));
		}
		kek = kek2;
	}
	return kek.back();
}*/

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  /*vector<int> order;
  int n = 11;
  for (int i = 1; i <= n; i++) {
  	order.pb(i);
  }
  vector<bool> used(n + 1);
  do {
  	int x = get(order);
  	if (!used[x]) {
  		used[x] = true;
  		cout << x << " :    ";
  		for (auto it : order) {
  			cout << it << ' ';
  		}
  		cout << '\n';
  	}
  } while (next_permutation(all(order)));*/
  int n, k;
  cin >> n >> k;
  n = 2 * n - 1;
  vector<int> ans(n + 1);
  vector<bool> used(n + 1);
  if (n == 3) {
  	if (k == 2) {
  		cout << "Yes\n1\n2\n3\n";
  	}
  	else {
  		cout << "No\n";
  	}
  }
  else {
  	if (k == 1 || k == n) {
  		cout << "No\n";
  	}
  	else {
  		cout << "Yes\n";
  		ans[(n + 1) / 2] = k;
  		ans[(n + 1) / 2 - 1] = k - 1;
  		ans[(n + 1) / 2 + 1] = k + 1;
  		used[k] = used[k - 1] = used[k + 1] = true;
  		if (k > 3) {
  			ans[(n + 1) / 2 + 2] = k - 2;
  			used[k - 2] = true;
  		}
  		else {
  			ans[(n + 1) / 2 - 2] = k + 2;
  			used[k + 2] = true;
  		}
  		int ptr = 1;
  		for (int i = 1; i <= n; i++) {
  			if (ans[i]) {
  				cout << ans[i] << '\n';
  			}
  			else {
  				while (used[ptr]) {
  					ptr++;
  				}
  				used[ptr] = true;
  				cout << ptr << '\n';
  			}
  		}
  	}
  }
} 

Measured memory_bytes: 3072
#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;
#define sz (int)1e7+1
vector<int> seive(sz,2);
int main()
{
    for(int i=2; i<sz; i++){
        for(int j=i+i; j<sz; j+=i){
            seive[j]++;
        }
    }
    seive[1]=1;
    int n; 
    cin>>n;
    long long s=0;
    for(int i=1; i<=n; i++){
        s += (long long int)i*seive[i];
    }
    cout<<s<<'\n';
}

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  sort(begin(v), end(v));
  map<int, int> mp;
  rep(i, n) mp[v[i]] = i;
  vector<vector<bool>> used(n, vector<bool>(n, false));
  int ans = 0;
  rep(i, n) rep(j, n) {
    if (i >= j) continue;
    int d = v[j] - v[i];
    int nxt = v[j] + d;
    int c = 2;
    while (mp.find(nxt) != mp.end() && !used[mp[nxt - d]][mp[nxt]]) {
      used[mp[nxt - d]][mp[nxt]] = true;
      nxt = v[mp[nxt]] + d, c++;
    }
    ans = max(ans, c);
  }
  cout << ans << endl;
}



Measured memory_bytes: 6592
function Main(input) {
  input = input.split("\n");
  const S = input[0].split(" ");
  S.unshift("x");
  console.log(S.indexOf("0"));
}

// デバッグ用
function debug() {
  var input = document.getElementById("input").value;
  Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30304
n,m=map(int,input().split())
a=list(map(int,input().split()))

b=[0]
for i in range(n):
    b.append((b[i]+a[i])%m)
db = dict()
for sb in b:
    if sb not in db:
        db[sb] = 0
    db[sb] += 1

res = 0
for sdb in db.values():
    res += (sdb * (sdb-1)) // 2

print(res)

Measured memory_bytes: 63256
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author aakas
 */
public class Main {
    static int N;
    static int W;
    static int[] w;
    static int[] p;
    static boolean[][] v;
    static long[][] dp;
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        W = sc.nextInt();
        w = new int[N];
        p = new int[N];
        v = new boolean[N][100001];
        dp = new long[N][100001];
        int totalProfit = 0;
        boolean flag = false;
        for(int i=0;i<N;i++)
        {
            w[i] = sc.nextInt();
            p[i] = sc.nextInt();
            totalProfit += p[i];
        }
        for(int i=totalProfit;i>0;i--)
        {
            if(s(0,i)<=W)
            {
                flag = true;
                System.out.println(i);
                break;
            }
        }
        if(!flag)
            System.out.println(0);
    }
    public static long s(int i,int V)
    {
        if(V<=0)
            return 0;
        if(i==N)
            return Integer.MAX_VALUE;
        if(v[i][V])
            return dp[i][V];
        v[i][V] = true;
        return dp[i][V] = Math.min(s(i+1,V),(s(i+1,V-p[i])+w[i]));
    }
}


Measured memory_bytes: 128852
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int p,res;
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>p;
	for(int i=1;i<=p;i++){
		for(int j=1;j<=p;j++){
			for(int k=1;k<=p;k++){
				res+=__gcd(__gcd(i,j),k);
			}
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3652
#include<cstdio>
using namespace std;
int main()
{
    int a,b,c,x,y;
    scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
    int sum=0;
    if(c<=(a+b)/2)
    {
        if(x<y)
        {
            sum+=x*2*c;
            sum+=(y-x)*b;
            if(y*2*c<sum)
                sum=y*2*c;
        }
        else
        {
            sum+=y*2*c;
            sum+=(x-y)*a;
            if(x*2*c<sum)
                sum=x*2*c;
        }
    }
    else
    {
        sum+=a*x+b*y;
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >>K;
	vector<pair<int, int> > A(N);
	vector<int> B(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i].second >> A[i].first;
	}
	sort(A.rbegin(), A.rend());
	int num = 0;
	int sum = 0;
	vector<int> cnt(N + 1, 0);
	vector<int> st;
	for (int i = 0; i < K; i++) {
		sum += A[i].first;
		//cerr << i << " " << A[i].second << endl;
		if (cnt[A[i].second] == 0) {
			cnt[A[i].second]++;
			num++;
		}
		else {
			cnt[A[i].second]++;
			st.push_back(i);
		}
	}
	//cerr << sum << " " << num << endl;
	res = max(res, sum + num * num);
	for (int i = K; i < N; i++) {
		if (cnt[A[i].second] == 0) {
			if (st.size() == 0)break;
			int j = st.back();
			st.pop_back();
			cnt[A[j].second]--;
			sum -= A[j].first;


			cnt[A[i].second]++;
			sum += A[i].first;
			num++;
			res = max(res, sum + num * num);
			//cerr << i << endl;
			//cerr << sum << " " << num << endl;
		}
	}


	cout << res << endl;
}

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);

    int n;
    ll k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int f[n];
    for (int i = 0; i < n; i++) {
        cin >> f[i];
    }
    sort(a, a+n);
    sort(f, f+n);
    reverse(f, f+n);

    ll l = -1, r = 1e12 + 1;
    while (r - l > 1) {
        ll mid = (l + r) / 2;

        ll d = 0;
        for (int i = 0; i < n; i++) {
            d += max(a[i] - mid / f[i], 0ll);
        }

        if (d <= k) {
            r = mid;
        } else {
            l = mid;
        }
    }

    cout << r << endl;

    return 0;
}


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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

//---------------------------------------------------------------
// 正しい結果を出せない！　論理がシンプルすぎるのだろう・・・
//---------------------------------------------------------------
int A, B, C;

signed main(){
	cin >> A >> B >> C;
//	cout << "A=" << A << "  B=" << B << "  C=" << C << endl;
	
	int ans = 0;
	int wk, ac, ba, cb;
	while(true) {
		if(A == B && B == C) {
			break;
		}
		ac = abs(A - C);
		ba = abs(B - A);
		cb = abs(C - B);
//		cout << "A-C=" << ac << "  B-A=" << ba << "  C-B=" << cb << endl;
		if(A == B || B == C || C == A) {
			if(A == B)			wk = A - C;
			else if(B == C)		wk = B - A;
			else if(C == A)		wk = C - B;
			if(wk % 2 == 0) {
				if(wk > 0)	ans += wk/2;
				else		ans += (-wk);
			} else {
				if(wk > 0)	ans += (wk/2 + 2);
				else		ans += (-wk);
			}
//			cout << "last wk = " << wk << endl;
			break;
		}
		if(ac < ba && ac < cb) {
			if(ac % 2 == 0) {
				ans += ac/2;
			} else {
				ans += (ac/2 + 1);
				B += 1;
			}
			if(A > C)	C = A;
			else		A = C;
//			cout << "1  A=" << A << "  B=" << B << "  C=" << C << "  ans=" << ans << endl;
		} else if(ba < ac && ba < cb) {
			if(ba % 2 == 0) {
				ans += ba/2;
			} else {
				ans += (ba/2 + 1);
				C += 1;
			}
			if(B > A)	A = B;
			else		B = A;
//			cout << "2  A=" << A << "  B=" << B << "  C=" << C << "  ans=" << ans << endl;
		} else if(cb < ac && cb < ba) {
			if(cb % 2 == 0) {
				ans += cb/2;
			} else {
				ans += (cb/2 + 1);
				A += 1;
			}
			if(C > B)	B = C;
			else		C = B;
//			cout << "3  A=" << A << "  B=" << B << "  C=" << C << "  ans=" << ans << endl;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
namespace atcoder {

// Implement (union by size) + (path compression)
// Reference:
// Zvi Galil and Giuseppe F. Italiano,
// Data structures and algorithms for disjoint set union problems
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

}  // namespace atcoder
using namespace std;
using namespace atcoder;

int main() {
	// 0-ind
	int N, Q; cin >> N >> Q;
	dsu d(N);
	while(Q--) {
		int t, u, v; cin >> t >> u >> v;
		if (t == 0) {
			d.merge(u, v);
		} else {
			cout << d.same(u, v) << endl;
		}
	}
}


Measured memory_bytes: 3980
a,b = gets.split(" ")

tuyosa = ["2","3","4","5","6","7","8","9","10","11","12","13","1"]

if tuyosa.index(a) > tuyosa.index(b)
    puts "Alice"
elsif
    tuyosa.index(a) < tuyosa.index(b)
    puts "Bob"
else
    puts "Draw"
end

Measured memory_bytes: 1788
s = list(input())

flag =0
if s[0] !="A":
    flag =1
else:
    index=2
    count=0
    while index<len(s)-1:
        if s[index]=="C":
            count+=1
        index+=1
    if count!=1:
        flag=1
    else:
        index2=0
        count2=0
        while index2<len(s):
            if s[index2]=="A" or s[index2]=="C":
                count2+=1
            elif s[index2].islower():
                pass
            else:
                flag=1
            index2+=1
        if count2!=2:
            flag =1
    
if flag==0:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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


int main(){

	int a,b;
	while(1){

		cin >> a;
		if(a==0) break;

		int x=a;
		for(int i=1;i<=9;i++){

			cin >> b;

			x-=b;

		}

		cout << x << endl;

	}

	return 0;
}

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

public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    public static void main(String[] args) {
        FastReader scanner = new FastReader();
        int N = scanner.nextInt();
        int W = scanner.nextInt();

        int[] wt = new int[N];
        int[] val = new int[N];

        for (int i = 0; i < N; i++) {
            wt[i] = scanner.nextInt();
            val[i] = scanner.nextInt();
        }
        long[][] DP = new long[2][W + 1];

        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= W; j++) {
                if (wt[i - 1] <= j) {
                    DP[1][j] = Math.max(DP[0][j], DP[0][j - wt[i - 1]] + val[i - 1]);
                } else {
                    DP[1][j] = DP[0][j];
                }
            }
            if (W >= 0) System.arraycopy(DP[1], 1, DP[0], 1, W);
        }
        System.out.println(DP[1][W]);
    }
}

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

int main()
{
	int64_t n, mod = 1000000007;
	cin >> n;
	map<pair<int64_t, int64_t>, int64_t> map;
	function<int64_t(int64_t, int64_t)> f = [&](int64_t s, int64_t t) {
		//a+b<=s
		//a^b<=t
		if (s < 0 || t < 0)
		{
			return int64_t(0);
		}
		if (map[make_pair(s, t)])
		{
			return map[make_pair(s, t)];
		}
		if (s == 0)
		{
			return map[make_pair(s, t)] = f(s / 2, t / 2);
		}
		return map[make_pair(s, t)] = (f(s / 2, t / 2) + f((s - 1) / 2, (t - 1) / 2) + f(s / 2 - 1, t / 2)) % mod;
	};
	map[make_pair(0, 0)] = 1;
	cout << f(n, n) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int t[200][3];
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
    for(int j=0;j<3;j++)
      cin>>t[i][j];
  for(int i=0;i<n;i++){
    int ans=0;
    for(int j=0;j<3;j++){
      int k;
      for(k=0;k<n;k++){
	if(i==k)continue;
	if(t[i][j]==t[k][j])break;
      }
      if(k==n)ans+=t[i][j];
    }
    cout<<ans<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
using namespace std;

//common
typedef long long i64,ll;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,r) for(int i=(l);i<(int)(r);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

string BITtoString(int bit){
    stringstream ss;
    while(bit!=0){ss<<(bit%2);bit/=2;}
    string res=ss.str();reverse(ALL(res));
    return res;
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

namespace EGraph{
	typedef int Cost;Cost CINF=1<<28;
	struct Edge{
		int from,to;Cost cost;
		Edge(int from,int to,Cost cost)
		: from(from),to(to),cost(cost) {};
		bool operator<(Edge r) const{
			return cost<r.cost;
		}
		bool operator>(Edge r) const{
			return cost>r.cost;
		}
	};
	typedef vector<vector<Edge> >  Graph;
}
using namespace EGraph;
class Main{
public:
	
	void run(){
		while(true){
			int N;cin >> N;
			if(N==0)break;
			vector<int> bs(N);REP(i,N) cin >> bs[i];

			bool end=false;			
			REP(loop,10000){
				//check
				bool ok=true;
				REP(i,N)if(bs[i]!=i+1){
					ok=false;break;
				}
				if(ok){
					end=true;
					cout << loop<<endl;break;
				}

				//run
				REP(i,N)bs[i]--;
				vector<int> nbs;
				REP(i,N)if(bs[i]!=0)nbs.push_back(bs[i]);
				nbs.push_back(N);
				bs=nbs;N=bs.size();
			}
			if(!end)cout <<-1<<endl;
		}
	}
};

 int main(){
	//ios::sync_with_stdio(false);
 	Main().run();
 	return 0;
 }

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

#define reg register
typedef long long ll;
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)

char IO;
int rd(){
	int s=0,f=0;
	while(!isdigit(IO=getchar())) if(IO=='-') f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}

const int N=2e3+10,P=1e9+7;

bool be;
int n;
int A[N][N];

struct Node{
	int x,d;
	bool operator < (const Node __) const{
		return d<__.d;
	}
};
queue <Node> Q;

struct Edge{
	int to,nxt;
}e[N*N*2];
int dep[N*N*2];
int head[N*N*2],ecnt,ind[N*N*2];
void AddEdge(int u,int v){
	e[++ecnt]=(Edge){v,head[u]};
	head[u]=ecnt;
	ind[v]++;
}

int id[N][N],cnt;
bool ed;

int main(){
	//cout<<&ed-&be<<endl;
	n=rd();
	rep(i,1,n) rep(j,1,i-1) id[i][j]=++cnt;
	rep(i,1,n) {
		rep(j,1,n-1) A[i][j]=rd();
		rep(j,2,n-1) {
			int x=i,y=A[i][j];
			int x2=i,y2=A[i][j-1];
			if(x<y) swap(x,y);
			if(x2<y2) swap(x2,y2);
			AddEdge(id[x2][y2],id[x][y]);
		}
	}
	rep(i,1,cnt) {
		if(!ind[i]) Q.push((Node){i,1});
		//dep[i]=1e9;
	}
	int ans=0;
	while(!Q.empty()) {
		Node t=Q.front();Q.pop();
		ans=max(ans,t.d);
		int u=t.x;
		//cout<<u<<' '<<t.d<<endl;
		cnt--;
		for(int i=head[u];i;i=e[i].nxt) {
			int v=e[i].to;
			dep[v]=max(dep[v],t.d+1);
			if(--ind[v]==0) Q.push((Node){v,dep[v]});
		}
	}
	if(cnt) puts("-1");
	else cout<<ans<<endl;
}








Measured memory_bytes: 40320
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
	long long N, K;
	cin >> N >> K;
	
	N = N % K;
	std::unordered_map<long long, char> um;
	um[N] = 1;
	
	long long v_min= N;
	do{
		N = abs(N - K);
		if(um.find(N) != um.end()) break;
      	um[N] = 1;
		if(N < v_min) v_min = N;
	}while(v_min != 0);
	
	cout << v_min << endl;
	
	return 0;
}


Measured memory_bytes: 256
alp_count = [0]*26



string = open(0).read()
string = string.lower()


alp = [chr(ord("a")+i) for i in range(26)]

c = 0

for j in range(26):
    c = string.count(alp[j])
    alp_count[j] += c
    print("%s : %d"%(alp[j],alp_count[j]))


Measured memory_bytes: 5568
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define pb push_back
    #define sz size()
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     

const ll ZER = 0;
ll MOD = 998244353;

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> l(k), r(k);
    rep(i, k)cin >> l[i] >> r[i];
    vector<ll> dp(n + 1, 0);
    vector<ll> dpsum(n + 1, 0);
    dp[1] = 1;
    dpsum[1] = 1;
    REP(i, 2, n){
        rep(j, k){
            ll li = max(ZER + 1, i - r[j]), ri = max(ZER, i - l[j]);
            //if(ri < 0)continue;
            (dp[i] += dpsum[ri] - dpsum[li - 1]) %= MOD;
        }
        (dpsum[i] = dpsum[i - 1] + dp[i]) %= MOD;
    }
  	//rep(i, n + 1)cout << dp[i] << " ";
  	if(dp[n] < 0)dp[n] += MOD;
    cout << dp[n] << endl;
}



Measured memory_bytes: 6044
#! /usr/local/bin/python

class N:
	def __init__(self, n):
		self.parent = n
		self.rank = 0
		self.n = n

def find( n: int) -> N:
	if data[n].parent == n:
		return data[n]
	else:
		data[n].parent = find(data[n].parent).n
		return data[data[n].parent]

def union( a: int, b: int):
	A = find(a)
	B = find(b)
	if A.rank > B.rank:
		B.parent = A.n
	elif A.rank < B.rank:
		A.parent = B.n
	elif A.n != B.n:
		B.parent = A.n
		A.rank = A.rank + 1

# Start
n, p = input().split(" ")
data = [ N(i) for i in range(int(n))]
for i in range(int(p)):
	com, x, y = input().split(" ")
	if com == '0':
		union(int(x),int(y))
	else:
		if find(int(x)).n != find(int(y)).n:
			print(0)
		else:
			print(1)

Measured memory_bytes: 9616
N = int(input())
ketu = ""
mozi = []
frag = 0
for i in range(N):
    stri = input()
    if (ketu != "" )and(ketu != stri[0]):
        frag = 1

    ketu = stri[-1]
    mozi.append(stri)

if frag == 1:
    print("No")
    exit()

if len(mozi) != len(list(set(mozi))):
    print("No")
    exit()

print("Yes")


Measured memory_bytes: 3060
#include<stdio.h>

int binarysearch(int *,int,int);

int binarysearch(int *S,int T,int n)
{
  int right = n,left = 0;
  int mid;

  while(right > left){
    mid = (right+left) / 2;
    if(S[mid] == T){
      return 1;
    }else if(T < S[mid]){
      right = mid;
    }else{
      left = mid + 1;
    }
  }

  return 0;
}
      
    

int main()
{
  int i,n,q,T,num=0;
  int S[100000];

  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T);
    if(binarysearch(S,T,n) == 1){
      num++;
    }
  }

  printf("%d\n",num);

  return 0;
}



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

int main(){
    int N,K,h,res=1e9;

    vector<int> v;

    cin >> N >> K;

    for (int i=0;i<N;i++){
        cin >> h;
        v.push_back(h);
    }
    sort(v.begin(),v.end());

    for (int i=0;i<N-K+1;i++){
        res = min(res,v[i+K-1]-v[i]);
    }

    


    // sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});

    cout << res << endl;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define ll long long int 

using namespace std;

int main(){
    int n;
    cin >> n;
    double arr[n+1];
    for(int i=0;i<n;i++) cin >> arr[i];
    double ans[n+1][n+1][2];
    for(int i=0;i<=n;i++){
        ans[0][i][0]=(double)1.000000000;
        ans[0][i][1]=(double)1.000000000;
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            if(j==0){
                ans[i][j][0]=(double)(ans[i-1][j][0])*(double)((double)1-arr[i-1]);
                ans[i][j][1]=(double)0;
            }else if(j==i){
                ans[i][j][0]=(double)0.0000000000;
                ans[i][j][1]=(double) (ans[i-1][j-1][1])*(double)arr[i-1];
            }
            else{
                ans[i][j][0]=(double)(ans[i-1][j][0])*((double)1-arr[i-1])+(double)(ans[i-1][j][1])*((double)1-arr[i-1]);
                ans[i][j][1]=(double)(ans[i-1][j-1][0])*(arr[i-1])+(double)(ans[i-1][j-1][1])*(double)(arr[i-1]);
            }
        }
    }
    double res=0;
    for(int i=1;i<=n;i++){
        if(i>=(n+1)/2){
            //cout <<ans[n][i][0]<<endl;
            //cout <<ans[n][i][1]<<endl;
            if(ans[n][i][0]!=0){
            res=(double)res+(double)ans[n][i][0];}
            if(ans[n][i][1]!=0){
            res=(double)res+(double)ans[n][i][1];}
        }
    }
    cout <<fixed<<setprecision(10)<<res<<endl;
    //cout << ans[n][n][0]<<endl;
    //cout << ans[n][n][1]<<endl;
}



Measured memory_bytes: 140928
from itertools import accumulate


def solve(string):
    n, *w = map(int, string.split())
    *w, = accumulate(w)
    return str(min([abs(w[-1] - 2 * w[i]) for i in range(n - 1)]))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

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

using ll = long long;
using Pii = pair<int, int>;

const int inf = 1e9 + 7;
const ll longinf = 1LL << 50;
const long long mod_const = 1e9 + 7;

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

using MIte = multimap<ll, ll, greater<ll> >::iterator;

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; }

using pll = pair<long long, long long>;

const int MAX = 1000005;
const int MOD = 1000000007;

ll 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;
	}
}

// 二項係数計算
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] % MOD) % MOD;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
		
	ll X,Y;
	cin >> X >> Y;

	if ((X + Y) % 3 != 0) {
		cout << "0" << endl;
		return 0;
	}

	ll diff = abs(Y - X);
	ll num = (X + Y) / 3;

	ll a = (num + diff) / 2;
	ll b = num - a;

	COMinit();
	ll ans = COM(num, a);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 23680
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,*t=map(int,open(0).read().split())\n"
"for p,x in zip(t[n+1::2],t[n+2::2]):print(sum(t[:n])-t[p-1]+x)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3280
n, k = map(int, input().split())
listInt = []
kq = 1e10
for i in range(n):
    listInt.append(int(input()))
listInt.sort()
for i in range(n - k + 1):
    kq = min(kq, listInt[i+k-1] - listInt[i])
print(kq)


Measured memory_bytes: 7384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    string s;cin>>s;
    rep(i,3){
        if(s.at(i)=='1'){
            s.at(i)='9';
        }else if(s.at(i)=='9'){
            s.at(i)='1';
        }
    }
    cout<<s<<endl;
}

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

int main() {
  string x , y , z ;
  cin >> x >> y >> z ; 
  
  int a = x.size() ;
  int b = y.size() ;
  
  a--; b--;
  
  if(x[a]==y[0] && y[b]==z[0] ) cout << "YES" << endl;
  else cout << "NO" << endl;
}



Measured memory_bytes: 256
import math

turn_angle = int(input())

current_angle = 90
position_dict = {'x': 0, 'y': 0}
move_one = {'x':0, 'y': 1}
num_actions = 1


def change_angle(turn_angle, current_angle):
    current_angle = current_angle + turn_angle
    if current_angle > 360:
        current_angle = current_angle - 360
    return current_angle

def resolve_direction(current_angle):
    radian_angle = (current_angle*math.pi)/180
    move_dict = {'x':round(math.cos(radian_angle), 3), 'y' : round(math.sin(radian_angle), 3)}
    return move_dict

def move_skater(position_dict, move_dict):
    for key, value in position_dict.items():
        position_dict[key] = round((value + move_dict.get(key, 0)), 3)
    return position_dict

position_dict = move_skater(position_dict, move_one)
current_angle = change_angle(turn_angle, current_angle)


origin_dict = {'x': 0.0, 'y': 0.0}

while position_dict != origin_dict:
    move_dict = resolve_direction(current_angle)
    position_dict= move_skater(position_dict, move_dict)
    current_angle = change_angle(turn_angle, current_angle)
    num_actions = num_actions + 1

print(num_actions)
    

Measured memory_bytes: 9624
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll n;
	cin>>n;
	cout << 24-n+24 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 100000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem2018 : Princess's Gamble **/
int main()
{
	int N, M, P;
	while (cin>>N>>M>>P, N||M||P) {
		vector<int> list(N);
		double sum=0;
		rep(i, N) {
			cin >> list[i];
			sum += list[i]*100;
		}
		sum -= sum*P/100;
		
		if (list[M-1] == 0)
			cout << 0 << endl;
		else
			cout << floor(sum/list[M-1]) << endl;
	}
}

Measured memory_bytes: 1272
import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    A, G, C, T = 0, 1, 2, 3
    dp = [[[[0] * 4 for _ in range(4)] for _ in range(4)] for _ in range(N+1)]
    for j in range(4):  # i - 2 文字目
        for k in range(4):  # i - 1 文字目
            for l in range(4):  # i 文字目
                if j == A and k == G and l == C:  continue
                if j == A and k == C and l == G:  continue
                if j == G and k == A and l == C:  continue
                dp[3][j][k][l] = 1
    
    for i in range(4, N+1):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    for m in range(4):
                        if j == A and k == G and l == C:  continue
                        if j == A and k == C and l == G:  continue
                        if j == G and k == A and l == C:  continue
                        if m == A and k == G and l == C:  continue
                        if m == A and j == G and l == C:  continue
                        dp[i][j][k][l] += dp[i-1][m][j][k]
                        dp[i][j][k][l] %= MOD
    
    res = 0
    for j in range(4):
        for k in range(4):
            for l in range(4):
                res += dp[N][j][k][l]
                res %= MOD
    
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3420
n, k = map(int,input().split())
mod = 10**9 + 7

def pow(x, y, mod):  # x**y の mod を返す関数
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = (ans * x) % mod
        x = (x**2) % mod
        y //= 2
    return ans

A = [0] + [k//i for i in range(1, k+1)]
B = list(set(A))
# print("A",A)
D = {}
for i in B:
    D[i] = pow(i, n, mod)

# print(D)

ans = [0] * (k+1)
for i in range(k, 0, -1):
    ans[i] = D[A[i]] % mod
    # print("ans",i,ans[i])
    ii = i * 2
    while ii <= k:
        # print("ii",ii,D[ii])
        ans[i] = (ans[i] - ans[ii]) % mod
        ii += i
# print(ans)
# print(sum(ans) % mod)

anss = 0
for i in range(1, len(ans)):
    anss = (anss + ans[i] * i) % mod
print(anss)

Measured memory_bytes: 75068
#include<bits/stdc++.h>
using namespace std;
int a[1000];
int main()
{
    string s;
    cin>>s;
    int l,i,d,c=0;
    l=s.size();
    for(i=0; i<l; i++)
    {
        d=s[i]-'A';
        a[d]++;
    }
    for(i=0;i<=26;i++)
    {
        if(a[i]==2)
            c++;
    }
    if(c==2)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m;
	cin >> n >> m;
	if(n == m)
		cout << "Yes\n";
	else cout << "No\n";

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

const int mod = 2019;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	vector<int> cnt(n+1, 0);
	int ten = 1;
	for(int i = n-1; i >= 0; --i){
		int num = ((s[i] - '0') * ten) % mod;
		cnt[i] = (cnt[i+1] + num) % mod;
		ten = (ten * 10) % mod;
	}
	ll ans = 0;
	map<int, ll> mp;
	for(int i = n; i >= 0; --i){
		ans += mp[cnt[i]]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4352
from math import sqrt
N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]

ans = 0
for i in range(N):
  for j in range(N):
    if j != i:
      ans += sqrt((xy[i][0] - xy[j][0]) ** 2  + (xy[i][1] - xy[j][1]) ** 2)
print(ans/N)

Measured memory_bytes: 3188
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	string s;
	cin >> s;
	cin >> K;
	long long int c = 0;
	for (auto i : s) {
		if (i == '1')c++;
		else break;
	}
	if (c >= K)cout << 1 << endl;
	else cout << s[c] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;
#define int LL

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int f[2005][2005];
struct node { int a, pos; } t[2005];

inline bool cmp(node a, node b) { return a.a > b.a; }

signed main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n; read(n);
  for (RI i = 1; i <= n; ++i)
    read(t[i].a), t[i].pos = i;
  sort(t + 1, t + 1 + n, cmp);
  memset(f, -0x7f, sizeof(f));
  f[0][0] = 0;
  for (RI i = 1; i <= n; ++i) {
    f[i][0] = f[i - 1][0] + t[i].a * abs(t[i].pos - (n - i + 1));
    for (RI j = 1; j <= i; ++j)
      f[i][j] = max(f[i - 1][j - 1] + t[i].a * abs(t[i].pos - j),
                    f[i - 1][j] + t[i].a * abs(t[i].pos - (n - (i - j) + 1)));
  }
  int ans = 0;
  for (RI i = 0; i <= n; ++i)
    ans = max(ans, f[n][i]);
  printf("%lld\n", ans);

  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 35196
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 5005
const int mod=1e9+7;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,f[N][2],dp[N][2],A,B,ans;
#define ck(x) (x>=mod?x-mod:x) 
int qpow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}
	return ans;
}
int main(){
	n=read(),A=read(),B=read();
	if(A>B)swap(A,B);
	f[0][0]=f[0][1]=1;
	for(int i=1;i<B;++i){
		for(int j=A;j<=i;++j){
			f[i][0]=ck(f[i][0]+f[i-j][1]);
		}
		for(int j=1;j<=i;++j){
			f[i][1]=ck(f[i][1]+f[i-j][0]);
		}
	}
	for(int i=1;i<n;++i){
		dp[i][0]+=(i<A);
		dp[i][1]+=(i<B?f[i][1]:0);
		for(int j=1;j<min(i,A);++j){
			dp[i][0]=ck(dp[i][0]+dp[i-j][1]);
		}
		for(int j=1;j<min(i,B);++j){
			dp[i][1]=(dp[i][1]+1LL*dp[i-j][0]*f[j-1][1])%mod;
		}
		if(n-i<A)ans=ck(ans+dp[i][1]);
		if(n-i<B)ans=(ans+1LL*dp[i][0]*f[n-i][1])%mod;
	}
	printf("%d\n",(qpow(2,n)-ans+mod)%mod);	
	return 0;
}


Measured memory_bytes: 3808
#include <stdio.h>
#include <string.h>
#define M 1046527
#define L 14

char H[M][L];
int getChar(char ch){
  switch(ch){
  case 'A':
	return 1;
  case 'C':
	return 2;
  case 'G':
	return 3;
  case 'T':
	return 4;
  default :
	return 0;
  }
}
long long getKey(char str[]){
  int i;
  long long weight=1;
  long long key=0;
  for(i=0; i<strlen(str); ++i){
	key+=getChar(str[i])*weight;
	weight*=5;
  }
  return key;
}
int h1(long long key){
  return key % M;
}
int h2(long long key){
  return (1+(key % (M-1)));
}

int insert(char str[]){
  long long key;
  key=getKey(str);
  int i, h;
  for(i=0; i<M; ++i){
	h=(h1(key)+i*h2(key))%M;
	if(strcmp(H[h], str)==0)
	  return 1;
	else if(strlen(H[h])==0){
	  strcpy(H[h], str);
	  return 0;
	}
  }
  return 0;
}
int find(char str[]){
  long long key;
  key=getKey(str);
  int i, h;
  for(i=0; i<M; ++i){
	h=(h1(key)+i*h2(key))%M;
	if(strcmp(H[h], str)==0)
	  return 1;
	else if(strlen(H[h])==0)
	  return 0;
  }
  return 0;
}
int main(){
  int n;
  char line[100];  
  int i;
  char *str_ptr;
  fgets(line, sizeof(line), stdin);
  sscanf(line, "%d", &n);
  for(i=0; i<M; ++i){
	H[i][0]='\0';
  }
  for(i=0; i<n; ++i){
	fgets(line, sizeof(line), stdin);
	if(line[strlen(line)-1]=='\n')
	  line[strlen(line)-1]='\0';
	str_ptr=strtok(line, " ");
	if(strcmp(str_ptr, "insert")==0){
	  str_ptr=strtok(NULL, " ");
	  insert(str_ptr);
	}else if(strcmp(str_ptr, "find")==0){
	  str_ptr=strtok(NULL, " ");
	  if(find(str_ptr)==1)
		printf("yes\n");
	  else if(find(str_ptr)==0)
		printf("no\n");
	}
	  
  }
  return 0;
}



Measured memory_bytes: 16040