akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd_ll(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
ll fiv(ll n){
  if(n==0){
    return 1;
  }
  else if(n==1){
    return 1;
  }
  return fiv(n-1)+fiv(n-2);
}
ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  int A,B,M;
  cin>>A>>B>>M;
  vi a(A),b(B),x(M),y(M),c(M);
  vector<tuple<int,int,int>> xyc(M);
  rep(i,A) cin >>a[i];
  rep(i,B) cin >>b[i];
  rep(i,M){
    cin>> x[i]>>y[i]>>c[i];
    xyc[i]= make_tuple(x[i],y[i],c[i]);    
  }
  int ans =200000;
  rep(i,M){
    ans = min( ans, a[get<0>(xyc[i])-1]+b[get<1>(xyc[i])-1]-get<2>(xyc[i]));
  }
  sort(all(a));
  sort(all(b));
  cout <<min(ans, a[0]+b[0])<<endl;

}





Measured memory_bytes: 3328
n = int(input())
list = list(map(int,input().split()))

number = 10000
for i in list:
  n_2 = 0
  while i%2 == 0:
    i = i /2
    n_2 = n_2 + 1
  if n_2 < number:
    number = n_2
print(number)

  

Measured memory_bytes: 2940
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	int i, len, j;
	int flags = 0;
	char lit;
	
    char str_s[101];
	char str_t[101];

	cin >> str_s;
	cin >> str_t;

	len = strlen(str_s);

	for (i = 0; i < len; i++) {
		if (strcmp(str_s, str_t) == 0) {
			flags = 1;
		    break;
		}
	    lit = str_s[0];
		for (j = 0; j < len - 1; j ++) {
			str_s[j] = str_s[j + 1];
		}
		str_s[len - 1] = lit;
	}

	if (flags == 1)
		cout << "Yes" << "\n";
	else
		cout << "No" << "\n";
	
	return 0;
}


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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

const int N = 1e5 + 7;

int par[N], sz[N];
int cnt[N];
vector <int> block[N];

int get(int v) {
  if (v == par[v]) {
    return v;
  }
  return par[v] = get(par[v]);
}

