akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int f=0;
  while(1){
    string s2;
    if(s=="ABC"){
      f=1;
      break;
    }
    if(s.size()<=3)break;
    char a;
    int t=0;
    int si=s.size()-1;
    
    if(s[0]=='A'&&s[1]=='B'&&s[2]=='C')a='A';
    else if(s[si-2]=='A'&&s[si-1]=='B'&&s[si]=='C')a='C';
    else a='B';

    for(int i=0;i<s.size();i++){
      if(i+2<s.size()&&s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
	s2+=a;
	i+=2;
	t=1;
      }else{
	if(s[i]==a){
	  t=0;
	  break;
	}
	s2+=s[i];
      }
    }
		
    //	cout<<s2<<endl;
    s=s2;
    if(t)continue;
    break;
  }
  if(f)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 3224
#include <iostream>

using namespace std;

int
main()
{
    int k,a,b;
    cin >> k >> a >> b;

    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3168
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<sstream>
#include<iomanip>

using namespace std;

#define INF 999999999

int ya[100001];

int main(){
	int ans=0, n, m, i, j, ins, now =0;
	ya[0] = 0;
	cin >> n >> m;
	for(i=0;i<n-1;i++){
		cin >> ins;
		ya[i+1] = ya[i] + ins;
	}
	for(j=0;j<m;j++){
		cin >> ins;
		ans += abs(ya[now+ins] - ya[now]);
		ans = ans % 100000;
		now += ins;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1552
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <int> v(n);
    generate(all(v),nxt);
    ll test=0;
    for(int i=0;i<n;i++)
        test+=v[i];
    test/=n;
    ll ans=0;
    for(int i=0;i<n;i++)
        ans+=pow((v[i]-test),2);
    test++;
    ll ans2=0;
    for(int i=0;i<n;i++)
        ans2+=pow((v[i]-test),2);
    cout<<min(ans,ans2)<<endl;

    return 0;   
}


 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a,b;
  cin>>a>>b;
  vector<int> c(a);
  rep(i,a)
    cin>>c.at(i);
              int d=0;
  rep(i,a){
    if(b<=c.at(i))
      d++;
       }
  cout<<d;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>


int main(){
  int N;
  scanf("%d",&N);
  int ans;
  if (N<10){
    ans = N;
  } else if (N<100){
    ans = 9;
  } else if (N<1000){
    ans = 9+(N-99);
  } else if (N<10000){
    ans = 9+(999-99);
  } else if (N<100000){
    ans = 9+(999-99)+(N-9999);
  } else {
    ans = 9+(999-99)+(99999-9999);
  }
  
  std::cout << ans << std::endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

string s;

int main(){
    cin >> s;
    for(int i=0;i<3;i++){
        if(s[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int a[100050];
int main()
{
    int n;
    scanf("%d", &n);
    if(n == 1)
    {
        puts("YES");
        return 0;
    }
    for(int i = 1;i <= n;++i)
        scanf("%d", &a[i]);
    int c = 0;
    for(int i = 1;i <= n;++i)
    {
        if(a[i] & 1)
            ++c;
    }
    if(c & 1)
        puts("NO");
    else
        puts("YES");
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
double mx = 0;
double path = 0;

double distance(pair<double,double>& p1, pair<double,double>& p2){
	return sqrt((p1.first-p2.first)*(p1.first-p2.first) + (p1.second-p2.second)*(p1.second-p2.second));
}

double pathlength(string s,vector<pair<double,double>>& v){
	double length = 0;

	pair<double,double> p1 = v[(int)(s[0]-'1')], p2;
	for(int i = 1; i < (int)s.length(); i++){
		p2 = v[(int)(s[i]-'1')];
		length += distance(p1,p2);
	}
	return length;
}

void permute(string s, int start, int end,vector<pair<double,double>>& v){
	if(start == end){
		mx += pathlength(s,v);
		path++;
		return;
	}
	for(int i = start; i < end; i++){
		swap(s[start],s[i]);
		permute(s,start+1,end,v);
		swap(s[start],s[i]);
	}
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n;
	string s;
	cin >> n;
	for(int i = 0; i < n; i++) s += ('1'+i);

	vector<pair<double,double>> v;
	double x, y;

	for(int i = 0; i < n; i++){
		cin >> x >> y;
		v.push_back({x,y});
	}
	permute(s,0,n,v);
	double ans = mx/path;
	cout << fixed << setprecision(10) << ans ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 500'000;
const int LOGN = 19;

int n, m, k;

int64 gcd(int64 a, int64 b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}

void solve(int) {
  int64 a, b;
  cin >> a >> b;
  cout << a * b / gcd(a, b) << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


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

c = 0
for i in range(n):
    if a[i] + a[i+1] <= b[i]:
        c += a[i] + a[i+1]
        a[i+1] = 0
    
    elif a[i] < b[i]:
        c += b[i]
        b[i] -= a[i]
        a[i+1] -= b[i]

    else:
        c += b[i]
print(c)

Measured memory_bytes: 19116
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
double dp[3234][3123];

int main()
{
   int n;
   cin >> n;
   vector <double> vec(n+1);
   for(int i = 1; i <= n; i++) cin >> vec[i];
   dp[1][1] = vec[1];
   dp[1][0] = 1.0-vec[1];
   for(int i = 2; i <= n; i++){
       for(int j = 0; j <= i; j++){
           dp[i][j] += dp[i-1][j]*(1.0-vec[i]);
           if(j > 0){
               dp[i][j] += dp[i-1][j-1]*vec[i];
           }
       }
   }
   double ans = 0;
   for(int i = n/2+1; i <= n; i++){
       ans += dp[n][i];
   }
   printf("%0.10f", ans);
}


Measured memory_bytes: 72320
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int w,a,b;
  cin>>w>>a>>b;
  int q=max(a,b);
  int qq=min(a,b);
  b=q;
  a=qq;
  cout<<max(0,b-(a+w))<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
const int MAXY=100000000-1;
const LD pi=acos(-1.0);
bool baliky=false;
int x1,y1,x2,y2,n,longest;
LL tempans;
LD ans;
//first itu x, second itu y
vector <pii> plist;
void perbaikiy(int &y){
	if(baliky)
		y=MAXY-y;
}
bool between(int l,int pos,int r){			//inklusif
	return (l<=pos&&pos<=r);
}
bool byy(pii a,pii b){			//sort by lowest y
	return (a.se<b.se);
}
int carilis(){				//cari lis dari plist
	sort(all(plist),byy);
	int ret=0;
	vector <int> terpendek;
	terpendek.pb(-1);			//kalau lis 0 anggap mi -INF;
	for(int i=0;i<plist.size();i++)
	{
		//cout<<x1<<" "<<plist[i].fi<<" "<<x2<<endl;
		if(!between(x1,plist[i].fi,x2))
			continue;
		if(!between(y1,plist[i].se,y2))
			continue;
		int tinggi=plist[i].fi-x1;
		//cout<<"tingginya "<<tinggi<<endl;
		int bawah=1,atas=ret,mid;
		while(bawah<=atas)
		{
			mid=(bawah+atas)>>1;
			if(terpendek[mid]>tinggi)
				atas=mid-1;
			else
				bawah=mid+1;
		}
		if(ret<bawah)
		{
			terpendek.pb(tinggi);
			ret++;
		}
		else
		{
			assert(terpendek[bawah]>tinggi);
			terpendek[bawah]=tinggi;
		}
	}
	return ret;
}
int main()
{
	scan(x1,y1),scan(x2,y2);
	if(x1>x2)
	{
		swap(x1,x2);
		swap(y1,y2);
	}
	baliky=(y1>y2);
	perbaikiy(y1);
	perbaikiy(y2);
	scan(n);
	plist.resize(n);
	for(int i=0;i<n;i++)
	{
		scan(plist[i].fi,plist[i].se);
		perbaikiy(plist[i].se);
	}
	longest=carilis();
	//cout<<"lisnya "<<longest<<endl;
	tempans=(y2-y1+x2-x1)*100LL;
	if(longest==min(x2-x1+1,y2-y1+1))
		ans=(LD) (tempans-(LL) 20*longest)+(LD) (5*longest+5)*pi;
	else
		ans=(LD) (tempans-(LL) 20*longest)+(LD) (5*longest)*pi;
	cout<<fixed<<setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 2936
#include <stdio.h>
#include <ctype.h>

int main(void) {
	char password[32];
	int i;
	int check=0;
	scanf("%s",password);
	for(i=0;password[i];i++) {
		if(isdigit(password[i]))check|=1;
		if(isupper(password[i]))check|=2;
		if(islower(password[i]))check|=4;
	}
	printf("%sVALID\n",(i>=6 && check==7)?"":"IN");
	return 0;
}

Measured memory_bytes: 536
"use strict";

function main(input) {
  	const args = input.split('\n');
  	const N = parseInt(args[0],10);
  	const nums = args.slice(1,N+1);
  	const isValid = nums.every((n)=>{
      	let ns = n.split(" ");
		let t = parseInt(ns[0],10),
            x = parseInt(ns[1],10),
            y = parseInt(ns[2],10);
        let sum = x + y;
      	return ( (t >= sum) && ( t % 2 === sum % 2) )
	})
	if(isValid){
    	console.log("Yes");
    } else {
        console.log("No");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29932
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a < b){
            if(b < c){
            System.out.printf("%d %d %d\n",a,b,c);
        }else if(a < c){
            System.out.printf("%d %d %d\n",a,c,b);
        }else{
            System.out.printf("%d %d %d\n",c,a,b);
        }
    }else{
        if(b < c){
            System.out.printf("%d %d %d\n",b,c,a);
        }else if(a < c){
            System.out.printf("%d %d %d\n",b,a,c);
        }else{
            System.out.printf("%d %d %d\n",c,b,a);
        }
    }
    }
}


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

int main()
{
  int s, a = 0;

  cin >> s;
  if ((s % 100) % 10)
    a++;
  if ((s / 10) % 10)
    a++;
  if (s / 100)
    a++;
  cout << a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) (((a%MOD+MOD)%MOD+(b%MOD+MOD)%MOD)%MOD)
#define MUL(a, b) ((((a%MOD+MOD)%MOD)*((b%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) (x/gcd(x,y)*y)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }
template<typename I> int ACC(I f, I l, int i){ return accumulate(f, l, i); }


int N, M;
VI g[100010];
int S, T;
int d[100010][3];


signed main(){
    cin >> N >> M;
    rep(i, 0, M){
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].pb(v);
    }
    cin >> S >> T;
    S--, T--;

    queue<PII> q;
    q.push({ S, 0 });
    d[S][0] = 0;
    while(!q.empty() && !d[T][0]){
        PII p = q.front();
        q.pop();
        for(int u : g[p.first])
            if(!d[u][(p.second+1)%3]) d[u][(p.second+1)%3] = d[p.first][p.second]+1, q.push({ u, (p.second+1)%3 });
    }

    if(d[T][0]) cout << d[T][0]/3 << endl;
    else cout << -1 << endl;

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector <float> a(n);
    for (int tsumugi = 0; tsumugi < n; tsumugi++){
        cin >> a[tsumugi];
    }

    double ans = 0;
    double tmp = 0;

    for (int matsuri = 0; matsuri < n; matsuri++){
        tmp += 1 / a[matsuri];
        // cout << tmp << endl;
    }
    ans = 1 / tmp;
    cout << ans << endl;
    return 0;
}

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

string o;
string e;

int main() {
	cin >> o >> e;
	
	int i;
	for (i = 0; i < min(o.length(), e.length()); i++) { cout << o[i] << e[i]; }
	for (; i < o.length(); i++) cout << o[i];
	for (; i < e.length(); i++) cout << e[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
//#define PB push_back
#define CLEAR(c,d) memset((c),(d),sizeof(c))
#define TO_STRING(VariableName) # VariableName
//#define DB(c) cout<<TO_STRING(c)<<"="<<(c)<<endl

#define EXIST(e,s) ((s).find(e)!=(s).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;
//{{{ io
struct IO{ }io;//dummy
#define endl "\n"
IO& operator>>(IO &io,int &n){scanf("%d",&n);return io;}
IO& operator>>(IO &io,unsigned int &n){scanf("%u",&n);return io;}
IO& operator>>(IO &io,long long &n){scanf("%lld",&n);return io;}
IO& operator>>(IO &io,unsigned long long &n){scanf("%llu",&n);return io;}
IO& operator>>(IO &io,double &n){scanf("%lf",&n);return io;}
IO& operator>>(IO &io,long double &n){scanf("%Lf",&n);return io;}
IO& operator>>(IO &io,char *c){scanf("%s",c);return io;}
IO& operator>>(IO &io,string &s){
    char c;s.clear();
    while(isspace(c=getc(stdin))){if(c==-1)return io;}
    do{
        s.push_back(c);
    }while(!isspace(c=getc(stdin)));
    if(c!=-1)ungetc(c,stdin);
    return io;
}
IO& operator<<(IO &io,const int &n){printf("%d",n);return io;}
IO& operator<<(IO &io,const unsigned int &n){printf("%u",n);return io;}
IO& operator<<(IO &io,const long long &n){printf("%lld",n);return io;}
IO& operator<<(IO &io,const unsigned long long &n){printf("%llu",n);return io;}
IO& operator<<(IO &io,const double &n){printf("%lf",n);return io;}
IO& operator<<(IO &io,const long double &n){printf("%Lf",n);return io;}
IO& operator<<(IO &io,const char c[]){printf("%s",c);return io;}
IO& operator<<(IO &io,const string &s){
    REP(i,s.size())putc(s[i],stdout);
}
//}}}
// }}}

string s,t;
int N;

int main(){
	io>>N;
	io>>s>>t;
	for(int i=N;i>=0;i--){
		if(s.substr(N-i,i)==t.substr(0,i)){
			io<<N*2-i<<endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;


int main () {
    int x;
    for (int i = 1 ; i <= 5 ; ++ i) {
        cin >> x;
        if (x == 0) {
            cout << i ;
            return 0;
        }
    }
}


Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };


int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

signed main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  REP(i, n) {
    if(a[i] != i +1) {
      swap(a[i], a[a[i]-1]);
      break;
    }
  }
  REP(i, n) {
    if(a[i] != i+1) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0; 
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

int main() {
	llong N;
	string S;

	cin >> N >> S;
	llong ans = 0;
	for (int i = 1; i < N; ++i)
		if (S[i] == S[i-1])
			++ans;

	cout << N - ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,L;
  cin >> N >> L;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  int m = -1;
  rep(i,N-1) {
    if(A[i]+A[i+1]>=L) {
      m = i;
    }
  }
  if(m<0) {
    cout << "Impossible" << endl;
    return 0;
  }
  cout << "Possible" << endl;
  rep(i,m) {
    cout << i+1 << endl;
  }
  drep(i,N-1) {
    cout << i+1 << endl;
    if(i==m) break;
  }
  return 0;
}

Measured memory_bytes: 1152
function main(input) 
{
    input = input.split(" ");
    var a = parseInt(input[0], 10);
    var b = parseInt(input[1], 10);
    var x = a * b;
    x %= 2;
    if (x == 1)
    {
        console.log("Odd");
    }
    else
    {
        console.log("Even");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W; cin >> H >> W;
  int a = 0;
  while(a < W + 2){ 
    cout << '#';
    a++;
  }
  cout << endl;
  for(int i = 0; i < H; i++){
    cout << '#';
    for(int j = 0; j < W; j++){
      char b; cin >>b;
      cout << b;
    }
    cout << '#' << endl;
  }
  a = 0;
  while(a < W + 2){
    cout << '#';
    a++;
  }
  cout <<endl;
      
}
  
  
  

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

int main()
{
    int n,k,h,counter=0;
    cin>>n>>k;
    vector<int> vec(n);

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

    for(int i=0;i<n;i++){
        if(vec[i]>=k){
            counter ++;
        }
    }
    cout<<counter<< endl;
    return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
from bisect import bisect_left as bl
class segtree:
    def __init__(self, nn):
        self.NN = nn
        self.XX = [0] * (2**(nn+1)-1)
    def getmax(self, i):
        j = 2**self.NN + i - 1
        ma = -1
        while j >= 0:
            ma = max(ma, self.XX[j])
            j = (j-1) // 2
        return -1 if ma <= 0 else INF - ma
    def updaterange(self, a, b, x):
        l = a + (1<<self.NN)
        r = b + (1<<self.NN)
        s = 0
        while l < r:
            if l%2:
                self.XX[l-1] = max(self.XX[l-1], x)
                l += 1
            if r%2:
                r -= 1
                self.XX[r-1] = max(self.XX[r-1], x)
            l >>= 1
            r >>= 1

N, Q = map(int, input().split())
st = segtree(18)
INF = 1<<50
X = []
D = []
for _ in range(N):
    s, t, x = map(int, input().split())
    X.append((s, t, x))
for _ in range(Q):
    D.append(int(input()))

for s, t, x in X:
    st.updaterange(bl(D, s-x), bl(D, t-x), INF-x)
for i in range(Q):
    print(st.getmax(i))

Measured memory_bytes: 109532
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]", B: "List[int]"):
    count = 0
    for i in range(N):
        if A[i] < B[i]:
            count += A[i]
            diff = B[i] - A[i]
            count += min(A[i+1], diff)
            A[i+1] = max(0, A[i+1] - diff)
        else:
            count += B[i]
    print(count)        
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N+1) ]  # type: "List[int]"
    B = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a.at(i);
  ll sum = 0;
  rep(i,n){
    sum += a.at(i);
  }
  ll snuke = 0;
  ll arai;
  ll m = pow(10,18);
  rep(i,n){
    if(i == n-1)break;
    snuke+= a.at(i);
    arai = sum - snuke;
    m = min(m,abs(snuke-arai));
  }
  cout << m << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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 (b<a) { a=b; return true; } return false; }

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

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,m;
    cin>>n>>m;

    VV g(n);

    rep(i,m){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }

    Vec perm(n);
    iota(ALL(perm),0);
    ll ans=0;

    do{
        bool ok = true;
        if(perm[0]!=0)continue;
        REP(i,1,n){
            ll to = perm[i];
            ll from = perm[i-1];
            if(find(ALL(g[from]),to) == g[from].end()){
                ok = false;
                break;
            }
        }
        if(ok){
            ans++;
        }
    }while (next_permutation(ALL(perm)));
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
N = int(input())
ac, wa, tle, re = 0, 0, 0, 0

for i in range(N):
    c = input()
    if c == "AC":
        ac += 1
    elif c == "WA":
        wa += 1
    elif c == "TLE":
        tle += 1
    else:
        re += 1

print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))


Measured memory_bytes: 69864
import fractions
 
ans=0
f=[0]
g=[0]
N = int(input())
A = list(map(int,input().split()))
for i in range(N-1):
    f.append(fractions.gcd(f[i],A[i]))
    g.append(fractions.gcd(g[i],A[N-i-1]))
for i in range(N):
    ans = max(ans,fractions.gcd(f[i],g[N-i-1]))
print(ans)

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////


//long long  Prime[3000000],nPrime;
//long long  mark[10000002];
//
//void seive(long long int n)
//{
//	long long int i,j,limit=sqrt(n*1.0)+2;
//	mark[1]=1;
//	for(i=4; i<=n ;i+=2)
//	mark[i]=1;
//	Prime[nPrime++]=2;
//	for(i=3; i<=n; i+=2)
//	{
//		if(!mark[i])
//		{
//			Prime[nPrime++]=i;
//			if(i<=limit)
//			{
//				for(j=i*i; j<=n ;j+=i*2)
//				{
//					mark[j]=1;
//				}
//			}
//		}
//	}
//}

int main()
{
    FASTIO;


    ll x , y;

    cin >> x >> y;

    cout << x*y << endl;





    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    if(n>1&&b>=a||n==1&&a==b)
    {
        cout<<(n-2)*(b-a)+1<<endl;
    }
    else
    {
        cout<<0<<endl; 
    }
    return 0;
} 

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		new Main(new Scanner(System.in), System.out, System.err).exec();
	}
	public final Scanner sc;
	public final PrintStream out, err;
	public Main(final Scanner sc, final PrintStream out, final PrintStream err) {
		this.sc = sc;this.out = out;this.err = err;
	}
	static private final long pair(int a, int b) {return (((long)a) << 32) + b;}
	static private final int upper(long v) {return (int)(v >> 32);}
	static private final int lower(long v) {return (int)(v & 0xFFFFFFFF);}

	//-----------------------------------------

	static private final long load(int end, int length) {
		return pair(end, length);
	}
	static private final int end(long load) {
		return upper(load);
	}
	static private final int length(long load) {
		return lower(load);
	}
	static private final long score(int count, int last) {
		return pair(count, last);
	}
	static private final int count(long score) {
		return upper(score);
	}
	static private final int last(long score) {
		return lower(score);
	}

	//------------------------------------------

	public void exec() throws Exception{
		final int N = sc.nextInt();
		for(int A=1;A<10;A++) {
			for(int B=1;B<10;B++) {
				if(N==A*B) {
					out.println("Yes");
					return;
				}
			}
		}
		out.println("No");
	}
}


Measured memory_bytes: 22996
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

def main():
    N, K = map(int, read().split())
    ans = N
    if N >= K:
        ans = N % K
    ans = min(ans, K - ans)
    print(ans)
    return

if __name__ == '__main__':
    main()



Measured memory_bytes: 12500
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void)
{
    int A[1000000];
    int i, j, min, t, n;
    long long int sum;
    scanf("%d",&n);
    if(n >= 0, n <= 10000)
    {
    for(j = 0; j < n; j++)
    {
        scanf("%d", &A[j]);
    }
    for(j = 0; j < n; j++)
    for(i = 0; i < n-1; i++)
    {
        min = i;
        for(j = i + 1; j < n; j++)
        if(A[min] > A[j])
        min = j;
        t = A[min];
        A[min] = A[i];
        A[i] = t;
    }
    sum = 0;
    for(i=0; i<=n; i++)
    {
        cin >> A[i];
        sum = sum + A[i];
    }
    cout << A[0] << " " << A[n-1] << " " << sum << endl;
    }
}



Measured memory_bytes: 3240
#include <stdio.h>

int main(void)
{
    int i, min = 10, time = 0, a[5];
    for (i = 0; i < 5; i++)
        scanf("%d", &a[i]);

    for (i = 0; i < 5; i++){
        if (a[i] % 10 == 0)
        {
            time += a[i];
        }
        else
        {
            time += (a[i] / 10 + 1) * 10;
        }
    }
    for (i = 0; i < 5; i++){
        if(min > (a[i] % 10) && 0 < (a[i] % 10)){
            min = a[i] % 10;
        }
    }

    printf("%d\n", time + (min - 10));
    return 0;
}

Measured memory_bytes: 128
#-*-coding:utf-8-*-

import sys

def main():
    n = int(input())
    numbers = [int(i) for i in input().split()]
    ans=1
    if 0 in numbers:
        print(0)
        sys.exit()
    else:
        for number in numbers:
            ans*=number
            if ans <= 1000000000000000000:
                continue
            else:
                print(-1)
                sys.exit()
        print(ans)            

if __name__ == "__main__":
    main()

Measured memory_bytes: 21640
/*In the name of ALLAH, Most Gracious, Most Merciful*/
#include<bits/stdc++.h>

#define ll                      long long int
#define ull                     unsigned long long int
#define PI                      2*acos(0.0)
#define sqr(x)                  (x)*(x)
#define EPS                     10E-10
#define MOD                     1000000007
#define longlimit               92233720368547758
#define infinity                (1<<28)
#define setbits                 __builtin_popcount
#define zerobits                __builtin_ctzll
#define pb(a)                   emplace_back(a)
#define mp                      make_pair
#define ff                      first
#define ss                      second
#define gcd(a, b)               __gcd(a,b)
#define lcm(a, b)               ((a)*(b))/gcd(a,b)
#define watch(x)                cout << (#x) << " is " << (x) << endl
#define FOR(x,n)                for (ll i=x,j=x,k=x;i<n,j<n,k<n;i++,j++,k++)
#define FORR(n,x)               for (ll i=n-1,j=n-1,k=n-1;i>=x,j>=x,k>=x;i--,j--,k--)
#define TEST_CASES()            ll t;cin>>t;while (t--)
#define PRECISION(a,x)          fixed<<setprecision(x)<<a<<endl;
#define all(a)                  (a.begin()),(a.end())
#define UNIQUE(X)               (X).erase(unique(all(X)),(X).end())
#define DELETE(X)               (X).erase (remove (all(X)),(X).end())
#define SORT_UNIQUE(c)          (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define FAST_IO()               ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define FILE_IO()               freopen("output.txt", "w", stdout);freopen("input.txt", "r", stdin)
using namespace std;
ll tc=1;


void solve()
{
    ll t=5,cnt=0,ans;
    while (t--)
    {
        ll a;cin>>a;
        if (a==0)ans=cnt;
        cnt++;
    }
    cout<<ans+1<<endl;

}

int32_t main()
{
    FAST_IO();
    //TEST_CASES()
        solve();
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;

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);

  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  vector<vector<int>> ret(h, vector<int>(w, 0));
  vector<P> pos;
  for (int i = 0; i < h; i++) {
    cin >> s[i];
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        pos.push_back(P(i, j));
        ret[i][j] = (int)pos.size();
      }
    }
  }
  assert((int)pos.size() == k);
  for (int i = 1; i <= k; i++) {
    int x = pos[i - 1].first, y = pos[i - 1].second;
    int l = y, r = y, u = x, d = x;
    while (0 <= l - 1 && ret[x][l - 1] == 0) {
      l--;
    }
    while (r + 1 < w && ret[x][r + 1] == 0) {
      r++;
    }
    while (0 <= u - 1) {
      bool f = true;
      for (int j = l; j <= r; j++) {
        if (ret[u - 1][j]) {
          f = false;
          break;
        }
      }
      if (!f) break;
      u--;
    }
    while (d + 1 < h) {
      bool f = true;
      for (int j = l; j <= r; j++) {
        if (ret[d + 1][j]) {
          f = false;
          break;
        }
      }
      if (!f) break;
      d++;
    }
    for (int nx = u; nx <= d; nx++) {
      for (int ny = l; ny <= r; ny++) {
        ret[nx][ny] = i;
      }
    }
  }
  for (int i = 0; i < h; i++) {
    printv(ret[i]);
  }
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int h, w;
    cin >> h >> w;

    char image[101][101];
    REP(i, h) {
        REP(j, w) {
           cin >> image[i + 1][j + 1];
        }
    }

    REP(i, h*2) {
        REP(j, w) {
            cout << image[static_cast<int>((i + 2)/2)][j + 1];
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var rgb = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var x = int.Parse(string.Join("", rgb));
            Console.WriteLine(x % 4 == 0 ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 13396
# coding: utf-8
s = input()
lenmax = 0
cnt = 0
data = ['A', 'C', 'G', 'T']
for i in range(len(s)):
    if s[i] in data:
        cnt += 1
    else:
        if cnt > lenmax:
            lenmax = cnt
        cnt = 0
print(max(lenmax, cnt))


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int i;
int n;
int a[100000];
int flag;

void solve(int i,int m){
	if(m==0){
	flag=1;
	return;
}
	if(i>=n)return;
	solve(i+1,m-a[i]);
	solve(i+1,m);
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	int q;
	cin>>q;
	for(int i=0;i<q;i++){
		flag=0;
		int x;
		cin>>x;
		solve(0,x);
		if(flag==1)cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
}


Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
const int mod = 1e9 + 7;
using namespace std;
typedef long long ll;


int main()
{
    int n;
    cin >> n;
    int num = n;
    ll ans = 1;
    vector<int> v(n+1);
    while(num > 1){
        int tmp = num;
        for(int i = 2; i <= n; i++){
            while(tmp % i == 0){
                v.at(i)++;
                tmp /= i;
            }
        }
        num--;
    }
    for(int i = 2; i <= n; i++){
        ans *= (v.at(i) + 1);
        ans %= mod;
    }
    cout << ans << endl;
}

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

public class Main {
	
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(in.readLine());
		int i1 = Integer.parseInt(st.nextToken()), i2 = Integer.parseInt(st.nextToken());
		int p = i1 + i2, m = i1 * i2, s = i1 - i2;
		System.out.println(Math.max(Math.max(p, m), s));
	
		
	}
	
}




Measured memory_bytes: 22996
#include<stdio.h>
int main()
{
    int n,rev=0,rem,a;
    scanf("%d",&n);
    a=n;
    while(n!=0 )
    {
        rem = n%10;
        rev = rev*10 + rem;
        n /= 10;
    }

    if (a == rev)
        printf("Yes");
    else
        printf("No");

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#define INF 2000000
#define MAX 100
#define WHITE 0
#define BLACK 1

using namespace std;

int n, d[MAX], color[MAX], w[MAX][MAX];

void dijkstra(int s){
    int u;
    for(u = 0; u < n; u++){
        d[u] = INF;
        color[u] = WHITE;
    }
    d[s] = 0;

    while(1){
        int mincost = INF;
        for(int i = 0; i < n; i++){
            if(color[i] != BLACK && d[i] < mincost){
                mincost = d[i];
                u = i;
            }
        }
        if(mincost == INF) break;
        
        color[u] = BLACK;

        for(int v = 0; v < n; v++){
            if(color[v] != BLACK && d[u] + w[u][v] < d[v]){
                d[v] = d[u] + w[u][v];
            }
        }
    }
}

int main(){
    int i, j;
    cin >> n;
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
            w[i][j] = INF;
        }
    }

    int u, k, v, c;
    for(i = 0; i < n; i++){
        cin >> u >> k;
        for(j = 0; j < k; j++){
            cin >> v >> c;
            w[u][v] = c;
        }
    }

    dijkstra(0);

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

    return 0;
}


Measured memory_bytes: 3144
import std;

int calc(long k, int[] a) {
    a = [0] ~ a;
    auto used = new long[a.length];
    used[] = -1;
    int p = 1;
    long step = 0;
    while (true) {
        if (step == k) {
            return p;
        }

        if (used[p] != -1) {
            // writeln("loop ", step - used[p]);
            auto m = (k - used[p]) % (step - used[p]);
            // writeln("m ", m);
            m += used[p];

            for (int i = 0; i < a.length; i++) {
                if (used[i] == m) return i;
            }
        }

        used[p] = step++;
        // writeln(p, " -> ", a[p]);
        p = a[p];
    }
    return 0;
}

void main() {
    long n, k; scan(n, k);
    auto a = readints;
    writeln(calc(k, a));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;


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

#define vec(v) vector<int>(v)
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define mapci(mp) map<char*,int>(mp)
#define mapcc(mp) map<char*,char*>(mp)
typedef long long ll;
using namespace std;

int main(){
	ll n,a,b;
	cin>>n;
	ll t[n+1],x[n+1],y[n+1];
	t[0]=0;
	x[0]=0;
	y[0]=0;
	for(int i=1;i<=n;i++){
		cin>>t[i]>>x[i]>>y[i];
	}
	for(int i=1;i<=n;i++){
		a=t[i]-t[i-1];
		b=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
		if(a>=b&&(a-b)%2==0){
			continue;
		}
		else{
			cout << "No"<<endl;
			return 0;
		}
	}
	cout<< "Yes"<<endl;
	return 0;
}


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

const int MAX_N = 100000;

int par[MAX_N + 1];

void init(int par[]){
    for(int i = 0; i < MAX_N + 1; ++i){
        par[i] = i;
    }
}

int find(int x){
    if(par[x] == x){
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int a, int b){
    if(find(a) == find(b)){
        return;
    } else {
        par[find(b)] = find(a);
    }
}

bool same(int a, int b, int par[]){
    return find(a) == find(b);
}

int main(){
    int N, M;
    cin >> N >> M;
    
    init(par);
    
    int p[N];
    for(int i = 1; i <= N; ++i){
        cin >> p[i];
    }
    
    for(int i = 0; i < M; ++i){
        int x, y;
        cin >> x >> y;
        unite(x, y);
    }
    
    int ans = 0;
    
    for(int i = 1; i <= N; ++i){
        if(find(i) == find(p[i])){
            ++ans;
        }
    }
    
    
    cout << ans << endl;
}


Measured memory_bytes: 1024