akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(i, v) for(auto i =  v.begin(); i !=  v.end(); ++i)
#define RFOR(i, v) for(auto i = v.rbegin(); i != v.rend(); ++i)

template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T> ostream & operator<<(ostream & os, const vector<T> & v) {
	os << "[";
	FOR(it, v) {
		if(it != v.begin()) { os << ", "; }
		os << *it;
	}
	os << "]";
	return os;
}
template<typename F, typename S> ostream & operator<<(ostream & os, const pair<F, S> & p) {
	os << "<" << p.FI << ", " << p.SE << ">";
	return os;
}

// ---- ----

string s;

int main() {
	cin >> s;
	s[ 5] = ' ';
	s[13] = ' ';
	
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
using namespace std;

int main(){
  string s;
  vector<vector<int> > field;
  while(getline(cin, s)){
    replace(s.begin(), s.end(), ',', ' ');
    int n;
    stringstream ss;
    ss << s;
    vector<int> v;
    while(ss >> n){
      v.push_back(n);
    }
    field.push_back(v);
  }
  
  int dp[101][101];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = field[0][0];
  for(int i = 1 ; i < field.size() ; i++){
    for(int j = 0 ; j < field[i].size() ; j++){
      if(i <= field.size() / 2){
	dp[i][j] = max(dp[i-1][j-1], dp[i-1][j]) + field[i][j];
      }
      else{
	dp[i][j] = max(dp[i-1][j], dp[i-1][j+1]) + field[i][j];
      }
    }
  }
  
  cout << dp[field.size()-1][0] << endl;
 
  /*
  for(int i = 0 ; i < field.size() ; i++){
    for(int j = 0 ; j < field[i].size() ; j++){  
      cout << field[i][j] << ' ';
    }
    cout << endl;
  }
  cout << endl;
      
  for(int i = 0 ; i < field.size() ; i++){
    for(int j = 0 ; j < field[i].size() ; j++){
      cout << dp[i][j] << ' ';
    }
    cout << endl;
  }
  */
  
  
}

Measured memory_bytes: 1312
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  if(abs(a-b)%2==0){
    cout<<"Alice"<<endl;
  }
  else{
    cout<<"Borys"<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,N) for(int (i)=0;(i)<(N);(i)++)
#define REPR(i,N) for(int (i)=(N);i>=0;i--)
#define FOR (i,m,n) for(int (i)=m;(i)<(n);(i)++)

int main(){
  int H, W,sum;
  string s0,s1,s2,temp;
  cin >> H >> W;

  cin >>s1 >>s2;

  
  REP(i,H){
    if(i>0){
      s0=s1;
      s1=s2;
      cin >>s2;
	}
    
    REP(j,W){
      sum=0;
      
      if(i>0 && j>0)if(s0.at(j-1)=='#')sum++;
      if(i>0)if(s0.at(j)=='#')sum++;
      if(i>0 && j<W-1 && W>1)if(s0.at(j+1)=='#')sum++;

      if(j>0)if(s1.at(j-1)=='#')sum++;
      if(s1.at(j)=='#')sum++;
      if(j<W-1 && W>1)if(s1.at(j+1)=='#')sum++;

      if(i<H-1 && j>0)if(s2.at(j-1)=='#')sum++;
      if(i<H-1)if(s2.at(j)=='#')sum++;
      if(i<H-1 && j<W-1 && W>1)if(s2.at(j+1)=='#')sum++;
      
      if(s1.at(j)=='#'){
	cout << '#';
	continue;
      }
      cout <<sum;
    }
    
    cout <<endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll dp[123456];

int main(void){
	ll a,b,ans=INFLL;
	int x,i;
	fill(dp,dp+123456,INFLL);
	dp[0] = 0ll;
	cin >> a >> b >> x;
	for(i=0; i<100000; ++i){
		dp[i+1000] = min(dp[i+1000],dp[i]+a);
		dp[i+500] = min(dp[i+500],dp[i]+b);
	}
	for(i=100000; i>=x; --i){
		ans = min(ans,dp[i]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 4080
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#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 fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int a, b;

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);

	cin >> a >> b;
	if(a <= 0 && b >= 0) {
		cout << "Zero";
		return 0;
	}

	if(a > 0 && b > 0) {
		cout << "Positive";
		return 0;
	}

	if(a < 0 && b < 0) {
		if((b - a) % 2 == 1) {
			cout << "Positive";
			return 0;
		}
		else {
			cout << "Negative";
			return 0;
		}
	}
}

Measured memory_bytes: 256
let () = Scanf.scanf "%d\n" @@ fun n ->
  let xys = Array.to_list @@ Array.init n @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun x y -> x, y in
  try
    let odd =
      match
        List.for_all (fun (x, y) -> (x land 1) = (y land 1)) xys,
        List.for_all (fun (x, y) -> (x land 1) <> (y land 1)) xys
      with
      | false, true -> true
      | true, false -> false
      | _, _ -> raise Not_found in
    print_string (if odd then "39\n" else "40\n1 ");
    for i = 38 downto 0 do
      Printf.printf "%d " @@ 1 lsl i
    done;
    print_newline ();
    let solve =
      Array.fold_right (fun d (x, y) ->
        match 0 <= x + y, 0 <= x - y with
        | true, true -> print_char 'R'; (x - d, y)
        | true, false -> print_char 'U'; (x, y - d)
        | false, true -> print_char 'D'; (x, y + d)
        | false, false -> print_char 'L'; (x + d, y)) @@
      Array.init 39 @@ ( lsl ) 1 in
    List.iter (fun (x, y) ->
      ignore (solve
        ( if odd
          then (x, y)
          else (print_char 'L'; (x + 1, y)) ));
      print_newline ()) xys
  with Not_found -> print_endline "-1"

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N; cin >> N;
    vector<vector<pair<int, ll>>> tree(N);
    rep(i, N - 1){
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--;b--;
        tree[a].push_back(make_pair(b, c));
        tree[b].push_back(make_pair(a, c));
    }
    int Q, K; cin >> Q >> K;
    K--;
    vector<ll> dist(N, -1);
    dist[K] = 0;
    queue<int> que;
    que.push(K);
    while(!que.empty()){
        int v = que.front(); que.pop();
        for(auto x:tree[v]){
            if(dist[x.first] != -1) continue;
            dist[x.first] = dist[v] + x.second;
            que.push(x.first);
        }
    }
    vector<ll> ans;
    rep(i, Q){
        int x, y; cin >> x >> y;
        x--;y--;
        ans.push_back(dist[x]+dist[y]);
    }
    rep(i, Q)cout << ans[i] << endl;
}

Measured memory_bytes: 12904
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong(), b = sc.nextLong(), c = sc.nextLong(), d = sc.nextLong();
        long ans = 0;
        long c_can;
        long ca = a, cb = b;
        if (ca % c != 0) {
            ca += c - (ca % c);
        }
        if (cb % c != c - 1) {
            cb += c - (cb % c) - 1;
        }
        c_can = (cb - ca+1) / c;

        long d_can;
        long da = a, db = b;
        if (da % d != 0) {
            da += d - (da % d);
        }
        if (db % d != d - 1) {
            db += d - (db % d) - 1;
        }
        d_can = (db - da+1) / d;

        long x = c * d;
        long p = c;
        long q = d;
        /* 自然数 a > b を確認・入替 */
        if(p < q){
            long tmp = p;
            p = q;
            q = tmp;
        }
        /* ユークリッドの互除法 */
        long r = p % q;
        while(r!=0){
            p = q;
            q = r;
            r = p % q;
        }
        long ukuriddo = x/q;

        long c_d_can;
        long cda = a, cdb = b;
        long cd = ukuriddo;
        if (cda % cd != 0) {
            cda += cd - (cda % cd);
        }
        if (cdb % cd != cd - 1) {
            cdb += cd - (cdb % cd) - 1;
        }
        c_d_can = (cdb - cda+1) / cd;

        System.err.println(ca);
        System.err.println(cb);
        System.err.println(c_can);
        System.err.println(da);
        System.err.println(db);
        System.err.println(d_can);
        System.err.println(cda);
        System.err.println(cdb);
        System.err.println(c_d_can);
        System.out.println(b-a+1-c_can-d_can+c_d_can);
    }
}


Measured memory_bytes: 21844
import java.util.*;

public class Main{
	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int d[]=new int[n];
		for(int i=0;i<n;i++){
			d[i]=sc.nextInt();
		}
		int count=1;
		Arrays.sort(d);
		for(int i=0;i<n-1;i++){
			if(d[i]!=d[i+1]){
				count++;
			}
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<math.h>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(),(x).end()

using namespace std;

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


template<typename T>
void dump(T *arr, int h, int w){
	rep(i,h){
		rep(j,w) cout << arr[i][j] << "\t";
		cout << "\n";
	}
}

template<typename T>
void dump(T *arr, int a){
	rep(i,a) cout << arr[i] << "\t";
	cout << "\n";
}

template<typename T>
void dump(vector<T> arr, int a){
	rep(i,a) cout << arr[i] << "\t";
	cout << "\n";
}

const int INF = 1e9;
const int MOD = 1e9+7;

bool compare(P a, P b){
	if(a.second != b.second) return a.second > b.second;
	else	return a.first > b.first;
}


int digits(ll num){
	ll d=0;
	while(num >= 1){
		num/= 10;
		d++;
	}
	return d;
}

ll pow_kai(ll a, int n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a;
    }
    a = a*a;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

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

	ll n;
	cin >> n;
	
	int n_keta=0, n_sita=n%10;
	int tmp=n;
	while(tmp >= 10){
		tmp/=10;
		n_keta++;
	}
	n_keta++;
	int n_ue=tmp;

	ll ans=0;
	repi(i, 1, n+1){
		//cout << "ans : " << ans << "\n";
	//	cout << i << "\n";
		
		//桁数と一番上の位の数と下の位の数求める
		tmp = i;
		int keta=0, sita=tmp%10;
		while(tmp >= 10){
			tmp /= 10;
			keta++;
		}
		keta++;
		int ue=tmp;

//		cout << keta << " " << ue << " " <<sita << "\n";
		
		if(sita==0) continue;
		if(ue==sita) ans += 1; //1けた作れる
		repi(j, 2, n_keta){ //nより桁数が少ないやつ
			ans += pow(10, j-2);
		}

		//nと桁数が同じ
		if(n_keta==2){
			if(sita*10 + ue <= n) ans+=1;
		}else if(n_keta > 2){ //間に挟む
			int x = (n - sita*pow(10, n_keta-1) - ue);
			if (x<0) continue;
			x /= 10;
//			cout << "x : " << x << "\n";
			if(x == 0){
				ans++;
				continue;
			} 

			int x_keta=0;
			tmp = x;
			while(tmp >= 1){
				tmp /= 10;
				x_keta++;
			}
			if(x_keta <= n_keta-2) ans += x+1;
			else if(x_keta > n_keta-2) ans += pow(10, n_keta-2);
		}
	}
	cout << ans << "\n";
		
	return 0;
}


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

typedef struct Point{
  double x;
  double y;
}P;

void koch(int n, P a,P b){
  if(n == 0) return;
  P s,t,u;
  double th = M_PI*60.0/180.0;

  s.x = (2.0*a.x+1.0*b.x)/3.0;
  s.y = (2.0*a.y+1.0*b.y)/3.0;
  t.x = (1.0*a.x+2.0*b.x)/3.0;
  t.y = (1.0*a.y+2.0*b.y)/3.0;
  u.x = (t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y = (t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}

int main(){
  P a,b;
  int n;

  scanf("%d",&n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}



Measured memory_bytes: 2052
import Data.Bool (bool)

main :: IO ()
main = do
    [h, w] <- fmap read . words <$> getLine
    xs     <- getContents
    answer $ solve h w xs

type Answer = Bool
answer :: Answer -> IO ()
answer = putStrLn . bool "Impossible" "Possible"

solve :: Int -> Int -> [Char] -> Answer
solve h w = ((h + w - 1) ==) . length . filter ('#' ==)


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3 = 0;
  int y3 = 0;
  int x4 = 0;
  int y4 = 0;
  int a = 0;
  int b = 0;
  if(x2 >= x1 && y2 >= y1){
    a = x2 - x1;
    if (a < 0)
      a = a * (-1);
    b = y2 - y1;
    if (b < 0)
      b = b * (-1);
    x3 = x2 - b;
    y3 = y2 + a;
    x4 = x1 - b;
    y4 = y1 + a;
  }
  else if(x2 <= x1 && y2 >= y1){
    a = x1 - x2;
    if (a < 0)
      a = a * (-1);
    b = y2 - y1;
    if (b < 0)
      b = b * (-1);
    x3 = x2 - b;
    y3 = y2 - a;
    x4 = x1 - b;
    y4 = y1 - a;
  }
  else if(x2 <= x1 && y2 <= y1){
    a = x1 - x2;
    if (a < 0)
      a = a * (-1);
    b = y1 - y2;
    if (b < 0)
      b = b * (-1);
    x3 = x2 + b;
    y3 = y2 - a;
    x4 = x1 + b;
    y4 = y1 - a;
  } 
  else{
    a = x2 - x1;
    if (a < 0)
      a = a * (-1);
    b = y1 - y2;
    if (b < 0)
      b = b * (-1);
    x3 = x2 + b;
    y3 = y2 + a;
    x4 = x1 + b;
    y4 = y1 + a;
  }
    cout << x3 << " " << y3 <<" "<< x4 <<" " << y4 << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll          long long
#define dl          double
#define pb          push_back
#define eb          emplace_back
#define mp          make_pair
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(i=a;i<b;i++)
#define all(v)      v.begin(),v.end()
#define allr(v)     v.rbegin(),v.rend()
#define mod         1e9+7
#define CIN(V,s,n)  for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n) for(int i=s;i<n;i++){cout <<  V[i] << " ";}
#define SbS         sortbysec
#define fast        ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);   for(ll i=0;i<V.size();i++) V[i] = 0;

// map<ll,vector<ll> > M;
// map<ll,vector<ll> >:: iterator it;
// it = M.begin();
// it.F will be ll
// it.S will be vector<ll>

using namespace std;

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}

ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}

int main()
{
ll t=1;
//cin >> t;
while(t--)
{
    ll a,b,c,d,n,m,i,j,k,h,l,l2,w,q=1,u,v,temp=0,cn=0,cp=0,c0=0,max1=0;
    cin >> n >> k;
    vector<pair<ll,ll> > DP;
    if(k <= (n-2)*(n-1)/2)
    {
        ll nE = n*(n-1)/2 - k;
        ll s=1,e=2;
        cout << nE <<endl;
        while(nE > 0)
        {
            cout << s << " " << e << endl;
            nE--;
            e++;
            if(e==n+1)
            {
                s++;
                e=s+1;
            }
        }

    }
    else
        cout << -1;


}
    return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
P = list(map(int,input().split()))
Q = []
R = P[K:]
s = 0.0
for i in range(K):
    Q.append((P[i]+1)/2)
s = sum(Q)
ans = s
for j in range(len(R)):
    r = (R[j] + 1)/2
    Q.append(r)
    s += (r - Q[j])
    ans = max(s,ans)
print(ans)

Measured memory_bytes: 25604
#include <stdio.h>

#define MAX 1000000

int main()
{
	int list[MAX];
	int i = 2, j, cnt = 0;
	int x;

	scanf("%d", &x);

	if (x == 2)
	{
		printf("2\n");
		return 0;
	}

	list[cnt] = i++;
	for (i = 2; i < MAX; i++)
	{
		for (j = 0; j <= cnt; j++)
		{
			if (i % list[j] == 0)
				break;
		}

		if (j > cnt)
		{
			list[++cnt] = i;
			if (i >= x)
				break;
		}
	}

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

	return 0;
}

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

int main() {
    
    // 1. input.
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    // 2. check.
    string ans = "Yes";
    // left side.
    if(x - r < 0) ans = "No";

    // right side.
    if(x + r > W) ans = "No";

    // upper side.
    if(y + r > H) ans = "No";

    // lower side.
    if(y - r < 0) ans = "No";
    
    // 3. output answer.
    cout << ans << endl;
    
    return 0;
    
}


Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	std::string s;
	long long n;

	std::cin >> n >> s;

	long long count = 0;
	for (size_t i = 0; i < s.length() - 2; i++)
	{
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
			count++;
		}
	}

	std::cout << count << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
using namespace std;


int main(int argc, char *args[]) {
	int N;
	int A[2][100];
	cin >> N;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++) {
			cin >> A[i][j];
		}
	}
	int sum = 0;
	int max = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (j <= i) sum += A[0][j];
			if (j == i) sum += A[1][j];
			if (j > i) sum += A[1][j];
		}
		if (sum > max) {
			max = sum;
		}
		sum = 0;
	}
	cout << max << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