void unite(int a, int b) {
  a = get(a), b = get(b);
  if (a != b) {
    if (sz[a] < sz[b]) swap(a, b);
    sz[a] += sz[b];
    par[b] = a;
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    par[i] = i;
    sz[i] = 1;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    unite(a, b);
    cnt[a]++;
    cnt[b]++;
  }
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    block[a].push_back(b);
    block[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    int ans = sz[get(i)];
    ans -= cnt[i];
    for (int x : block[i]) {
      if (get(x) == get(i)) {
        ans--;
      }
    }
    cout << ans - 1 << ' ';
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 7168
while(True):
    a,op,b=input().split()
    a = int(a)
    b = int(b)
    if op=='?':
        break
    if op=='+':
        print(a + b)
    elif op=='-':
        print(a - b)
    elif op=='*':
        print(a * b)
    elif op=='/':
        print(a // b)


Measured memory_bytes: 5596
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	char s[105],t[105];
	scanf("%s%s",s,t);
	int flag=1;
	int n = strlen(s);
	while(n--){
	//	printf("%s\n",s);
		if(strcmp(s,t)==0){
		flag=0;
			printf("Yes");	
			break;
		}
	else{
		char ch=s[strlen(s)-1];
		for(int i=strlen(s)-2;i>=0;i--){
			s[i+1]=s[i];
		}
		s[0]=ch;
	}	
	}
		if(flag){
			printf("No");
		}

	
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c, d;
	
	scanf("%d%d%d%d", &a, &b, &c, &d);
	
	if(a * b >= c * d) {
		printf("%d", a * b);
	}
	else {
		printf("%d", c * d);
	}
	return 0;
}

Measured memory_bytes: 128
let solve monsters =
  let min_hp = List.hd monsters in
  let rec inner cur_min =
    let ls = List.filter (fun e -> e mod cur_min <> 0) monsters in
    match ls with
    | [] -> cur_min
    | ls -> 
       List.fold_left (fun me e -> min me (e mod cur_min)) max_int ls |> inner
  in inner min_hp

let _ =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let monsters = ref [] in
  for i = 0 to n - 1 do
    Scanf.scanf (if i <> n - 1 then "%d " else "%d\n") 
      (fun m -> monsters := m::!monsters)
  done;
  List.sort (compare) !monsters
  |> solve |> print_int


Measured memory_bytes: 11648
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;

#define mp make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795

#define fill(x, v)  fillchar(x, v, sizeof(x))
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector< pii >   vpii;

#define MAXN 3010
#define MOD (int)(1e9 + 7)

int  f[MAXN][MAXN];
char s[MAXN];
int  n, ans;

int main() {
    scanf("%i%s", &n, s);
    f[1][1] = 1;
    for(int i = 2; i <= n; ++i) 
        if (s[i - 2] == '>') {
            for(int j = i - 1; j >= 1; --j) f[i][j] = (f[i][j + 1] + f[i - 1][j]) % MOD;
        } else {
            for(int j = 2; j <= i; ++j) f[i][j] = (f[i][j - 1] + f[i - 1][j - 1]) % MOD;
        }

    for(int i = 1; i <= n; ++i) ans = (ans + f[n][i]) % MOD;
    printf("%i\n", ans);

    return 0;
}

Measured memory_bytes: 34304
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <ctype.h>
#include <cassert>
#include <stack>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <functional>
#include <ctime>
#include <limits>
#include <tuple>
#include <complex>
#include <numeric>
#include <future>
#include <random>

using namespace std;

#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define left _left
#define right _right

const ld pi = acos(-1.0);

template<typename T>
T abs(T x) {
    return x > 0 ? x : -x;
}

template<typename T>
T sqr(T x) {
    return x * x;
}

template<typename T>
bool chmin(T &x, T y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}

template<typename T>
bool chmax(T &x, T y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}

template<typename U, typename V>
ostream &operator<<(ostream &s, const pair<U, V> &x) {
    s << "(" << x.fst << ", " << x.snd << ")";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const vector<U> &x) {
    s << "[";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "]";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const set<U> &x) {
    s << "{";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "}";
    return s;
}

template<int sz>
ostream operator<<(ostream &s, const bitset<sz> &x) {
    for (int i = 0; i < sz; i++) {
        s << x[i];
    }
    return s;
}


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


int main() {

    srand(time(NULL));

#ifdef LOCAL
    freopen("a.in", "r", stdin);
    //freopen("a.in", "w", stdout);
#else
    //freopen("brackets.in", "r", stdin);
    //freopen("brackets.out", "w", stdout);
#endif

    int n;
    cin >> n;
    map<int,int> a, b;
    int c = 0, d = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (i & 1) {
            a[x]++;
            c++;
        } else {
            b[x]++;
            d++;
        }
    }


    vector<pair<int,int>> uu;
    for (auto kv : a) {
        uu.pb(mp(-kv.snd, kv.fst));
    }

    vector<pair<int,int>> vv;
    for (auto kv : b) {
        vv.pb(mp(-kv.snd, kv.fst));
    }

    uu.pb(mp(0, -1));
    vv.pb(mp(0, -2));
    sort(uu.begin(), uu.end());
    sort(vv.begin(), vv.end());

    uu.resize(min<int>(5, uu.size()));
    vv.resize(min<int>(5, vv.size()));

    int ans = 1e9;

    for (auto kv : uu) {
        for (auto kv2 : vv) {
            if (kv2.snd == kv.snd) {
                continue;
            }

            chmin(ans, (c + kv.fst) + (d + kv2.fst));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6136
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int

int n, m, ans = 0;
int a[50], b[50];
int path[50][50] = {};
int pass[50] = {}, sp;

void dfs(int sp)
{
    pass[sp] = 1;
    for (int i = 0; i < n; i++)
    {
        if (path[sp][i] == 1 && pass[i] == 0)
        {
            dfs(i);
        }
    }
}

int main()
{

    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        path[a[i]][b[i]] = 1;
        path[b[i]][a[i]] = 1;
    }

    // for (int i = 0; i < n; i++)
    // {
    //     for (int j = 0; j < n; j++)
    //     {
    //         cout << path[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    for (int i = 0; i < m; i++)
    {
        path[a[i]][b[i]] = 0;
        path[b[i]][a[i]] = 0;

        for (int j = 0; j < 50; j++)
            pass[j] = 0;
        dfs(0);
        // for (int i = 0; i < n; i++)
        // {
        //     cout << pass[i] << " ";
        // }
        // cout << endl;
        int f = 1;
        for (int i = 0; i < n; i++)
        {
            if (pass[i] == 0)
            {
                f = 0;
                break;
            }
        }
        if (!f)
        {
            ans++;
            //cout << "YES" << endl;
        }

        path[a[i]][b[i]] = 1;
        path[b[i]][a[i]] = 1;
    }
    cout << ans << endl;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);

    ll N, M;
    cin >> N >> M;

    vector<ll> A(M, 0);
    REP(i, N){
        ll K;
        cin >> K;

        REP(j, K){
            ll a;
            cin >> a;
            A[a-1]++;
        }
    }

    ll ans = 0;
    REP(i, M){
        if(A[i] == N) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        boolean[][] cards = new boolean[4][13];
        for (int i=0; i<n; i++) {
            String s = stdIn.next();
            switch (s.charAt(0)) {
                case 'S':cards[0][stdIn.nextInt()-1] = true; break;
                case 'H':cards[1][stdIn.nextInt()-1] = true; break;
                case 'C':cards[2][stdIn.nextInt()-1] = true; break;
                case 'D':cards[3][stdIn.nextInt()-1] = true; break;
            }
        }
        char[] c = {'S','H','C','D'};
        for (int i=0; i<4; i++) {
            for (int j=0; j<13; j++) {
                if (!cards[i][j]) {
                    System.out.println(c[i]+" "+(j+1));
                }
            }
        }
    }
}



Measured memory_bytes: 26216
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 0x7ffffff;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	double n, k;
	cin >> n >> k;
	double res = 0.0;
	if (n >= k) {
		res += (n - k + 1) / n;
	}
	for (int i = 1; i <= min(n, k - 1); ++i) {
		int tmp = i;
		int cnt = 0;
		while (tmp < k) {
			tmp *= 2;
			cnt++;
		}
		double now = 1.0 / n;
		while (cnt) {
			now /= 2.0;
			cnt--;
		}
		res += now;
	}
	cout << fixed << setprecision(12) << res << endl;
	return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        long X = long.Parse(Console.ReadLine());
        long temp = 0;
        long ans;

        for(long i=1; ; i++)
        {
            temp += i;
            if (temp >= X)
            {
                ans = i;
                break;
            }
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define S (1<<10)
#define INF (1e9)
#define N 50
#define M 10
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> P1;
typedef pair<int,P1> P2;
int d[S][2][N][N],h,w,m,sy,sx,gy,gx;
string s[N],t[M][N];
int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};

int getFloor(int y,int x,int A){
  if(s[y][x]=='|')return 3;
  int cnt=0;
  for(int i=0;i<m;i++){
    if(!(A&(1<<i)))continue;
    if(t[i][y][x]=='*')cnt++;
  }
  if('A'<=s[y][x]&&s[y][x]<='Z')return (cnt%2)?0:1;
  if(s[y][x]=='^')return (cnt%2)?0:1;
  return (cnt%2)?1:0;
}

int bfs(){
  for(int i=0;i<S;i++)
    for(int j=0;j<2;j++)
      for(int k=0;k<N;k++)
	for(int l=0;l<N;l++)
	      d[i][j][k][l]=INF;
  queue<P2> q;
  q.push(P2(0,P1(P(0,0),P(sy,sx))));
  d[0][0][sy][sx]=0;
  while(!q.empty()){
    P2 t=q.front(); q.pop();
    int cost=t.first;
    int Switch=t.second.first.first;
    int F=t.second.first.second;
    int y=t.second.second.first;
    int x=t.second.second.second;
    if(d[Switch][F][y][x]<cost)continue;
    if(y==gy&&x==gx)return cost;
    for(int i=0;i<4;i++){
      int ny=y+dy[i],nx=x+dx[i];
      if(s[ny][nx]=='#')continue;
      int nSwitch=Switch,f=0;
      if('a'<=s[y][x]&&s[y][x]<='z')
	nSwitch^=(1<<(s[y][x]-'a')),f=1;
      if('A'<=s[y][x]&&s[y][x]<='Z')
	nSwitch^=(1<<(s[y][x]-'A')),f=1;
      int nF=getFloor(y,x,nSwitch);
      if(s[y][x]=='|'){
	if(d[Switch][!F][y][x]>cost+1){
	  d[Switch][!F][y][x]=cost+1;
	  q.push(P2(cost+1,P1(P(Switch,!F),P(y,x))));
	}
      }
      if(f&&d[nSwitch][nF][y][x]>cost+1){
	d[nSwitch][nF][y][x]=cost+1;
	q.push(P2(cost+1,P1(P(nSwitch,nF),P(y,x))));
      }
      int r=getFloor(ny,nx,Switch);
      if(r==3)r=F;
      if(F!=r)continue;
      if(d[Switch][F][ny][nx]>cost+1){
	d[Switch][F][ny][nx]=cost+1;
	q.push(P2(cost+1,P1(P(Switch,F),P(ny,nx))));
      }
    }
  }
  return -1;
}

int main(){
  cin>>w>>h;
  for(int i=0;i<h;i++){
    cin>>s[i];
    for(int j=0;j<w;j++){
      if(s[i][j]=='%')sy=i,sx=j;
      if(s[i][j]=='&')gy=i,gx=j;
    }
  }
  cin>>m;
  for(int i=0;i<m;i++)
    for(int j=0;j<h;j++)
      cin>>t[i][j];
  cout<<bfs()<<endl;
  return 0;
}

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

int main(void) {
    int N, M;
    cin >> N >> M;

    vector<int> p(M);
    vector<string> S(M);
    vector<int> wa(N);
    vector<int> problem(N);

    for(int i=0;i<M;i++) {
        cin >> p.at(i) >> S.at(i);
    }

    int ac_ans=0, wa_ans=0;
    for(int i=0;i<M;i++) {
        if(problem.at(p.at(i)-1)==1) continue;
        else {
            if(S.at(i)=="AC") {
                problem.at(p.at(i)-1)=1;
                ac_ans++;
            }
            else {
                wa.at(p.at(i)-1)++;
            }
        }
    }

    for(int i=0;i<N;i++) {
        wa_ans += problem.at(i)*wa.at(i);
    }
    
    cout << ac_ans << " " << wa_ans << endl;

    return (0);
}


Measured memory_bytes: 6912
n = int(input())
ans = ""
for i in range(1, n + 1):
    if(i % 3 == 0):
        ans += " " + str(i)
        continue
    x = i
    while(x):
        if(x % 10 == 3):
            ans += " " + str(i)
            break
        x //= 10
print(ans)


Measured memory_bytes: 5628
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();
      int[] data = new int[n];
      int count =1;

      for(int i = 0;i<n;i++){
        data[i] = sc.nextInt();
      }

      Arrays.sort(data);

      for(int i = 0;i<n-1;i++){
        if(data[i]<data[i+1]){
          count++;
        }
      }
      System.out.println(count);
  }
}


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

