akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define f(a, b, c) for(int a = b; a < c; a++)
#define fr(a, b, c) for(int a = b; a >= c; a--)
using namespace std;


//ll fact[1000001]; ll inv[1000001];
//ll primes[100007];
//ll arr[1000007];
//ll modPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//
//	ll halfpow = modPower(b, p / 2);
//	ll toReturn = (halfpow * halfpow) % mod;
//	if (p % 2)
//		toReturn = (toReturn * b) % mod;
//
//	return toReturn;
//}
//
//ll fastPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//	ll ans = fastPower(b, p / 2);
//	ans = (ans * ans);
//	if (p % 2 != 0)
//		ans = (ans * b);
//	return ans;
//}
//ll GcdRecursive(ll a, ll b) {
//	if (b == 0) return a;
//	return GcdRecursive(b, a % b);
//}
//ll modLCM(ll a, ll b) {
//	ll val = GcdRecursive(a, b);
//	ll tmp = ((a % mod) * (b % mod)) % mod;
//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
//	return finalVal;
//
//}
//ll LCM(ll a, ll b) {
//	return (a * b) / GcdRecursive(a, b);
//}
//void move1step(ll& a, ll& b, ll q) { // a and b by reference
//	ll c = a - q * b;
//	a = b;
//	b = c;
//}
//ll GcdIterative(ll a, ll b) {
//	while (b) move1step(a, b, a / b);
//	return a;
//}
//
//void pre(ll n) {
//
//	fact[0] = 1;
//	inv[0] = 1;
//
//	for (ll i = 1; i <= n; i++) {
//		fact[i] = (i * fact[i - 1]) % mod;
//		inv[i] = modPower(fact[i], mod - 2);
//		arr[i] = modPower(i, mod - 2);
//	}
//}
//
//ll npr(ll n, ll r) {
//	return ((fact[n] * inv[n - r]) % mod);
//}
//
//ll ncr(ll n, ll r) {
//	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
//}
//
//void sieve(ll val) {
//	memset(primes, 1, sizeof primes);
//	primes[0] = primes[1] = false;
//	for (int i = 2; i <= val; i++) {
//		if (primes[i]) {
//			for (int j = i * i; j <= val; j += i) {
//				primes[j] = 0;
//			}
//		}
//	}
//
//}

const ll mod = 1e9 + 7;
const ll N = 2e6 + 7;
const ll inf = 1e9 + 5;




string n;


int main()
{
    MohamedMotaz;
    cin >> n;
    f(i,0,3) if (n[i] == '7') return cout << "Yes", 0;
    cout << "No";

}





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

using namespace std;