#define INF 1000000007
 
#define ARRAY_MAX 100005
 
int main(){

    string s[10] = {{""},
                    {'.',',','!','?',' '},
                    {'a','b','c'},
                    {'d','e','f'},
                    {'g','h','i'},
                    {'j','k','l'},
                    {'m','n','o'},
                    {'p','q','r','s'},
                    {'t','u','v'},
                    {'w','x','y','z'}};

    int n;
    cin >> n;
    REP(i,n){
        string ans;
        string str;
        cin >> str;
        int cnt = 0;
        REP(j,str.length()){
            if(str[j] != '0'){
                cnt++;
            }else{
                if(j != 0 && str[j-1] != '0'){
                    int index = str[j-1]-'0';//index
                    if(index == 1){
                        ans.push_back(s[index][(cnt-1)%5]);
                    }else if(index == 7 || index == 9){
                        ans.push_back(s[index][(cnt-1)%4]);
                    }else{
                        ans.push_back(s[index][(cnt-1)%3]);
                    }
                    cnt = 0;
                }else{
                    cnt = 0;
                }
            }
        }
        cout << ans << endl;
    }




    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void) {
	int n; cin >> n;
	vector<int> a;
	rep(i, 3 * n) {
		int d; cin >> d; a.push_back(d);
	}
	sort(all(a));
	ll sum = 0;
	int idx = 3 * n - 2;
	rep(i, n){
		sum += a[idx];
		idx -= 2;
	}
	cout << sum << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) V vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define cont const auto
