akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> 
#define int long long 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> hashing;
int pow(int x,int n,int mod){int res = 1;while (n){if (n&1){res = (res*x)%mod;n--;}else{x = (x*x)%mod;n/=2;}}return res;}
const int MOD = 1e9 + 7;

/////////////////////////////////////" Please Don't ruin it "//////////////////////////////////////


int32_t main(){

    int A,B,C,K;
    cin>>A>>B>>C>>K;

    int ans = 0;
    ans += min(K,A);
    K-=min(K,A);

    K-=min(K,B);

    ans-=min(K,C);
    K-=min(K,C);

    cout<<ans<<'\n';

    return 0;

}

Measured memory_bytes: 3624
N = int(input())
A = list(map(int, input().split()))

tmp = [0 for i in range(N+1)]
length = 0
for i in range(N):
  tmp[i+1] = tmp[i] + A[i]
  length += A[i]
  
ans = 10 ** 10
for i in range(1, N+1):
 ans = min(ans, abs((length - tmp[i]) - tmp[i]))

print(ans)


Measured memory_bytes: 26220
#include <bits/stdc++.h>
using namespace std;
int n,m,c,b[110],a[110],nr,ok,i,j;
int main()
{
    cin>>n>>m>>c;
    for(i=1;i<=m;i++)
        cin>>b[i];
    for(i=1;i<=n;i++)
    {
        nr=c;
        for(j=1;j<=m;j++)
        {
            cin>>a[j];
            nr=nr+a[j]*b[j];
        }
        if(nr>0)
            ok++;
    }
    cout<<ok;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    int pay = 1000;
    while(pay <= 10000) {
        if(pay >= N) {
            cout << (pay - N) << endl;
            break;
        }
        pay += 1000;
    }
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1e9+7;
const long long maxn=2*1e5+10;
const long long inf=99999999999;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<ll> uid(l, r); return uid(rng); }
 
ll power(ll x, ll y){  
	ll p=mode, res=1;
    x = x % p;
    while (y > 0) {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}  

vector<ll> adj[maxn];

void solve(){
	
	ll n;
	cin>>n;
	map<ll,ll> mp;
	ll ans=0;
	for (int i=1;i<=n;i++){
		ll x;
		cin>>x;
		if (mp.find(i-x)!=mp.end()) ans+=mp[i-x];
		mp[i+x]++;
	}
	cout<<ans<<endl;
	
	return;
}
 
int main(){ 
    
    #ifndef ONLINE_JUDGE
		//freopen("input.txt", "r", stdin);
    #endif
    srand(time(0)); 
    
    ios::sync_with_stdio(0);
    cin.tie(0);
 	
	//T{ solve(); }
	solve();
	
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int a, b, c, d;
  a = s[0] - '0';
  b = s[1] - '0';
  c = s[2] - '0';
  d = s[3] - '0';
  rep(i,2){
    rep(j,2){
      rep(k,2){
        int num = a;
        if(i == 0) num += b;
        if(i == 1) num -= b;
        if(j == 0) num += c;
        if(j == 1) num -= c;
        if(k == 0) num += d;
        if(k == 1) num -= d;
        if(num == 7){
          cout << a << (i == 0 ? "+" : "-") << b << (j == 0 ? "+" : "-") << c << (k == 0 ? "+" : "-") << d << "=7" << endl;
          return 0;
        }
      }
    }
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
h = [int(i) for i in input().split()]

flag = True
for i in reversed(range(n - 1)):
    if h[i] - h[i + 1] == 1:
        h[i] -= 1
    elif h[i] > h[i + 1]:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14396
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int a, b;
  cin >> a >> b;
  if ((a * b) % 2 == 0) P("Even");
  else P("Odd");
  return 0;
}



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

void swap(int *x,int *y){
    int tmp=0;
    tmp=*x;
    *x=*y;
    *y=tmp;
}

int main(){
  int x,y;
  vector<int> X;
  vector<int> Y;
  while(cin >> x,cin >>y){
    X.push_back(x);
    Y.push_back(y);
    if(x==0 && y==0) break;
  }
    
  for(int i=0;i<X.size();i++){
        if(Y[i]<X[i]) swap(X[i],Y[i]);
	if(Y[i]==0 && X[i]==0) break;
        cout << X[i] << " " << Y[i] << endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 3140
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn=1e6+10;
int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    if(b-a+1<=2*k){
        for(int i=a;i<=b;i++) cout<<i<<endl;
    }else{
        for(int i=a;i<a+k;i++) cout<<i<<endl;
        for(int i=b-k+1;i<=b;i++) cout<<i<<endl;
    }
    return 0;
}


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

public class Main {
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

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

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

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args) {
		FastReader fr = new FastReader();

		int N = fr.nextInt();
		int W = fr.nextInt(); // upto 10^5
		int[] w = new int[N];
		long[] v = new long[N]; 
		
		for(int i = 0; i < N; i++) {
			w[i] = fr.nextInt();
			v[i] = fr.nextLong();
		}
		
		long[][] dp = new long[N+1][W+1];
		
		for(int i = 1; i <= N; i++) {
			for(int j = 1; j <= W; j++) {
				if (w[i-1] > j) dp[i][j] = dp[i-1][j];
				else dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1]);
			}
		}
		
		System.out.println(dp[N][W]);
	}

}


