akhauriyash/Code-Regression huggingface dataset:
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    string s,t;
    R(s,t);
    int AA=0;
    REP(i,3)AA+=(s[i]==t[i]);
    W(AA);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {

    int n, a, b, c;
    scanf("%d", &n);

    int arr01[n];
    int arr03[n - 1];

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

    int mysum = 0;
    for (int j = 0; j < n; j++) {
        scanf("%d", &b);
        mysum += b;
    }

    for (int k = 0; k < n - 1; k++) {
        scanf("%d", &c);
        arr03[k] = c;
    }

    for (int l = 0; l < n - 1; l++) {

        int first = arr01[l];
        int second = arr01[l + 1];

        if (first + 1 == second) {
            mysum += arr03[first - 1];
        }

    }

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

    return 0;

}

Measured memory_bytes: 128
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
class Main
{
    public static void main(String[] args) {
        try {
            int cnt = 0;
            HashMap<Integer, Integer> hm = new HashMap<>();
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int ar[] = new int[n];
            for (int i = 0; i < n; i++) {
                ar[i] = sc.nextInt();
            }
            for (int i = 0; i < n; i++) {
                hm.put(ar[i], 0);
            }
            for (int i = 0; i < n; i++) {
                hm.put(ar[i], hm.get(ar[i]) + 1);
            }
            for (Map.Entry<Integer, Integer> m : hm.entrySet()) {
                int v = m.getValue();
                int k = m.getKey();
                if (v < k)
                    cnt = cnt + v;
                else
                    cnt = cnt + v - k;
            }
            System.out.println(cnt);
        }
        catch (Exception e)
        {
            return;
        }
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int n=3;
int a[3];

int main(){
  rep(i,n)cin>>a[i];
  sort(a,a+n);
  cout<<a[2]-a[0]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  int k;  cin>>k;
  string s; cin>>s;
  int n=s.size();
  if(n>k){
    s = s.substr(0, k);
    s += "...";
  }
  cout<<s<<endl;
    return 0;
}


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

int main(){
	int N;
	vector<int> V, C;
	vector<int> v;
	
	cin >> N;
	V.resize(N);
	C.resize(N);

	for(int i = 0; i < N; ++i)
		cin >> V[i];

	for(int i = 0; i < N; ++i)
		cin >> C[i];


	// V-C;
	for(int i = 0; i < N; ++i){
		v.push_back(V[i]-C[i]);
	}

	sort(v.begin(), v.end(), greater<int>());
	int ans = 0, cnt = 0;
	for(int i = 0; i < N; ++i){
		if(v[i] > 0){
			ans += v[i];
		}else{
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
s = input()
x,y = map(int,input().split(" "))
l = [len(c) for c in s.split("T")]
X = l[::2]
Y = l[1::2]
 
ansX = set([X[0]])
for i in range(1,len(X)):
    ansX = set([c+X[i] for c in ansX]+[c-X[i] for c in ansX])
 
ansY = set([0])
for i in range(0,len(Y)):
    ansY = set([c+Y[i] for c in ansY]+[c-Y[i] for c in ansY])
    
if x in ansX and y in ansY:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 61020
import java.util.*;
import java.math.*;
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();
    }
    Arrays.sort(a);
    long hen1 = 0;
    long hen2 = 0;
    for(int i = a.length-1; i >= 1; i--){
      if(a[i] == a[i-1]){
        if(hen1 == 0){
          hen1 = a[i];
          i--;
        }else{
          hen2 = a[i];
          break;
        }
      }
    }
    System.out.println(hen1 * hen2);
  }
}


Measured memory_bytes: 51052
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>

using namespace std;

char str1[1234],str2[1234],str3[1234];

int main()
{
    scanf("%s%s%s",str1,str2,str3);
    printf("%c%c%c",str1[0]-32,str2[0]-32,str3[0]-32);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,n) for(int i=0;i<n;i++)
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x;
    cin >> x;
    cout << 1-x << endl;


	return 0;
}

Measured memory_bytes: 3632
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

M,D = II()

ans = 0

for i in range(M+1):
    for j in range(2,10):
        for k in range(2,10):
            if int(str(j)+str(k))>D:
                continue
            else:
                if i==j*k:
                    ans += 1

print(ans)

Measured memory_bytes: 40816
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
vector <int> a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    for(auto &i : a) cin >> i;
    ll ans = 0;
    int las = 0;
    for(int i = 0 ; i < n ; i++){
        if(a[i] == 0){
            las = 0;
            continue;
        }
        if(las){
            ans++;
            a[i]--;
            las = 0;
        }
        ans += a[i] / 2;
        las = a[i] % 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
input = defined?(DATA) ? DATA : STDIN
n = input.gets.to_i
n -= 1
(1..).each do |i|
  if n < 26 ** i
    str = n.to_s(26)
    str = str.tr('0-9a-p', 'a-z')
    str = str.rjust(i, 'a')
    puts str
    break
  end
  n -= 26 ** i
end


Measured memory_bytes: 14332
N = int(input())
Flag = 0
nList = []
nList.append(N)
i = 2
while Flag==0:
  Tmp = N % 2
  TmpN = N
  if Tmp == 0:
    TmpN /= 2
  else:
    TmpN = 3 * N + 1
  
  if TmpN in nList:
    Flag = 1
    break
  else:
    nList.append(TmpN)
    N = TmpN
    i += 1

print(i)


Measured memory_bytes: 3060
import java.util.*;
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();
      if(a+b >= c) System.out.println("Yes");
      else System.out.println("No");
      sc.close();
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	string s;
	cin>>s;
	int ans = 0;
	rep(i,s.size()-1){
		if(s[i] != s[i+1])ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	vector<vector<pair<int, int>>> map(n + 1);
	FOR_LT(i, 0, n - 1) {
		int a, b; cin >> a >> b;
		map[a].push_back({ b, i });
		map[b].push_back({ a, i });
	}

	vector<int> colors(n - 1);
	vector<int> visit(n + 1);

	queue<pair<int, int>> search;
	search.push({ 1, 0 });
	visit[1] = true;
	int mc = 0;
	while (!search.empty()) {
		auto cur = search.front();
		search.pop();

		int cc = cur.second;
		int nc = 1;

		for (auto& next : map[cur.first]) {
			if (visit[next.first]) continue;

			if (nc == cc) nc++;

			visit[next.first] = true;
			colors[next.second] = nc;
			mc = max(nc, mc);
			search.push({ next.first, nc });
			nc++;
		}
	}

	cout << mc << endl;
	FOR_LT(i, 0, n - 1) {
		cout << colors[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 7424
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;


int main(){
    int s, w; cin >> s >> w;
    if(w >= s){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
	return 0;
}


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

#ifdef DEBUG
#include "../include/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

const int mod = 1000000007;
long long p3[100010];

void init_p3() {
    p3[0] = 1;
    for (int i=1; i<100010; ++i) {
        p3[i] = (p3[i-1] * 3) % mod;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    init_p3();

    string L;
    cin >> L;

    int N = L.size();
    
    long long ans = 0;
    long long k = 1;

    for (int i=0; i<N; ++i) {
        int rest = N-i-1;
        if (i == N-1) {
            ans += (L[i] == '0' ? k : k*3);
            ans %= mod;
        } else {
            if (L[i] == '0') {
                // pass
            } else if (L[i] == '1') {
                ans += (k * p3[rest]) % mod;
                ans %= mod;
                k = (k * 2) % mod;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <vector>
using namespace std;

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


int a[505][505];

int b[505][505];
vector<int> odd[505];
int num = 0;



int main() {
	int H, W;
	
	int k = -1;
	cin >> H >> W;

	rep(i, H) {
		rep(j, W) {

			cin >> a[i][j];
			b[i][j] = a[i][j];
		}

   }



	rep(i, H) {
		rep(j, W) {
			if (i % 2 == 0 && b[i][j] % 2 == 1 && (i != H - 1 || j != W - 1)) {
				if (j != W - 1) {
					num += 1;
					b[i][j + 1] += 1;
				}

				else {

					num += 1;
					b[i + 1][j] += 1;
				}

			}

			else if (i % 2 == 1 && b[i][W - j - 1] % 2 == 1 && (i != H - 1 || j != W - 1)) {
				if (j != W - 1) {
					num += 1;
					b[i][W - j - 2] += 1;
				}

				else {

					num += 1;
					b[i + 1][W - j - 1] += 1;
				}


			}


		}
	}





	cout << num << endl;


	rep(i, H) {
		rep(j, W) {
			if (i % 2 == 0 && a[i][j] % 2 == 1 && (i != H - 1 || j != W - 1)) {
				if (j != W - 1) {
					cout << i + 1 << " " << j + 1 << " " << i + 1 << " " << j + 2 << endl;
					a[i][j + 1] += 1;
			   }

				else {

					cout << i + 1 << " " << j + 1 << " " << i + 2 << " " << j + 1 << endl;
					a[i + 1][j] += 1;
				}
				
			}

			else if (i % 2 == 1 && a[i][W - j - 1] % 2 == 1 && (i != H - 1 || j != W - 1)) {
				if (j != W - 1) {
					cout << i + 1 << " " << W - j << " " << i + 1 << " " << W - j - 1 << endl;
					a[i][W - j - 2] += 1;
				}

				else {

					cout << i + 1 << " " << W - j << " " << i + 2 << " " << W - j << endl;
					a[i + 1][W - j - 1] += 1;
				}

				
			}


		}
	}



	
	
	return 0;
}

Measured memory_bytes: 4096
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>

using namespace std;

int main() {
    string S;
    string M;
    cin>>S;
    M="abcdefghijklmnopqrstuvwxyz";

    for(int i=0;i<26;i++){
        if(S[0]==M[i]){

            cout<<M[i+1]<<endl;
        }
    }
    

}


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

typedef long long ll;
typedef unsigned long long ull;

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

  map<char, ll> m;
  for (int i = 0; i < s.size(); ++i) {
    auto itr = m.find(s[i]);
    if (itr != m.end()) {
      cout << "no" << endl;
      return 0;
    }
    m[s[i]] = 1;
  }

  cout << "yes" << endl;
  
  return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
A_o,A_e = [],[]
for i in range(n):
    if i % 2 == 0:
        A_o.append(A[i])
    if i % 2 == 1:
        A_e.append(A[i])
if n % 2 == 1:
    B = list(reversed(A_o)) + A_e
elif n % 2 == 0:
    B = list(reversed(A_e)) + A_o
for e in B:
    print(e,"",end = "")

Measured memory_bytes: 26020
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;
ll d[mm];
ll vis[mm];
int main()
{
	ll n,m,i,j,x,k;
    cin>>n;
    k=n%10;
    if(k==2||k==4||k==5||k==7||k==9) 
    printf("hon\n");
    else if(k==3)
    printf("bon\n");
    else if(k==0||k==1||k==6||k==8)
    printf("pon\n");
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>
#define HWRC 1000
 
int main()
{
    char HW[HWRC][HWRC];
    char RC[HWRC][HWRC];
    int H,W,R,C,i,j,k,cnt = 0;
    int Ck[HWRC];
    int Cn[HWRC];

    scanf("%d%d",&H,&W);
    for(i=0;i<H;i++)    scanf("%s",&HW[i]);
    scanf("%d%d",&R,&C);
    for(i=0;i<R;i++)    scanf("%s",&RC[i]);

    for(i=0;i<R;i++)
    {
        k = 0;
        Cn[i] = 0;

        for(j=0;j<C;j++)
        {
            if(RC[i][j]==RC[i][0])
            {
                k++; /* 0列目と同じなのは何列目までか */
                Cn[i] = k-1; /* 比較済みとなり得る列数 */
            }
            else
            {
                break;
            }
        }
        Ck[i] = C-k+1; /* 必ず比較しなければならない列数 */
    }

	/* テーブルAの行を検索 */
    for(i=0;i<=H-R;i++)
    {
		/* テーブルAの列を検索 */
        for(j=0;j<=W-C;j++)
        {
			/* テーブルBの行と一致する列を検索 */
            for(cnt = 0;cnt < R;cnt++)
            {
                if(memcmp(&HW[i+cnt][j],&RC[cnt][0],C)!=0)
                {
                    break;
                }
            }

            while(cnt == R)
            {
                printf("%d %d\n",i,j);
                j++;
                if(j<=W-C)
                {
                    for(cnt = 0;cnt < R;cnt++)
                    {
                        if(memcmp(&HW[i+cnt][j+Cn[cnt]],&RC[cnt][Cn[cnt]],Ck[cnt])!=0)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    break;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int N, Q;

	while (cin >> N >> Q, N && Q) {
		int avail[100] = {};

		for (int i = 0; i < N; i++) {
			int M; cin >> M;
			for (int j = 0; j < M; j++) {
				int tmp; cin >> tmp;
				avail[tmp-1] += 1;
			}
		}

		int max = 0;
		int idx = -1;
		for (int i = 0; i < 100; i++) {
			if (avail[i] >= Q && max < avail[i]) {
				idx = i;
				max = avail[i];
			}
		}

		cout << (idx == -1 ? 0 : idx+1) << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main()
{
    int N,M,i,sum=0;
    scanf("%d %d", &N, &M);
    int A[M];
    for(i=0; i<M; i++)
    {

      scanf("%d", &A[i]);
      sum=sum+A[i];
    }
    if(sum>N)
    {
        printf("-1\n");
    }
    else
    {
        printf("%d", N-sum);
    }
    return 0;

}


Measured memory_bytes: 1744
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n+1);
  for(int i = 1; i <= n; i++) cin >> a[i];
  vector<int> v(n+1, 0);
  for(int i = n; i >= 1; i--){
    int sum = 0;
    for(int j = i*1; j <= n; j += i){
      sum += v[j];
    }
    sum %= 2;
    v[i] = (a[i]+2-sum)%2;
  }
  vector<int> ans;
  for(int i = 1; i <= n; i++){
    if(v[i]) ans.push_back(i);
  }
  cout << ans.size() << endl;
  for(int i = 0; i < ans.size(); i++){
    cout << ans[i] << endl;
  }
  return 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back

typedef long long ll;
using namespace std;

const ll MAXN = +100500;
const ll INF = 1e18;

ll a[MAXN];
ll b[MAXN];

int main() {
    ll n;
    cin >> n;
    ll k = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        k += a[i];
    }
    for (int i = 0; i < n; i++) {
        b[i] = a[(i + 1) % n] - a[i];
    }

    if (k % ((n * n + n) / 2) != 0) {
        cout << "NO";
        return 0;
    }

    k /= (n * n + n) / 2;
    for (int i = 0; i < n; i++) {
        b[i] -= k;
        if (b[i] > 0) {
            cout << "NO";
            return 0;
        }
        if (b[i] % n != 0) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define all(c)      (c).begin(),(c).end()
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

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

template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(auto x: v) {
    os << x << " ";
  }
  return os;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &x : v) is >> x;
  return is;
}

/********************* MODULAR ARITHMETIC *******************************/

ll MOD = 1000000007;

void mod(ll &a){ if(a > MOD) a %= MOD; }
ll add(ll a, ll b) { a += b; mod(a); return a; }
ll mul(ll a, ll b) { mod(a); mod(b); a *= b; mod(a); return a; }
ll sub(ll a, ll b) { mod(a); mod(b); a -= b; a += MOD; mod(a); return a; }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

ll inv(ll a) { return powr(a, (MOD - 2)); }

/******************************** START *********************************/
const int N = 100005;

int main()
{
  ifalse;
  string s;
  cin >> s;
  int n = s.length();
  vector < ll > dp(2020);

  int ans = 0;
  for(int i = 0; i < n; i ++) {
      int d = s[i] - '0';
      vector < ll > dp2(2020);
      for(int j = 0; j < 2019; j ++) {
          dp2[(j * 10 + d) % 2019] += dp[j];
      }
      dp2[d] ++;
      ans += dp2[0];
      swap(dp, dp2);
  }


  cout << ans, nl;
  return 0;
}

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

#define pb push back
#define clr clear()
#define sz size()
#define fs first
#define sc second

#define rep(i,a) for(int i=0;i<(int)(a);i++)
#define rrep(i,a) for(int i=(int)(a)−1;i>=0;i−−)
#define all(a) (a).begin(),(a).end()
#define EQ(a,b) (abs((a)−(b)) < EPS)
#define INIT(a) memset(a,0,sizeof(a))

using namespace std;
typedef double D;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const D EPS = 1e-8;
const int INF = 1e8;
const D PI = acos(-1);

int v; //頂点数
int n;
int a,b,c;
int d[20][20]; //ク&#12441;ラフの隣接行列
void WarshallFloyd(void){ rep(k,v)rep(i,v)rep(j,v)d[i][j] = min(d[i][j],d[i][k]+d[k][j]); }

int main(){
  while(cin >> n,n){
    rep(i,20){
      rep(j,20)d[i][j] = INF;
      d[i][i] = 0;
    }

    v = 0;
    rep(i,n){
      cin >> a >> b >> c;
      v = max(v,max(a,b));
      d[a][b] = d[b][a] = c;
    }
    v++;

    WarshallFloyd();

    int res = -1, dis = INF;
    rep(i,v){
      int tmp = 0;
      rep(j,v)tmp += d[i][j];
      if(dis > tmp){
	dis = tmp; res = i;
      }
    }
    cout << res << " " << dis <<  endl;
  }
    
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
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 namespace std;

int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    return gcd(b,a%b);
}

int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    int T=0,A=0;
    rep(i,N){
        int t,a; cin>>t>>a;
        if(T<=t and A<=a){
            T=t; A=a;
        }else{
            int tmp=(T+t-1)/t;
            chmax(tmp,(A+a-1)/a);
            T=tmp*t; A=tmp*a;
        }
    }
    cout<<T+A<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    while(true) {
      int H = in.nextInt();
      int W = in.nextInt();

      if (H == 0 && W == 0) break;
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          System.out.print("#");
        }
        System.out.println();
      }
      System.out.println();
    }
  }
}

Measured memory_bytes: 32752
#include <iostream>

int main() {

	int a, b;

	std::cin >> a >> b;

	if (a < b) {
		std::cout << "a < b"
			<< std::endl;
	}
	else if (a > b) {
		std::cout << "a > b"
			<< std::endl;
	}
	else{
		std::cout << "a == b"
			<< std::endl;
	}
		return 0;
}



Measured memory_bytes: 3088
n = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
tot = sum(a)
count = 0
for i in a:
	if((i * 4 * n[1]) >= tot):
		count += 1
if(count >= n[1]):
	print('Yes')
else:
	print('No')

Measured memory_bytes: 61876
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();

    let ans = n / 3;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string S; cin >> S;

    int ans = 0;
    rep(i,S.size()){
        if (S[i] == '1') ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 3604
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
sa = [(a[i], i) for i in range(N)]
sa.sort(key = lambda x: (-x[0], -abs(x[1] - (N - 1) / 2)))
dp = [[0] * (N + 1) for _ in range(N + 1)]
for k in range(N):
  x, i = sa[k]
  for l in range(k + 1):
    r = k - l
    nr = N - 1 - r
    dp[l + 1][r] = max(dp[l + 1][r], dp[l][r] + abs(l - i) * x)
    dp[l][r + 1] = max(dp[l][r + 1], dp[l][r] + abs(nr - i) * x)
res = 0
for l in range(N):
  r = N - l
  res = max(res, dp[l][r])
print(res)

Measured memory_bytes: 100444
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int X, t;

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

  int ans = 0;
  if (X > t) {
    ans = X - t;
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int n, a, b, c;
int l[8];
int ans = 1000000000;

int calc_mp(string str) {
    int len_a = 0;
    int len_b = 0;
    int len_c = 0;
    int mp = 0;
    rep(i, 0, n) {
        if (str[i] == '0') {
            if (len_a != 0) mp += 10;
            len_a += l[i];
        }
        if (str[i] == '1') {
            if (len_b != 0) mp += 10;
            len_b += l[i];
        }
        if (str[i] == '2') {
            if (len_c != 0) mp += 10;
            len_c += l[i];
        }
    }

    if (len_a == 0 || len_b == 0 || len_c == 0) return -1;

    mp += abs(len_a - a) + abs(len_b -b) + abs(len_c - c);
    return mp;
}

void dfs(string select, int depth) {
    if (depth == n) {
        int x = calc_mp(select);
        if (x == -1) return;

        ans = min(ans, x);
        return;
    }

    rep(i, 0, 4) dfs(select + (char)(i + '0'), depth + 1);
}

int main() {
    cin >> n >> a >> b >>c;
    rep(i, 0, n) cin >> l[i];

    dfs("", 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Stack;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmpArray = br.readLine().split(" ");
		int n = Integer.parseInt(tmpArray[0]);
		int q = Integer.parseInt(tmpArray[1]);

		@SuppressWarnings("unchecked")
		ArrayList<Integer>[] queue = new ArrayList[n];
		for(int i = 0; i < n; i++){
			queue[i] = new ArrayList<Integer>();
		}

		for(int i = 0; i < q; i++){
			tmpArray = br.readLine().split(" ");

			//enqueue
			if(tmpArray[0].equals("0")){
				int t = Integer.parseInt(tmpArray[1]);
				int x = Integer.parseInt(tmpArray[2]);

				queue[t].add(x);
			}
			//front
			else if(tmpArray[0].equals("1")){
				int t = Integer.parseInt(tmpArray[1]);

				if(!queue[t].isEmpty()){
					System.out.println(queue[t].get(0));
				}
			}
			//dequeue
			else {
				int t = Integer.parseInt(tmpArray[1]);

				if(!queue[t].isEmpty()){
					queue[t].remove(0);
				}
			}
		}

	}
}


Measured memory_bytes: 68920
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>
#include<set>
#include<map>
using namespace std;

int main(){
    int n,ans=1;
    char s[100010];
    scanf("%d",&n);
    scanf("%s",s);
    for(int i=1;i<n;i++){
        if(s[i]!=s[i-1]){
            ans++;
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 1016
#include <stdio.h>

int main()
{   int n;
    scanf("%d",&n);
    int h[n];
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    int cnt=0,max=0;
    for(int i=n-1;i>0;i--){
        if(h[i]<=h[i-1]){
            cnt++;
        }else{
            if(max<cnt){
                max=cnt;
            }
            cnt=0;
        }
    }
    if(max<cnt){
                max=cnt;
            }
    printf("%d",max);

    return 0;
}


Measured memory_bytes: 512
def main():
  n,m=map(int,input().split())
  x=list(map(int,input().split()))
  xmod=[y%m for y in x]
  from collections import Counter
  cx=dict(Counter(x))
  cxmod=dict(Counter(xmod))
  ans1,ans2=0,0 # ams1:m倍になるペア、ans2:同数のペア。ans1からもとめる
  for k in cxmod.keys():
    if k==0:
      ans1+=cxmod[k]//2
      cxmod[k]-=2*(cxmod[k]//2)
    else:
      if k==m-k:
        ans1+=cxmod[k]//2
        cxmod[k]-=2*(cxmod[k]//2)
      elif m-k in cxmod.keys():
        tmp=min(cxmod[k],cxmod[m-k])
        ans1+=tmp
        cxmod[k]-=tmp
        cxmod[m-k]-=tmp
  for k in cx:
    v=cx[k]
    if v>=2 and cxmod[k%m]>=2:
      tmp=min(v//2,cxmod[k%m]//2)
      ans2+=tmp
      cxmod[k%m]-=tmp*2

  print(ans1+ans2)
if __name__=='__main__':
  main()



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

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> vec(h);
  
  for(int i =0; i< (w+2) ; i++){
    cout << '#';
  }
  cout << endl;
  
  for(int i=0; i<h ; i++){
    cout << '#';
    cin >> vec.at(i);
    cout << vec.at(i) << '#' << endl;
  }
  
  for(int i =0; i< (w+2) ; i++){
    cout << '#';
  }
  cout << endl;   
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		
		System.out.println(Math.max(Math.max(a+b, a-b), a*b));
	}
}

Measured memory_bytes: 23892
import qualified Control.Monad as M
import qualified Data.List as L
average xs = sum xs / (fromIntegral $ length xs)

path table (_:[]) = 0
path table (a:b:xs) = sqrt ((x1-x2)^2+(y1-y2)^2) + (path table (b:xs))
 where
  [x1,y1] = table !! a
  [x2,y2] = table !! b

main = do
 n <- readLn :: IO Int
 arr<-map ((map read).words)<$> M.replicateM n getLine :: IO [[Double]]
 print $ average [path arr xs|xs<-L.permutations [0..n-1]]

Measured memory_bytes: 3452
import scala.io.StdIn.readInt
  
object Main {
  val r = Array(2,3,5,7)
  
  def twoPow(d:Int,s:Int):(Int,Int) = {
    if(d%2 == 1) (d,s)
    else twoPow(d>>1,s+1)
  }
  
  def maybePrime(i:Int,d:Int,s:Int, n:Int):Boolean = {
    if(i>3) true
    else {
      val a = r(i)
      val x = BigInt(a).modPow(d,n).toLong
  
      if(x==1 || x==n-1) maybePrime(i+1,d,s,n)
      else repeat(s-1,x*x%n, i, d, s, n)
    }
  }
  
  def repeat(j:Int, x:Long, i:Int, d:Int, s:Int, n:Int):Boolean = {
    if(j==0) false
    else if(x==1) false
    else if(x==n-1) maybePrime(i+1,d,s,n)
    else repeat(j-1,x*x%n,i,d,s,n)
  }
  
  def isPrime(n:Int):Boolean = {
    if(n<1000) (2 to Math.sqrt(n).toInt).forall(n%_ != 0)
    else if(n%2==0) false
    else {
      val (d,s) = twoPow(n-1,0)
      maybePrime(0,d,s,n)
    }
  }
  
  def main(args:Array[String]) = {
    val n = readInt
    println((0 until n).count{ _=> isPrime(readInt) })
  }
}

Measured memory_bytes: 59692
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
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; }
//#define int long long

void solve() {
    int a, b; cin >> a >> b;
    cout << ((b - 1) + (a - 1) - 1) / (a - 1) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
x = int(input())

# x までの素数を探す
prim_numbers = [2]
for divided in range(3, x, 2):
    for prim in prim_numbers:
        if divided % prim == 0:
            continue
        else:
            prim_numbers.append(divided)
            break


def is_prim(q):
    for divider in prim_numbers:
        if q % divider == 0:
            return False
    return True


# 2 なら終わり
if x == 2:
    print(x)
    exit()
# 偶数なら、奇数だけ調べるようにする
if x % 2 == 0:
    x += 1
while True:
    if is_prim(x):
        print(x)
        exit()
    else:
        x += 2
        continue


Measured memory_bytes: 14128
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back

using namespace std;
typedef long long int ll;

ll find(ll pref[], int lim, ll val){
	ll l = 0, r = lim;
	while (l < r){
		ll m = (l+r+1)/2;
		if (2*pref[m] <= val) l = m;
		else r = m-1;
	}
	if (l < lim-1){
		ll k = l+1;
		if (abs(2*pref[k]-val) < abs(2*pref[l]-val)) return pref[k];
	}
	return pref[l];
}

ll find2(ll pref[], int lim, ll val, int n){
	ll l = lim+1, r = n-1;
	while(l < r){
		ll m = (l+r+1)/2;
		if (2*(pref[m]-pref[lim]) <= val) l = m;
		else r = m-1;
	}
	if (l < n-2){
		ll k = l+1;
		if (abs(2*(pref[k]-pref[lim])-val) < abs(2*(pref[l]-pref[lim])-val)) return pref[k]-pref[lim];
	}
	return pref[l]-pref[lim];
}

int main(void){
	// #ifndef JUDGE
	// freopen("in.txt", "r", stdin); 
	// #endif
	fast;
	int n; cin >> n;
	ll a[n], pref[n];
	for (int i = 0; i < n; ++i){
		cin >> a[i];
		if (i) pref[i] = a[i] + pref[i-1];
		else pref[i] = a[i];
	}
	ll ans = 1e18;
	for (int i = 1; i < n-2; ++i){
		ll left = pref[i];
		ll one = find(pref, i, left);
		ll two = pref[i] - one;
		ll three = find2(pref, i, pref[n-1]-pref[i], n);
		ll four = pref[n-1]-pref[i]-three;
		ll cur = max({one, two, three, four}) - min({one, two, three, four});
		ans = min(cur, ans);
	}
	cout << ans << '\n';

}

Measured memory_bytes: 3328
#include <stdio.h>
#include <set>
using namespace std;

set<long long> gat;

void test2(long long n)
{
	for (long long i = 1; i*i <= n; i++) if (n % i == 0){
		gat.insert(i);
		gat.insert(n / i);
	}
}

void test(long long i, long long n)
{
	if (i > 1){
		while (n % i == 0) n /= i;
		if (n % i == 1) gat.insert(i);
	}
}

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

	gat.insert(1);
	for (long long i = 1; i * i <= n; i++) if (n % i == 0){
		test(i, n);
		test(n / i, n);
	}

	test2(n - 1);

	printf ("%lld\n", gat.size() - 1);
	return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  ll k;
  cin >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  vector<bool> seen(n + 1);
  int loc = 1;
  while (!seen[loc]) {
    if (!k) {
      cout << loc << '\n';
      return 0;
    }
    seen[loc] = true;
    loc = a[loc - 1];
    --k;
  }
  fill(begin(seen), end(seen), false);
  vector<int> seq;
  while (!seen[loc]) {
    seq.push_back(loc);
    seen[loc] = true;
    loc = a[loc - 1];
  }
  int m = (int) seq.size();
  int ind = k % m;
  while (ind <= 0)
    ind += m;
  cout << seq[ind % m] << '\n';
  return 0;
}


Measured memory_bytes: 5036
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static final long MOD = 1_000_000_007;

	public static void main(String[] args) {
		int N = sc.nextInt();
		long K = sc.nextLong();
		Matrix mat = new Matrix(N, N);
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				mat.v[i][j] = sc.nextInt();
			}
		}
		mat = mat.pow(K);
		long ans = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				ans += mat.v[i][j];
			}
		}
		System.out.println(ans % MOD);
	}

	static class Matrix {

		long[][] v;

		Matrix(int dh, int dw) {
			this.v = new long[dh][dw];
		}

		Matrix mul(Matrix o) {
			Matrix ret = new Matrix(this.dim1(), o.dim2());
			for (int i = 0; i < this.dim1(); ++i) {
				for (int j = 0; j < o.dim2(); ++j) {
					for (int k = 0; k < this.dim2(); ++k) {
						ret.v[i][j] += this.v[i][k] * o.v[k][j];
						ret.v[i][j] %= MOD;
					}
				}
			}
			return ret;
		}

		Matrix pow(long p) {
			Matrix ret = new Matrix(this.dim1(), this.dim1());
			for (int i = 0; i < this.dim1(); ++i) {
				ret.v[i][i] = 1;
			}
			Matrix base = this.clone();
			while (p > 0) {
				if (p % 2 != 0) {
					ret = ret.mul(base);
				}
				p /= 2;
				base = base.mul(base);
			}
			return ret;
		}

		int dim1() {
			return this.v.length;
		}

		int dim2() {
			return this.v[0].length;
		}

		public Matrix clone() {
			Matrix ret = new Matrix(this.dim1(), this.dim2());
			for (int i = 0; i < this.dim1(); ++i) {
				for (int j = 0; j < this.dim2(); ++j) {
					ret.v[i][j] = this.v[i][j];
				}
			}
			return ret;
		}
	}
}

Measured memory_bytes: 27856
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  string N; cin>>N;
  if(N[0]=='7'||N[1]=='7'||N[2]=='7')cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)

using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    cout << a*b << ' ' << 2*(a+b) << endl;
}


Measured memory_bytes: 3064
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        String S = scanner.next();
        StringBuilder result= new StringBuilder();
        for (int i =0;i< S.length();i++){
            result.append("x");
        }
        pw.println(result);
        pw.close();
    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String file) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }

}


Measured memory_bytes: 21716
#include <stdio.h>

int main(void){
    int h, n, i, sum=0;
    scanf("%d %d", &h, &n);
    int a[n];
    for (i=0;i<n;i++){
        scanf("%d", &a[i]);
    }
    for (i=0;i<n;i++){
        sum = sum + a[i];
    }
    if (h <= sum){
        printf("Yes");
    }
    else {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) a.begin(),a.end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define debug(x) cout<<#x<<": "<<x<<endl
#define INF 1e9
typedef long long ll;

int main(void){
    int n;
    cin>>n;
    map<char,int> mp;
    rep(i,n){
        string s;
        cin>>s;
        mp[s[0]]++;
    }
    string MARCH = "MARCH";
    ll a[5]={};
    rep(i,5){
        a[i] = mp[MARCH[i]];
    }
    ll res = 0;
    rep(i,5)rep(j,i)rep(k,j){
        res += a[i]*a[j]*a[k];
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    ll N;
    cin >> N;

    ll ans = 0;

    for (ll k = 1; k <= N; k++) {
        ll l = N / k;
        ans += k * l * (l + 1) / 2;
    }

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

Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int i=0;
	while(1) {
		int x=1;
		cin >> x;
		if(x == 0) {
			return 0;
		}
		i += 1;
		cout << "Case " <<i <<": "<< x<<endl;
	}
}


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

long gcd(long n, long m) {
	if (n == 0)return m;
	if (n < m)swap(n, m);
	return gcd(n % m, m);
}

int main() {
	string s; cin >> s;
	int K; cin >> K;
	int a;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != '1') {
			a = i;
			break;
		}
	}
	if (a < K) {
		cout << s[a];
	}
	else cout << 1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	int n;
	cin >> n;
	if (n % 1000 == 0) 
	{
		cout << 0 << endl;
	}
	else 
	{
		int m = ceil(n / 1000.0) *1000 - n;
		cout << m << endl;
	}

}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int H, W;
    while (cin >> H >> W) {
        if (H == 0 && W == 0) {
            break;
        }
        for (int i=0; i<H; ++i) {
            for (int j=0; j<W; ++j) {
                cout << "#";
            }
            cout << "\n";
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 1176