int main(){
  vector<int> nums;
  int a, b, c;
  for (int i=0;i<3;i++){
    int tmp;
    cin >> tmp;
    nums.push_back(tmp);

  }
  sort(nums.begin(), nums.end());
  cout << nums[0]+nums[1] << endl;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main(){
	int n,ans=0;
	cin>>n;

	print(   (n-2)*180   );
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
 
  int m,n;
  cin >> n >> m;
  if(n == m) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int mod = 1e9+7;
const int N = 123;

long long p[N];
int H, W, K;
long long dp[N][8];

bool check(int x) {
  int prev = 0;
  while (x) {
    if ((x&1) && prev) return false;
    prev = x&1;
    x >>= 1;
  }
  return true;
}

long long rek(int h, int pos) {
  if (h == H) return pos == (K-1);
  long long &ret = dp[h][pos];
  if (ret != -1) return ret;
  ret = 0;
  for (int j = 0; j < 3; ++j) {
    if (pos == 0 && j == 1) continue;
    if (pos == W-1 && j == 2) continue;
    long long cur = 0;
    int lmt = pos-1;
    if (j == 1) --lmt;
    for (int i = 0; i < (1 << max(lmt, 0)); ++i) {
      if (!check(i)) continue;
      ++cur;
    }
    long long cur2 = 0;
    lmt = W-1-pos-1;
    if (j == 2) --lmt;
    for (int i = 0; i < (1 << max(lmt, 0)); ++i) {
      if (!check(i)) continue;
      ++cur2;
    }
    cur *= cur2;
    if (j == 1) {
      ret = (ret + cur*rek(h+1, pos-1)%mod) % mod;
    } else if (j == 2) {
      ret = (ret + cur*rek(h+1, pos+1)%mod) % mod;
    } else {
      ret = (ret + cur*rek(h+1, pos)%mod) % mod;
    }
  }
  return ret;
}

void solve() {
  memset(dp, -1, sizeof(dp));
  scanf("%d%d%d", &H, &W, &K);
  printf("%lld", rek(0, 0));
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3852
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
dics = {}
for i in s:
	if i in dics:
		dics[i] += 1
	else:
		dics[i] = 1
dict = {}
for j in t:
	if j in dict:
		dict[j] += 1
	else:
		dict[j] = 1
ans = 0
for i in dics.keys():
	if i in dict:
		ans = max(ans, dics[i]-dict[i])
	else:
		ans = max(ans, dics[i])
print (ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
	int i;
	int n, input, min, max;
	long long int sum;
	scanf("%d",&n);
	sum = 0;
	min = 1000001;
	max = -1000001;
	for(i=0;i<n;i++){
		scanf("%d",&input);
		if(min > input) min=input;
		if(max < input) max=input;
		sum+=input;
	}
	printf("%d %d %lld\n", min, max, sum);
	return 0;
}



Measured memory_bytes: 2756
#include<bits/stdc++.h>
using namespace std;
int a[200001],c[200002],n,k;
int main()
{
	cin>>n>>k;
	register int i,j,t,s,f;
	for(i=1;i<=n;++i){
		cin>>a[i];
	} 
	for(j=1;j<=k;++j){
		memset(c,0,sizeof(c));
		for(i=1;i<=n;++i)
		{
			++c[max(1,i-a[i])];
			--c[min(n+1,i+a[i]+1)];
		}
		s=0,f=1;
		for(i=1;i<=n;i++)
		{
			a[i]=s+=c[i];
			if(a[i]<n)f=0;
		}
		if(f)break;
	}
	for(i=1;i<=n;++i)
	{
		cout<<a[i]<<" ";
	}
	return 0; 
}

Measured memory_bytes: 5196
#include <stdio.h>

#define MAX_N 100002

typedef struct { char *p; int tm; } Q;
Q que[(MAX_N<<1)+2]; int top, end;
char name[MAX_N][20];

char buf[20], *p;
int in()
{
	int n = 0;
	while (*p >= '0') n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}

int main()
{
	int  n, q, tm, i;
	Q  t;

	fgets(p=buf, 20, stdin);
	n = in(), q = in();
	for (i = 0; i < n; i++) {
		fgets(p=name[i], 20, stdin);
		while (*p > ' ') p++; *p++ = 0;
		que[i].p = name[i], que[i].tm = in();
	}

	tm = 0, top = 0, end = n;
	while (top != end) {
		t = que[top]; if (++top == MAX_N) top = 0;
		if (t.tm <= q) {
			printf("%s %d\n", t.p, tm+t.tm);
			tm += t.tm;
		} else {
			t.tm -= q;
			que[end] = t; if (++end == MAX_N) end = 0;
			tm += q;
		}
	}
	return 0;
}




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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

  mint ans, a, b, c;
  ans.x = 0; a.x = 10; b.x = 9; c.x = 8;
  if (n > 1) {
    ans += a.pow(n)  + c.pow(n);
    ans -= b.pow(n);
    ans -= b.pow(n);
  }

  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 3596
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),q=s.nextInt();
		int[]a=new int[n];
		boolean[]b=new boolean[n];
		int r=0,p=0;
		for(int Q=0;Q<q;++Q){
			int i=s.nextInt()-1;
			if(s.next().equals("WA"))
				++a[i];
			else if(!b[i]){
				++p;
				r+=a[i];
				a[i]=0;
				b[i]=true;
			}
		}
		System.out.println(p+" "+r);
	}
}


