akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

map<int, int> flag;
int main()
{
	int a[55];
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	int sum = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = i + 1; j <= n; j++)
		{
			if(flag[a[i] * a[j]] == 0) {
				//flag[a[i] * a[j]] = 1;
				sum += a[i] * a[j];
			}
		}
	}
	cout << sum << endl;
    
     return 0;
}


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

sorted_x = sorted(x)
m1 = sorted_x[int(n / 2) - 1]
m2 = sorted_x[int(n / 2)]

for i in range(n):
    if x[i] <= m1:
        b = m2
    else:
        b = m1
    print(b)


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

int     main() {
        int N;
        cin >>N;
        long T=1;
        long A=1;
        long t, a;
        for (int i=0; i<N; i++) {
                cin >>t >>a;
                long B=max(T/t, A/a);
                long T0=t*B;
                long A0=a*B;
                while ((T0<T)||(A0<A)) {
                        T0 += t;
                        A0 += a;
                }
                T=T0;
                A=A0;
        }
        cout <<T+A <<endl;
        return 0;
};

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


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    string S;
    cin >> S;
    int ans = 0;
    rep(i, 3) if(S[i] == '1') ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
#define pb emplace_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
const ll max_n = 200005;
ll n, c, cr[max_n];
ll sz[max_n], depth[max_n], ans[max_n];
ll bg[max_n], bc[max_n];
bool dead[max_n], uc[max_n], us[max_n], ue[max_n];
vector<ll> g[max_n], gt;

void dfs1(ll now, ll pr){
    bg[now] = 1;
    for(auto to: g[now]) if(to != pr && !dead[to]) {
        dfs1(to, now);
        bg[now] += bg[to];
    }
}     

void dfs2(ll now, ll pr){
    gt.pb(now);
    us[cr[now]] = true;
    if(!uc[cr[now]]) bc[cr[now]] += bg[now];
    else ue[now] = true;
    uc[cr[now]] = true;
    for(auto to: g[now]) if(to != pr && !dead[to]) {
        dfs2(to, now);
    }
    if(!ue[now]) uc[cr[now]] = false;
    ue[now] = false;
}

void dfs3(ll now, ll pr){
    gt.pb(now);
    us[cr[now]] = true;
    if(!uc[cr[now]]) bc[cr[now]] += bg[now];
    else ue[now] = true;
    uc[cr[now]] = true;
    for(auto to: g[now]) if(to != pr && !dead[to]) {
        dfs3(to, now);
    }
    if(cr[now] != cr[c] && !ue[now]) uc[cr[now]] = false;
    ue[now] = false;
}

int main(void) {
    cin >> n;
    rep(i,1,n) cin >> cr[i];   
    rep(i,1,n-1){
        ll aa, bb;
        cin >> aa >> bb;
        g[aa].pb(bb);  g[bb].pb(aa);
    }
    auto find_centroid = [&](ll root) {
        auto get_size = [&](auto &&self, ll v, ll p) -> void {
            sz[v] = 1;
            for(auto to: g[v]) if(to != p && !dead[to]) {
                self(self, to, v);
                sz[v] += sz[to];
            }
        };
        get_size(get_size, root, -1);
        auto dfs = [&](auto &&self, ll v, ll p) -> ll {
            for(auto to: g[v]) if(to != p && !dead[to]) {
                if(sz[to] > sz[root]/2) return self(self, to, v);
            }
            return v;
        };
        return dfs(dfs, root, 0);
    };
    auto centroid_decomposition = [&](auto &&self, ll root, ll d) -> void {
        c = find_centroid(root);
        dfs1(c, 0);
        dfs2(c, 0);
        bc[cr[c]]--;
        for(auto to: gt){
            if(us[cr[to]]) ans[cr[to]] -= bc[cr[to]] * bc[cr[to]];
            bc[cr[to]] = 0;
            us[cr[to]] = false;
        }
        gt.clear();
        dead[c] = true;
        depth[c] = d;
        for(auto to: g[c]) if(!dead[to]) {
            uc[cr[c]] = true;
            us[cr[c]] = true;
            bc[cr[c]] = bg[to];
            gt.pb(c);
            dfs3(to, c);
            for(auto to2: gt){
                if(us[cr[to2]]) ans[cr[to2]] += 2 * bc[cr[to2]] * (bg[c] - bg[to]);
                if(us[cr[to2]]) ans[cr[to2]] += bc[cr[to2]] * bc[cr[to2]];
                bc[cr[to2]] = 0;
                us[cr[to2]] = false;
            }
            uc[cr[c]] = false;
            gt.clear();
        }
        ans[cr[c]] += 2;
        for(auto to: g[c]) if(!dead[to]) {
            self(self, to, d+1);
        }
        dead[c] = false;
    };
    centroid_decomposition(centroid_decomposition, 1, 0);
    rep(i,1,n) cout << ans[i] / 2 << endl;
    return 0;
    }


Measured memory_bytes: 44636
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        total = 0
        for k in range(d):
            total += ((x[i][k] - x[j][k]) ** 2)
        total **= 0.5
        if total == int(total):
            cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <map>
using namespace std;

#define ll long long

