akhauriyash/Code-Regression huggingface dataset:
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

string s;
int ans;

main(){
	cin>>s;
	int yo=0;
	rep(i,s.size()){
		if(s[i]=='T'&&yo==0)ans++;
		else if(s[i]=='S')yo++;
		else yo--;
	}
	dump(ans+yo);
}

Measured memory_bytes: 640
K = int(input())
if K%2==0:
    print("-1")
elif K%5==0:
    print("-1")
else:
    ans = 0
    temp = 0
    check = 0
    for i in range(K):
        ans += 1
        temp *= 10
        temp += 7
        temp %= K
        
        if temp==0:
            check+=1
        
        if check==1:
            break
    print(ans)

Measured memory_bytes: 9180
#include <iostream>
#include <vector>
using namespace std;
int main(){
    long N,M;
    cin >> N >> M;
    vector<int>A(M);
    for(int i=0;i<M;i++){
        cin >> A[i];
    }
    for(int i=0;i<M;i++){
        N -= A[i];
    }
    if(N <0){
        cout << -1;
    }else{
        cout << N;
    }
}

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

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	int a = std::min(n, m);
	int b = std::max(n, m);
	for (int i = 0; i < b; ++i)
	{
		printf("%d", a);
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 128
/*
 * Author : Sadi
 * Sat 27/06/2020
 * 14:09:42.49
 */
#include <bits/stdc++.h>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif

    long long n;
    cin >> n;
    if(n == 0) {
        cout << 0 << endl;
    }
    else {
        string s;
        while(n != 0) {
            if(n % 2 == 1 or n % 2 == -1) {
                n--;
                s += '1';
            }
            else {
                s += '0';
            }
            n /= -2;
        }
        reverse(s.begin(), s.end());
        cout << s << endl;
    }

    return 0;
}


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

#define int long long

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector <int> P, Q;
	int tmp;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		P.push_back(tmp);
	}
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		Q.push_back(tmp);
	}
	int ans = 0;
	int A = 0;
	vector <int> B(n);
	copy(P.begin(), P.end(), B.begin());
	do {
		if (P == Q) {
			ans = A;
			break;
		}
		A++;
	} while (next_permutation(P.begin(), P.end()));
	A = 0;
	do {
		if (B == Q) {
			ans = A;
			break;
		}
		A++;
	} while (next_permutation(Q.begin(), Q.end()));
	cout << ans;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc176/tasks/abc176_b
#include <bits/stdc++.h>
using namespace std;

int main() {
	char ch;
	long long ans=0;	
	while (cin>>ch) {
		ans+=(ch-'0');
	}
	
	if (0==ans%9) {
		cout<<"Yes\n";
	} else {
		cout<<"No\n";
	}

	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

bool issame(vll& a, vll& b)
{
    bool flg = true;
    rep(i, 0, a.size()) {
        if (a[i] != b[i]) {
            flg = false;
        }
    }
    return flg;
}

int main()
{
    ll N;
    cin >> N;
    vll P(N);
    vll Q(N);   
    rep(i, 0, N) {
        cin >> P[i];
    }
    rep(i, 0, N) {
        cin >> Q[i];
    }
    vll seq(N);
    rep(i, 0, N) {
        seq[i] = i + 1;
    }
    ll a = -1;
    ll b = -1;
    ll cnt = 1;
    do {
        if (issame(seq, P)) {
            a = cnt;
            break;
        }
        ++cnt;
    } while (next_permutation(seq.begin(), seq.end()));


    cnt = 1;
    rep(i, 0, N) {
        seq[i] = i + 1;
    }
    do {
        if (issame(seq, Q)) {
            b = cnt;
            break;
        }
        ++cnt;
    } while (next_permutation(seq.begin(), seq.end()));


    cout << abs(a-b) << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  int first = -1;
  int last = -1;
  
  for(int i=0;i<s.size();i++){
    if(first==-1 && s.at(i)=='A'){
      first = i ;
    }
    if(s.at(i)=='Z'){
      last = i ;
    }
  }
  cout << last - first + 1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

bool judge(vector< int > &w, int k, int p){
	vector< int > track(k,0);
	int j=0;
	
	for(int i=0;i<w.size();++i){
		if(w[i] > p)return false;
		if(track[j] + w[i] <= p){
			track[j] += w[i];
		}else{
			++j;
			if(j>=k){
				return false;
			}else{
				track[j] = w[i];
			}
		}
	}
	return true;
}

int main() {
	int n,k,min,max,sum,mid;
	vector< int > w;
	
	
	cin >> n >> k;
	w.resize(n);
	sum = 0;
	for(int i=0;i<n;++i){
		cin >> w[i];
		sum += w[i];
	}
	
	min = sum / k;
	max = sum;

	while(max - min > 1){
		mid = ceil(0.5 *(min + max));
		
		if(judge(w,k,mid)){
			max = mid;
		}else{
			min = mid;
		}
	}
	
	if(judge(w,k,min))cout << min << endl;
	else cout << max << endl;
	
	return 0;
}

Measured memory_bytes: 1796
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  for(int i=0; i<S.size(); i++){
    int x = S.at(i) - 'A';
    x += N;
    x %= 26;
    S.at(i) = 'A' + x;
  }
  cout << S << endl;
}

Measured memory_bytes: 256
import fractions
from functools import reduce

# 最大公約数
# 引数を直接入れる
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)        
# 引数がリスト型
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