Measured memory_bytes: 63540
a = list(map(int, input().split()))
N = a[0]
M = a[1]
price = 0
b = [list(map(int, input().split())) for i in range(N)]
lst = sorted(b)
for i in lst:
    if M <= i[1]:
        price = price + i[0] * M
        print(price)
        break
    else:
        M = M - i[1]
        price = price + i[0] * i[1]


Measured memory_bytes: 28648
//https://atcoder.jp/contests/abc131/tasks/abc131_a
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
// clang-format on
int main()
{
    string S;
    cin >> S;
    cout << (S.end() == adjacent_find(ALL(S)) ? "Good" : "Bad") << endl;
    return 0;
}

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

int pref[MAXn], suff[MAXn], n, ar[MAXn], ans;

int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> ar[i];
	pref[0] = ar[0];
	for (int i = 1; i < n; i++)
		pref[i] = __gcd(ar[i], pref[i-1]);
	for (int i = n - 1; i >= 0; i--) {
		suff[i] = __gcd(suff[i+1], ar[i]);
	}
	for (int i = 0; i < n; i++) {
		int tmp = 0;
		if (i)
			tmp = pref[i-1];
		tmp = __gcd(tmp, suff[i+1]);
		ans = max(ans, tmp);
	}
	cout << ans;
}