int main() {
	int a[4], b[4], c[5][5];
	bool flag;
	for (int i = 0; i < 3; i++) {
		for (int j = 0;j < 3; j++) {
			cin >> c[i][j];
		}
	}
	a[0] = 0;
	for (int i = 0; i < 3; i++) b[i] = c[0][i] - a[0];
	for (int i = 0; i < 3; i++) a[i] = c[i][0] - b[0];
	flag = true;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (c[i][j] != a[i] + b[j])flag = false;
		}
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main()
{
    int set;
    int num[3];
    int a,b,c;
    
    if(set < 1000)
        cin >> set;
        
    for(int i = 0; i < set; i++){
        for(int j =0; j < 3; j++){
            cin >> num[j];
        }
        sort(num, num+3);
        if(num[0] * num[0] + num[1] * num[1] == num[2] * num[2]){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1168
x1, y1, x2, y2 = map(int, input().split())
a = x2 - x1
b = y2 - y1
x3 = x2 - b
y3 = y2 + a
x4 = x3 - a
y4 = y3 - b
print("{} {} {} {}".format(x3, y3, x4, y4))


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int x = Integer.parseInt(str[0]);
		int a = Integer.parseInt(str[1]);

		if (x < a) {
			System.out.println("0");
		} else {
			System.out.println("10");
		}
	}
}


Measured memory_bytes: 32712
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int x;
    cin >> x;
    vector<bool> expo(x+1);
    
    expo[1] = 1;
    for(int b=2; b<=x; b++){
        int v = b*b;
        while(v<=x){
            expo[v] = 1;
            v *= b;
        }
    }
    for(int i = x; i>=1; i--)if(expo[i]){
        cout << i << endl;
        return 0;
    }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    S = SI()
    S = S[::-1]
    N = len(S)
    dp = [0 for j in range(13)]
    dp2 = [0 for j in range(13)]

    for i, c in enumerate(S):
        if i == 0:
            if c == '?':
                for j in range(10):
                    dp[j] = 1
            else:
                dp[int(c)] = 1
        else:
            if c == '?':
                for j in range(10):
                    amari = (j * pow(10, i, 13)) % 13
                    for k in range(13):
                        dp2[k] = (dp2[k] + dp[(k-amari)%13]) % MOD
            else:
                for k in range(13):
                    amari = (int(c) * pow(10, i, 13)) % 13
                    dp2[k] = (dp2[k] + dp[(k-amari) % 13]) % MOD

            dp = dp2
            dp2 = [0 for j in range(13)]

    dprint(dp)
    print(dp[5])



solve()

Measured memory_bytes: 43500
#include<iostream>
#include<vector>
#include<algorithm>

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define EACH(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

struct HeavyLight {
  vector<vector<int> > len, tree;
  int pathCount,n;
  vector<int>size,parent,in,out,path,pathSize,pathPos,pathRoot;

  HeavyLight(vector<vector<int> >tree)
    :tree(tree),n(tree.size()),size(n),parent(n),in(n),out(n),
     path(n),pathSize(n),pathPos(n),pathRoot(n){
    int time=0;
    dfs(0,-1,time);
    buildPaths(0,newPath(0));
    len=vector<vector<int> >(pathCount);

    REP(i,pathCount){
      int m=pathSize[i];
      len[i].resize(2*m);
      fill(ALL(len[i]),0);
      fill(len[i].begin()+m,len[i].begin()+2*m,1);
      for(int j=2*m-1;j>1;j-=2)len[i][j>>1]=len[i][j]+len[i][j^1];
    }
  }

  void dfs(int u, int p, int &k){
    in[u]=k++, parent[u]=p, size[u]=1;
    EACH(v,tree[u])if(*v!=p)dfs(*v, u, k),size[u]+=size[*v];
    out[u]=k++;
  }

  int newPath(int u){ pathRoot[pathCount]=u; return pathCount++; }

  void buildPaths(int u, int pt){
    path[u]=pt, pathPos[u]=pathSize[pt]++;
    EACH(v,tree[u])if(*v != parent[u])
      buildPaths(*v, 2*size[*v] >= size[u] ? pt : newPath(*v));
  }

  bool isAncestor(int p, int ch){
    return in[p] <= in[ch] && out[ch] <= out[p];
  }

  int lca(int a,int b){
    for(int root; !isAncestor(root=pathRoot[path[a]],b);a=parent[root]);
    for(int root; !isAncestor(root=pathRoot[path[b]],a);b=parent[root]);
    return isAncestor(a,b)?a:b;
  }
};


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

  int n;
  cin >> n;
  vector<vector<int> >tree(n);
  
  REP(i,n){
    int k;
    cin >> k;
    REP(j,k){
      int ch;
      cin >> ch;
      tree[i].push_back(ch);
    }
  }

  HeavyLight hl = HeavyLight(tree);

  int q;
  cin >> q;
  while(q--){
    int u,v;
    cin >> u >> v;
    cout << hl.lca(u,v) << "\n";
  }
  
  return 0;
}

Measured memory_bytes: 25292
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    string s;
    string t;
    cin >> s;
    cin >> t;
    ll count=0;
    for(ll i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
        {
            count++;
        }
    }
    cout << count <<"\n";

}