# 最小公倍数
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
# 引数を直接入れる
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
# 引数がリスト型
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
n,x=map(int,input().split())
b=list(map(int,input().split()))
a=[]
for i in b:
  a.append(abs(i-x))
print(gcd_list(a))

Measured memory_bytes: 89424
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
#define ll long long
#define out(a) printf("%lld",a)
#define ln printf("\n")
const int N=1e5+50;
const int MOD=1e9+7;
const int inf=0x7f7f7f7f;
using namespace std;
int n;
int b;
ll ans=0,tot;
int a[N];
char s[N][20],ss[N][20];
map<string,int>cnt;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	  scanf("%s",s[i]);
	for (int i=1;i<=n;i++){
	  for (int j=0;j<10;j++)
	    a[j+1]=s[i][j];
	  sort(a+1,a+10+1);
	  for (int j=1;j<=10;j++)
	    ss[i][j-1]=char(a[j]);
	  //cout<<ss[i]<<endl;
	  ans=ans+cnt[ss[i]];
	  cnt[ss[i]]++;
	}
	out(ans);
  	return 0;
}

Measured memory_bytes: 15232
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int n, m;
    cin >> n >> m;

    int a, b;
    vector<pii> v;

    for(int i = 0; i < m; i++) {
        cin >> a >> b;
        v.bash({b, a});
    }

    sort(ALL(v));

    int ans = 0, t = 0;

    for(int i = 0; i < m; i++) {
        if(!ans or v[i].second > t) {
            t = v[i].first - 1;
            ans++;
        }
    }

    cout << ans << endl;


  
    return 0;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    vector<string> arr = {"AC", "WA", "TLE", "RE"};
    vector<int> cnt(4);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        for(int i = 0; i < 4; i++)
        {
            if(arr[i].compare(s) == 0)
            {
                cnt[i]++;
            }
        }
    }
    for(int i = 0; i < 4; i++)
    {
        cout << arr[i] << " x " << cnt[i] << endl;
    }
}

Measured memory_bytes: 3588
#include<stdio.h>
typedef long long ll;
const int mod=1e9+7;
void fmax(int&a,int b){
	a<b?a=b:0;
}
int mul(int a,int b){return(ll)a*b%mod;}
int ad(int a,int b){return(a+=b)>=mod?a-mod:a;}
void inc(int&a,int b){(a+=b)>=mod?a-=mod:0;}
int h[200010],nex[200010],to[200010],M;
void add(int a,int b){
	M++;
	to[M]=b;
	nex[M]=h[a];
	h[a]=M;
}
int d[200010],c[200010];
int md[200010],son[200010];
void dfs(int x){
	int i,k=0;
	for(i=h[x];i;i=nex[i]){
		dfs(to[i]);
		if(md[to[i]]>md[k])k=to[i];
	}
	son[x]=k;
	md[x]=md[k]+1;
}
struct dat{
	int f0,f1,z;
	dat(int a=1,int b=1,int c=1):f0(a),f1(b),z(c){}
}p[200010],*f[200010],*now=p;
void operator+=(dat&a,const dat&b){
	int t=mul(ad(a.f0,a.f1),ad(b.f0,b.f1));
	a.f1=ad(mul(a.f1,b.f0),mul(a.z,b.f1));
	a.f0=ad(t,mod-a.f1);
	a.z=mul(a.z,b.f0);
}
void dfs2(int x){
	if(!f[x]){
		f[x]=now;
		now+=md[x];
	}
	if(son[x]){
		f[son[x]]=f[x]+1;
		dfs2(son[x]);
	}
	for(int i=h[x];i;i=nex[i]){
		if(to[i]!=son[x])dfs2(to[i]);
	}
}
void dfs3(int x){
	int i,j,k;
	for(i=h[x];i;i=nex[i])dfs3(to[i]);
	k=0;
	for(i=h[x];i;i=nex[i]){
		if(to[i]!=son[x]){
			fmax(k,md[to[i]]);
			for(j=0;j<md[to[i]];j++)f[x][j+1]+=f[to[i]][j];
		}
	}
	for(i=0;i<=k;i++)f[x][i].z=f[x][i].f0;
}
int pw[200010];
int main(){
	int n,i,x,s;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&x);
		add(x,i);
		d[i]=d[x]+1;
	}
	for(i=0;i<=n;i++)c[d[i]]++;
	dfs(0);
	dfs2(0);
	dfs3(0);
	pw[0]=1;
	for(i=1;i<=n;i++)pw[i]=ad(pw[i-1],pw[i-1]);
	s=0;
	for(i=0;i<md[0];i++)inc(s,mul(f[0][i].f1,pw[n+1-c[i]]));
	printf("%d",s);
}