Measured memory_bytes: 1408
#include <iostream>
#include <climits>

using namespace std;
#define MAX 100
#define WHITE 0
#define BLACK 1

int W[MAX][MAX],color[MAX],d[MAX],p[MAX];
int n,u,k,v,c;

int Djs()
{
   int minv,u;
   d[0]=0;
   while(1)
   {
    minv=INT_MAX;
     u=-1;
    for(int i=0;i<n;i++)
    {
       if(d[i]<minv&&color[i]!=BLACK)
       {
           minv=d[i];
           u=i;
       }
    }
    if(u==-1) break;
    color[u]=BLACK;
    for(int v=0;v<n;v++)
    {
       if(W[u][v]!=INT_MAX&&color[v]!=BLACK)
       {
           if(d[u]+W[u][v]<d[v])
           {
               d[v]=d[u]+W[u][v];
               p[v]=u;
           }
       }
    }
   }
   for(int i=0;i<n;i++)
   {
       cout<<i<<" "<<d[i]<<endl;
   }
}

int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
     d[i]=INT_MAX;
     p[i]=-1;
     for(int j=0;j<n;j++)
     {
        W[i][j]=INT_MAX;
     }
    }
    for(int i=0;i<n;i++)
    {
     cin>>u>>k;
     for(int j=0;j<k;j++)
     {
        cin>>v>>c;
        W[u][v]=c;
     }
    }
    Djs();
    return 0;
}



Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b, c; cin >> a >>b;
	//string s,t; cin >> s>>t;
	if (a == 1 || b == 1) {
		if (a == b)cout << "Draw";
		else {
			if (a == 1)cout << "Alice";
			else cout << "Bob";
		}
		return 0;
	}
	if (a<b)cout<< "Bob";
	else if (a>b)cout<< "Alice";
	else cout << "Draw";


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
def gozyo(x,y):
    w = 0
    while True:
        if y == 0:
            return x,w
        x = x % y
        z = x
        x = y
        y = z
        w += 1
    

while True:
    a,b = map(int,input().split())
    if a == 0 and b == 0:
        break
    if a < b:
        c = a
        a = b
        b = c
    u = gozyo(a,b)
    print(u[0],u[1])


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

const int N=1000000;

//?´???°??¨
bool p[N+1];
//?????£?????????
int f[1100][1100]={0};
//??§?¨??????????
vector<pi> d(2*N);