Measured memory_bytes: 138120
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REP2D(i,j,h,w) for(long long i=0;i<h;i++) for(long long j=0;j<w;j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=h;i++) for(long long j=1;j<=w;j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) (a.begin()),(a.end())
#define RANGE(a) (a),(a+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<a<<endl;
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);
#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 100000
//---------------------

int n,a[MAXN];
ll sum[MAXN];

int main(){
  	cin>>n;
  	REP(i,n) cin>>a[i];
  	sum[0]=0;
  	REP1(i,n) sum[i] = sum[i-1] + ((i%2)?-1:1)*a[i-1];
  	//cout<<-sum[n]<<" ";
  	REP(i,n) {
  	  	int sign=(i%2)?1:-1;
  		cout<< -sign * ( sum[i]-(sum[n]-sum[i])) <<" ";
  	}
  	cout<<endl;
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
//int g(int x){
//	x=modpow(x,MOD-2);
//	return x;
//}
int n,a[100],ans=0;
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n){
		for(int j=i+1;j<n;j++){
			ans+=a[i]*a[j];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
open List;;let rec d=function|[]->false|h::t when mem h t->true|_::t->d t and e s=let rec($)i a=if i=String.length s-1then rev a else if String.contains"aeiou"s.[i]then(i+1)$(s.[i+1]::a)else(i+1)$a in 0$[s.[0]]and s n=let rec($)i a=if i=n then rev a else(i+1)$(e(read_line())::a)in let z=sort compare(0$[])in if d z then -1else let rec g k=function|([],_)->k|(_,[])->k|(x::_,y::_)when x<>y->k|(_::x,_::y)->g(k+1)(x,y) and f k=function|[]->k|[_]->k|x::(y::_ as t)->f(max k(g 0(x,y)))t in 1+f 0z let rec q()=let n=read_int()in if n<>0then q(Printf.printf"%d
"(s n));;q()

Measured memory_bytes: 4336
#include <stdio.h>
#define MAX 10

int a[MAX];

int dfs(int b, int c, int count) {
  if (b > a[count] && c > a[count]) return 0;
  if (count + 1 == MAX) return 1;
  if (b > a[count]) return dfs(b, a[count], count + 1);
  if (c > a[count]) return dfs(a[count], c, count + 1);
  return dfs(b, a[count], count + 1) || dfs(a[count], c, count + 1);
}

int main(void) {
  int n, i, judgement;
  scanf("%d", &n);
  while (n--) {
    for (i = 0; i < MAX; i++) {
      scanf("%d", &a[i]);
    }
    
    judgement = dfs(0, 0, 0);
    if (judgement) printf("YES\n");
    else printf("NO\n");
  }
}

Measured memory_bytes: 580
while True:
    a,op,b = map(str,input().split())
    if(op == '?'):
         break

    if(op == "+"):
        print(int(a)+int(b))
    elif(op == "-"):
        print(int(a)-int(b))

    elif(op == "*"):
        print(int(a)*int(b))
    elif(op =="/"):
        print(int(a)//int(b))


Measured memory_bytes: 5592
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




int main() {
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
}


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

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




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

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

void solve() {
	int n; cin >> n;
    vector<int> a(n), b(n);
    int asum = 0, bsum = 0, cnt = 0;
    vector<int> d(n);
    int msum = 0;
    rep(i, n) {
        cin >> a[i];
        asum += a[i];
    }
    rep(i, n) {
        cin >> b[i];
        bsum += b[i];
        if(a[i] < b[i]) ++cnt;
        d[i] = a[i] - b[i];
        if(d[i] < 0) msum += -d[i];
    }
    if(bsum > asum) {
        cout << -1 << endl;
        return;
    }
    if(cnt == 0) {
        cout << 0 << endl;
        return;
    }
    sort(all(d));
    reverse(all(d));
    vector<int> dsum(n + 1, 0);
    rep(i, n) {
        dsum[i + 1] = dsum[i] + d[i];
    }
    int pcnt = lower_bound(all(dsum), msum) - dsum.begin();
    cout << cnt + pcnt << endl;
}

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

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;

static const long M = 1000000007;

int main() {
    int n;
    cin >> n;
    
    long p = 1;
    for (int i = 1; i <= n; i++) {
        p = (p * i) % M;
    }
    
    cout << p << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int a,b,c,i,j,k;
    cin>>a>>b;
    int t=0;
    for(i=0;i<a;i++){
        cin>>c;
        t=t+c;
        if(t>b){
            t=1+i;
            break;
        }
        if(i==a-1){
            t=a+1;
        }
    }
    cout<<t<<endl;
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define hhh printf("hhh\n")
#define see(x) (cerr<<(#x)<<'='<<(x)<<endl)
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0;char c=getchar();while(c<'0'||c>'9')c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x;}

const int maxn = 1e3+10;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-7;

int N, M;
int pre[maxn], dis[maxn], vis[maxn];
int head[maxn], to[maxn*2], nxt[maxn*2], tot;
int ans[maxn], cnt=inf, res[maxn], cur;

inline void add_edge(int u, int v) {
    ++tot; to[tot]=v; nxt[tot]=head[u]; head[u]=tot;
}

int main() {
    //ios::sync_with_stdio(false); cin.tie(0);
    N=read(), M=read();
    for(int i=1; i<=M; ++i) {
        int u=read(), v=read();
        add_edge(u,v);
    }
    for(int i=1; i<=N; ++i) {
        memset(vis,0,sizeof(vis));
        int st=i;
        vis[st]=1;
        queue<int> q; q.push(st);
        while(q.size()) {
            int u=q.front(); q.pop();
            for(int i=head[u]; i; i=nxt[i]) {
                if(vis[to[i]]) continue;
                int v=to[i];
                dis[v]=dis[u]+1; vis[v]=1; pre[v]=u;
                q.push(v);
            }
        }
        for(int i=1; i<=N; ++i) {
            if(i==st||!vis[i]) continue;
            cur=0;
            for(int j=head[i]; j; j=nxt[j]) {
                if(to[j]==st) {
                    int v=i;
                    while(v!=st) res[++cur]=v, v=pre[v];
                    res[++cur]=st;
                    if(cur<cnt) {
                        cnt=cur; for(int i=1; i<=cur; ++i) ans[i]=res[i];
                    }
                    break;
                }
            }
        }
    }
    if(cnt==inf) printf("-1\n");
    else {
        cout<<cnt<<endl;
        for(int i=1; i<=cnt; ++i) printf("%d\n", ans[i]);
    }
}

Measured memory_bytes: 256
local function uf_initialize(n)
  local parent = {}
  for i = 1, n do parent[i] = i end
  return parent
end

local function uf_findroot(idx, parent)
  local idx_update = idx
  while parent[idx] ~= idx do
    idx = parent[idx]
  end
  while parent[idx_update] ~= idx do
    parent[idx_update], idx_update = idx, parent[idx_update]
  end
  return idx
end

local n, m = io.read("*n", "*n")
local lang = {}
for i = 1, m do lang[i] = {} end
for i = 1, n do
  local k = io.read("*n")
  for j = 1, k do
    local l = io.read("*n")
    table.insert(lang[l], i)
  end
end

local parent = uf_initialize(n)
for i = 1, m do
  if 1 < #lang[i] then
    local a = lang[i][1]
    local ra = uf_findroot(a, parent)
    for j = 2, #lang[i] do
      local b = lang[i][j]
      local rb = uf_findroot(b, parent)
      parent[b], parent[rb] = ra, ra
    end
  end
end
local g = uf_findroot(1, parent)
local ret = true
for i = 2, n do
  if uf_findroot(i, parent) ~= g then
    ret = false
    break
  end
end
print(ret and "YES" or "NO")


Measured memory_bytes: 7548
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

//入力
int a,b,c;
bool ans = false;

int main() {

	cin >> a >> b >> c;

	if (a == b + c) ans = true;
	if (b == a + c) ans = true;
	if (c == a + b) ans = true;
	
	if (ans) cout << "Yes" << endl;

	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	ints := readLineAsInts()
	fmt.Println(math.Ceil(float64(ints[0]) / float64(2*ints[1]+1)))
}

func toInt(s string) int {
	i, e := strconv.Atoi(s)
	if e != nil {
		fmt.Println(e)
	}
	return i
}

func nextLine(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return toInt(nextLine(scanner))
}

func readStr() string {
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return nextLine(scanner)
}

func readLineAsStr() string {
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanLines)
	return nextLine(scanner)
}

func readLineAsInts() []int {
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanLines)
	s := strings.Split(nextLine(scanner), " ")
	ints := make([]int, len(s))
	for i, str := range s {
		ints[i] = toInt(str)
	}
	return ints
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		sc.nextLine();
		String s=sc.nextLine()+"XX";
		int sum = 0;
		for(int i=0;i<s.length()-2;i++){
			if(s.charAt(i)=='A'&&s.charAt(i+1)=='B'&&s.charAt(i+2)=='C')
				sum++;
		}
		System.out.print(sum);
	}
}

Measured memory_bytes: 21332
/*
    Vora Mahammadasim
*/

#include<bits/stdc++.h>
#include<stdio.h>
#define int long long
#define pb emplace_back
#define Mod 1000000007
#define all(a) a.begin(),a.end()
#define ps(a) partial_sum(all(a),a.begin())
using namespace std;

const int N = 1e7+1;

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int>a(N);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j+=i){
            a[j]++;
        }
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        ans += (i*a[i]);
    }
    cout<<ans;
}