Measured memory_bytes: 19712
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

int main(){
  string S, T;
  cin >> S >> T;
  for(int i=0; i<S.length(); i++){
    if(S[i]!=T[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		 Scanner scan = new Scanner(System.in);
		 int A = scan.nextInt();
		 int B = scan.nextInt();
		 
		 if (A <= 8 && B <= 8) {
			 System.out.println("Yay!");
		 } else {
			 System.out.println(":(");
		 }
		 
		 scan.close();

	}

}


Measured memory_bytes: 23892
#include<iostream>
using namespace std;
int main(void)
{
    int n,m,x,y,mx,mn;
    cin >> n >> m >> x >> y;
    mx=x,mn=y;
    while(n--)
    {
        cin >> x;
        if(mx<x) mx=x;
    }
    while(m--)
    {
        cin >> y;
        if(mn>y) mn=y;
    }
    if(mx>=mn) cout << "War";
    else cout << "No War";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define pyn(a) if(a)puts("Yes");else puts("No");
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
int n,a,b;
bool flag;
int main()
{
    sc2(a,b);
    int minn=min(a,b),maxx=max(a,b);
    rep(i,1,maxx)pf(minn);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


	public class Main {
		
		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			String S = sc.next();
			char[] s = S.toCharArray();
			char[] c = new char[26];
			int n = s.length;
			char lastc = 'X';
			
			
			for(int i=0;i<n;i++) {
				c[(s[i]-'a')]++;
			}
			
			if(S.equals("zyxwvutsrqponmlkjihgfedcba")){
				System.out.println(-1);
				return;
			}
			
			if(n<26) {
				for(int i=0;i<26;i++) {
					if(c[i]==0) {
						lastc = (char)(i+97);
						break;
					}
				}
				
				System.out.print(S);
				System.out.print(lastc);
				return;
			}
			
			int count = 0;
			for(int i=n-1;i>=0;i--) {
				count = i;
				
				for(int j=s[i]-'a'+1;j<26;j++) {
					if(c[j]==0) {
						lastc = (char)(j+97);
						break;
					}
				}
				
				c[(s[i]-'a')] = 0;
				
				if(lastc!='X') {
					break;
				}
			}
			
			for(int i=0;i<count;i++) {
				System.out.print(s[i]);
			}
			System.out.println(lastc);
	    }
		
	}
	


Measured memory_bytes: 35664
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B = get_ints

if A > 9 || B > 9
  puts '-1'
else
  puts A * B
end


Measured memory_bytes: 14492
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
#define op1(x) cout<<"Scenario #"<<x<<": "
#define endl "\n"
using namespace std;
const ll mod = 1000000007;
const ll INF = LLONG_MAX;
const int N = 18;
const ll MAXN = 1000001;

ll spf[MAXN];


void sieve()
{
	spf[1] = 1;
	for (int i = 2; i < MAXN; i++)


		spf[i] = i;


	for (int i = 4; i < MAXN; i += 2)
		spf[i] = 2;

	for (int i = 3; i * i < MAXN; i++)
	{

		if (spf[i] == i)
		{

			for (int j = i * i; j < MAXN; j += i)


				if (spf[j] == j)
					spf[j] = i;
		}
	}
}


void solve(int t)
{

	sieve();

	ll n;
	cin >> n;
	ll a[n];

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

	ll gcd = 0;
	for (int i = 0; i < n; i++)
	{
		gcd = __gcd(gcd, a[i]);
	}

	if (gcd > 1)
	{
		cout << "not coprime" << endl;
		return;
	}


	vector<ll> fac[n];
	map<ll, ll> mp;

	for (int i = 0; i < n; i++)
	{
		ll x = a[i];
		while (x != 1)
		{
			fac[i].push_back(spf[x]);
			mp[spf[x]]++;
			x = x / spf[x];
		}
	}


	ll num = 0;
	for (int i = 0; i < n; i++)
	{
		map<ll, ll> d;
		for (auto j : fac[i])
		{
			d[j]++;
		}
		ll ff = 1;
		for (auto j : d)
		{
			if (mp[j.F] - j.S > 0) ff = 0;
		}

		num += ff;
	}

	if (num == n)
	{
		cout << "pairwise coprime" << endl;
	}
	else
	{
		cout << "setwise coprime" << endl;
	}




}


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





	int t = 1;
	//cin >> t;



	for (int i = 1; i <= t; i++)
	{
		solve(i);

	}
}

Measured memory_bytes: 99156
#include<stdio.h>
 
int main(void){
  int i;
  int n;
  int m;
  int a;
  scanf("%d%d",&n, &m);
  for(i = 0; i < m; i++){
    scanf("%d", &a);
    n -= a;
  }
  if (n < 0)
    printf("-1\n");
  else
    printf("%d\n",n);
}

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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n, k;
  cin >> n >> k;
  map<int, int> mp;
  REP(i,n) {
    int a, b;
    cin >> a >> b;
    mp[a] += b;
  }
  int i = 1;
  int index = 0;
  while(k > index) {
    index += mp[i];
    ++i;
  }
  cout << i-1;
  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 6528
#include <algorithm>
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define REP(i, a) for (ll i(0), _##i(a); i < _##i; ++i)
#define FOR(i, a, b) for (ll i(a), _##i(b); i <= _##i; ++i)

#ifdef LOCAL
#define _NTH_ARG(_1, _2, _3, _4, _5, _6, N, ...) N
#define _FE_1(_CALL, x) _CALL(x)
#define _FE_2(_CALL, x, ...) _CALL(x) _FE_1(_CALL, __VA_ARGS__)
#define _FE_3(_CALL, x, ...) _CALL(x) _FE_2(_CALL, __VA_ARGS__)
#define _FE_4(_CALL, x, ...) _CALL(x) _FE_3(_CALL, __VA_ARGS__)
#define _FE_5(_CALL, x, ...) _CALL(x) _FE_4(_CALL, __VA_ARGS__)
#define _FE_6(_CALL, x, ...) _CALL(x) _FE_5(_CALL, __VA_ARGS__)
#define FOR_EACH_MACRO(MACRO, ...)                                             \
  _NTH_ARG(__VA_ARGS__, _FE_6, _FE_5, _FE_4, _FE_3, _FE_2, _FE_1)              \
  (MACRO, __VA_ARGS__)
#define watch(x) cerr << "\033[1;32m" #x " = \033[1;34m" << (x) << "\033[0m; ";
#define debug(...)                                                             \
  cerr << "\033[2;31mLine " << __LINE__ << ": \033[0;m";                       \
  FOR_EACH_MACRO(watch, __VA_ARGS__)                                           \
  cerr << endl
#else
#define debug(...)
#endif

using namespace std;

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  return os << '{' << p.first << ", " << p.second << '}';
}

template <class T, class = decltype(begin(declval<T>())),
          class = enable_if_t<!is_same<T, string>::value>>
ostream &operator<<(ostream &os, const T &c) {
  os << '[';
  for (auto it = begin(c); it != end(c); ++it)
    os << (it == begin(c) ? "" : ", ") << *it;
  return os << ']';
}
using ll = long long;

void solve() {
  int n, w;
  cin >> n >> w;
  vector<pair<int, int>> a(n + 1);
  FOR(i, 1, n) { cin >> a[i].F >> a[i].S; }
  vector<vector<ll>> dp(n + 1, vector<ll>(w + 1));
  
  FOR(i, 1, n) {
    FOR(j, 1, w) {
      dp[i][j] = dp[i - 1][j];
      if (a[i].F <= j) {
        dp[i][j] = max(dp[i][j], a[i].S + dp[i - 1][j - a[i].F]);
      }
    }
  }
  cout << dp[n][w] << "\n";
}

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

  int T = 1;
  // cin >> T;
  while (T--) {
    solve();
  }
}


Measured memory_bytes: 80256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int INF=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-9;
int main()
{
    int n;
    scanf("%d",&n);
    printf("%d\n",n*(n+1)/2);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int n;
    cin >> n;
    vector <int> d(n+1), cnt(n+1);
    for (int i = 1; i <= n; ++i) {
        cin >> d[i];
        ++cnt[d[i]]; 
    }   
    
    int ans = 1;
    const int MOD = 998244353;

    if (cnt[0] != 1) {
        cout << 0 << endl;
        exit(0);
    }   
    if (d[1] != 0) {
        cout << 0 << endl;
        exit(0);
    }   

    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < cnt[i]; ++j)
            ans = ans * cnt[i-1] % MOD;
    }   
    cout << ans << endl;
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int ans;
  for (int i=0;i<N;i++){
    if(S[i]=='.') ans++;
  }
  int now=ans;
  for (int i=0;i<N;i++){
    if(S[i]=='#') now++;
    else now--;
    ans=min(ans,now);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    int  A,B,C;
    scanf("%d%d%d",&A,&B,&C);
 
    if((A==B&&A!=C&&B!=C)||(B==C&&B!=A&&C!=A)||(C==A&&C!=B&&A!=B))
    {
        printf("Yes\n");
    }
    else
        printf("No\n");
 
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

vector<int> G[100010];
int d[2][100010];
int cnt[2];
void dfs(int v, int parent, int player) {
	for (int to : G[v]) {
		if (to == parent) continue;
		d[player][to] = d[player][v] + 1;
		dfs(to, v, player);
	}
}

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(0, -1, 0);
	dfs(N - 1, -1, 1);
	for (int i = 0; i < N; i++) {
		if (d[0][i] <= d[1][i]) cnt[0]++;
		else cnt[1]++;
	}
	if (cnt[0] > cnt[1]) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
}


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