//??????????§??????¨?????????????????????????´???°????????°????????§???
int dp[N+1];
//
int last[N+1];

int main()
{
    //?´???°??¨??????
    fill(p,p+N+1,true);
    p[0]=p[1]=false;
    for(int i=2; i<=N; ++i)
    {
        if(p[i]) for(int j=2; i*j<=N; ++j) p[i*j]=false;
    }

    //??????????????°???
    pi c(525,525);
    //1??????????????????
    int now=1;

    //?????£???????????????
    f[c.fi][c.se]=now;
    d[now]=c;
    ++now;
    int w=1;
    while(now<=N)
    {
        //??????w
        rep(i,w)
        {
            ++c.se;
            f[c.fi][c.se]=now;
            d[now]=c;
            ++now;
        }

        //??????w
        rep(i,w)
        {
            --c.fi;
            f[c.fi][c.se]=now;
            d[now]=c;
            ++now;
        }

        //??????w+1
        rep(i,w+1)
        {
            --c.se;
            f[c.fi][c.se]=now;
            d[now]=c;
            ++now;
        }

        //??????w+1
        rep(i,w+1)
        {
            ++c.fi;
            f[c.fi][c.se]=now;
            d[now]=c;
            ++now;
        }

        w+=2;
    }

    //?????¨?????????
    while(1)
    {
        int m,n;

        scanf(" %d %d", &m, &n);
        if(m==0) break;

        memset(dp,0,sizeof(dp));
        memset(last,0,sizeof(last));

        rep(i,m+1) if(p[i]) last[i]=i;

        for(int y=1100-1-1; y>0; --y)rep(x,1100)
        {
            int cur=f[y][x];
            if(cur==0 || cur>m) continue;

            //printf("  focus %d\n", cur);

            if(p[cur])
            {
                ++dp[cur];
                if(dp[cur]==1) last[cur]=cur;
            }

            for(int dir=-1; dir<=1; ++dir)
            {
                int nx=x+dir;
                int ny=y-1;

                if(0<=nx && nx<1100)
                {
                    int nxnum=f[ny][nx];
                    if(nxnum>m) continue;

                    if(dp[nxnum]<dp[cur])
                    {
                        dp[nxnum]=dp[cur];
                        last[nxnum]=last[cur];

                        //printf("update %d : %d, %d\n", nxnum,dp[nxnum],last[nxnum]);
                    }
                    else if(dp[nxnum]==dp[cur] && last[nxnum]<last[cur])
                    {
                        last[nxnum]=last[cur];
                        //printf("update'' %d : , %d\n", nxnum,last[nxnum]);
                    }
                }
            }
        }

        printf("%d %d\n", dp[n], last[n]);
    }

    return 0;
}

Measured memory_bytes: 31688
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <new>

#define FOR(i,m,n)    for(int i=m;i<n;i++)
#define FORB(i,m,n)    for(int i=m;i>=n;i--)
#define INF 999999999
#define ll long long
#define PUSH(a) push_back(a)
#define POP() pop_back()
#define SORT(v,n) sort(v,v+n)
#define VSORT(v) sort(v.begin(),v.end())

using namespace std;

int dy[] = { 0,0,1,-1 };
int dx[] = { 1,-1,0,0 };

typedef struct {
	int A;
	int B;
}Data;

int main() {
	int N;
	cin >> N;
	Data min;
	min.B = 1000000001;
	Data d[100000];
	for (int i = 0;i < N;i++) {
		cin >> d[i].A; cin >> d[i].B;
		if (min.B > d[i].B) {
			min.A = d[i].A; min.B = d[i].B;
		}
	}
	cout << min.A + min.B << endl;

}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
int n,m;
long long sum;
vector<int> G[8];

void solve(int now,bool* arrived){
    bool t_arrived[8];
    for(int i=0;i<n;i++)t_arrived[i]=arrived[i];
    t_arrived[now]=1;
    bool flag=1;
    for(int i=0;i<n;i++)if(!t_arrived[i])flag=0;
    if(flag) sum++;
    for(auto x: G[now])if(!t_arrived[x])solve(x,t_arrived);
}

int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    bool arrived[8];
    solve(0, arrived);
    cout<<sum<<endl;
}


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

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  string s = "NG";
  for(int i = a; i <= b; i++) {
    if(i % k == 0) {
      s = "OK";
    }
  }
  cout << s << endl;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  int a[n], x = 0;
  for (int i=0; i<n; i++) {
    cin>>a[i];
    x = x ^ a[i];
  }
  for (int i=0; i<n; i++) cout<<(x ^ a[i])<<' ';
  cout<<'\n';
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll res=INT_MAX,s[100500],n,k;
int main() {
     
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>s[i];
    for(int l=1;l<=n-k+1;l++) {
        int r=l+k-1;
        res=min(res,s[r]-s[l]+min(abs(s[r]),abs(s[l])));
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;
void solve(){
    int n, q;
    cin >> n >> q;
    string a;
    cin >> a;
    vi pre(n + 1, 0);
    for(int i = 0; i < n; i++){
        if(a[i] == 'A' && a[i + 1] == 'C'){
            pre[i + 1] = pre[i] + 1;
        }
        else pre[i + 1] = pre[i];
    }
    //for(int i = 0; i <= n; i++)cout << i << ' ' << pre[i] << endl;
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        cout << pre[r - 1] - pre[l - 1] << "\n";
    }
}


int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}
// vse dolzhny vyiti v internet po hhtp