#define fi first
#define se second
#define Vec vector
#define P pair
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

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

  int a,b;
  cin>>a>>b;
  a*=3;
  a+=b;
  out(a/2);
  
  
  
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  all(a) begin(a),end(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;

int main()
{
    string s;
    rep(i,3) {
        cin>>s;
        cout<<char(s[0]+'A'-'a');
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

char s[200002];
int f[200001][7];
int main(){
	int n;
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=0;i<=n;i++)
		for(int j=0;j<6;j++)
			f[i][j]=i==j+1?1:-2e9;
	for(int i=1;i<=n;i++)
		for(int j=0;j<6;j++){
		//	printf("%d %d %d\n",i,j,f[i][j]);
			if(i-j<1)continue;
			for(int k=0;k<6;k++){
				if(i+k+1>n)continue;
				if(k==j){
					int ok=1;
					for(int w=0;w<=k;w++)
						if(s[i+w+1]!=s[i-j+w])
							ok=0;
					if(ok)continue;
				}
				f[i+k+1][k]=max(f[i+k+1][k],f[i][j]+1);
			}
		}
	int ans=0;
	for(int i=0;i<6;i++)
		ans=max(ans,f[n][i]);
	printf("%d\n",ans);
}


Measured memory_bytes: 7364
N,M = map(int,input().split())
p = [0] + [int(x) for x in input().split()]

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    def find(self, x):
        if self.par[x] == x:    return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:    self.rank[x] += 1

    def same_check(self, x, y):
        return self.find(x) == self.find(y)

UF = UnionFind(N)
for _ in range(M):
    x,y = map(int,input().split())
    UF.union(x, y)

unionUF, unionp = [set() for _ in range(N+1)], [set() for _ in range(N+1)]
for i in range(1, N+1):
    temp = UF.find(i)
    unionUF[temp].add(i)
    unionp[temp].add(p[i])

ans = 0
for i in range(len(unionUF)):
    ans += len(unionUF[i] & unionp[i])
print(ans)

Measured memory_bytes: 73164
#include<bits/stdc++.h>
using namespace std;
#define rep(_,a,b) for(int _=a;_<b;_++)
#define per(_,a,b) for(int _=b-1;_>=a;_--)
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;

int a[200];
int main(){
    int n,ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        scanf("%d",&a[i]);
        if(i%2==1&&a[i]%2==1) ans++;
    }
    printf("%d",ans);
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,S=0;
  cin >>N;
  
  for (int i=0;i<N;i++){
    int r,l;
    cin >> r>>l;
    S+=l-r+1;
  }
  cout <<S <<endl;
}

Measured memory_bytes: 256
n,k = map(int, input().split())
s=input()
if s[k-1]=='A':
    print(s[0:k-1]+'a'+s[k:])
if s[k-1]=='B':
    print(s[0:k-1]+'b'+s[k:])
if s[k-1]=='C':
    print(s[0:k-1]+'c'+s[k:])

Measured memory_bytes: 3060
#include <iostream>
#include <list>


using namespace std;

const int N = 1000;

int main()
{
	list<int> L[N];
	int n, q;
	cin >> n >> q;
	
	while (q--)
	{
		int d, t;
		cin >> d >> t;
		if (d == 0)
		{
			int x;
			cin >> x;
			L[t].push_back(x);
		}
		else if (d == 1)
		{
//			if (!L[t].empty())
//				cout << L[t].top() << endl;
			list<int>::iterator it = L[t].begin();
			
			while (it != L[t].end())
			{
				if (it != L[t].begin())
					cout << ' ';
				cout << *it; 
				it++;
			}
			cout << endl;
		}
		else
		{
			int s;
			cin >> s;
			
			L[s].splice(L[s].end(),L[t]);
		}
	}
}


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

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

	int base = 1;
	while(base<=n)
		base<<=1;
	vector<long long> t(2*base,0); // creating a perfect binary tree and will only ask queries from base+0 to base+n

	long long dp[n+1];//the max possible beauty  if the last taken height is i
	memset(dp,0,sizeof(dp));
	for(int i =0;i<n;i++){
		int l = 0;
		int r = base + h[i]; // the right bound .. finding the max vlue from [0,h)
		long long best = 0;
		for(l+=base;l<r;l>>=1,r>>=1){
			if(l&1)
				best = max(best, t[l++]);
			if(r&1)
				best = max(best,t[--r]);
			// cout << l << " l r " << r << endl;
		}
		dp[h[i]] = best + a[i];

		for(int j = h[i]+base;j>=1;j>>=1){
			t[j] = max(t[j],dp[h[i]]);
		}
		// cout << dp[h[i]] << " " << h[i] << " " << endl;
	}
	long long ans = 0;
	for(int i =0;i<=n;i++){
		ans = max(ans,dp[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 7424
def third_root(q)
  x = q / 2.0
  
  x -= (x ** 3 - q) / (3 * x ** 2) while (x ** 3 - q).abs > 0.00001 * q
  
  return x
end

while true
  q = gets.to_i
  
  break if q == -1
  
  puts third_root(q)
end

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

using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
	if (a == 0) {
		cout << 1;
	} else if (b == 0) {
		cout << 2;
	} else if (c == 0) {
		cout << 3;
	} else if (d == 0) {
		cout << 4;
	} else if (e == 0) {
		cout << 5;
	}
	return 0;
} 
 


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a; cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    map<int, int> mp;
    mp[a]++;
    mp[b]++;
    for(int i=1; i<=3; i++){
        if(mp[i] == 0){
            cout << i;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, M, a, b;
    cin >> N >> M;
    vector<pii> pi;
    REP(i, M) {
        cin >> a >> b;
        pi.push_back({b, a});
    }
    sort(ALL(pi));

    int ans = 0, right = 0;
    for (auto p : pi) {
        if (p.second >= right) {
            right = p.first;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<string>

using namespace std;

int main(){

	int H,W;

	string temp;
	int te[55][55];


	int c[55][55]={0};

	cin >>H >> W;

	for(int j=0; j<H; j++){

		cin >> temp;
		for(int i=0; i<W; i++){

			
			if(temp[i] == '#')	te[i][j]=1;
			
		}
	}



	for(int j=0; j<H; j++){
		for(int i=0; i<W; i++){

			if(te[i][j] ==1 ){

				for(int k=-1; k<2; k++){
					for(int l=-1; l<2; l++){

						if(i-l>=0 && j-k>=0 ) c[i-l][j-k]++;

					//	cout <<i <<" "<<j <<" " <<l <<" " << k <<endl;
					}
				}
				


			}


		}
	}
	
	for(int j=0; j<H; j++){
		for(int i=0; i<W; i++){

			if(te[i][j]==1)cout<<'#';

			else cout <<c[i][j];


		}

		cout << endl;
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#define gc getchar_unlocked
#define pc putchar_unlocked
#define ll long long
#define mod 1000000007

using namespace std;

int cost[20][20];
ll score[1 << 16];
ll dp[1 << 16];

ll go(int mask, int n ) {
    if(mask == 0) {
        return 0;
    }
    if(dp[mask] != -1) return dp[mask];
    ll res = 0;
    for(int newMask = mask; newMask > 0; newMask = (newMask - 1) & mask) {
        res = max(res, score[newMask] + go(mask ^ newMask, n));
    }
    return dp[mask] = res;
}

int main() {
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            cin >> cost[i][j];
        }
    }
    for(int mask = 0; mask < 1 << n; ++mask) {
        dp[mask] = -1;
        for(int i = 0; i < n; ++i) {
            if(mask & 1 << i) {
                for(int j = i + 1; j < n; ++j) {
                    if(mask & 1 << j)
                        score[mask] += cost[i][j];
                }
            }
        }
    }
    ll res = max(score[(1 << n) - 1], go((1 << n) - 1, n));
    cout << res;
}


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

int main(){

  int A[4], be, end;
  string S;
  cin >> S;

  for(int i=0; i<4; i++){
    A[i] = S[i]-'0';
  }
  be = A[0]*10 + A[1];
  end = A[2]*10 + A[3];

  if(be > 12 || be == 0){
    if(end > 12 || end == 0){
      cout << "NA" << endl;
    }else{
      cout << "YYMM" << endl;
    }
  }else{
    if(end > 12 || end == 0){
      cout << "MMYY" << endl;
    }else{
      cout << "AMBIGUOUS" << endl;
    }
  }


  return 0;
}


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  int N, K, m = INF;
  cin >> N >> K;
  VI h(N);
  REP(i,N) {
    cin >> h.at(i);
  }
  SORT(h);
  REP(i,N-K+1) {
    int delta;
    delta = h.at(i+K-1) - h.at(i);
    m = min(m, delta);
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 640
N,A,B=[int(i) for i in input().split()]
ans=0
for i in range(1,N+1):
    L=len(str(i))
    count=0
    for j in range(L):
        count=count+int(str(i)[j])
    if A<=count<=B:
        ans+=i
    else:
        continue
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=1e5+5;
int x[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>x[i];
	int ans=2e9;
	for(int i=1;i<=n-k+1;i++)
	{
		int a=x[i],b=x[i+k-1];
		if(b<=0)
			ans=min(ans,-a);
		if(a>=0)
			ans=min(ans,b);
		if(a<0 && b>0)
			ans=min({ans,2*b-a,b-2*a});
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 640
function main(input) {
  input=input.trim();
  const a = parseInt(input.split("\n")[0], 10);
  const b = parseInt(input.split("\n")[1], 10);
  const c = parseInt(input.split("\n")[2], 10);
  const d = parseInt(input.split("\n")[3], 10);
  console.log(Math.min.apply(null, [a,b])+Math.min.apply(null, [c,d]));

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7372
N,M,K=gets.chomp.split.map(&:to_i)
$MOD=10**9+7

class Combi
  def initialize(max_n, mod = 10**9+7)
      @mod = mod
      @max_n = max_n

      @fac = Array.new(@max_n+1)
      @inv = Array.new(@max_n+1)
      @finv = Array.new(@max_n+1)

      @fac[0] = @fac[1] = 1
      @finv[0] = @finv[1] = 1
      @inv[1] = 1
      2.upto(@max_n) do |i|
          @fac[i] = @fac[i-1] * i % @mod
          @inv[i] = @mod - @inv[@mod%i] * (@mod/i) % @mod
          @finv[i] = @finv[i-1] * @inv[i] % @mod
      end
  end

  def nCk(n,k)
      @fac[n] * @finv[n - k] * @finv[k] % @mod
  end
end

combi = Combi.new(200000)

def solve(n,m)
  ret=0
  1.upto(m-1) do |i|
    ret = (ret + n*n*i*(m-i)) % $MOD
  end
  ret
end

ans=0
ans+=solve(N,M)
ans%=$MOD
ans+=solve(M,N)
ans%=$MOD

puts (ans * combi.nCk(N*M-2,K-2))%$MOD

Measured memory_bytes: 6652
#include <iostream>
using namespace std;
int n,p[10][10],ans;

void saiki(int sum,int x,int day,int I){
  int f=1;
  for(int i=I+1;i<n;i++) 
    for(int j=1;(p[day][i]/p[day-1][i])&&(x/(p[day-1][i]*j));j++){
      f=0;
      saiki(sum+p[day][i]*j,x-p[day-1][i]*j,day,i);
    }
  if(f)ans=max(ans,sum+x);
}

int main(){
  int d,x;
  cin>>n>>d>>x;
  for(int i=0;i<d;i++)
    for(int j=0;j<n;j++)cin>>p[i][j];

  ans=x;
  for(int i=0;i<d-1;i++)saiki(0,ans,i+1,-1);
  cout<<ans<<endl;
  return 0;
}

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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define MAXX 100005

#define PI 3.14159265358979323846264338327950

#define ll signed long long int

ll t = 0 , n, cons = 1e18, c[MAXX], ans = 1, mx, a[MAXX], b[MAXX] ;

signed main()
{
    FAST;
    cin >> n;
    for(ll i = 0; i < n; i++){
    	cin >> a[i];
    	
	}
	sort(a, a+n);
	if(a[0] == 0){
		cout << 0;
		return 0;
	}
	for(ll i = 0; i < n; i++){
		ans *= a[i];
		if(ans > cons || ans <= 0){
			cout << -1;
			return 0;
		}
		
	}
	cout << ans;
}

Measured memory_bytes: 4424
/* ***************************************
Author        :Scau.ion
Created Time  :2016/10/29 19:58:45 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

using namespace std;

int main()
{
    IOS;
	int n;
    cin>>n;
    char s[200],t[200];
    cin>>(s+1)>>(t+1);
    for (int j=1;j<=n+1;++j)
    {
        bool flag=1;
        for (int k=j;k<=n;++k)
            if (s[k]!=t[k-j+1]) flag=0;
        if (flag)
        {
            cout<<n+j-1<<endl;
            break;
        }
    }
	return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,x,m;
    cin >> n >> x >> m;
    vector<ll> spare(m, -1);
    ll now = x;
    if(n <= 1e8){
        ll ans = 0;
        ll now = x;
        rep(i,n){
            ans += now;
            now = now*now%m;
        }
        cout << ans << endl;
        return 0;
    }
    rep(i,m){
        if(spare[now] != -1) break;
        else{
            spare[now] = i;
            now = now*now%m; 
        }
    }
    ll start = spare[now];
    ll end = i;
    ll shuuki = end-start;
    now = x;
    ll ans = 0;
    for(i = 0;i < start;++i){
        ans += now;
        now = now*now%m;
        --n;
        if(n == 0){
            cout << ans << endl;
        }
    }
    ll kurikaesi = 0;
    for(i = start;i < end;++i){
        kurikaesi += now;
        now = now*now % m;
    }
    ans += n/shuuki*kurikaesi;
    n %= shuuki;
    while(n){
        ans += now;
        now = now*now%m;
        --n;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4052
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int a, b, c;
int main() {
  cin >> a >> b >> c;
  if (b-a == c-b) puts("YES");
  else puts("NO");
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, k, a[202020];
vector<i64> c, d;
void solve(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i] >= 0) c.push_back(a[i]);
		else d.push_back(abs(a[i]));
	}
	int C = c.size(), D = d.size();
	
	sort(c.begin(),c.end(), greater<i64>());
	sort(d.begin(),d.end(), greater<i64>());
	
	int cc = 0, dd = 0;
	i64 ans = 1;
	if(C == 0){
		if(k % 2){
			for(int i = 0; i < k; i++){
				ans *= -d[D-i-1];
				ans = mod(ans,INF);
			}
		}
		else{
			for(int i = 0; i < k; i++){
				ans *= -d[i];
				ans = mod(ans,INF);
			}
		}
		cout << ans << endl;
		return;
	}
	if(n==k){
		for(int i = 0; i < n; i++){
			ans = mod(ans*a[i],INF);
		}
		cout << ans << endl;
		return;
	}
	
	if(k & 1){
		ans *= c[cc];
		cc++;
		k--;
	}
	for(int i = 0; i < k; i+=2){
		if(dd > D-2){
			ans *= (c[cc]*c[cc+1])%INF;
			ans %= INF;
			cc+=2;
		}
		else if(cc > C-2){
			ans *= (d[dd]*d[dd+1])%INF;
			ans %= INF;
			dd+=2;
		}
		else if(c[cc]*c[cc+1] >= d[dd]*d[dd+1]){
			ans *= (c[cc]*c[cc+1])%INF;
			ans %= INF;
			cc+=2;
		}
		else{
			ans *= (d[dd]*d[dd+1])%INF;
			ans %= INF;
			dd+=2;
		}
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 6060
import numpy as np
S = input()
H = np.array([int(i) for i in input().split()])
c = 0
max_l = 0
for x in (H[:-1] - H[1:]):
  if x >= 0:
    c+=1
  else:
    if max_l<c:
	    max_l = c
    c=0
if max_l<c:
	max_l = c

print(max_l)

Measured memory_bytes: 23504
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;


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

  vector<int> dp(n, INF);
  dp[0] = 0;
  for (int i = 0; i < n - 1; ++i) {
    dp[i + 1] = min(dp[i] + abs(h[i] - h[i + 1]), dp[i + 1]);
    if (i < n - 2) {
      dp[i + 2] = min(dp[i] + abs(h[i] - h[i + 2]), dp[i + 2]);
    }
  }

  cout << dp[n - 1] << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;



int main(){
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  int ans = 0;
  rep(i, n-1){
    int tmp = a[i+1] - a[i];
    ans = max(ans, tmp);
  }
  int tmp = k - a[n-1] + a[0];
  ans = max(ans, tmp);
  cout << k - ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int a[200];
int b[200];

int main()
{
	int n,m;
	scanf("%d",&n);
	for(int i = 0; i < 2 * n; i++)
	{
		a[i] = i + 1;
	}
	scanf("%d",&m);
	for(int i = 0; i < m; i++)
	{
		int w;
		scanf("%d",&w);
		if(w == 0)
		{
			for(int i = 0; i < n; i++)
			{
				b[i * 2] = a[i];
				b[i * 2 + 1] = a[i + n];
			}
		}
		else
		{
			int now = 0;
			for(int i = w; i < 2 * n; i++)
			{
				b[now] = a[i];
				now++;
			}
			for(int i = 0; i < w; i++)
			{
				b[now] = a[i];
				now++;
			}
		}
		for(int i = 0; i < 2 * n; i++)
		{
			a[i] = b[i];
		}
	}
	for(int i = 0; i < 2 * n; i++)
	{
		printf("%d\n",a[i]);
	}
	getchar();
	getchar();
	return 0;
}

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

public class Main {
	static final int MOD = (int)1e9+7;

	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		String s = sc.next();
		
		StringBuilder sb = new StringBuilder(s);

		sb.deleteCharAt(sb.length() - 1);
		
		while(true) {
			StringBuilder l = new StringBuilder();
			StringBuilder r = new StringBuilder();
			
			sb.deleteCharAt(sb.length() - 1);
			
			for(int i = 0; i < sb.length() / 2; i++) {
				l.append(sb.charAt(i));
			}
			
			for(int i = sb.length() / 2; i < sb.length(); i++) {
				r.append(sb.charAt(i));
			}
			
			if(l.toString().equalsIgnoreCase(r.toString())) {
				out.println(sb.length());
				return;
			}
		}
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}
	
	public static long factorial(int n) {
		long a;
		
		if(n > 0) {
			a = n * factorial(n - 1);
		}else{
			a = 1;
		}
		
		return a;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(K key, V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 23252