Measured memory_bytes: 3852
import networkx as nx

N, K = [int(x) for x in input().split()]
A = [[int(x) for x in input().split()] for i in range(N)]


graph = nx.DiGraph()

SOURCE = 2 * N
SINK = SOURCE + 1

graph.add_node(SOURCE, demand=-K * N)
for i in range(N):
    graph.add_node(i)  # row
    graph.add_node(i + N)  # col
graph.add_node(SINK, demand=K * N)


for r in range(N):
    graph.add_edge(SOURCE, r, capacity=K, weight=0)
for r in range(N):
    for c in range(N):
        graph.add_edge(r, c + N, capacity=1, weight=-A[r][c])  # neg to maximize
for r in range(N):
    graph.add_edge(r + N, SINK, capacity=K, weight=0)

graph.add_edge(SOURCE, SINK, capacity=N * K, weight=0)  # slack


flowDict = nx.algorithms.flow.min_cost_flow(graph)
total = 0
grid = [["." for c in range(N)] for r in range(N)]
for r in range(N):
    for c in range(N):
        if flowDict[r][c + N]:
            grid[r][c] = "X"
            total += A[r][c]

print(total)
for row in grid:
    print("".join(row))



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

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

using namespace std;

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

signed main(){
  int N;
  cin>>N;
  int A[N];
  int min_num = 10000000000;
  rep(i, N){
    cin >> A[i];
  }

  int max=0;
  int res=1;
  int euclid;
  sort(A, A+N);
  int index;
  int a;
  vector<int> v;
  if(N<50){
    a = N;
  }else{
    a = 50;
  }
  for(int j=0;j<a;j++){
    euclid = A[j];
    int tmp;
    rep(i, N){
      tmp = euclidean_gcd(euclid, A[i]);
      if(min_num>tmp){
        min_num = tmp;
        v.push_back(i);
        index = i;
      }
    }
  }
  int max_euc = 0;
  sort(v.begin(), v.end());
  euclid = 0;
  rep(j,a){
    index = v[j];
    euclid = 0;
    for(int i=0;i<N;i++){
      if(i==index) continue;
      if(euclid<=0) euclid=A[i];
      euclid = euclidean_gcd(euclid, A[i]);
    }
    if(max_euc<euclid){
      max_euc = euclid;
    }
  }
  cout << max_euc << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

void output(int a[],int n){
    int i;
    for(i=0;i<n;i++){
        if(i==0)printf("%d",a[i]);
        else printf(" %d",a[i]);
    }
    printf("\n");
    return;    
}

int main(void){
    int i,j;
    
    int n;
    scanf("%d\n",&n);
    
    int a[n],tmp[n];
    for(i=0;i<n;i++){
        scanf("%d \n",&a[i]);
        tmp[i]=a[i];
    }
    
    int q;
    scanf("%d\n",&q);
    
    int b,m,e;
    int k;
    while(q--){
        scanf("%d %d %d\n",&b,&m,&e);
        for(k=0;k<e-b;k++){
            tmp[b+((k+(e-m))%(e-b))]=a[b+k];
        }
        for(i=0;i<n;i++)a[i]=tmp[i];
    }
    
    output(a,n);
    
    return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, m, x;std::cin >> n >> m >> x;
  vll v(n);
  vvl dat = VV(n, m, 0, ll);
  re(i, n){
    std::cin >> v[i];
    re(j, m) std::cin >> dat[i][j];
  }
  ll INF = 1000000000000000000;
  ll ans = 1000000000000000000;
  for(int i=0;i<(1<<n);i++){
    vll ok(m, 0);
    ll cost = 0;
    for(int j=0;j<n;j++){
      if(((i>>j)&1)==0) continue;
      cost += v[j];
      for(int k=0;k<m;k++) ok[k] += dat[j][k];
    }
    bool f = true;
    for(int j=0;j<m;j++) if(ok[j]<x) f = false;
    if(f) ans = min(ans, cost);
  }

  std::cout << (ans==INF?-1:ans) << '\n';
  return 0;
}


Measured memory_bytes: 3160
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <string>
#include <cstring>
//purvikaurraina
using namespace std;
const int maxn = 2e5 + 100;
int f[maxn];
int d[maxn];
int ff(int x){
    if (f[x] == x) return x;
    int a = f[x];
    int b = ff(f[x]);
    d[x] += d[a]; 
    f[x] = b;
    return b;
}
//purvikaurraina
int unit(int x,int y,int z){
    int fx = ff(x);
    int fy = ff(y);
    if (fx == fy){
        return (d[y] - d[x]) == z;
    }
    f[fy] = fx;
    d[fy] = d[x] + z -d[y];
    return 1;
}
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for (int i = 1; i <= n; i++) f[i] = i;
    int flag = 0;
    for (int i = 0; i < m; i++){
        int x,y,d;
        scanf("%d%d%d",&x,&y,&d);
        if (!unit(x,y,d))
        {
            flag = 1;
        }
    }
    if (flag) printf("No\n");
    else printf("Yes\n");
}

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