Measured memory_bytes: 1408
read n;
array=($(echo $n|factor|cut -d ' ' -f2-))
ans=10**15
len=${#array[@]}
if ((len==1));then
    echo $((${array[0]}-1))
    exit 0
elif ((len>=12));then
    echo $n|awk '   
                    {
                        n=$1
                        ans=1e12
                        for(i=1;i*i<=n;i++){
                            if(n%i!=0){
                                continue;
                            }
                            res = n/i+i-2;
                            if(res<ans){
                                ans=res;
                            }
                        }
                    }
                    END{print ans}
                '
    exit 0
fi

for ((b=1;b<(1<<len)-1;b++));do
    ga=1
    gb=1
    for ((i=0;i<len;i++));do
        if ((b & (1<<i)));then
            ((ga*=${array[i]}))
        else
            ((gb*=${array[i]}))
        fi
    done
    if ((ga+gb-2<ans));then
        ans=$(($ga+$gb-2))
    fi
done
echo $ans

Measured memory_bytes: 856
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 3006
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
typedef long long ll;
//#define P 998244353
int n , P;
int S[MAXN][MAXN] , C[MAXN][MAXN];

int Pow( int x , int a ) {
	int ret = 1;
	while( a ) {
		if( a & 1 ) ret = ret * 1ll * x % P;
		x = x * 1ll * x % P , a >>= 1;
	}
	return ret;
}

int p2[MAXN];
void solve() {
	cin >> n >> P;
	S[0][0] = C[0][0] = 1 , p2[0] = 1;
	rep( i , 1 , n + 1 ) {
		C[i][0] = 1 , S[i][0] = 0;
		rep( j , 1 , i ) S[i][j] = ( S[i - 1][j - 1] + S[i - 1][j] * 1ll * j ) % P , C[i][j] = ( C[i - 1][j - 1] + C[i - 1][j] ) % P;
		p2[i] = p2[i - 1] * 2 % ( P - 1 );
	}
	int ans = 0;
	rep( i , 0 , n ) {
		int re = 0;
		rep( j , 0 , i ) re = ( re + S[i + 1][j + 1] * 1ll * Pow( 2 , ( n - i ) * 1ll * j % ( P - 1 ) ) ) % P;
		re = re * 1ll * Pow( 2 , p2[n - i] ) % P * C[n][i] % P;
		ans = ( ans + ( ( i & 1 ) ? P - re : re ) ) % P;
	}
	cout << ans << endl;
}

signed main() {
//	freopen("ex_A2.in","r",stdin);
//	freopen("out","w",stdout);
//	int T;cin >> T;while( T-- ) solve();
    solve();
}



Measured memory_bytes: 58780
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const int INF = 0x3f3f3f3f;
ll max(ll a, ll b){return a > b ? a : b;}
ll min(ll a, ll b){return a < b ? a : b;}

int mpow(int b, int e)
{
    int ret=1;
    for(int i=0; i<e; i++)
    {
        ret=ret*b%mod;
    }
    return ret;
}

ll dp[100001];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, w, w1, val;
    cin >> n >> w;
    int nn=n;
    for(int i=1; i<=1000*n; i++) dp[i] = 100000000000000;
    while(nn--)
    {
        cin >> w1 >> val;
        for(int i=1000*n-val; i>=0; i--)
        {
            if(dp[i]!=100000000000000) dp[i+val] = min(dp[i+val], dp[i]+w1);
        }
        dp[val] = min(dp[val], w1);
    }
    for(int i=1000*n; i>=0; i--)
    {
        if(dp[i]<=w)
        {
            cout << i;
            return 0;
        }
    }
}
//TODO: 56
//come back to 50D, 55D


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  string s[3];
  rep(i,0,3){
    cin>>s[i];
    cout<<s[i][i];
  }
  cout<<endl;
}

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

