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

int main() {
	long long n, a=0, b = 0, ans = 10000000, c;
	cin >> n;
	string s;
	cin >> s;
	
	for(int i = 0; i < n; i++){
		if(s[i] == 'E'){
			b++;
		}
	}
	
	for(int i = 0; i < n; i++){
		if(s[i] == 'E'){
			b--;
		}
		if(ans > a + b){
			c = i;
			ans = a + b;
		}
		if(s[i] == 'W'){
			a++;
		}
	}
	/*
	if(s[c] == 'E'){
		ans--;
	}*/
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 900
h, w, k = map(int, input().split())
c = [list(input()) for i in range(h)]
ans = 0
for p in range(1<<h):
    for q in range(1<<w):
        black = 0
        for m in range(h):
            for n in range(w):
                if (p>>m)&1 == 0 and (q>>n)&1 == 0 and c[m][n] == "#":
                    black += 1
        if black == k:
            ans += 1
print(ans)

Measured memory_bytes: 9036
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int a[n][n],d[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> a[i][j];
            d[i][j]=a[i][j];
        }
    }
    bool okok=1;
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
                if(d[i][j]!=a[i][j])okok=0;
            }
        }
    }
    if(!okok){
        cout << -1 << endl;
        return 0;
    }
    ll res=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            bool ok=1;
            for(int k=0;k<n;k++){
                if(k==i||k==j)continue;
                if(d[i][j]==d[i][k]+d[k][j])ok=0;
            }
            if(ok){
                res+=d[i][j];
            }
        }
    }
    cout << res << endl; 
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();

    int[] H = new int[N];
    for (int i = 0; i < N; i++) {
      H[i] = scn.nextInt();
    }

    boolean flg = true;
    for (int i = N - 2; i >= 0; i--) {
      if (H[i] - H[i + 1] > 1) {
        flg = false;
        break;
      }

      if (H[i] - H[i + 1] == 1) {
        H[i]--;
      }
    }

    System.out.println(flg ? "Yes" : "No");
  }
}

Measured memory_bytes: 50704
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <numeric>

int testcase_ends() {
  size_t n, m;
  scanf("%zu %zu", &n, &m);
  if (n == 0 && m == 0) return 1;

  std::vector<int> d(m+1);
  for (size_t i = 0; i < n; ++i) {
    size_t di;
    int v;
    scanf("%zu %d", &di, &v);
    d[di] = std::max(d[di], v);
  }

  int res = std::accumulate(d.begin(), d.end(), 0);
  printf("%d\n", res);

  return 0;
}

int main() {
  while (!testcase_ends()) {}
}




Measured memory_bytes: 2720
import java.util.Scanner;

public class Main {

	static int[] par, rank;
	
	static void init(int N) {//初期化
		for(int i=0; i<N; i++) {
			rank[i]=0;
			par[i]=i;
		}
	}

	static int root(int x) {//親を求める
		//System.out.println("para="+par[x]);
		if(par[x]==x) {
			return x;
		}
		return par[x]=root(par[x]);
	}

	static boolean same(int x, int y) {//判定(同グループかどうか)
		return (root(x)==root(y));
	}

	static void unite(int x, int y) {//まとめる
		x = root(x);
	    y = root(y);
	 
	    if(x == y)return;
	 
	    if(rank[x] < rank[y]){
	        par[x] = y;
	    }else{
	        par[y] = x;
	        if(rank[x] == rank[y])rank[x]++;
	    }
	}


	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
				int n=sc.nextInt();
				int m=sc.nextInt();
				rank=new int[n+1];
				par=new int[n+1];
				init(n);
				for(int i=0; i<m; i++) {
					int a=sc.nextInt();
					int b=sc.nextInt();
					unite(a, b);
				}
				int q=sc.nextInt();
				//System.out.println("q="+q);
				for(int i=0; i<q; i++) {
					int a=sc.nextInt();
					int b=sc.nextInt();
					//System.out.println("a="+a+" b="+b);
					if(same(a, b)) {
						System.out.println("yes");
					}
					else {
						System.out.println("no");
					}
				}

		}
	}
}


Measured memory_bytes: 74736
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll A[3];
  cin >> A[0] >> A[1] >> A[2];
  sort(A,A+3);
  if(A[0]%2==0 || A[1]%2==0 || A[2]%2==0){
    cout << "0" << endl;
  }else{
    cout << A[0]*A[1] << endl;
  }
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
import sys
x, n = map(int, input(). split())
l = [0]*n
m = [0]*200
ans = 0
p = list()
if n > 0:
  p = list(map(int, input(). split()))