using namespace std;
using ll = long long;

#define FOR(i,m,n) for(ll i=m; i<(ll)n; ++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  ll n; cin >> n;
  ll a, b, c, d, e; cin >> a >> b >> c >> d >> e;
  ll x = min({a, b, c, d, e});
  cout << (n + x - 1) / x + 4 << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
l = [i for i in range(N)]
r = [i for i in range(N)]

b = [0] * N
for i in range(N):
    b[a[i]-1] = i

ans = 0
for i in range(N-1,-1,-1):
    m = b[i]
    x,y = l[m],r[m]
    ans += (i+1)*(m-x+1)*(y-m+1)
    l[min(y+1,N-1)] = x
    r[max(x-1,0)] = y
print(ans)

Measured memory_bytes: 35804
#include <stdio.h>
int main() {
  char s[30002];
  int n, ans=0;
  scanf("%d", &n);
  scanf("%s", &s);
  
  for(int i=0; i<1000; i++){
    int c[3] = {i/100, (i/10)%10, i%10};
	int f = 0;
	for(int j = 0; j < n; j++) {
      if(s[j] == ('0' + c[f])) f++;
	  if (f == 3) break;
    }
    if (f == 3) ans++;
  }
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  int result = K;

  if (N > 1) {
    for (int i = 2; i <= N; i++) {
      result *= K - 1;
    }
  }
  cout << result << 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 all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,t,m,n,a)vector<vector<t> > name(m,vector<t> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	string a,b;
	std::cin >> a>>b;
	a=a+b;
	int n=stoi(a);
	//std::cout << n << std::endl;
	for (int i = 0; i <= sqrt(n+1); i++) {
		/* code */
		if(i*i==n){
			std::cout << "Yes" << std::endl;
			exit(0);
		}
	}
	std::cout << "No" << std::endl;
}


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

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int, int> PII;