int main(){
  int n;
  cin >> n;
  int a[n+1];
  long long x[n+1];
  x[1] = 0;
  for ( int i = 1; i <= n; i++){
    cin >> a[i];
    if ( i % 2 == 0){
      x[1] -= a[i];
    } else {
      x[1] += a[i];
    }
  }

  for ( int i = 2; i <= n; i++){
    x[i] = 2*a[i-1]-x[i-1];
  }
  for (int i = 1; i <= n; i++){
    if ( i > 1) cout << " ";
    cout << x[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
long H, W, D, Q, L, R; cin >> H >> W >> D;
long A[H][W]; map<long, vector<long>> V;
REP(i, H){ REP(j, W){ cin >> A[i][j]; V[A[i][j]]={i+1, j+1}; } }
long S[H*W+1]={};
REP(i, H*W+1){
  if(i<=D){ continue; }
  S[i]+=S[i-D]+(abs(V[i-D][0]-V[i][0])+abs(V[i-D][1]-V[i][1]));
}
cin >> Q;
REP(i, Q){ 
  cin >> L >> R;
  cout << S[R]-S[L] << "\n";
}
}

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

int main()
{
    int n;
    cin>>n;
    long long arr[n+5];

    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
       // k=min(k,arr[i]);
    }
    long long k=arr[0];
    sort(arr,arr+n);
    for(int i=0;i<n;i++)
    {
       if(arr[i]%k!=0)
       {
           long long p=arr[i]%k;
           long long a=p,b=k;
           while(b%a!=0)
           {
               b%=a;
               if(a>b)swap(a,b);
           }
           k=min(b,a);
       }
    }

    cout<<k;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b;
    cin>>a>>b;
    if(a==b){
        cout<<"unsafe";
        exit(0);
    }
    if(a<b){
        cout<<"unsafe";
    }
    else{
        cout<<"safe";
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[200010];
int main() {
	ll n;
	cin>>n;
	vector<ll> b;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		a[x]++;
		b.push_back(x);
	}
	ll ans=0;
	for(ll i=0;i<200010;i++){
		ll now=a[i];
		ans+=a[i]*(a[i]-1)/2;
	}
	for(ll i=0;i<n;i++){
		ll now=b[i];
		cout << ans-a[now]*(a[now]-1)/2+(a[now]-1)*(a[now]-2)/2<<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
#include <map>
#include <cmath>
typedef long long int ll;
using namespace std; 
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int a,b;cin>>a>>b;
	if(a<=b){
		for(int i=0;i<b;i++){
			cout<<a;
		}
		cout<<endl;
	}
	else{
		for(int i=0;i<a;i++){
			cout<<b;
		}
		cout<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <typeinfo>
#include <cmath>
using namespace std;
#define ll long long 
const ll MOD = 1e9 + 7;
 
set<int> graph[100005];
ll dp[100005][2]; 
 
void solve(int current_node, int parent){
    for (auto x: graph[current_node]) {
        if ((x == parent))
            continue;
        solve(x, current_node);
        dp[current_node][0] = (dp[current_node][0] % MOD * (dp[x][0] + dp[x][1]) % MOD) % MOD;    
        dp[current_node][1] = (dp[current_node][1] % MOD * (dp[x][0]) % MOD) % MOD; 
    }
    return;
}
 
int main()
{
    int N;
    cin >> N;
    if (N > 1){
        for (int i=0; i<N; ++i) {
            int src, dst;
            cin >> src >> dst;
            // cout << src << " "<< dst << endl;
            graph[src].insert(dst);
            graph[dst].insert(src);
        }
    }    
    for (int i=0; i<100005; ++i) {
        dp[i][0] = 1;
        dp[i][1] = 1;
    }
        
    // root is 1 and it's parent is 0, init condition for 0th(non-existing) node
    // dp[i][j] is the number of ways of 
    // color 0 = white and 1 = black
    solve(1, -1);
    cout << (dp[1][0] + dp[1][1]) % MOD;
    return 0;
}

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

int main() {
    string S, T;
    cin >> S >> T;
    for (int i = 1; i <= S.length(); i++) {
        string sub1 = S.substr(S.length() - i, S.length()), sub2 = S.substr(0, S.length() - i);
        if (sub1 + sub2 == T) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

n = int(input())
a = list(map(int, input().split()))

dict = {}
for i in a:
    if dict.get(i) is None:
        dict[i] = 1
    else:
        dict[i] += 1

#print(dict)

for i in range(1, n+1):
    if dict.get(i) is None:
        print(0)
    else:
        print(dict[i])


Measured memory_bytes: 112048
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;

vector<int> A;
vector<vector<int>> edge;
int64 dfs(int v, int pre){
    if(edge[v].size()==1 && pre == edge[v][0]){//葉
        return A[v];
    }
    bool can_win = false;
    for(auto to:edge[v]){
        if(to==pre) continue;
        int64 tmp = dfs(to,v);
        if(tmp < A[v]) can_win=true;
    }
    if(can_win) return INF;
    return A[v];
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    A.resize(N);
    REP(i,N) cin >> A[i];
    edge.resize(N);
    int a,b;
    REP(i,N-1){
        cin >> a >> b;
        edge[--a].emplace_back(--b);
        edge[b].emplace_back(a);
    }
    vector<int> ans;
    REP(i,N){
        auto res = dfs(i,-1);
        if (res==INF) ans.emplace_back(i+1);
    }
    cout << ans;

}

Measured memory_bytes: 640