Measured memory_bytes: 81260
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n;
vector<ll> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        a.push_back(temp);
    }
    ll ans = LINF;
    for (int i = -100; i <= 100; i++)
    {
        ll score = 0;
        for (int j = 0; j < n; j++)
        {
            score += pow(i - a[j], 2);
        }
        chmin(ans, score);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<edge>> graph;
const ll MOD = 1000000007;
using namespace std;

int main()
{
  int c[3][3];
  REP(i, 3)
  {
    REP(j, 3)
    {
      cin >> c[i][j];
    }
  }

  int val = c[0][0] + c[1][1] + c[2][2];
  bool flag = true;

  flag = flag && val == c[0][0] + c[1][2] + c[2][1];
  flag = flag && val == c[0][1] + c[1][0] + c[2][2];
  flag = flag && val == c[0][1] + c[1][2] + c[2][0];
  flag = flag && val == c[0][2] + c[1][0] + c[2][1];
  flag = flag && val == c[0][2] + c[1][1] + c[2][0];

  if (flag)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N; cin >> N;
  set<int> s{};
  for (int i = 0; i < N; ++i) {
    int a; cin >> a;
    s.emplace(a);
  }
  auto ans = ((int)s.size() == N) ? "YES" : "NO";
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 9600
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  int p=c-a;
  int q=d-b;
  double norm=p*p+q*q;
  int query;
  scanf("%d",&query);
  while(query--){
    int x,y;
    scanf("%d%d",&x,&y);
    x-=a;
    y-=b;
    double innerNorm=p*x+q*y;
    double xx=a+p*innerNorm/norm;
    double yy=b+q*innerNorm/norm;
    printf("%.9lf %.9lf\n",xx,yy);
  }
}

int main(void){
  run();
  return 0;
}



Measured memory_bytes: 2100
#x=int(input())
n=int(input())
m=102
chars=['A','T','C','G']
mo=10**9+7
d3=set()
d4=set()
for i in chars:
    for j in chars:
        for k in chars:
            d3.add(i+j+k)
            for l in chars:
                d4.add(i+j+k+l)
        
kinsoku4=set()
kinsoku3=['AGC','ACG','GAC']

for y in chars:
    kinsoku4.add('AG'+y+'C')
    kinsoku4.add('A'+y+'GC')
    for z in kinsoku3:
        kinsoku4.add(y+z)
        kinsoku4.add(z+y)


dp=[dict() for i in range(m)]
cnt=[0]*m
for i in d4:
    if i not in kinsoku4:
        dp[4][i]=1
    

t=101
for i in range(4,t):
    for ch in chars:
        for p in dp[i-1].keys():
            if p[1:4]+ch not in kinsoku4:
                if p[1:4]+ch in dp[i]:
                    dp[i][p[1:4]+ch]+=dp[i-1][p]%mo
                else:
                    dp[i][p[1:4]+ch]=dp[i-1][p]%mo
for i in range(t):
    for x in d4:
        if x not in kinsoku4 and x in dp[i]:
            cnt[i]+=dp[i][x]%mo
    cnt[i]%=mo

#print(len(kinsoku4),kinsoku4)
#print(dp)

#for x in cnt:
    #print(x%mo)

if n==3:
    ans=61
    print(ans)
else:
    print(cnt[n])




Measured memory_bytes: 42480
#include<cstdio>
#include<cstring>
char a[10010];
bool c,f;
int i;
int main() {
    scanf("%s",a); 
    for(i=0;i<strlen(a);i++){
        if(a[i]=='C') c=true;
        if(a[i]=='F'&&c==true) f=true;
    }
    if(f==true) printf("Yes\n");
    else printf("No\n"); 
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d\n", a * b);
}

Measured memory_bytes: 3724
#include<stdio.h>

int main(){
    int h,w;
    while(scanf("%d %d",&h,&w) && (h != 0 || w != 0)){
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2676
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int a[3],k;
int main(){
  cin >> a[0] >> a[1] >> a[2] >> k;
  sort(a,a+3);
  for(int i=0;i<k;i++){
    a[2]*=2;
    sort(a,a+3);
  }
  cout << a[0]+a[1]+a[2] << endl;
  return 0;
}


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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int d,n;
  scanf("%d%d",&d,&n);
  if(d==0){
    printf("%d\n",n==100?101:n);
  } else if(d==1){
    printf("%d\n",n==100?10100:n*100);
  } else {
    printf("%d\n",n==100?1010000:n*10000);
  }
  return;
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
n = int(input())
s = input()
k = int(input())

sk = s[k-1]
anslis = [s[i] for i in range(n)]
ans = ""

for i in range(n):
    if s[i] != sk:
        anslis[i] = "*"

for i in range(n):
    ans = ans + str(anslis[i])

print(ans)

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

int main()
{
    int a,n;
    cin>>a;
    string ss;
    set<string> ::iterator it;
    set<string>s;
    map<string,int>m;

    while(a--){
        cin>>ss;
        m[ss]=m[ss]+1;
    }
    int ma=0;
    map<string ,int> ::iterator mm=m.begin();

    for(;mm!=m.end();++mm){
        if(mm->second >=ma )
            ma=mm->second;
    }
     mm=m.begin();

    for(;mm!=m.end();++mm){
        if(mm->second ==ma )
           s.insert(mm->first);
    }
    it=s.begin();
    for(;it !=s.end();++it){
        cout<<*it<<endl;
    }
}


Measured memory_bytes: 34560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int a,b;
    char op;
    while(1){
        cin >> a >> op >> b;
        if(op == '?') return 0;
        if(op == '+') cout << a+b << endl;
        if(op == '-') cout << a-b << endl;
        if(op == '*') cout << a*b << endl;
        if(op == '/') cout << a/b << endl;
    }
    return 0;
}


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

using namespace std;

int N, M;
int cnt[305];
vector<int> A[305];


int main(void)
{
	cin >> N >> M;
	
	int tmp;
	for(int n = 0; n < N; n++){
		for(int m = 0; m < M; m++){
			cin >> tmp;
			A[n].push_back(tmp);
		}
	}
	
	int ans = 100000;
	int max, max_j;
	
	
	for(int i = 0; i < M; i++){
		
		for(int j = 1; j <= M; j++) cnt[j] = 0;
		for(int j = 0; j < N; j++){
			cnt[A[j][0]]++;
		}
		
		max = -1;
		for(int j = 1; j <= M; j++){
			if(max < cnt[j]){
				max = cnt[j];
				max_j = j;
			}
		}
		
		if(ans > max) ans = max;
		
		for(int j = 0; j < N; j++){
			for(int k = 0; ; k++){
				if(A[j][k] == max_j){
					A[j].erase(A[j].begin() + k);
					break;
				}
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}
	

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



int main() {
	string s, t;
	cin >> s >> t;
	int ans = INT_MAX;
	int n = (int) s.size(), m = (int) t.size();
	for (int i = 0; i + m - 1 < n; i++) {
		int now = 0;
		for (int j = 0; j < m; j++) {
			if (s[i + j] != t[j]) {
				now++;
			}
		}
		ans = min(ans, now);
	}
	cout << ans;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll inf = numeric_limits<ll>::max()/3;

int main(void){
  ll n;
  cin >> n;
  vector< ll > num(n);
  vector< ll > index(n);
  for(int i = 0;i < n;++i){
    cin >> num[i];
    --num[i];
    index[num[i]] = i;
  }
  ll cnt = 1;
  ll res = 0;
  for(int i = 1;i < n;++i){
    if(index[i] > index[i-1]){
      ++cnt;
    }else{
      res = max(res,cnt);
      cnt = 1;
    }
  }
  res = max(res,cnt);
  cout << n - res << endl;
  return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;
using ll = long long;
using ull = unsigned long long;


#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

auto sumdig(ll num) {
	ll dig, sum;
	sum = 0;
	while (num) {
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}
	return sum;
}

auto mdist(pair<int, int> a, pair<int, int> b) {
	return abs(a.first - b.first) + abs(a.second - b.second);
}
int main() {

	ll x;
	cin >> x;
	ll m = 100;
	ll year = 0;
	while (true) {
		if (m >= x) {
			cout << year << endl;
			return 0;
		}
		year++;
		m *= 1.01;

	}


	return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
int n,dp[100100][3],val[100100][3];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
	n=read();
	rep(i,1,n) rep(j,0,2) val[i][j]=read();
	memset(dp,-0x3f,sizeof(dp));
	dp[0][0]=dp[0][1]=dp[0][2]=0;
	rep(i,1,n) rep(j,0,2) rep(k,0,2)
	{
		if (k==j) continue;
		dp[i][j]=max(dp[i][j],dp[i-1][k]+val[i][j]);
	}
	int ans=0;
	rep(i,0,2) ans=max(ans,dp[n][i]);
	printf("%d",ans);
	return 0;
}

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

int main(int argc, char* argv[]) {
  queue<int> q;
  int x, y;

  cin >> x >> y;
  while(!(x == 0 && y == 0)){
    q.push(x);
    q.push(y);
    cin >> x >> y;
  }

  while(!q.empty()){
    x = q.front();
    q.pop();
    y = q.front();
    q.pop();
    for(int j = 0 ; j < x ; j++){
      for(int k = 0 ; k < y ; k++){
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>

int main(void){

  int N , T;
  scanf("%d %d", &N , &T);

  int c , t;
  int min_cost =10000;
  for(int i = 0 ; i < N ; i++){
    scanf("%d %d", &c , &t);

    if(t <= T){                     //時間内判定

      if(c < min_cost){
	min_cost = c;
      }
    }

  }

  if(min_cost == 10000){
    
    printf("TLE\n");
    
  }else{

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

  }


  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <limits>

using namespace std;
typedef long long ll;

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> x(n), y(n);
    for(int i = 0; i < n; ++i){
        ll xi, yi;
        cin >> xi >> yi;
        x.at(i) = xi;
        y.at(i) = yi;
    }

    ll ans = numeric_limits<ll>::max();
    for(int xsi = 0; xsi < n; ++xsi){
        for(int xei = xsi + 1; xei < n; ++xei){
            ll xs = x.at(xsi);
            ll xe = x.at(xei);
            if(xs > xe){ swap(xs, xe); }
            for(int ysi = 0; ysi < n; ++ysi){
                for(int yei = ysi + 1; yei < n; ++yei){
                    ll ys = y.at(ysi);
                    ll ye = y.at(yei);
                    if(ys > ye){ swap(ys, ye); }
                    ll count = 0;
                    for(int i = 0; i < n; ++i){
                        if(xs <= x.at(i) && x.at(i) <= xe &&
                           ys <= y.at(i) && y.at(i) <= ye){
                            count++;
                        }
                    }
                    if(count >= k){
                        ans = min(ans, (xe - xs) * (ye - ys));
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

    typedef long long int ll;
    int arr[100005];
    int arr2[100005];
    int main()
    {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string str,str1,temp;
    char x,y;
    int n,k,cnt=0,sum=0,flag=0;
    cin>>n>>k>>str;
    str1=temp=str;
    for(int i=0;i<str.size();i++)
    {
        if(str[i]=='R')sum++;
        else flag++;
    }
    if(sum>flag)x='R',y='L';
        else
            x='L',y='R';
    sum=flag=0;
    for(int i=0;i<str.size();i++)
    {
        if(str[i]==x){
        flag++;
        for(int j=i;str[j]==x&&flag<=k;j++)
        {
            str[j]=y;
            if(str1[j+1]==x)
                i++;
        }
        }
    }
    flag=0;
    for(int i=str1.size()-1;i>=0;i--)
    {
        if(str1[i]==x){
            flag++;
        for(int j=i;str1[j]==x&&flag<=k;j--)
        {
            str1[j]=y;
            if(str1[j+1]==x)
                i++;
        }
        //cout<<str1[j];
        }
    }

    for(int i=0;i<str.size()-1;i++)
    {
        if(str[i]==str[i+1])
            sum++;
    }
    flag=0;
    for(int i=0;i<str1.size()-1;i++)
    {
        if(str1[i]==str1[i+1])
            flag++;
    }
    int typ=max(flag,sum);

    str1=str=temp;

     sum=flag=0;
    for(int i=0;i<str.size();i++)
    {
        if(str[i]==y){
        flag++;
        for(int j=i;str[j]==y&&flag<=k;j++)
        {
            str[j]=x;
            if(str1[j+1]==y)
                i++;
        }
        }
    }
    flag=0;
    for(int i=str1.size()-1;i>=0;i--)
    {
        if(str1[i]==y){
            flag++;
        for(int j=i;str1[j]==y&&flag<=k;j--)
        {
            str1[j]=x;
            if(str1[j+1]==y)
                i++;
        }
        //cout<<str1[j];
        }
    }

    for(int i=0;i<str.size()-1;i++)
    {
        if(str[i]==str[i+1])
            sum++;
    }
    flag=0;
    for(int i=0;i<str1.size()-1;i++)
    {
        if(str1[i]==str1[i+1])
            flag++;
    }





    cout<<max(typ,max(flag,sum))<<endl;



    }


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

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

#define INF 1e9

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  REP(i, N){
    cin >> X[i];
  }
  sort(X.begin(), X.end());
  int ans = INF;
  REP(med, 101){
    int cost = 0;
    REP(i, N){
      cost += (X[i] - med) * (X[i]-med);
    }
    ans = min(cost, ans);
  }
  cout << ans << endl;
  return 0;
}


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

int dsum(int n)
{
    int sum = 0;
    while (n) {
        sum += n % 10; n /= 10;
    }
    return sum;
}

int main()
{
    int n; cin >> n;
    int d = dsum(n);
    cout << ((n % d == 0) ? "Yes" : "No") << endl;
    return 0;
}

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


public class Main {
	private	static	BufferedReader br = null;

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

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[]	aPair = null;

		while((aPair = parsePair()) != null) {
			calc(aPair);
		}
	}

	private static int[] parsePair() {
		int[]	aPair = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					aPair = new int[2];
	
					String[]	as = line.split(" ");
					int			n1 = Integer.parseInt(as[0]);
					int			n2 = Integer.parseInt(as[1]);
	
					aPair[0] = n1;
					aPair[1] = n2;
				}
			}
		}
		catch (NumberFormatException e) {}
		catch (IOException e) {}

		return aPair;
	}

	private static void calc(int[] aMatrix) {
		int	nGcd = gcd(aMatrix[0], aMatrix[1]);							// 最大公約数
		int	nLcm = (nGcd == 0) ? 0 : aMatrix[0] * (aMatrix[1] / nGcd);	// 最小公倍数

		System.out.printf("%d %d\n", nGcd, nLcm);
	}

	private static int gcd(int n1, int n2) {
		int		nGcd = 0;			// 最大公約数
		int[]	aNum = new int[3];	// 計算用の配列

		if (n1 == n2) {
			nGcd = n1;
		}
		else {
			aNum[0] = n1;
			aNum[1] = n2;
			aNum[2] = Math.abs(n1 - n2);

			Arrays.sort(aNum);
			nGcd = gcd(aNum[0], aNum[1]);
		}
		
		return nGcd;
	}
}

Measured memory_bytes: 18640
#include<bits/stdc++.h>
using namespace std ; 
# define pb push_back
# define ll long long 
# define endl "\n"
const int MOD = 998244353; 

ll power(ll a , ll n)
{
	ll res = 1;
	
	while(n)
	{
		if(n & 1)
			res = (res * a) % MOD;
		
		n >>= 1;
		a = (a * a) % MOD;
	}
	
	return res;
}



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

	int l , r , d ; 
	cin >> l >> r >> d ; 
	int cnt = 0 ;
	for(int i = l ; i<= r ; ++i) {
		if(i%d == 0)
			++cnt ; 
	}
	cout << cnt ;
   	return 0 ; 
}



Measured memory_bytes: 3576
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i(0);i<n;i++)
typedef long long ll;

int main(){
	long H;
    cin >> H;
    long cnt = long(log(H)/log(2.0)) +1;
    long ans(0);
    rep(i,cnt){
        ans += pow(2,double(i));
    }

    cout << ans << endl;

    return 0;
}



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

int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  for(int i=0;i<tx-sx;i++) cout << "R";
  for(int i=0;i<ty-sy;i++) cout << "U";
  for(int i=0;i<tx-sx;i++) cout << "L";
  for(int i=0;i<ty-sy;i++) cout << "D";
  cout << "DR";
  for(int i=0;i<tx-sx;i++) cout << "R";
  for(int i=0;i<ty-sy;i++) cout << "U";
  cout << "ULUL";
  for(int i=0;i<tx-sx;i++) cout << "L";
  for(int i=0;i<ty-sy;i++) cout << "D";
  cout << "DR" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+10 ;
bool flag[MAXN];
bool factor(int x){
    int cnt = 0 ;
    while( x % 2 == 0 ){
        cnt++;
        x/=2 ;
        if ( cnt >= 2 ) return false ;
    }
    for(int i=3;i*i<=x;i+=2){
        while( x % i == 0 ){
            cnt++;
            x /= i ;
            if ( cnt >= 2 ) return false;
        }
    }
    if ( x > 2 ){
        cnt++ ;
    }
    if ( cnt >= 2 ) return false ;
    return true ;
}
int main(){
    for(int i=3;i<=MAXN;i+=2){
        if ( factor(i) && factor( (i+1)/2 ) ){
            flag[i] = true ;
        }
    }
    vector<int> v(MAXN+10);
    v[0] = 0 ;
    for(int i=1;i<v.size();i++){
        v[i] = v[i-1];
        if ( flag[i] )
            v[i]++;
    }
    int q ;
    cin >> q ;
    while(q--){
        int l , r ;
        cin >> l >> r ;
        cout << v[r] - v[l-1] << endl;
    }
    return 0 ;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define inf 1000000000000000001
#define mp make_pair
#define N 100009
#define PI acos(-1.0)
using namespace std;
void SieveOfEratosthenes(bool prime[]) 
{ 
    prime[0]=false;
    prime[1]=false;
  
    for (int p=2; p*p<=N+1; p++) 
    { 
        if (prime[p] == true) 
        { 
             
            for (int i=p*p; i<=N+1; i += p) 
                prime[i] = false; 
        } 
    } 
  
} 

int main()
{

  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);

  // ll t;
  ll t=1;
  // cin>>t;
  
  while(t--){
    ll x;
    cin>>x;
    bool prime[N];
    memset(prime,true,sizeof(prime));
    SieveOfEratosthenes(prime);
    ll i=2;
    while(1){
      if(prime[i]){
        if(x<=i){
          cout<<i;
          return 0;
        } 
      }
      i++;
    }


  }  
 

}




  




 

Measured memory_bytes: 384
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

constexpr int factorial(const int &n) {
  return n == 0 ? 1 : n * factorial(n - 1) % MOD;
}

void solve() {
  int n, m;
  cin >> n >> m;
  if (abs(n - m) > 1) {
    cout << 0 << endl;
    return;
  }
  int c         = factorial(n) * factorial(m) % MOD;
  if (n == m) c = c * 2 % MOD;
  cout << c << endl;
}


Measured memory_bytes: 1280