#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const LL mod = 1000000007;

int main()
{
    LL N;
    cin >> N;
    vector<LL> A(N);
    REP(i, N) cin >> A[i];
    
    LL ans = 0;
    for(LL i=59; i>=0; --i) {
        LL count = 0;
        REP(j, N) if (A[j] & (1LL << i)) count++;
        ans *= 2;
        ans %= mod;
        ans += count * (N-count) % mod;
        ans %= mod;
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>

using namespace std;

typedef long long ll;

const int maxn= 1e5+5;

int main() {
	int n , maxnum = 0 , a[maxn] = {0};
	scanf("%d",&n);
	while(n--) {
		int now;
		scanf("%d",&now);
		a[now]++;
		a[now-1]++;
		a[now+1]++;
	}
	for(int i=0 ; i<maxn ; i++) {
		if(a[i] > maxnum) maxnum = a[i];
	}
	printf("%d\n",maxnum);
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int a, b, c;
  cin>>a>>b>>c;
  Int sum = a + b + c;
  if(sum >= 22) cout<<"bust"<<endl;
  else cout<<"win"<<endl;

  return 0;
}


Measured memory_bytes: 256
loop {
  a, op, b = gets.split(" ").map(&:to_s)
  a = a.to_i
  b = b.to_i

  op == '?' && break

  if op == '+'
    puts a + b
  elsif op == '-'
    puts a - b
  elsif op == '*'
    puts a * b
  else
    puts a / b
  end
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

const int MAX_N = 200020;

int dp[2][3][4][MAX_N];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;
  int n = s.size();
  string t = s;
  t.erase(unique(all(t)), t.end());
  if(t.size() == 1) {
    cout << 1 << endl;
    return 0;
  }

  if(n <= 3) {
    queue<string> que;
    set<string> used;
    que.push(s);
    used.insert(s);
    while(!que.empty()) {
      string u = que.front(); que.pop();
      //cout<<u<<endl;
      rep(i, n-1) {
	if(u[i] != u[i+1]) {
	  char a = u[i], b = u[i+1];
	  if(a > b) swap(a, b);
	  char c;
	  if(a == 'a' && b == 'b') c = 'c';
	  else if(a == 'a' && b == 'c') c = 'b';
	  else if(a == 'b' && b == 'c') c = 'a';
	  string v = u;
	  v[i] = v[i+1] = c;
	  if(!used.count(v)) {
	    used.insert(v);
	    que.push(v);
	  }
	}
      }
    }
    cout << used.size() << endl;
    return 0;
  }

  int ans = n == (int)t.size();
  int MOD = 998244353;
  dp[0][0][3][0] = 1;
  rep(i, n) {
    rep(is_ok, 2) {
      rep(mod_v, 3) {
	rep(prev_c, 4) {
	  rep(add_c, 3) {
	    dp[is_ok||(prev_c==add_c)][(mod_v+add_c)%3][add_c][i+1] += dp[is_ok][mod_v][prev_c][i];
	    dp[is_ok||(prev_c==add_c)][(mod_v+add_c)%3][add_c][i+1] %= MOD;
	  }
	}
      }
    }
  }
  int s_mod = 0;
  rep(i, n) s_mod += (s[i]-'a');
  s_mod %= 3;
  rep(last_c, 3) (ans += dp[1][s_mod][last_c][n]) %= MOD;
  cout << ans << endl;

  return 0;
}


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

public class Main{

    public static void solve(InputReader in, PrintWriter out) throws Exception {

        int n = in.nextInt();

        int[] arr = new int[n];

        for(int i=0;i<n;i++)
            arr[i]=in.nextInt();

        int[] dp = new int[n+1];

        dp[0]=0;
        dp[1]=0;
        dp[2]= Math.abs(arr[1]-arr[0]);

        for(int i=3;i<=n;i++)
        {
            int val1 = Math.abs(arr[i-1]-arr[i-2]) + dp[i-1];
            int val2 = Math.abs(arr[i-1]-arr[i-3]) + dp[i-2];

            dp[i]= Math.min(val1,val2);
        }

        out.println(dp[n]);

    }

    /////////////////////////////////////////////////////////


    private final static long hash(long x, long y) {
        x += offset;
        y += offset;
        return x << 32 | y;
    }

    private final static int offset = (int) 3e5;

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        private String nextToken() throws IOException {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
                tokenizer = new StringTokenizer(reader.readLine());
            return tokenizer.nextToken();
        }

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

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

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

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

    }
}


Measured memory_bytes: 43436
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.length(); ++i)
    {
        if (s == t)
        {
            cout << "Yes" << endl;
            return 0;
        }
        char c = s.front();
        string tmp = s.substr(1);
        tmp.push_back(c);
        s = tmp;
    }
    cout << "No" << endl;
    return 0;
}


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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int k = 0;
  while(true){
    if(k % 2 == 0){
      C -= B;
    }else{
      A -= D;
    }
    if(A <= 0){
      cout << "No" << endl;
      break;
    }else if(C <= 0){
      cout << "Yes" << endl;
      break;
    }
    k += 1;
  }
}