int main(void) {
  int n, m;
  cin >> n >> m;
  vector <string> A;
  vector <string> B;
  for(int i = 0; i < n; i++) {
    string s;
    cin >> s;
    A.push_back(s);
  }
  for(int i = 0; i < m; i++) {
    string s;
    cin >> s;
    B.push_back(s);
  }

  if(n == m) {
    for(int i = 0; i < n; i++) {
      if(A[i] != B[i]) {
	cout << "No" << endl;
	return 0;
      }
    }
    cout << "Yes" << endl;
    return 0;
  }

  for(int i = 0; i < n - m; i++) {
    for(int j = 0; j < n - m; j++) {
      // A[i][j]がスタート
      bool flag = true;
      for(int k = 0; k < m; k++) {
	for(int l = 0; l < m; l++) {
	  if(A[i + k][j + l] != B[k][l]) {
	    flag = false;
	    break;
	  }
	}
	if(!flag) {
	  break;
	}
      }
      if(flag) {
	cout << "Yes" << endl;
	return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  vector<ll> v(n);
  map<ll,ll> m;
  rep(i,n){
    cin >> v[i];
    m[v[i]] = 0;
  }
  auto it = m.begin();
  ll cnt = 0;
  while(it!=m.end()){
    it->second = cnt;
    cnt++;
    it++;
  }
  vector<ll> newv(n);
  rep(i,n){
    newv[i] = m[v[i]];
  }
  ll ans = 0;
  rep(i,n){
    ans += abs(newv[i] - i) %2;
  }
  cout << ans /2 << endl;
}




Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int n, l=100, r=1, ans, tmp=0;
    cin >> n;
    vi x(n);
    rep(i, n){
        cin >> x[i];
        r=max(r,x[i]);
        l=min(l,x[i]);
    }
    REP(i, l, r+1){
        rep(j, n){
            tmp+=(x[j]-i)*(x[j]-i);
        }
        if(i==l){
            ans=tmp;
            tmp=0;
        }else{
            ans=min(tmp,ans);
            tmp=0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
S = input()
T = input()

lt = len(T)
ans = lt
for num in range(len(S) - lt + 1):
    s = S[num:num+lt]
    diff = 0
    for i in range(len(T)):
        if(T[i] != s[i]):
            diff += 1
    ans = min(ans, diff)

print(ans)

Measured memory_bytes: 73192
n = int(input())
a = list(map(int, input().split()))
fCount = 0
tCount = 0
oCount = 0

for i in range(n):
    if a[i] % 4 == 0:
        fCount += 1
    elif a[i] % 2 == 0:
        tCount += 1
    else:
        oCount += 1

ans = 0
# ans = n - fCount * 3 - (tCount // 2) * 2
#print(fCount, tCount)

if tCount > 1:
    if fCount > 0:
        if oCount >= fCount:
            ans = n - (2 * fCount + 1) - tCount + 1
        else:
            #print(2 * fCount + 1 + tCount)
            ans = n - (2 * fCount + 1) - tCount
    else:
        ans = n - tCount
else:
    if fCount > 0:
        ans = n - (2 * fCount + 1)
    else:
        ans = n

#print(ans)

if ans > 0:
    print('No')
else:
    print('Yes')




Measured memory_bytes: 63472
#include <iostream>

using namespace std;
static const int MAX=100;

int main () {
  int i, j, p, v, n, A[MAX];

  cin >> n;
  for (i = 0; i < n; i++) cin >> A[i];

  // print array
  for (p = 0; p < n; p++) {
    cout << A[p];
    if (p != n-1)
      cout << ' ';
  }
  cout << endl;

  // Insertion Sort
  for (i = 1 ; i < n; i++) {
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;


    for (p = 0; p < n; p++) {
      cout << A[p];
      if (p != n-1)
        cout << ' ';
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3032
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define rep(i, x) for(int i = 0; i < (int)(x); i++)
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define debug(x) cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

  int n,k;
  cin >> n>>k;
  vector<int> v(n);
  rep(i,n)cin >> v[i];
  sort(ALL(v), greater<int>());
  int c=0;
  rep(i,k) c+=v[i];
  cout << c << endl;

  return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#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 FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

bool is_palindrome(string s){
    int n = s.size();
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-1-i]) return false;
    }

    return true;
}

int main(){
    string s;
    cin >> s;
    int n = s.size();

    bool a,b,c;
    int index_a,index_b;
    index_a = (n-1)/2 , index_b = ((n+3)/2)-1;
    a = is_palindrome(s);
    b = is_palindrome(s.substr(0,index_a));
    c = is_palindrome(s.substr(index_b));

    if(a&&b&&c) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



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

int main() {
    int X; cin >> X;
    int ans = 1;
    while ((ans * (ans + 1)) / 2 < X) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

class NODE{
public:
	int to,cost;
	NODE(int a,int b){to = a , cost = b;}
};
bool operator<(const NODE &a,const NODE &b){
	return a.cost > b.cost;
}
int main(){
	int s,d;
	while(cin >> s >> d , s || d){
		vector<NODE> graph[100];
		rep(i,s)rep(j,s)if(i!=j)graph[i].push_back(NODE(j,0));
		int ret = 0;
		rep(i,s){
			rep(j,d){
				int c; cin >> c;
				if(c){
					graph[i].push_back(NODE(s+j,c));
					graph[s+j].push_back(NODE(i,c));
				}
			}
		}
		rep(i,d-1){
			rep(j,d-1-i){
				int c; cin >> c;
				if(c){
					graph[s+i].push_back(NODE(s+1+i+j,c));
					graph[s+1+i+j].push_back(NODE(s+i,c));
				}
			}
		}
		vector<int> get;
		priority_queue<NODE> Q;
		Q.push(NODE(0,0));
		bool done[100] = {0};
		while(Q.size()){
			NODE q = Q.top(); Q.pop();
			if(done[q.to])continue;
			else ret += q.cost , done[q.to] = true;
			get.push_back(q.cost);
			rep(i,graph[q.to].size()) Q.push(graph[q.to][i]);
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 0
import std.stdio,std.string,std.conv;

int main()
{
	string s;
	int count_1 = 0,count_2 = 0;
	while((s = readln.chomp).length != 0)
	{
		string[] _s = s.split(",");
		int len1 = _s[0].to!int;
		int len2 = _s[1].to!int;
		int len3 = _s[2].to!int;

		if(len3*len3 == len1*len1 + len2*len2) count_1++;
		if(len1 == len2) count_2++;
	}

	writeln(count_1);
	writeln(count_2);
	return 0;
}

Measured memory_bytes: 1068
def solve():
    N, A, B = [int(i) for i in input().split()]
    if (A - B) % 2 == 0:
        print(abs(A - B) // 2)
    else:
        ans1 = ((N - A) + (N - B) + 1) // 2
        ans2 = ((A - 1) + (B - 1) + 1) // 2
        print(min(ans1, ans2))

if __name__ == "__main__":
    solve()


Measured memory_bytes: 61704
N,M=map(x->parse(Int,x),split(readline()))
A=sort(map(x->parse(Int,x),split(readline())))
num=[2,5,5,4,5,6,3,7,6]
dp=Array{Int}(N+1)
dp[1]=0
for i=1:N
	ret=-10^10
	for a=A
		if num[a]<=i
			ret=max(ret,dp[i-num[a]+1]+1)
		end
	end
	dp[i+1]=ret
end
id=N+1
while id>1
	now=-1
	for a=A
		if id>num[a]&&dp[id-num[a]]+1==dp[id]
			now=a
		end
	end
	print(now)
	id-=num[now]
end
println()


Measured memory_bytes: 126448
N = int(input())
S = []

for i in range(N):
  S.append(int(input()))
  
S.sort()
ans = sum(S)

if ans % 10 != 0:
  print(ans)
  exit()
  
for i in range(N):
  if S[i] % 10 != 0:
    ans -= S[i]
    print(ans)
    exit()

print(0)


Measured memory_bytes: 9012
#include <iostream>

using namespace std;

#define MAX 45

int FibValue[MAX];

long long FibonacciNumber(int n)
{
	if (FibValue[n] != -1) return FibValue[n];

	if (n == 0 || n == 1)
	{
		FibValue[n] = 1;
		return FibValue[n];
	}

	FibValue[n] = FibonacciNumber(n - 1) + FibonacciNumber(n - 2);
	return FibValue[n];
}

int main()
{
	for (int i = 0; i < MAX; ++i)
		FibValue[i] = -1;
	int n; cin >> n;

	cout << FibonacciNumber(n) << endl;

	return 0;
}


Measured memory_bytes: 3088
import java.util.Scanner;

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

    int n = sc.nextInt();
    String s = sc.next();
    char[] chars = s.toCharArray();
    char[] ret = new char[chars.length];

    for (int i = 0; i < chars.length; i++) {
      if (chars[i] + n > 'Z') {
        ret[i] = (char) (chars[i] + n - 'Z' + 'A' - 1);
      } else {
        ret[i] = (char) (chars[i] + n);
      }
    }
    StringBuilder result = new StringBuilder();
    for (char c : ret) {
      result.append(c);
    }
    System.out.println(result.toString());
  }
}


Measured memory_bytes: 22100
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
void solve()
{
    int x,n;
    cin>>x>>n;
    set<int>s;
    rep0(i,n){
        int x;
        cin>>x;
        s.in(x);
    }
    int mi=mod;
    int wh=0;
    repp(i,-5,105){
        if(s.find(i)==s.end()){
            if(abs(i-x)<mi){
                mi=abs(i-x);
                wh=i;
            }
        }
    }
    pr(wh);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  bool yes = false;
  for (int i = 1; i <= (9); ++i){
    for (int j = 1; j <= (9); ++j){
      if(n==i*j) yes = true;
    }
  }
  if(yes) puts("Yes");
  else puts("No");

  return 0;
}


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

using namespace std;
#define N 200200
#define SIGMA 26

int i, n;
int v[N];
long long s, curr, curr1;
long long values[N];

int main()
{
    ios::sync_with_stdio();
    cin.tie(0);
    cin >> n;
    for (i = 0; i < n; ++i){
        cin >> v[i];
        ++values[v[i]];
    }
    s = 0LL;
    for (i = 0; i < n; ++i)
        if (values[i + 1])
        s += values[i + 1] * (values[i + 1] - 1LL) / 2LL;
    for (i = 0; i < n; ++i){
        curr = values[v[i]] * (values[v[i]] - 1LL) / 2LL;
        if (values[v[i]] > 1LL)
            curr1 = (values[v[i]] - 1LL) * (values[v[i]] - 2LL) / 2LL;
        else
            curr1 = 0LL;
        cout << s - curr + curr1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define INF 0x3f3f3f3f
typedef long long ll;
/*while(l<=r)
{
    ll mid=(l+r)/2;
    if(check(mid)) r=mid-1;
    else l=mid+1;
}*/
ll n,m;
ll d[5005][5005];
ll work(string s)
{
    //ll l=s.size();
    memset(d,0,sizeof(d));
    ll resl=0;
    rep1(i,n)
    {
        for(int j=i+1;j<=n;j++)
        {
            //d[i][j]=0;
            //cout<<s[i]<<" "<<s[j]<<"\n";
            if((s[i-1]==s[j-1])&&(d[i-1][j-1]<(j-i)))
            {
                d[i][j]=d[i-1][j-1]+1;
                resl=max(resl,d[i][j]);
                //cout<<"haha\n";
            }
            else d[i][j]=0;
            //cout<<i<<" "<<j<<" "<<d[i][j]<<" "<<resl<<"\n";

        }
        //return resl;
    }
    return resl;
}
int main()
{
    while(cin>>n)
    {
        string tmp;
        cin>>tmp;
        cout<<work(tmp)<<"\n";
    }

    return 0;
}


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

int main() {
    int N;
    string ans;
    cin >> N;
    for(int i = 0; i < N; i++) {
        string S;
        cin >> S;
        if(S == "Y") {
            ans = "Four";
            break;
        }
    }
    if(ans=="Four"){
        cout << ans << endl;
    }else{
        ans = "Three";
        cout << ans << endl;
    }}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
    int n; cin >> n;
    set<int> s;
    rep(i, n) {
        int d; cin >> d;
        s.insert(d);
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 256
def resolve():
    n = int(input())
    if n==2:
        print("2")
        exit()
    for j in range(10000):
        flag = 1
        a = int((n+j)**0.5)+1
        for i in range(2, a+1):
            if (n+j) % i== 0:
                flag = -1
            if i == a and flag ==1:
                print(n+j)
                exit()
resolve()

Measured memory_bytes: 38512
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long ksm(long long u,long long v){
	long long o=1;
	while(v){
		if(v&1)
			o=o*u%mo;
		u=u*u%mo;
		v>>=1;
	}
	return o;
}
int n,k,i,sum[200005],x,y,flag;
int top,nex[200005],to[200005],fir[100005];
void lj(int u,int v){
	top++;
	nex[top]=fir[u];
	fir[u]=top;
	to[top]=v;
}
void ss(int u,int v){
	for(int top1=fir[v];top1;top1=nex[top1])
		if(to[top1]!=u)
			ss(v,to[top1]);
	if(sum[v]==0){
		if(v==1)
			flag=1;
		sum[u]++;
	}	
	if(sum[v]==2)
		flag=1;
}
int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
   	n=read();
   	for(i=1;i<n;i++){
   		x=read();
		y=read();
		lj(x,y);
		lj(y,x);
   	}
   	ss(1,1);
   	if(flag==1)
   		printf("First\n");
   	else
   		printf("Second\n");
    return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int64_t a[29][200'000], b[29][200'000];

int main()
{
    int n;
    cin >> n;

    rep(i, n)
    {
        int aa;
        cin >> aa;

        rep(j, 29)
        {
            int mask = 1 << (j + 1);

            a[j][i] = aa % mask;
        }
    }

    rep(i, n)
    {
        int bb;
        cin >> bb;
        rep(j, 29)
        {
            int mask = 1 << (j + 1);

            b[j][i] = bb % mask;
        }
    }

    int result = 0;
    rep(i, 29)
    {
        sort(a[i], a[i] + n);
        sort(b[i], b[i] + n);

        int lb1 = 1 << i;
        int ub1 = lb1 << 1;
        int lb2 = (lb1 << 1) + lb1;
        int ub2 = ub1 << 1;

        int ones = 0;
        rep(j, n)
        {
            ones += lower_bound(b[i], b[i] + n, ub1 - a[i][j]) - lower_bound(b[i], b[i] + n, lb1 - a[i][j]);
            ones += lower_bound(b[i], b[i] + n, ub2 - a[i][j]) - lower_bound(b[i], b[i] + n, lb2 - a[i][j]);
            ones %= 2;
        }
        int flag = ones << i;

        result |= flag;
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 90880
import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

def sol():
    N = int(input())
    S = input().rstrip()

    ans = 0
    prev = -1

    for s in S:
        if prev != s:
            ans += 1
            prev = s

    print(ans)

sol()

Measured memory_bytes: 3700
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    n,m = map(int, input().split())
    wa = 0
    ac = 0
    used = {}
    wa_tmp = {}
    for _ in range(m):
        p,s = map(str, input().split())
        if used.get(p):
            continue
        if s == 'WA':
            if not wa_tmp.get(p):
                wa_tmp[p] = 0
            wa_tmp[p] += 1
        if s == 'AC':
            ac += 1
            used[p] = True
            if wa_tmp.get(p):
                wa += wa_tmp[p]
    print(ac, wa)


if __name__ == '__main__':
    main()


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

int main() {
    int n, x;
    cin  >> n >> x;
    int l, d = 0;
    for (int i = 0;i < n;i++) {
        if (x < d) {
            cout << i << endl;
            return 0;
        }
        cin >> l;
        d += l;
    }
    if (x < d) cout << n << endl;
    else cout << n+1 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        for(int i=1;i<=n;i++){
            int x=i;
            if(x%3==0){
                System.out.print(" "+i);
            }
            else{
                while(true){
                    if(x%10==3){
                        System.out.print(" "+i);
                        break;
                    }
                    x/=10;
                    if(x!=0)continue;
                    else break;
                }
                }
            }
            System.out.print("\n");
        }
    }


Measured memory_bytes: 28464
#include<iostream>
using namespace std;
int main(){
	bool a[1000000];
	for(int abc=2;abc<=999999;abc++){
		a[abc]=true;
	}
	for(int abc=2;abc<=999999;abc++){
		if(a[abc]==true){
			for(int ab=abc*2;ab<=999999;ab+=abc){
				a[ab]=false;
			}
		}
	}
	int ad;
	while(cin>>ad){
		int ansa=0;
		for(int abc=2;abc<=ad;abc++){
			if(a[abc]==true){
				ansa++;
			}
		}
		cout<<ansa<<endl;
	}
	return 0;
}

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

int main(){

 int x, h, m, s;

 cin >> x;

 h = x / 3600;
 m = (x % 3600) / 60;
 s = x % 60;

 cout << h << ":" << m << ":" << s << "\n";

 return 0;
}

Measured memory_bytes: 1168
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=1)
ans=0
for i in range(N-1):
    if i==0:
        ans+=A[0]
    else:
        ans+=A[(i+1)//2]
print(ans)

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

int main(){
  int n, i;
  cin >> n;
  char s[n];
  for(i = 0; i < n; i++) cin >> s[i];
  bool flag = false;
  for(i = 0; i < n; i++) if(s[i] == 'Y') flag = true;
  if(flag) cout << "Four" << endl;
  else cout << "Three" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

#include <vector>

using namespace std;

int main()
{
    int m, n, p ,q ;
    cin >> n >> m;

    vector<vector<int> > a(n, vector<int>(m));

    for(int i=0; i< n ; i++){
        for (int j = 0; j < m; j++ ) {
            cin >> p;
            a[i][j] = p;
        }
    }

    vector<vector<int> > b(m,vector<int>(1));

    for (int i = 0; i < m; i++) {
        cin >> q;      
        b[i][0] = q;
         }
    
    vector<vector<int> > c(n, vector<int>(1));

    for (int i = 0; i < n; i++) {
        c[i][0] = 0;
        for (int h = 0; h < m;h++) {
            c[i][0] = c[i][0] + a[i][h] * b[h][0];
        }
    }

    for (int i = 0; i < n; i++) {
        cout << c[i][0] <<endl;
        }

    return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()

using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;

int main(void){
	int H,W;cin>>H>>W;
	vector<vector<char>> VVI(H,vector<char>(W,0));
	rep(aa,H)rep(bb,W)cin>>VVI[aa][bb];

	int cnt = 0;
	for(int i = 0; i < H; i++){
		for(int t = 0; t < W; t++){
			cnt = 0;
			if(VVI[i][t] == '.'){
				cnt = 0;
				for(int x = -1; x <= 1; x++){
					for(int y = -1; y <= 1; y++){
						if(i + y >= 0 && t + x >= 0 && i + y < H && t + x < W){
							if(VVI[i + y][t + x] == '#')	cnt++;
						}
					}
				}
				VVI[i][t] = to_string(cnt)[0];
			}
		}
	}
	//出力
	rep(j , H){
		rep(q , W){
			cout<<VVI[j][q];
		}
		cout<<endl;
	}

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
int a[200001], c[200001], b[200001];
ll dp[200001];
int main() {
	
	int n, m;
	cin >> n;
	for (int i = 1; i <= n; i++) 
		cin>>a[i];
	c[1] = a[1];
	int tot = 1;
	for (int i = 2; i <= n; i++) {
		if (a[i] != c[tot])
			c[++tot] = a[i];

	}                                         ///把连续的相同的数变为一个
	dp[0] = 1;                                ///dp[i]是截止到第i位的结果数
	for (int i = 1; i <= tot; i++) {
		if (b[c[i]])                           ///b[i]是i上一次在c中出现的位置，若i未出现过则b[i]为0
			dp[i] = (dp[i - 1] + dp[b[c[i]]]) % mod;
		else 
			dp[i] = dp[i - 1];
		dp[i] %= mod;
		b[c[i]] = i;

	}
	cout << dp[tot] << endl;
	return 0;

}

Measured memory_bytes: 7460
A = input()
B = input()
if len(A) > len(B):
    print("GREATER")
elif len(A) < len(B):
    print("LESS")
else:
    for i in range(len(A)):
        if int(A) > int(B):
            print("GREATER")
            break
        elif int(A) < int(B):
            print("LESS")
            break
    else:
        print("EQUAL")

Measured memory_bytes: 9084
#include<bits/stdc++.h>
#define F first
#define S second
#define REP(i, a, b, c) for(int i = a; i <= b; i+=c)
#define pb push_back
#define int unsigned long long int
#define MAX 1e18
#define MOD 1000000007
using namespace std;

int dp[405][405];

int csum(int a[], int s, int e)
{
  int ans = 0;
  for (int i = s; i <= e; i++)
    ans = (ans + a[i]);
  return ans;
}

int solve(int a[], int i, int j) {
  if (i >= j)
    return  0;
  if (dp[i][j] != -1)
    return dp[i][j];
  dp[i][j] = MAX;
  for (int k = i; k < j; k++)
  {
    dp[i][j] = min(dp[i][j], solve(a, i, k) + solve(a, k + 1, j) + csum(a, i, k) + csum(a, k + 1, j));
  }
  return dp[i][j];
}

int32_t main()
{
  ios :: sync_with_stdio(false); cin.tie(0);
  int t = 1;
  //cin >> t;
  for (int i9 = 1; i9 <= t; i9++)
  {
    int n;
    cin >> n;
    int a[n];
    REP(i, 0, n - 1, 1) {
      cin >> a[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(a, 0, n - 1);
  }

}

Measured memory_bytes: 4936
from bisect import bisect_left

N, M = map(int, input().split())

P = []
Y = []
PY = [[] for _ in range(N+1)]

for _ in range(M):
    p, y = map(int, input().split())
    P.append(p)
    Y.append(y)
    PY[p].append(y)

for i in range(N+1):
    PY[i].sort()

for i in range(M):
    x = bisect_left(PY[P[i]], Y[i]) + 1
    print("%06d%06d" % (P[i], x))

Measured memory_bytes: 24116
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    long long ans=1;
    long long a[100011];
    for(int i=0;i<n;++i){
        cin>>a[i];
        if(a[i]==0) {
            cout<<0<<endl;
            return 0;
        }
    }
    for(int i=0;i<n;++i){    
        if(a[i]>1000000000000000000/ans){
            cout<<-1<<endl;
            return 0;
        }
        ans*=a[i];
    }
    cout<<ans<<endl;
    
}


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

int main()
{
	int n;
	int a[100000], b[100000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}

	int maxa = -1, minb = 1000000001;
	for (int i = 0; i < n; i++) {
		maxa = max(maxa, a[i]);
		minb = min(minb, b[i]);
	}

	cout << maxa + minb << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
	S=S%3600;
	m=S/60;
	S=S%60;
	s=S;
	printf("%d:%d:%d\n",h,m,s);
}


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

int main()
{
  int N, M;
  int t_max = 0;
  bool t[86401] = {false};

  scanf("%d", &N);
  for (int i = 0; i < N; i++){
    int h, m;
    scanf("%d%d", &h, &m);
    t[h * 3600 + m * 60] = true;
    t_max = max(t_max, h * 3600 + m * 60);
  }
  scanf("%d", &M);
  for (int i = 0; i < M; i++){
    int h, m;
    scanf("%d%d", &h, &m);
    t[h * 3600 + m * 60] = true;
    t_max = max(t_max, h * 3600 + m * 60);
  }

  for (int i = 0; i < t_max; i += 60){
    if (t[i]){
      printf("%d:%02d ", i / 3600, i % 3600 / 60);
    }
  }
  printf("%d:%02d\n", t_max / 3600, t_max % 3600 / 60);

  return (0);
}

Measured memory_bytes: 1288
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

bank b r t = (b, f)
  where
    f y
      | t==1 = (1 + (y * r) % 100)
      | t==2 = (1 + (r % 100)) ^ y

main = do
    n <- getInt
    unless (n==0) $ do
        y <- getInteger
        fst . maximumBy (comparing snd) . map (fmap ($y) . apply3 bank) <$> replicateM n getIntegers >>= print >> main


Measured memory_bytes: 5708
import sys
import math
input = sys.stdin.readline


def main():
    sc = Scan()
    N = sc.intarr()[0]
    A = sc.intarr()

    count = 0

    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            tmp = A[i]
            A[i] = A[minj]
            A[minj] = tmp
            count += 1
    display(A)
    print(count)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


main()



Measured memory_bytes: 5684
#include<stdio.h>
int main(void){
	int a[7],b[7],i;
	for(i=0;i<7;i++){
		scanf("%d %d",&a[i],&b[i]);
	}
	for(i=0;i<7;i++){
		printf("%d\n",a[i]-b[i]);
	}
	return 0;
}

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

int c[3][3];

int main() {
  cin >> c[0][0] >> c[0][1] >> c[0][2];
  int diff = 0;
  bool ans = true;
  for (int i = 1; i <= 2; i++) {
    cin >> c[i][0];
    diff = c[i][0] - c[i-1][0];
    for (int j = 1; j <= 2; j++) {
      cin >> c[i][j];
      if (diff != c[i][j] - c[i-1][j]) {
	ans = false;
      }
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
using System;
using System.Text;

class ABC076C
{
	static public void Main(string[] args)
	{
		string Sd = Console.ReadLine();
		string T = Console.ReadLine();
		
		if(Sd.IndexOf(T) != -1)
		{
			Console.WriteLine(Sd.Replace('?', 'a'));
		}
		else
		{
			bool match = false;
			int i = Sd.Length - T.Length;
			for(; i >= 0; i--)
			{
				int j=0;
				for(; j<T.Length; j++)
				{
					if(Sd[i+j] != '?' && Sd[i+j] != T[j])
					{
						break;
					}
				}
				if(j == T.Length)
				{
					match = true;
					break;
				}
			}
			if(match)
			{
				StringBuilder sb = new StringBuilder(Sd);;
				for(int j = 0; j<T.Length; j++)
				{
					sb[i+j] = T[j];
				}
				sb.Replace('?', 'a');	
				Console.WriteLine(sb);
			}
			else
			{
				Console.WriteLine("UNRESTORABLE");
			}
		}

	}
}


Measured memory_bytes: 13280
#include <bits/stdc++.h>
using namespace std;
const int M = 100001;
int n, w, i, j, wt[M], val[M]; long long ans[M];
int main ()
{
    cin >> n >> w;
    for(i = 1; i <= n; i++) cin >> wt[i] >> val[i];
    for(i = 1; i <= n; i++)
    {
        for(j = w; j >= wt[i]; j--)
        {
            ans[j] = max(ans[j], ans[j-wt[i]] + val[i]);
        }
    }
    cout << ans[w] << endl;
}

Measured memory_bytes: 4408
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <typeinfo>
using namespace std;

int main()
{
    string s1, s2;
    getline(cin, s1);
    getline(cin, s2);
    int s1l, s2l;
    s1l = s1.length();
    s2l = s2.length();
    // cout << s1l << " " << s2l << endl;
    int dp[s1l+1][s2l+1] = {0};
  	fill(*dp, *dp + (s1l+1)*(s2l+1), 0);
  /*
  for (int i=0; i<=s1l; ++i) {
      for (int j=0; j<=s2l; ++j)
  		cout << dp[i][j] << " ";
      cout << endl;
    }*/
  	for (int i=1; i<=s1l; ++i) {
      for (int j=1; j<=s2l; ++j){
        if (s1[i-1] == s2[j-1]) {
          dp[i][j] = 1 + dp[i-1][j-1];
        }
        else {
          dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
      }
    }  
  /*
  	cout << dp[s1l][s2l] << endl;
  	for (int i=0; i<=s1l; ++i) {
      for (int j=0; j<=s2l; ++j)
  		cout << dp[i][j] << " ";
      cout << endl;
    }
    */
 	//cout << typeid(s1).name() << endl;
	if (dp[s1l][s2l] == 0) {
      cout << " " << endl;
  	  return 0;
    }  
  	else {
      string res;
      int i = s1l;
      int j = s2l;
      while (res.size() < dp[s1l][s2l]){
        if (s1[i-1] == s2[j-1]) {
          //cout << typeid(s1[i-1]).name() << endl;
            res += s1[i-1];
            i -= 1;
            j -= 1;
        }
        else {
            if (dp[i-1][j] > dp[i][j-1])
                i -= 1;
            else
                j -= 1;
        }
      }
      reverse(res.begin(), res.end()); 
      cout << res<< endl;
    }  
  	
  return 0;
}
  

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

int main() {
  long long n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  
  long long x, y, z, w;
  x = min(a, b);
  y = min(c, d);
  z = min(x, y);
  w = min(e, z);
  
  long long t = 0;
  if(n % w == 0){
    t += n / w;
  }
  
  else if(n % w > 0){
    t += n / w + 1;
  }
  
  cout << t + 4 << endl;
}


Measured memory_bytes: 256
using System;

public class Program {
    public static void Main() {
        while (true) {
            string input = Console.ReadLine();
            if (input == null) break;
            decimal[] num = Array.ConvertAll(input.Split(' '), value => decimal.Parse(value));
            Console.WriteLine(Math.Round((num[2]*num[4]-num[5]*num[1])/(num[4]*num[0]-num[1]*num[3]), 3, MidpointRounding.AwayFromZero).ToString()+" "+(Math.Round((num[2]*num[3]-num[5]*num[0])/(num[1]*num[3]-num[4]*num[0]), 3, MidpointRounding.AwayFromZero)).ToString());
        }
    }
}

Measured memory_bytes: 9356
import math

x = int(input())

if x == 2:
    print(2)
    exit()

elif x%2 == 0:
    ans = x+1

else:
    ans = x

#2以外の素数は奇数であることに注意

while True:
    for i in range(3, int(math.sqrt(ans))+1, 2):
        if ans%i == 0:
            ans += 2
            break
    else:
        print(ans)
        exit()



Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  vector<pair<ll,ll>> v;
  REP(i,n){
    ll x,y;
    cin>>x>>y;
    v.emplace_back(x,y);
  }
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  vector<pair<ll,ll>> p;
  REP(i,n)REP(j,n){
    if(i==j) continue;
    ll x1,x2,y1,y2;
    tie(x1,y1)=v[i];
    tie(x2,y2)=v[j];
    p.emplace_back(x2-x1,y2-y1);
  }
  sort(ALL(p));
  int mx=0;
  int sum=1;
  REP(i,p.size()-1) {
    if (p[i] == p[i+1]) {
      ++sum;
    } else {
      mx=max(mx,sum);
      sum=1;
    }
  }
  mx=max(mx,sum);
  cout << n-mx << endl;
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
#define N 1000050
char w[N];
int n,sum,a[N];
int main() {
	scanf("%s",w+1); n=strlen(w+1);
	int i,k;
	for(i=1;i<=n;i++) a[i]=w[i]-'0';
	reverse(a+1,a+n+1);
	int jw=0;
	for(i=1;i<=n;i++) {
		int tmp=a[i]*9+jw;
		a[i]=tmp%10,jw=tmp/10;
	}
	if(jw) a[++n]=jw;
	int lim=n;
	for(i=1;i<=n;i++) sum+=a[i];
	for(k=1;k<=2*lim;k++) {
		int t=a[1]; a[1]+=9; i=1;
		while(a[i]>=10) {
			sum-=t; t=a[i+1]; a[i+1]+=a[i]/10; a[i]%=10; sum+=a[i]; i++;
		}
		sum-=t; sum+=a[i];
		if(sum<=9*k) return printf("%d\n",k),0;
	}
}


Measured memory_bytes: 4480
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>

using namespace std;

typedef complex<double> xy_t;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;

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

int nums[9][9];
bool ok[9][9];

bool check(int y, int x){
	int num = nums[y][x];
	rep(i, 9){
		if(i == y) continue;
		if(nums[i][x] == num) return false;
	}
	rep(i, 9){
		if(i == x) continue;
		if(nums[y][i] == num) return false;
	}
	int by = y / 3;
	int bx = x / 3;
	rep(i, 3){
		rep(j, 3){
			if(by * 3 + i == y && bx * 3 + j == x) continue;
			if(nums[by*3+i][bx*3+j] == num) return false;
		}
	}
	return true;
}

int main(){
	int n;
	cin >> n;
	rep(i, n){
		if(i != 0) cout << endl;
		memset(ok, true, sizeof(ok));
		rep(j, 9)rep(k, 9) cin >> nums[j][k];
		rep(j, 9)rep(k, 9) ok[j][k] = check(j, k);
		rep(j, 9){
			rep(k, 9){
				if(!ok[j][k]) cout << '*';
				else cout << ' ';
				cout << nums[j][k];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

int n, m;

struct bmatch {
    vector<int> lis[210];
    int mat[210], vis[210];
    void clear() {
        memset(mat,-1,sizeof(mat));
        for (int i=0;i<201;i++) lis[i].clear();
        memset(vis,0,sizeof(vis));
    }
    void add_edge(int a, int b) {
        lis[a].push_back(b+n);
    }
    int dfs(int here, int t) {
        vis[here] = t;
        for (int &there : lis[here]) {
            if (~mat[there]) {
                if (vis[mat[there]]!=t) {
                    if (dfs(mat[there],t)) {
                        mat[there] = here;
                        return 1;
                    }
                }
            }
            else {
                mat[there] = here;
                return 1;
            }
        }
        return 0;
    }
    void match() {
        for (int i=0;i<n;i++) {
            dfs(i,i+1);
        }
    }
} bm;

int mat[110][110];
int arr[110][110];
int brr[110][110];
int crr[110][110];

int main() {
    scanf("%d%d",&n,&m);
    for (int i=0;i<n;i++) for (int j=0;j<m;j++) scanf("%d",&arr[i][j]), arr[i][j]--;
    for (int i=0;i<n;i++) {
        for (int k=0;k<n;k++) {
            int c = 0;
            for (int j=0;j<m;j++) if (arr[i][j]/m==k) c++;
            mat[i][k] = c;
        }
    }
    for (int j=0;j<m;j++) {
        bm.clear();
        for (int i=0;i<n;i++) {
            for (int k=0;k<n;k++) if (mat[i][k]) bm.add_edge(k,i);
        }
        bm.match();
        for (int i=0;i<n;i++) {
            brr[i][j] = bm.mat[i+n];
            mat[i][bm.mat[i+n]]--;
        }
    }
    for (int i=0;i<n;i++) {
        for (int j=0;j<m;j++) {
            for (int k=0;k<m;k++) {
                if (arr[i][j]/m==brr[i][k]) {
                    crr[i][k] = arr[i][j];
                    brr[i][k] = -1;
                    break;
                }
            }
        }
    }
    for (int i=0;i<n;i++) {
        for (int j=0;j<m;j++) printf("%d ",crr[i][j]+1); printf("\n");
    }
    for (int j=0;j<m;j++) {
        vector<int> vec;
        for (int i=0;i<n;i++) vec.push_back(crr[i][j]);
        sort(vec.begin(),vec.end());
        for (int i=0;i<n;i++) crr[i][j] = vec[i];
    }
    for (int i=0;i<n;i++) {
        for (int j=0;j<m;j++) printf("%d ",crr[i][j]+1); printf("\n");
    }

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int main(int argc, const char * argv[]) {
	int n,t;
	queue<int> q;
	cin >> n >> t;
	int p[100005];
	string s[100005];
	for(int i = 0;i<n;i++){
		cin >> s[i];
		cin >> p[i];
		q.push(i);
	}
	int time = 0;
	while(!q.empty()){
		int now = q.front();
		q.pop();
		if(p[now]>t){
			p[now]-=t;
			time += t;
			q.push(now);
		}else{
			time += p[now];
			cout << s[now]<< " " << time << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4704
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int A, B;
    cin >> A >> B;

    for(int i=1; i<=10000; i++) {
        if(int(i*0.08)==A && int(i*0.1)==B) {
            cout << i << endl;
            return 0;
        }
    }
    
    cout << -1 << endl;


    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
    int a;
    cin >> a ;
    int s = 0;
    vector<int>v(a);
    int b = 0;
    for (int i = 0; i < a; i++) {
        cin >> v[i];
        s += v[i];
        b = max(b, v[i]);
    }
    if (s - 2 * b > 0) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}


Measured memory_bytes: 384
//////////////////////////////
// Author: whatisit
// Date: 2020-05-14 21:44 
//////////////////////////////
#include <bits/stdc++.h>
using namespace std;

int n, max_occur;
string s;
map<string, int> m;

void solve() {
	cin >> n;
	while (n--) {
		cin >> s;
		m[s] += 1;
		if (m[s] > max_occur) max_occur = m[s];
	}
	for (auto it = m.begin(); it != m.end(); ++it) {
		if (it->second == max_occur)
			cout << it->first << endl;
	}
}

int main() {
	//cin.tie(0); ios_base::sync_with_stdio(0);
	solve();
	return 0;
}

Measured memory_bytes: 25216
import sys

n = int(sys.stdin.readline())
x = list(map(int, sys.stdin.readline().split()))
y = list(map(int, sys.stdin.readline().split()))
absxy = [abs(x[i]-y[i]) for i in range(n)]

for dim in range(1,4):
    total = sum( (absxy[i]**dim for i in range(n)) )
    print(round(total**(1/dim), 6))
    
print(float(max(absxy)))


Measured memory_bytes: 5656
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
int n,col[450][450],cnt[450],tt;
template<typename I>inline void read(I&ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0' && ch<='9'){x=10*x+ch-'0'; ch=getchar();}
	ot=x*f;}
template<typename I,typename... U>inline void read(I&x,U&... y){read(x); read(y...);}
int main()
{
//	freopen(".in","r",stdin);
	read(n);
	for(int i=2;i*(i-1)/2<=n;i++)
	{
		if(i*(i-1)/2==n)
		{
			printf("Yes\n%d\n",i);
			for(int j=1;j<i;j++)
			{
				for(int k=j+1;k<=i;k++)
				{
					col[j][++cnt[j]]=++tt;
					col[k][++cnt[k]]=tt;
				}
				printf("%d ",cnt[j]);
				for(int k=1;k<=cnt[j];k++) printf("%d ",col[j][k]); printf("\n");
			}
			printf("%d ",cnt[i]); for(int k=1;k<=cnt[i];k++) printf("%d ",col[i][k]);
			return 0;
		}
	}
	printf("No\n");
//	fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 2176
#define rep(i,n) for (int i=0;i<n;i++)
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int main(){
  string s;
  cin >> s;
  int co=0;
  rep(i,3){
    if(s.at(i)=='R') co++;
  }
  
  if(co==3)
    cout << 3 << endl;
  else if(co==2 && s.at(1)!='S')
    cout << 2 << endl;
  else if(co==0)
    cout << 0 << endl;
  else
    cout << 1 << endl;
    
    
}

Measured memory_bytes: 3608
#include <iostream>

int main() {
    std::string S;
    std::cin >> S;
    int result = 0;
    for (int i = 0; i < 4; ++i) {
        if (S[i] == '+') {
            ++result;
        } else {
            --result;
        }
    }
    std::cout << result << std::endl;
    return 0;
}


Measured memory_bytes: 256