else:
  print(x)
  sys.exit()
for i in range(n):
  l[i] = abs(x-p[i])
  m[l[i]] += 1
if m[0] == 0:
  print(x)
else:
  for j in range(1, 200):
    if m[j] != 2:
      a = x-j
      A = x+j
      b = p.count(a)
      B = p.count(b)
      if b == 0:
        ans = a
      else:
        ans = A
      break
  print(ans)

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

int a[26] {};

void solve() {
    // ある文字列にすべての文字が偶数回出現するかどうか

    string w;
    cin >> w;

    for (auto c : w) {
        a[c-'a']++;
    }

    for (auto n : a) {
        if (n % 2) {
            cout << "No" << endl;
            return;
        }
    }

    cout << "Yes" << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}



Measured memory_bytes: 256
n=int(input())

if n<105:
  print(0)
else:
  lst=[]
  
  for i in range(105,n+1):
    counter = 1
    if i % 2 == 1:
      for j in range(2, i+1):
        if i % j == 0:
          counter += 1
        if counter > 8:
          break
      if counter == 8:
        lst.append(i)
  print(len(lst))

Measured memory_bytes: 3060
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
        int int2 = Integer.parseInt(scan.next());

//        String str1 = scan.next();
        int int3 = Integer.parseInt(scan.next());
//        String str1 = scan.next();

        int ans_int = 0;
        double ans_dob = 0;
        String ans = "";

        if((int1*int2)>int3){
            ans_int = int3;
        }else{
            ans_int = int1*int2;
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(ans_int);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
using I64II = tuple<int64_t, int, int>;
using Graph = vector<vector<I64II>>;
using PQueue = priority_queue<I64II, vector<I64II>, greater<I64II>>;

int	main()
{
	int	N, M;
	int	S;
	cin >> N >> M >> S;
	Graph	graph(N);
	int	U, V;
	int	A, max_stock = 0;
	int64_t	B;
	for (int i = 0; i < M; ++i) {
		cin >> U >> V >> A >> B;
		--U; --V;
		graph.at(U).push_back(make_tuple(B, A, V));
		graph.at(V).push_back(make_tuple(B, A, U));
		max_stock = max(A, max_stock);
	}
	max_stock *= (N - 1);
	vector<int>		C_vec(N);
	vector<int64_t> D_vec(N);
	int				C;
	for (int i = 0; i < N; ++i) {
		cin >> C >> D_vec.at(i);
		if (C > max_stock)
			C = max_stock;
		C_vec.at(i) = C;
	}
	int64_t	cost[50][2500] = {};
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= max_stock; ++j)
			cost[i][j] = -1;
	}
	S = min(max_stock, S);
	PQueue p_que;
	cost[0][S] = 0;
	p_que.push(make_tuple(0, S, 0));
	int		u, v;
	int		fare, stock_u, stock_v;	
	int64_t	dist, cost_u, cost_v;
	while (!p_que.empty()) {
		auto	tpl1 = p_que.top();
		p_que.pop();
		tie(cost_u, stock_u, u) = tpl1;
		if (stock_u < max_stock) {
			v = u;
			stock_v = min(stock_u + C_vec.at(u), max_stock);
			cost_v = cost_u + D_vec.at(u);
			if (cost[v][stock_v] == -1 || cost[v][stock_v] > cost_v) {
				cost[v][stock_v] = cost_v;
				p_que.push(make_tuple(cost_v, stock_v, v));
			}
		}
		for (auto tpl2 : graph.at(u)) {
			tie(dist, fare, v) = tpl2;
			stock_v = stock_u - fare;
			if (stock_v < 0) continue;
			cost_v = cost_u + dist;
			if (cost[v][stock_v] == -1 || cost[v][stock_v] > cost_v) {
				cost[v][stock_v] = cost_v;
				p_que.push(make_tuple(cost_v, stock_v, v));
			}
		}
	}
	int64_t	min_cost[50] = {};
	for (int i = 1; i < N; ++i) {
		min_cost[i] = -1;
		for (int j = 0; j <= max_stock; ++j) {
			if (cost[i][j] == -1) continue;
			if (min_cost[i] == -1 || min_cost[i] > cost[i][j])
				min_cost[i] = cost[i][j];
		}
		cout << min_cost[i] << endl;
	}
}


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

using namespace std;