Measured memory_bytes: 3632
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n,k;
    cin>>n>>k;

    vector<int> v(n);
    for(int i=0;i<n;++i)
        cin>>v[i];

    sort(all(v));

    int beg=-inf,en=inf;
    int mid,ans;

    while(beg<=en)
    {
        mid=(beg+en)/2;

        int cur=0,pos,beg2,en2,mid2;
        for(int i=0;i<n;++i)
        {
            if(v[i]==0)
            {
                if(mid>=0)
                    cur+=(n-i-1);
            }
            else if(v[i]<0)
            {
                beg2=i+1,en2=n-1;
                pos=n;

                while(beg2<=en2)
                {
                    mid2=(beg2+en2)/2;

                    if(v[i]*v[mid2]<=mid)
                    {
                        pos=mid2;
                        en2=mid2-1;
                    }
                    else
                        beg2=mid2+1;
                }

                cur+=(n-pos);
            }
            else
            {
                beg2=i+1,en2=n-1;
                pos=i;

                while(beg2<=en2)
                {
                    mid2=(beg2+en2)/2;

                    if(v[i]*v[mid2]<=mid)
                    {
                        pos=mid2;
                        beg2=mid2+1;
                    }
                    else
                        en2=mid2-1;
                }

                cur+=(pos-i);
            }
        }

        //cout<<mid<<" "<<cur<<"\n";

        if(cur>=k)
        {
            ans=mid;
            en=mid-1;
        }
        else
            beg=mid+1;
    }

    cout<<ans;
}