const int N = 1e5 + 5;

int A[N];

int main(){
	int n, ans = 1;
	cin>>n;
	for(int i = 1; i <= n; i++)	cin>>A[i];

	bool increasing = 0, not_set = 1;

	for(int i = 2; i <= n; i++){
		if(A[i] == A[i - 1])	continue;
		if(A[i] > A[i - 1]){
			if(not_set)	increasing = 1, not_set = 0;
			else{
				if(!increasing)	not_set = 1, ans++;
			}
		}
		else{
			if(not_set)	increasing = 0, not_set = 0;
			else{
				if(increasing)	not_set = 1, ans++;
			}
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    deque<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }

    ll ans = 0;
    for(int t = 0; t < N; t++) {
        bool flag = true;
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                if (i == j) continue;
                if (S[i][j] != S[j][i]) flag = false;
            }
        }
        if (flag) ans += N;

        string temp = S.back();
        S.pop_back(); S.push_front(temp);
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

Int calc(Int x){
  string s=to_string(x);
  Int res=0;
  for(Int i=0;i<(Int)s.size();i++) res+=s[i]-'0';
  return res;
}

signed main(){
  Int k;
  cin>>k;
  Int ans=calc(k);
  Int INF=1LL<<55;
  vector<Int> dist((k+100)*2,INF);
  using P=pair<Int,Int>;
  priority_queue<P,vector<P>,greater<P> > q;
  dist[k]=0;
  q.push(P(dist[k],k));
  while(!q.empty()){
    P p=q.top();q.pop();
    Int v=p.second,d=p.first;
    if(dist[v]<d) continue;
    ans=min(ans,dist[v]+calc(v));
    //cout<<v<<":"<<d<<endl;
    for(Int i=0;i<10;i++){
      Int t=(v+k*i);
      Int c=t%10,u=t/10;
      assert(u<(k+100)*2);
      if(dist[v]+c>=dist[u]) continue;
      //cout<<u<<":::"<<c<<endl;
      dist[u]=dist[v]+c;
      q.push(P(dist[u],u));
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 7792
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1000000007;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
  string t,p;
  cin >> t >> p;
  int num = 0;
  while(true){
    num = t.find(p,num);
    if(num+1) cout << num << endl;
    else break;
    num++;
  }
}



Measured memory_bytes: 3216
#include <stdio.h>

int main(){
  int i = 0, j = 0, k = 0, A_num[200000], Z_num[200000], length;
  char str[200000];
  while(1){
    scanf("%c", &str[i]);
    if(str[i] == 'A'){
       A_num[j] = i;
       j += 1;
    }else if(str[i] == 'Z'){
      Z_num[k] = i;
      k += 1;
    }else if(str[i] == '\n'){
      break;
    }
    i += 1;
  }

  length = Z_num[k-1] - A_num[0] + 1;
  printf("%d\n", length);
  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<map>
#include<stdlib.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<vector<int> > v(2,vector<int>(n/2,0));
    for(int i=0;i<n;i++){
        cin >> v[i%2][i/2];
    }
    for(int i=0;i<2;i++){
        sort(v[i].begin(),v[i].end());
        v[i].push_back(0);
    }
    vector<vector<vector<int> > > a(2,vector<vector<int> >(2,vector<int>(2,0)));
    //printf("%d %d %d %d\n%d %d %d %d\n",a[0][0][0],a[0][0][1],a[0][1][0],a[0][1][1],a[1][0][0],a[1][0][1],a[1][1][0],a[1][1][1]);
    for(int i=0;i<2;i++){
        int cnt=1;
        for(int j=1;j<=n/2;j++){
            if(v[i][j]==v[i][j-1])cnt++;
            else {
                if(cnt>a[i][0][0]){
                    a[i][1][0]=a[i][0][0];
                    a[i][0][0]=cnt;
                    a[i][1][1]=a[i][0][1];
                    a[i][0][1]=v[i][j-1];
                }else {
                    if(cnt>a[i][1][0]){
                        a[i][1][0]=cnt;
                        a[i][1][1]=v[i][j-1];
                    }
                }
                cnt=1;
            }
            //printf("%d %d %d %d\n%d %d %d %d\n",a[0][0][0],a[0][0][1],a[0][1][0],a[0][1][1],a[1][0][0],a[1][0][1],a[1][1][0],a[1][1][1]);
        }
    }
    if(a[0][0][1] != a[1][0][1]) cout << n - a[0][0][0] - a[1][0][0] << endl;
    else cout << n - max(a[0][0][0]+a[1][1][0],a[0][1][0]+a[1][0][0]) << endl;
    //printf("%d %d %d %d\n%d %d %d %d\n",a[0][0][0],a[0][0][1],a[0][1][0],a[0][1][1],a[1][0][0],a[1][0][1],a[1][1][0],a[1][1][1]);
    return 0;
}

Measured memory_bytes: 888
#include <cstdio>

#define PRINCIPAL 100000
#define RATE 1.05
#define ROUND_UNIT 1000

int main(void)
{
  int n;
  unsigned long debt = PRINCIPAL;

  std::scanf("%d\n", &n);

  for (int i = 0; i < n; i++) {
    debt = debt * RATE;
    debt = (debt + (ROUND_UNIT - 1)) / ROUND_UNIT * ROUND_UNIT;
  }

  std::printf("%lu\n", debt);
  
  return 0;
}



Measured memory_bytes: 2580
#include <stdio.h>

int main() {
  int X, Y, output = 1;
  scanf("%d %d", &X, &Y);
  for(int i = 0; i < X; i++) {
    (output+Y > output*2) ? output =output* 2 : output =output+Y;
  }
  printf("%d\n", output);
  return 0;
}

Measured memory_bytes: 1696
#include<stdio.h>
#include<string.h>
int main(void)
{
	int n;
	int i;
    double y=0;
	
    scanf("%d",&n);
     
    for(i=0;i<n;i++){
	double x;
	char u[3];
		scanf("%lf",&x);
        scanf("%s",&u);
		if(strcmp(u,"JPY")==0){
            y += x;
        }else{
            y += x*380000;
        }
			
	}
	printf("%lf\n",y);
	
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    
    vector<pair<long long,long long>> arr(N);
    for(int i=0;i<N;i++){
        cin >> arr[i].first >> arr[i].second;
    }
    sort(arr.begin(),arr.end());
    
    long long honsuu = 0,ans = 0;
    
    int i=0;
    for(i=0;honsuu<M;i++){
        ans += arr[i].first * arr[i].second;
        honsuu += arr[i].second;
    }
    
    if(honsuu-M>0){
        ans -= (honsuu - M)*arr[i-1].first;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <set>
#include <cstdio>
int i,n,v[9999];main(){for(;scanf("%d",&n),n;){std::set<int>t;for(i=1;i<n;i++)v[i]=0,t.insert(i*i%n);for(std::set<int>::iterator s=t.begin(),S=s,T=t.end();s!=T;S=++s)for(;++S!=T;v[i>n/2?n-i:i]+=2)i=*S-*s;for(i=0;i<n/2;)printf("%d\n",v[++i]);}}

Measured memory_bytes: 1296
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	const double eps = 1e-9;
	public void Solve(){
		
		double mi = 1e18;
		for(int i=0;i<N;i++){
			for(int j=i+1;j<N;j++){
				double cx = (X[i] + X[j])/2.0;
				double cy = (Y[i] + Y[j])/2.0;
				double r2 = (cx - X[i]) * (cx - X[i]) + (cy - Y[i]) * (cy - Y[i]);
				bool chk = true;
				for(int k=0;k<N;k++){
					//Console.WriteLine((cx - X[k]) * (cx - X[k]) + (cy - Y[k]) * (cy - Y[k]));
					chk &= (cx - X[k]) * (cx - X[k]) + (cy - Y[k]) * (cy - Y[k]) < r2 + eps;
				}
				//Console.WriteLine("{0} {1} {2} {3}",chk,cx,cy, r2);
				if(chk){
					mi = Math.Min(mi, r2);
				}
			}
		}
		if(N == 2){
			Console.WriteLine(Math.Sqrt(mi));
			return;
		}
		
		for(int i=0;i<N;i++){
			for(int j=i+1;j<N;j++){
				for(int k=j+1;k<N;k++){
					
					if(Det(X[i] - X[k], Y[i] - Y[k], X[j] - X[k], Y[j] - Y[k]) == 0) continue;
					double cx = 0, cy = 0;
					sol(2*(X[i] - X[j]), 2*(Y[i] - Y[j]), 2*(X[i] - X[k]), 2*(Y[i] - Y[k]),
						(X[i] * X[i] - X[j] * X[j] + Y[i] * Y[i] - Y[j] * Y[j]),
						(X[i] * X[i] - X[k] * X[k] + Y[i] * Y[i] - Y[k] * Y[k]),
						ref cx, ref cy);
					
					double r2 = (cx - X[i]) * (cx - X[i]) + (cy - Y[i]) * (cy - Y[i]);
					bool chk = true;
					for(int kk=0;kk<N;kk++){
						chk &= (cx - X[kk]) * (cx - X[kk]) + (cy - Y[kk]) * (cy - Y[kk]) < r2 + eps;
					}
					if(chk){
						mi = Math.Min(mi, r2);
					}
					
					
				}
			}
		}
		
		
		Console.WriteLine("{0:F15}",Math.Sqrt(mi));
		
		
		
	}
	
	long Det(long a, long b, long c, long d){
		return a * d - b * c;
	}
	void sol(double a, double b, double c, double d, double x, double y, ref double z, ref double w){
		double det = a * d - b * c;
		z = (d * x - b * y) / det;
		w = (-c * x + a * y) / det;
	}
	
	
	
	
	int N;
	int[] X,Y;
	public Sol(){
		N = ri();
		X = new int[N];
		Y = new int[N];
		for(int i=0;i<N;i++){
			var d = ria();
			X[i] = d[0];
			Y[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

const int DIM = 5e2 + 5;

int dp[DIM][11];

int main( void ) {
    ios::sync_with_stdio( false );
    cin.tie(); cout.tie();
    
    int n;
    cin >> n;
    
    for( int i = 1; i <= 9; i ++ )
        dp[0][i] = numeric_limits<int> :: min() / 3;
    
    for( int i = 1; i <= n; i ++ ) {
        int x;
        cin >> x;
        
        for( int j = 0; j <= 9; j ++ )
            dp[i][j] = max( dp[i - 1][j], dp[i - 1][(j - x % 10 + 10) % 10] + x );
    }
    
    cout << max( *max_element( dp[n] + 1, dp[n] + 10 ), 0 );
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string text = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  int n;
  cin >> n;
  string s;
  cin >> s;
  for(int i = 0; i < s.length(); i++){
    int begin = 0;
    int end = text.length() - 1;
    int p = (begin + end) / 2;
    while(s[i] != text[p]){
      if(s[i] < text[p]){
        end = p - 1;
      }else{
        begin = p + 1;
      }
      p = (begin + end) / 2;
    }
    p += n;
    if(p >= text.length()){
      p -= text.length();
    }
    s.replace(i,1,text,p,1);
  }
  cout << s << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> m(n);
  for (int i = 0; i < n; i++) {
    cin >> m[i].first;
  }
  for (int i = 0; i < n; i++) {
    cin >> m[i].second;
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (m[i].first > m[i].second) { res += m[i].first - m[i].second; }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 500001

typedef struct Node {
    long key;
    struct Node *p, *l, *r;
} Node;

Node *root, *NIL;


void insert(long k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->l = z->r = NIL;
    
    while (x != NIL) {
	y = x;
	if (z->key < x->key) x = x->l;
	else x = x->r;
    }
    z->p = y;
    
    if (y == NIL) root = z;
    else if (z->key < y->key) y->l = z;
    else y->r = z;
}

void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->l);
    printf(" %d", u->key);
    inorder(u->r);
}

void preorder(Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->l);
    preorder(u->r);
}

void print() {
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
}

int main() {
    long n, i, x;
    char st[20];
    scanf("%ld", &n);
    for (i = 0; i < n; i++) {
 	scanf("%s", st);
	scanf("%ld", &x);
	if (st[0] == 'i') insert(x);
	if (st[0] == 'p') print();
    }
    return 0;
}

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

using namespace std;

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, a, b) for (int i = a; i < b; i++)

int n;
long long a[50];

void culcp() {
	rep(i, n-1) {
		cout << i+1 << " " << i+2 << endl;
	}
}

void culcm() {
	rep(i, n-1) {
		cout << n-i << " " << n-i-1 << endl;
	}
}

void plusma(int mai) {
	rep(i, n) {
		cout << mai << " " << i+1 << endl;
	}
	culcp();
}
	
void plusmi(int mii) {
	rep(i, n) {
		cout << mii << " " << i+1 << endl;
	}
	culcm();
}

int main()
{
	cin >> n;
	rep(i, n) cin >> a[i];
	long long mi, ma;
	int mai, mii;
	mi = ma = a[0];
	mai = mii = 1;
	rep(i, n) {
		if (mi > a[i]) mi = a[i], mii = i+1;
		if (ma < a[i]) ma = a[i], mai = i+1;
	}
	if (mi >= 0) {
		cout << n-1 << endl;
		culcp();
	} else if (ma <= 0) {
		cout << n-1 << endl;
		culcm();
	} else if (ma > -mi) {
		cout << 2*n-1 << endl;
		plusma(mai);
	} else {
		cout << 2*n-1 << endl;
		plusmi(mii);
	}
	return 0;
}

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



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  int n;
  bool flag=false;
  cin>>n;
  for(int i=1;i<=9;i++){
    int a;
    if(n%i==0){
      a=n/i;
      if(i<=9 && a<=9){
        flag=true;
        break;
      }
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)

E = Hash.new { |h, k| h[k] = [] }

M.times do
  a, b = gets.split.map(&:to_i)

  E[a] << b
  E[b] << a
end

queue = []
queue << [1, -1]
ans = Hash.new
visited = Hash.new(false)

until queue.empty?
  cur, from = queue.shift

  next if visited[cur]
  visited[cur] = true

  ans[cur] = from

  E[cur].each do |to|
    queue << [to, cur]
  end
end

if (2..N).all? { |n| ans[n] }
  puts 'Yes'

  (2..N).each do |n|
    puts ans[n]
  end
else
  puts 'No'
end


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int x;
    cin >> x;

    int div = x / 100;
    int rem = x % 100;

    bool ok = false;
    if (x < 100) ok = false;
    else if (rem == 0) ok = true;
    else if (x >= div * 100 && x <= div * 105) {
        ok = true;
    }

    if (ok) cout << 1 << '\n';
    else cout << 0 << '\n';
    return 0;
}

Measured memory_bytes: 256
def get_char_ngram(n, s):
    char_gram = [''.join(s[i:i+n]) for i in range(len(s)-n+1)]
    return char_gram

s = input()
K = int(input())
res = set()
for i in range(1, K+1):
    tmp = set(get_char_ngram(i, s))
    res = res.union(tmp)
res = sorted(list(res))
print(res[K-1])

Measured memory_bytes: 40816
#include<stdio.h>
int main(void)
{
	int n,count;
	while(scanf("%d",&n)!=EOF){
		count=0;
		for(int f1=0;f1<10;f1++){
			for(int f2=0;f2<10;f2++){
				for(int f3=0;f3<10;f3++){
					for(int f4=0;f4<10;f4++){
							if(f1+f2+f3+f4==n){
							count++;
						}
					}
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int A[2000];

int main()
{
	int N;
	ll K, ans = 0;

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

	rep(i, N) {
		rep(j, N) {
			if (j < i) {
				if (A[i] > A[j]) {
					ans = (ans + (K - 1) * K / 2) % MOD;
				}
			}
			else if (i < j) {
				if (A[i] > A[j]) {
					ans = (ans + K * (K + 1) / 2) % MOD;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * B - Multiplication 2
 * N 個の整数 A1,...,AN が与えられます。
 * A1×...×AN を求めてください。
 * ただし、結果が 10の18乗 を超える場合は、代わりに -1 を出力してください。
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 入力値
        int n = sc.nextInt();
        long[] a = new long[n];

        for ( int i = 0; i < n; i++ ) {
            a[i] = sc.nextLong();
            if ( a[i] == 0 ) {
                System.out.println(0);
                sc.close();
                return;
            }
        }

        // 最大値
        long max = ( long ) Math.pow( 10, 18 );

        // 入力値を計算
        long result = 1;
        for( int i = 0; i < n; i++ ) {

            try {
                result = Math.multiplyExact( result, a[i] );
                if( result > max ) {
                    System.out.println( "-1" );
                    sc.close();
                    return;
                }
            }
            catch ( Exception e ) {
                System.out.println( "-1" );
                sc.close();
                return;
            }
        }

        System.out.println( result );

        sc.close();
    }
}

Measured memory_bytes: 61336
#include <bits/stdc++.h>
using namespace std;
int n;
long long AA, BB;
int t[5009];
long long dp[5009][5009]; //from i, limit j
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>AA>>BB;
    for(int i=1; i<=n; i++)
    {
        cin>>t[i];
    }
    for(int i=n; i>=1; i--)
    {
        for(int lim=0; lim<=n; lim++)
        {
            if(t[i]<lim)
            {
                dp[i][lim]=dp[i+1][lim]+BB;
            }
            else
            {
                dp[i][lim]=min(dp[i+1][t[i]], dp[i+1][lim]+AA);
            }
        }
    }
    cout<<dp[1][0]<<endl;
    return 0;
}


Measured memory_bytes: 195968
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class DPairCards {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N, M, ans = 0;
        in>>N>>M;
        vc<unordered_map<int, int>> F(M+1);
        REP(i, N){
            int x;
            in>>x;
            F[x%M][x]++;
        }
        REP(i, M/2+1){
            int j = (M-i) % M, szi = 0, szj = 0, ki = 0, kj = 0;
            for(auto& p : F[i]) szi += p.second, ki += p.second / 2;
            for(auto& p : F[j]) szj += p.second, kj += p.second / 2;
            if(i==j) ans += szi / 2;
            else{
                if(szi>szj) swap(szi, szj), swap(ki, kj);
                ans += szi + min((szj-szi)/2, kj);
            }
        }
        out<<ans<<'\n';
    }
};


int main() {
	DPairCards solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 15012
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(int, H, W, N);
    vector<int> a(N);
    read(a);

    auto mat = makeV(0, H, W);

    int cur = 0;
    rep(i, 0, H) {
        if (i & 1) {
            repr(j, W - 1, 0) {
                while (a[cur] <= 0) ++cur;
                mat[i][j] = cur + 1;
                --a[cur];
            }
        } else {
            rep(j, 0, W) {
                while (a[cur] <= 0) ++cur;
                mat[i][j] = cur + 1;
                --a[cur];
            }
        }
    }

    rep(i, 0, H) print(mat[i]);

    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main() {

    int N, M, K; cin >> N >> M >> K;
    bool ok = false;
    for (int n = 0; n <= N; ++n) {
        for (int m = 0; m <= M; ++m) {
            if (N*m + M*n - 2*m*n == K) {
                ok = true;
            }
        }
    }
    
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

int main(){
  ll N,s=0,ans=0;
  cin >> N;
  vec A(N);
  rep(i,N){
    cin >> A.at(i);
    ans+=s*A.at(i);
    ans%=MOD;
    s+=A.at(i);
    s%=MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

bool issame(int x, int y, const vector<int> &group) {
    bool x_found = false;
    bool y_found = false;
    for (auto n : group) {
        if (x == n)
            x_found = true;
        if (y == n)
            y_found = true;
    }
    return x_found && y_found;
}

int main() {
    fastIO;

    vector<int> g1{1, 3, 5, 7, 8, 10, 12};
    vector<int> g2{4, 6, 9, 11};
    vector<int> g3{2};

    int x, y;
    cin >> x >> y;

    bool is_same = false;

    if (issame(x, y, g1) || issame(x, y, g2) || issame(x, y, g3))
        is_same = true;

    if (is_same)
        cout << "Yes\n";
    else
        cout << "No\n";
}


Measured memory_bytes: 3588
def modComb(n, r, mod):
    nume = 1
    deno = 1
    for i in range(r):
        nume = nume*(n-i) % mod
        deno = deno*(i+1) % mod
    return nume*pow(deno, mod-2, mod) % mod
 
n, a, b = map(int, input().split())

mod = 10**9+7

ans = (pow(2, n, mod) -1 - modComb(n, a, mod)
       - modComb(n, b, mod)) % mod

print(ans)

Measured memory_bytes: 9140
#include<iostream>
    #include<algorithm>
    #include<stack>
    #include<queue>
    #include<string>
    #include<functional>
    using namespace std;
     
    #define INF (1<<21)
    #define MOD 1000000007
   
    int main() {
        int n=0;
        int x;
        string N;
        cin>>N;
        x=stoi(N);
        for(int i=0;i<N.length();i++){
            n+=N[i]-'0';
        }
        if(x%n==0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        return 0;


    }

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

// 3点P1,P2,P3とするとP1P2ベクトルとP1P3ベクトルの外積がSになる
// P1を原点にとるとS=|X2*Y3-X3*Y2|
// P2を(1,0)とすればS=|Y3|となり整数となるが
// 制約上X,Yは0~10^9の範囲内なのでSが10^9より大きい場合に不適
// P2を(10^9,1)とするとS=|10^9*Y3-X3|となるので
// P3をうまく置くことでSが1~10^18の値まですべて対応できる

int main(){
    ll S;
    cin >> S;
    ll X3,Y3;
    if(S<=1000000000){
        X3 = S;
        Y3 = 0;
    }else{
        for(int i=1;i<=1000000000;i++){
            Y3 = i;
            X3 = 1000000000*Y3 - S;
            if(0<=X3 && X3<=1000000000){
                break;
            }
        }
    }
    cout << "0 0 1000000000 1 " << X3 << " " << Y3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
long long n, nt, mn, ans, a[200005], b[200005][20];
int main() {
	int i, j;
	scanf("%lld", &n);
	for(i=0; i<n; i++) scanf("%lld", a+i);
	for(j=0; j<20; j++) {
		nt = n;
		b[n][j] = nt;
		for(i=n-1; i>=0; i--) {
			b[i][j] = nt;
			if(a[i]>>j & 1) nt = i;
		}
	}
	for(i=0; i<n; i++) {
		mn = n;
		for(j=0; j<20; j++) {
			nt = b[i][j];
			if((a[i]>>j & 1) == 0) nt = b[nt][j];
			if(nt<mn) mn = nt;
		}
		ans += mn-i;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 33024
while true
  w, h = gets.split.map(&:to_i)
  break if w == 0
  xh = {}; yh = {}
  xa = []; ya = []
  xa << 0; xa << w
  ya << 0; ya << h
  points = []
  gets.to_i.times do
    point = gets.split.map(&:to_i)
    points << point
    xa << point[0]; xa << point[2]
    ya << point[1]; ya << point[3]
  end
  xa.sort!.uniq!; ya.sort!.uniq!
  xs = xa.size; ys = ya.size
  xa.each_with_index{ |a, i| xh[a] = i+1 }
  ya.each_with_index{ |b, i| yh[b] = i+1 }
  fld = Array.new(ys+1){ Array.new(xs+1, true) }
  fld[0].fill(false); fld[ys].fill(false)
  fld.map{ |arr| arr[0] = arr[xs] = false }
 
  for point in points
    x1, y1, x2, y2 = point
    for a in (yh[y1]...yh[y2])
      for b in (xh[x1]...xh[x2])
        fld[a][b] = false
      end
    end
  end
  ret = 0
  for y in (1...ys)
    for x in (1...xs)
      next unless fld[y][x]
      arr = []
      arr << [y, x]
      until arr.empty?
        ny, nx = arr.shift
        [[-1,0],[0,-1],[1,0],[0,1]].each do |dy, dx|
          px = nx+dx; py = ny+dy
          if fld[py][px]
            arr << [py, px] 
            fld[py][px] = false
          end
        end
      end
      ret += 1
    end
  end
  p ret
end

Measured memory_bytes: 14208
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
double dp[2][200];
double ans[200000];
double p[200];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  p[0] = 1;
  rep(i, 100-1) p[i+1] = p[i]*0.5;
  int L = 150000;
  int T = 150;
  dp[0][0] = 1;
  ans[0] = 0;
  double base = 0;
  rep(i, L) {
    rep(j, T) dp[1][j] = 0;
    dp[1][1] = dp[0][0];
    for (int j=1; j<T-1; j++) {
      // succ
      dp[1][j+1] += dp[0][j] * p[j];
      // fail
      dp[1][0] += (dp[0][j] * (1.0-p[j]));
      base += (dp[0][j] * (1.0-p[j])) * j;
    }
    ans[i+1] = base;
    rep(j, T) ans[i+1] += dp[1][j]*j;
    swap(dp[0], dp[1]);
  }

  while (cin >> N) {
    if (N == 0) break;
    cout << fixed << setprecision(20) << ans[N] << "\n";
  }
  return 0;
}

Measured memory_bytes: 4420