int main() {
  int n, k; cin >> n >> k;

  string s; cin >> s;
  string ret = "";

  char ini = s[0];
  ret += ini;

  bool is_renzoku = false;
  for (int i = 0; i < n; i++) {
    if (i == 0) { continue; }
    if (s[i] != ini && k != 0 ) {
      is_renzoku = true;
      if (s[i] == 'R') { ret += "L"; }
      else { ret += 'R'; }
    } else {
      if ( is_renzoku ) { k--; }
      is_renzoku = false;
      ret += s[i];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if ( i == 0 ) { continue; }
    if ( ret[i] == ret[i-1] ) { ans++; }
  }
 
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 640
N,*A = $<.read.split.map(&:to_i)
B = [0]*(N+1)
A.each{|a|
	B[a] += 1
}
C = B.inject(0){|c,b|
	c + b*(b-1)/2
}
A.each{|a|
	b = B[a]
	p C+1-b
}

Measured memory_bytes: 31996
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    ll N;
    cin >> N;

    ll  table[11][11];
    for(int i = 0; i < 10;i++){
        for(int l = 0; l < 10;l++){
            table[i][l] = 0;
        }
    }

    for(int i = 1; i < N+1;i++){
        int rs =  i%10;
        int ls= i;
        while(ls >= 10){
            ls/=10;
        }
        table[ls][rs]++;
    }
    
    ll ans = 0;
    for(int i = 1; i < 10;i++){
        for(int l = 1; l < 10;l++){
            ans += table[i][l]*table[l][i];
        }
    }

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

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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n;
  cin >> n;

  vector<pair<int, int>> seg;
  int mx = INT_MIN, mn = INT_MAX;
  for (int i = 0; i < n; ++i) {
    int l, r;
    cin >> l >> r;

    mx = max(mx, l);
    mn = min(mn, r+1);
    seg.emplace_back(l, r+1);
  }

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans = max(ans, max(0, mn - mx) + seg[i].second - seg[i].first); 
  }

  vector<pair<int, int>> p;
  for (int i = 0; i < n; ++i) {
    int a = max(0, seg[i].second - mx);
    int b = max(0, mn - seg[i].first);

    p.emplace_back(a, b);
  }

  sort(p.begin(), p.end(), [&](auto la, auto lb) {
    if (la.first == lb.first) return la.second > lb.second;
    return la.first < lb.first;
  });

  mn = INT_MAX;
  for (int i = 0; i < n; ++i) {
    if (i)  ans = max(ans, mn + p[i].first);
    mn = min(mn, p[i].second);
  }

  cout << ans << '\n';
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9

using namespace std;
typedef long long ll;

int main(void) {
  int k;
  string s;
  cin >> k >> s;

  if (s.size() <= k) {
    cout << s << endl;
  }
  else {
    cout << s.erase(k) << "..." << endl;
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define fi first
#define se second
#define For(i, a, b) for (ll i = (a); i <= (b); ++i)
#define Ford(i, a, b) for (ll i = (a); i >= (b); --i)
#define endl '\n'
#define debug(a) cout << a << endl
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;

const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
const ll limit2 = 1e3 + 5;
const ll limit3 = 1e4 + 5;

ll test;
ll n, m, x;
ll res = 0, sum = 0, ans = 0, kd, hkd;
bool ok = false;

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


void ReadIn(){
    cin >> x;
    For(i, -150, 150)
        For(j, -150, 150){
            sum = (i * i * i * i * i) - (j * j * j * j * j);
            if(sum == x){
                cout << i << " " << j;
                return;
            }
        }
}
int main(){
    FastIn();
    ReadIn();
}
/*
* Ctrl + Shift + K Delete Line
* Ctrl + / TOGGLE LINE COMMENT
Ctrl + F Find
* Ctrl + H  REPLACE
* shift + alt + f FORMAT CODE DOCUMENT
Shift + alt + uparrow/downarrow Copy line up/down
Ctrl + ]/[ INDENT/OUTDENT LINE
*/


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int count( string str );
bool check( string str, vector<string> & sv);

int main(int argc, char const *argv[]) {
    int m, sum;
    string str;
    vector<int> v;

    cin>>m;
    for (int i = 0; i < m; i++) {
        cin>>str;
        sum = count( str );
        v.push_back( sum );
    }

    for(auto it = v.begin(); it != v.end(); it++){
        cout<<*it<<endl;
    }
    return 0;
}

int count( string str ){
    int n, m, scnt;
    int sum = 0;
    int size = str.size();
    string first, second, temp;
    vector<string> sv;
    scnt = size - 1;

    for (int i = 0; i < scnt; i++) {
        for(int j = 0; j < i + 1; j++ ) first.push_back( str[j] );
        for(int j = i+1; j < size; j++ ) second.push_back( str[j] );

        if(check( first + second, sv)) sv.push_back( first + second );
        if(check( second + first, sv)) sv.push_back( second + first );
        reverse(second.begin(), second.end());
        if(check( first + second, sv)) sv.push_back( first + second );
        if(check( second + first, sv)) sv.push_back( second + first );
        reverse(first.begin(), first.end());
        if(check( first + second, sv)) sv.push_back( first + second );
        if(check( second + first, sv)) sv.push_back( second + first );
        reverse(second.begin(), second.end());
        if(check( first + second, sv)) sv.push_back( first + second );
        if(check( second + first, sv)) sv.push_back( second + first );

        first.clear();
        second.clear();
    }
    return sv.size();;
}

bool check( string str, vector<string> &sv ){
    for (auto it = sv.begin(); it != sv.end(); it++) {
        if(*it == str ) return false;
    }
    return true;
}

Measured memory_bytes: 3120
N =int(input())
#横文字数、縦N行の行列を作成
s = [list(input()) for i in range(N)]

#文字列をアルファベット順に並び替える
for i in range(len(s)):
    s[i].sort()
s.sort()   
ans = 0 
cnt = 1
for i in range(1,N):
    for j in range(10):
        #1文とその次の文の文字を比較
        #異なっていた場合はbreak
        if(s[i][j] != s[i-1][j]):
            break
    else:
        cnt +=1
        continue
    ans += cnt*(cnt-1)//2
    cnt =1
ans +=cnt*(cnt-1)//2
print(ans)

Measured memory_bytes: 26308
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;
int main(){
  ll n; cin >> n;
  unordered_map<ll,ll> as;
  ll sum=0;
  rep(i,n){
    ll a; cin >> a;
    as[a]++;
    sum+=a;
  }
  ll q; cin >> q;
  rep(i,q){
    ll b,c; cin >> b >> c;
    ll bcnt = as[b], ccnt=as[c];
    sum += c*bcnt - b*bcnt;
    as[b]=0; as[c]+=bcnt;
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 6988
X,Y=map(int,input().split())

mod=10**9+7 
def nCr(n, r, mod):#mod=10**9+7 
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

if (X+Y)%3 !=0:
      print(0)
      exit()

n=((2*X)-Y)//3
m=((X+Y)//3)-n

if n<0 or m<0:
      print(0)
      exit()

print(nCr(n+m,min(n,m),mod))


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
using namespace std;

int main(){
    int N;
    int H[1000];
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> H[i];
    }

    int highest = 0;
    int count = 0;
    for (int i = 0; i < N; i++){
        if(highest <= H[i]){
            count++;
            highest = H[i];
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	static double R = 6378.1;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (true) {
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			double c = sc.nextDouble();
			double d = sc.nextDouble();
			if (a == -1 && b == -1 && c == -1 && d == -1)
				break;
			double x1 = R * Math.cos(Math.PI * a / 180)
					* Math.cos(Math.PI * b / 180);
			double y1 = R * Math.cos(Math.PI * a / 180)
					* Math.sin(Math.PI * b / 180);
			double z1 = R * Math.sin(Math.PI * a / 180);

			double x2 = R * Math.cos(Math.PI * c / 180)
					* Math.cos(Math.PI * d / 180);
			double y2 = R * Math.cos(Math.PI * c / 180)
					* Math.sin(Math.PI * d / 180);
			double z2 = R * Math.sin(Math.PI * c / 180);
			double ip = x1 * x2 + y1 * y2 + z1 * z2;
			double normp = Math.sqrt(x1 * x1 + y1 * y1 + z1 * z1)
					* Math.sqrt(x2 * x2 + y2 * y2 + z2 * z2);
			double th = Math.acos(ip / normp);
			System.out.println(Math.round(R * th));
		}
	}
}

Measured memory_bytes: 12000
# A - Dividing a String
S = input()

arr = [S[0]]
i = 1

while i < len(S):
	s = S[i]
	
	if s == arr[-1]:
		if i + 1 < len(S):
			i += 1
			s += S[i]
		else:
			arr[-1] += s
			break
	
	arr.append(s)
	i += 1

print(len(arr))

Measured memory_bytes: 8068
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 入力
		int n = sc.nextInt();// 中間ポイントの数

		int[] p = new int[n * 3];
		for(int i = 0; i < n * 3; i++){
			p[i] = sc.nextInt();
		}

		//
		String result = "Yes";
		for(int i = 0; i < n; i++){

			int t = 0;
			int x = 0;
			int y = 0;

			if(i == 0){
				t = p[i * 3];
				x = p[i * 3 + 1];
				y = p[i * 3 + 2];
			}else{
				t = p[i * 3] - p[(i - 1) * 3];
				x = p[i * 3 + 1] - p[(i - 1) * 3 + 1];
				y = p[i * 3 + 2] - p[(i - 1) * 3 + 2];
			}
			
			if(!canGo(t, x, y)){
				result = "No";
				break;
			}
		}

		// 出力
		System.out.println(result);
	}

	// 移動可能か
	static boolean canGo(int t, int x, int y){
		//System.out.print("t:" + t + " x:" + x + " y:" + y);

		// 制約条件
		if(t < abs(x) + abs(y)){
			// System.out.println(" No(条件１)");
			return false;
		}
		if(t%2 != abs(x + y)%2){
			// System.out.println(" No(条件２)");
			return false;
		}

		// System.out.println(" Yes");
		return true;
	}
}




Measured memory_bytes: 92972
n=int(input())
s=list(input())
a=[chr(i) for i in range(65,65+26)]

for i in range(len(s)):
  for j in range(len(a)):
    if s[i]==a[j]:
      if j+n<26:
        s[i]=a[j+n]
      else:
        s[i]=a[j+n-26]
      break

print(''.join(s))

Measured memory_bytes: 39920
#include <iostream>
#include<vector>
#include <algorithm>
#include <math.h>
using namespace std;
int main(void)
{
	int N,D;
	cin >> N>>D;
	vector<vector<int>> X(N, vector<int>(D));
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < D; j++)
		{
			cin >> X[i][j];

		}
	}

	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			int norm = 0;
			for (int k = 0; k < D; k++)
			{
				int diff = abs(X[i][k] - X[j][k]);
				norm += diff * diff;
			}
			
			bool flag = false;
			for (int k = 0; k <= norm; k++)
			{
				if (k * k == norm)
				{
					flag = true;
				}
			}
			if (flag==true)
			{
				ans++;
			}
		}



	}

	
	cout << ans << endl;
	
}