int32_t main()
{
    //fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}

Measured memory_bytes: 1792
import java.util.*;

class Main
{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        String t = sc.next();
        
        int changeCount = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != t.charAt(i)) {
                changeCount++;
            }
        }
        
        System.out.println(changeCount);
    }
}

Measured memory_bytes: 41200
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
VEC<int> x;
int n, m;

int main() {
  cin >> n >> m;
  x = VEC<int>(m);
  REP(i, 0, m) {
    cin >> x[i];
    x[i] += 1e5;
  }
  sort(ALL(x));
  //   DUMP(x);
  VEC<int> d(m - 1);
  REP(i, 0, m - 1) { d[i] = x[i + 1] - x[i]; }
  sort(ALL(d));
  LL sum = 0;
  //   DUMP(d);
  REP(i, 0, m - n) { sum += d[i]; }
  cout << sum;

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main() {
long long n;
cin >> n;
int ans = 10;
for(long long i = 1; i*i <= n; i++) {
if(n%i != 0) continue;
if(to_string(n/i).size() < ans) ans = to_string(n/i).size();
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
long long n, s, x[2], a[100005];
int main() {
	int i, j;
	scanf("%lld", &n);
	for(i=0; i<n; i++) scanf("%lld", &a[i]);
	for(j=0; j<2; j++) {
		for(i=s=0; i<n; i++) {
			s += a[i];
			if((i+j)%2) {
				if(s<=0) x[j] += 1-s, s=1;
			} else {
				if(s>=0) x[j] += s+1, s=-1;
			}
		}
	}
	printf("%lld", x[0]<x[1] ? x[0]:x[1]);
	return 0;
}

Measured memory_bytes: 896
from collections import deque
N, M = map(int,input().split()) 
P = [list(map(int,input().split())) for i in range(M)]
A = [ [] for _ in range(N)]
#node_info = [{'node':d,'connect':[],'depth':-1,'dir':-1} for d in range(N)]

for path in P:
    A[path[1]-1].append(path[0]-1)
    A[path[0]-1].append(path[1]-1)
#print(A)

previous = [-1 for i in range(N)]
previous[0]=0

que = deque([0])

while len(que) != 0:
    v = que.popleft()
    for v_i in A[v]:
        if previous[v_i] != -1:
            continue
        else:
            que.append(v_i)
            previous[v_i] = v
for i in range(N):
    if previous[i] == -1:
        print('No')
        exit()
print('Yes')
for i in range(1,N):
    print(previous[i]+1)

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

int main() {
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
    return 0;
}

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

int N,M;
int C[16];
int x[20000];

/* [now position][prev value] */
int memo[20000][256];

int tansaku(int now_pos,int prev_value) {
	int result=0x7fffffff;
	int i;
	if(now_pos>=N)return 0;
	if(memo[now_pos][prev_value]>0)return memo[now_pos][prev_value]-1;
	for(i=0;i<M;i++) {
		int now_result;
		int now_sample=prev_value+C[i];
		if(now_sample<0)now_sample=0;
		if(now_sample>255)now_sample=255;
		now_result=(now_sample-x[now_pos])*(now_sample-x[now_pos]);
		now_result+=tansaku(now_pos+1,now_sample);
		if(now_result<result)result=now_result;
	}
	memo[now_pos][prev_value]=result+1;
	return result;
}

int main(void) {
	while(scanf("%d%d",&N,&M)==2 && (N|M)!=0) {
		int i;
		for(i=0;i<M;i++)scanf("%d",&C[i]);
		for(i=0;i<N;i++)scanf("%d",&x[i]);
		memset(memo,0,sizeof(memo));
		printf("%d\n",tansaku(0,128));
	}
	return 0;
}

Measured memory_bytes: 22244
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    cin >> s;
    int count = 0;
    if (s[0] == '1') count++;
    if (s[1] == '1') count++;
    if (s[2] == '1') count++;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3592
# include <cstdio>
# include <iostream>
# include <queue>
# include <cstring>
# include <string>
# define mod 1000000007
# define R register int
# define ll long long

using namespace std;

const int maxn=100100;
int n,m,fac=1,h;
int p[maxn],c[maxn];
ll f[maxn],inv[maxn];
ll ans=1;

ll qui (ll a,ll b)
{
	ll s=1;
	while (b)
	{
		if(b&1LL) s=s*a%mod;
		a=a*a%mod;
		b=b>>1LL;
	}
	return s%mod;
}

ll C (int a,int b)
{
	return f[b]*qui(f[a],mod-2)%mod*qui(f[b-a],mod-2)%mod;
}

int main()
{
	scanf("%d%d",&n,&m);
	f[0]=1;
	for (R i=1;i<=n+50;++i)
		f[i]=1LL*i*f[i-1]%mod;
	for (R i=2;1LL*i*i<=m;++i)
	{
		if(m%i==0) p[++h]=i;
		while (m%i==0) c[h]++,m/=i;
	}
	if(m!=1) p[++h]=m,c[h]=1;
	for (R i=1;i<=h;++i)
		ans=(ans*C(n-1,n+c[i]-1))%mod;
	printf("%lld",ans%mod);
	return 0;
}

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

int main() {
    while (true) {
        int n;
        cin >> n;
        if (!n) return 0;

        int maxi = 0, mini = 10000000;
        while (n--) {
            int a, b, c, d, e;
            cin >> a >> b >> c >> d >>e;
            int sum = a + b + c + d + e;
            maxi = max(maxi, sum);
            mini = min(mini, sum);
        }
        cout << maxi << " " << mini << endl;
    }
}

Measured memory_bytes: 3092
import java.util.Scanner;
import java.io.IOException;
public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (a == 0 && b == 0)
                break;
            if (a>=b){
                System.out.println(b + " " + a);
            }else{
                System.out.println(a + " " + b);
            }
        }
    }
}

Measured memory_bytes: 26400
#include <random>
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld eps = 1e-12;
constexpr int inf = numeric_limits<int>::max() / 2;
constexpr ll mod = 1e9 + 7;
mt19937_64 rnd{random_device()()};

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  ll a;
  cin >> a;
  string s;
  cin >> s;
  string b = "";
  b += s[0];
  b += s[2];
  b += s[3];
  cout << a * stoll(b) / 100 << endl;
}


Measured memory_bytes: 3672
import bisect
N=int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
total = 0
for i in range(N):
  total += bisect.bisect_left(a,b[i]) * (N - bisect.bisect_right(c,b[i]))
print(total)

Measured memory_bytes: 23360
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9 + 7
num_1 = 0
num_2 = 0
for i in range(N):
  for j in range(N):
    if j < i:
      if A[j] < A[i]:
        num_2 += 1
    elif j > i:
      if A[j] < A[i]:
        num_1 += 1
        num_2 += 1
K1 = (K)*(K-1)//2%MOD
print((num_1*K + num_2 * K1)%MOD)
    

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std;
int main()
{
    int n,k; cin>>n>>k;
    int a[n] = {0};
    int d,b;
    for(int i=0;i<k;i++)
    {
        cin>>d;
        for(int j=0;j<d;j++)
        {
            cin>>b;
            a[b-1]++;
        }
    }
    int sum=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==0)
            sum++;
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3636
x = input()

ans = len(x)
tmp_s = 0
mae = 1

for i in range(len(x)):
    if x[i] == 'S':
        #if mae == 0:
        #    tmp_s = 1
        tmp_s += 1
    elif tmp_s > 0:
        ans -= 2
        tmp_s -= 1
        mae = 0
        
print(ans)

Measured memory_bytes: 3500