Measured memory_bytes: 256
n,k=map(int,input().split())
v=list(map(int,input().split()))
ans=0
d=[]
for i in range(min(n+1,k+1)):
    for j in range(min(n-i+1,k-i+1)):
        d=v[:i]+v[n-j:]
        d.sort(reverse=True)
        for _ in range(k-i-j):
            if d and d[-1]<0:
                d.pop()
        ans=max(ans,sum(d))

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;
import java.io.PrintWriter;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    PrintWriter pw = new PrintWriter(System.out, true);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++)
        pw.print(i < B ^ j < A ? 1 : 0);
      pw.println();
    }
  }
}

Measured memory_bytes: 43348
n = int(input())
x = list(map(int, input().split()))
a = list(enumerate(x))
a.sort(key = lambda x: x[1])
b = []
for i in range(n//2):
    b.append((a[i][0], a[n//2][1]))
for i in range(n//2, n):
    b.append((a[i][0], a[n//2 - 1][1]))
b.sort(key = lambda x: x[0])
for _, m in b:
    print(m)


Measured memory_bytes: 51724
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 1e9 + 7;
const int MX = 110000;
ll inv[MX], f[MX], invf[MX];
void calc(){
	inv[0] = inv[1] = f[0] = f[1] = invf[0] = invf[1] = 1;
	for (int i = 2; i < MX; i++){
		inv[i] = mod - mod / i * inv[mod % i] % mod;
		f[i] = f[i - 1] * i % mod;
		invf[i] = invf[i - 1] * inv[i] % mod;
	}
}
inline ll P(ll n, ll k){
	return n >= k ? f[n] * invf[n - k] % mod : 0;
}
	
int dp[1 << 16];

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	calc();
	
	int n, m; cin >> n >> m;
	vi a(m), b; rep(i, m) cin >> a[i];
	a.insert(a.begin(), 1);
	a.pb((1 << n) + 1);
	rep(i, a.size() - 1) b.pb(a[i + 1] - a[i] - 1);
	
	rep(i, 1 << n) dp[i] = 1;
	
	for(int i = 0; i < b.size(); i++){
		
		rep(j, 1 << n){
			int rem = j - a[i] + 1;
			dp[j] = dp[j] * P(rem, b[i]) % mod;
		}
		
		if(i + 1 == b.size()) break;
		
		for(int k = n - 1; k >= 0; k--) rep(j, 1 << n) if(j >> k & 1)
			dp[j] = (dp[j] + mod - dp[j ^ 1 << k]) % mod;
		rep(j, 1 << n){
			if(j > a[i + 1] - 2) dp[j] = dp[j] * (j - a[i + 1] + 2ll) % mod;
			else dp[j] = 0;
		}
		rep(k, n) rep(j, 1 << n) if(j >> k & 1) dp[j] = (dp[j] + dp[j ^ 1 << k]) % mod;
		
	}
	
	ll ans = dp[(1 << n) - 1];
	rep(i, n){
		ans = ans * 2 % mod;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3072
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, M;
        public long MOD = 1000000007;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                M = line[1];
            }

            var DP = new long[M + 1, N + 1, N + 1]; // 回数、孤立点、強連結成分サイズ
            DP[0, N - 1, 1] = 1;

            for (int i = 0; i < M; i++)
            {
                for (int s = 0; s <= N; s++)
                {
                    for (int c = 0; c <= N; c++)
                    {
                        if (s + c <= N)
                        {
                            int sd = Math.Max(s - 1, 0);
                            DP[i + 1, sd, c] += DP[i, s, c] * s;
                            DP[i + 1, sd, c] %= MOD;

                            int c2 = N - s;
                            DP[i + 1, s, c2] += DP[i, s, c] * c;
                            DP[i + 1, s, c2] %= MOD;

                            DP[i + 1, s, c] += DP[i, s, c] * (N - s - c);
                            DP[i + 1, s, c] %= MOD;
                        }

                    }
                }
            }

            long ret = DP[M, 0, N];
            Console.WriteLine(ret);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 222688
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef long double LD;

const int MOD = 1e9 + 7;
const int MAXS = 1 << 16;

int main() {
	int N, X, Y, Z;
	cin >> N >> X >> Y >> Z;

	int xyz = (1 << (X + Y + Z - 1)) | (1 << (Y + Z - 1)) | (1 << (Z - 1));
	int mask = (1 << (X + Y + Z)) - 1;
	int mask2 = mask >> 1;

	int dp[2][MAXS];
	int idx = 0, _idx;
	dp[idx][0] = 1;
	for (int k = 0; k < N; ++k) {
		_idx = idx;
		idx ^= 1;
		memset(dp[idx], 0, sizeof(dp[idx]));
		for (int i = 0; i <= mask2; ++i) {
			if (dp[_idx][i] > 0) {
				for (int j = 1; j <= 10; j++) {
					int _i = ((i << j) | (1 << (j-1)));
					if ((_i&xyz) != xyz) (dp[idx][_i&mask2] += dp[_idx][i]) %= MOD;
				}
			}
		}
	}
	long res = 1;
	for (int i = 0; i < N; ++i) (res *= 10) %= MOD;
	for (int i = 0; i <= mask2; ++i) (res -= dp[idx][i]) %= MOD;

	cout << (res + MOD) % MOD << endl;

	return 0;
}


Measured memory_bytes: 768
//10-04-2K20
    //Happy Coding :)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 1000000007
#define MAX 1000000000000
#define N 305

int main()
{
    fastio;
    ll n,sum=0,i;

    cin>>n;

    for(i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
            sum+=i;
    }
    cout<<sum;
    cout<<"\n";
    return 0;   //:D
}





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

int main() {
  int n; cin >> n;
  int one_cnt = 0;
  int start = 1;
  int break_num = 0;
  
  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    if (a == 1) ++one_cnt;
    
    if (a == start) ++start;
    else ++break_num;
  }
  
  if (one_cnt < 1) cout << -1 << endl;
  else cout << break_num << endl;
  
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
    int n;
    cin>>n;
    if(n<1000) cout<<"ABC"<<endl;
    else cout<<"ABD"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

  string s, t;

  cin >> s >> t;

  int n = s.size();

  vector<vector<char>> arrays(26);

  REP(i, n) arrays[s[i] - 'a'].push_back(t[i]);
  //REP(i, arrays.size()) cout << arrays[i] << endl;

  bool tmp = true;
  REP(i, 26) {
    for (int j = 0; j < arrays[i].size(); j++) {
      if(arrays[i][0] != arrays[i][j]) {
        tmp = false;
        break;
      }
    }
  }

  vector<vector<char>> arrayt(26);

  REP(i, n) arrayt[t[i] - 'a'].push_back(s[i]);
  //REP(i, arrays.size()) cout << arrays[i] << endl;
  REP(i, 26) {
    for (int j = 0; j < arrayt[i].size(); j++) {
      if(arrayt[i][0] != arrayt[i][j]) {
        tmp = false;
        break;
      }
    }
  }


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

  return 0;
}


Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a,b,i;
  b = 100;
  i = 0;
  cin >> a;
  while(b < a){
    long long c = b / 100;
    b = b + c;
    i++;
  }
  cout << i;
}

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

using namespace std;
typedef long long ll;

const int N = 2e5 + 10;
int cnt[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        cnt[a] += 1;
        cnt[b] += 1;
    }
    for (int i = 0; i < n; i++) {
        if (cnt[i] % 2 == 1) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define MOD (long int)10e9 + 7
#define LD long double

int ans = 12 * 100000 + 20;

int main(){
    string s;
    cin >> s;
    if(s == "ARC"){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>*/
#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = {1,0,-1,0};
ll dy[4] = {0,1,0,-1};

int main(){
    string s;
	cin >> s;
	cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
	return 0;
}  


Measured memory_bytes: 256
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]
AB.sort(key=lambda x:(x[1],x[0]))

ans = 0
rb = -1
for a,b in AB:
  if a>rb:
    ans += 1
    rb = b-1
print(ans)


Measured memory_bytes: 35460
#include <stdio.h>
int main(){
int n;
int a;
scanf("%d %d",&n,&a);
int min = a;
long sum = a;
int max = a;

for (int i = 1;i<n;i++){
scanf("%d",&a);
if (a > max){
max = a;
}else if (a < min){
min = a;
}
sum = sum + a;
}
printf ("%d %d %ld\n",min,max,sum);

return 0;
}


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

//Constants
const long long INF = std::numeric_limits<long long>::max();
const long long MOD = 1e9 + 7;
const long double PI = 3.141592653589793;

//MACROS
#define pb push_back
#define fi first
#define se second
#define rep(i, begin, end) for (int i = (begin); i < (end); i++)
#define per(i, begin, end) for (int i = (begin) - 1; i >= (end); i--)
typedef long long LL;
typedef pair <LL,LL> PLL;

const long long N = 1e10;

int n, ans;
vector<LL> primes;
map<PLL,int> num;
map<LL,LL> square;

int main() {
	scanf("%d", &n);
	for (int i = 2; 1LL * i * i < N; i++) {
        bool flag = 0;
        for (int j = 0; j < primes.size() && primes[j] * primes[j] < i; j++) {
            if (i%primes[j] == 0) { flag = 1; break; }
        }
        if (!flag) primes.push_back(i), square[1LL*i*i] = i;
	}

	while(n--) {
        LL x, v1 = 1, v2 = 1;
        scanf("%lld", &x);
        for (int i = 0; i < primes.size() && primes[i] * primes[i] * primes[i] <= x; i++) {
            int c = 0;
            while (x%primes[i] == 0) x /= primes[i], c++;
            c %= 3;
            if (c == 1) v1 *= primes[i] * primes[i], v2 *= primes[i];
            else if (c == 2) v1 *= primes[i], v2 *= primes[i] * primes[i];
        }
        if (square.count(x) == 1) v1 *= square[x], v2 *= x;
        else v1 *= x * x, v2 *= x;
        num[{v1,v2}]++;
	}

    while (!num.empty()) {
        pair<PLL,int> top = *num.begin();
        if (top.fi.fi == 1) ans++;
        else {
            ans += max(num[{top.fi.se,top.fi.fi}], top.se);
            num.erase({top.fi.se,top.fi.fi});
        }
        num.erase(num.begin());
    }

    cout << ans;
}


Measured memory_bytes: 7168
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



//bit全探索
vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int main(){
    ll x;
    cin >> x;
    ll res = 0;

    res = x / 500 * 1000;
    x %= 500;

    res += x / 5 * 5;
    cout << res << endl;
}



Measured memory_bytes: 256
/*
[ ( ^ _ ^ ) ]
*/

// problem: atc/dp_o

import java.io.*;
import java.util.*;


public class Main {
    int INF = (int)1e9;
    long MOD = 1000000007;

    long[][] dp;
    boolean[][] vis;

    long go(int[][] a, int n, int i, int m) {
        if(i==n) {
            return 1;
        }
        if(dp[i][m]!=-1) return dp[i][m];
        long rs = 0;
        for(int j=0; j<n; j++) {
            int x = (1<<j);
            if(a[i][j]==1 && (m&x)==0) {
                m = m ^ x;
                rs += go(a, n, i+1, m);
                rs %= MOD;
                m = m ^ x;
            }
        }
        dp[i][m] = rs;
        return rs;
    }

    void solve(InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int[][] a = new int[n][n];
        for(int i=0; i<n; i++) {
            for(int j=0; j<n; j++) {
                a[i][j] = in.nextInt();
            }
        }
        dp = new long[n][1<<n];
        for(int i=0; i<n; i++) {
            Arrays.fill(dp[i], -1);
        }
        long rs = go(a, n, 0, 0);
        out.println(rs);
    }
    

    public static void main(String[] args) throws IOException {
        if(args.length>0 && args[0].equalsIgnoreCase("d")) {
            DEBUG_FLAG = true;
        }
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        long start = System.nanoTime();
        while(t-- >0) {
            new Main().solve(in, out);
        }
        long end = System.nanoTime();
        debug("\nTime: " + (end-start)/1e6 + " \n\n");
        out.close();
    }
    
    static boolean DEBUG_FLAG = false;
    static void debug(String s) {
        if(DEBUG_FLAG) System.out.print(s);
    }
    
    public static void show(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    
    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;
    
        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

i64 gcd(i64 a, i64 b) {
    if (a < b) swap(a, b);

    i64 t;
    while(b > 0) {
        t = a % b;
        a = b;
        b = t;
    }

    return a;
}

int main() {
    i64 N, X; cin >> N >> X;

    i64 g = 0;
    i64 x;
    REP(i, N) {
        cin >> x;
        g = gcd(g, abs(X - x));
    }
    cout << g << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

int main(void){
    for(int e, m; m = INF, cin >> e, e; cout << m << endl)
        for(int z = 0; z * z * z <= e; z++)
            for(int y = 0; y * y <= e - z * z * z; y++){
                int x = e - z * z * z - y * y;
                m = min(m, x + y + z);
            }

    return 0;
}

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

#define modm 1000000007

char c[4]={'E','W','N','S'};

int gcd(int a ,int b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
int main(){
	llt n,ans=0;
//	cin>>n;
	string s,str;
	cin>>s>>str;
	str.pop_back();
	if(s==str)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	//cout<<ans<<endl;

}


Measured memory_bytes: 3628
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

a,b = rl()

c = int(str(a)+str(b))
c_ = int(c**0.5)

if c==c_*c_:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
MOD = 10**9 + 7
def main():
  N = int(input())
  S1 =str(input())
  S2 = str(input())
  if N > 1 and S1[0] == S1[1]:
      ans = 6
  else:
    ans = 3
  flag = False
  for i in range(N-1):
    if S1[i] == S1[i+1]:
      flag = True
      continue
    else:
      if flag:
        if i+2 < N:
          if S1[i+1] == S1[i+2]:
            ans *= 3
            ans %= MOD
        flag = False
      else:
        ans *= 2
        ans %= MOD
  print(ans)
if __name__ == "__main__":
  main()
  

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for(int i = 0;i < values.length;i++){
			values[i] = i + 1;
		}
		for(int i = 0;i < n;i++){
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			int c = values[a];
			values[a] = values[b];
			values[b] = c;
		}

		for(int i = 0;i < values.length;i++)System.out.println(values[i]);

	}
}

Measured memory_bytes: 25984
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<int,int>
#define V vector<ll>
#define M map<int,int>
#define S set<int>
#define L list<int>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){

  CIN(x);
  ll kai=0;
  FOR(i,1,INF){
    kai+=i;
    if(kai>=x){COUT(i);break;}
  }

  return 0;
}


Measured memory_bytes: 256
sa = gets.chomp.chars
sb = gets.chomp.chars
sc = gets.chomp.chars

turn = 'a'

loop do
  case turn
  when 'a'
    if sa.size == 0
      puts 'A'
      exit
    else
      turn = sa.shift
    end
  when 'b'
    if sb.size == 0
      puts 'B'
      exit
    else
      turn = sb.shift
    end
  when 'c'
    if sc.size == 0
      puts 'C'
      exit
    else
      turn = sc.shift
    end
  end

end

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

int main(){
  int n, x;
  vector<int> a;
  int sum = 0;
  
  cin >> n >> x;

  for(int i = 0; i < n; i++){
    int b;
    cin >> b;
    sum += b;
    a.push_back(b);
  }
  
  sort(a.begin(), a.end());
  
  int num = 0;
  num = (x - sum);
  if(num == 0){
    cout << n << endl;
  } else {
    cout << n + num / a[0] << endl;
  }
  
  return 0;
}
  
  

Measured memory_bytes: 256