akhauriyash/Code-Regression huggingface dataset:
# -*- coding:utf-8 -*-

num = list(map(int,input().split()))
N = num[0]
M = num[1]

a = []
b = []

firstisland = []
islandlast = []

for i in range(M):
    num = list(map(int,input().split()))
    a.append(num[0])
    b.append(num[1])
    if (num[0] == 1):
        firstisland.append(num[1])
    if (num[1] == N):
        islandlast.append(num[0])

island = set(firstisland) & set(islandlast)

if (len(island) > 0):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")



Measured memory_bytes: 28064
#include<stdio.h>
main(){
  double mt,high=0,low=10000,ans;
  while(scanf("%lf",&mt)!=EOF){
    if(mt>high){
      high=mt;
    }
    else if(mt<low){
      low=mt;
    }
  }
  ans=high-low;
  printf("%.3f\n",ans);
  return 0;
}

Measured memory_bytes: 648
#include<stdio.h>
#include<string.h>
int main()
{
	char s[100002];
	scanf("%s",s);
	int len=strlen(s);
	if((s[0]==s[len-1]||len%2!=0)&&(s[0]!=s[len-1]||len%2==0))
	printf("First\n");
	else printf("Second\n");
}


Measured memory_bytes: 256
//<<???????¨????????????????>>?¬¬??????????¢?
//DFS
#include <iostream>
#include <stdio.h>
using namespace std;

int Num[10];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        bool flag=false;
        for(int k=0;k<10;k++)
            scanf("%d",&Num[k]);
        for(int a=0;a<8;a++)
        {
            for(int b=a+1;b<9;b++)
            {
                for(int c=b+1;c<10;c++)
                {
                    if(Num[a]>Num[b]&&Num[b]>Num[c])
                    {
                        flag=true;
                    }
                }
            }
        }
        if(flag) cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
    }
    return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n, T; cin>>n>>T;
  vector<ll> t(n);
  rep(i,n) cin>>t[i];
  ll ans=T*n;
  irep(i,1,n){
    ans-=max(0LL,T-(t[i]-t[i-1]));
  }
  cout<<ans<<endl;
}

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

using namespace std;

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

    int cnt[4] = {};
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        cnt[a % 4]++;
    }

    cnt[1] += cnt[3];
    if (cnt[2] != 0) cnt[1]++;
    if (cnt[0] >= cnt[1] - 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
char S[101];
int l,i,j,hug=0;
 scanf("%s",S);
  l=strlen(S);
  for(i=0,j=l-1;i<j;i++,j--){
  	if(S[i]!=S[j])hug++;
  }
  printf("%d\n",hug);
  return 0;
}

Measured memory_bytes: 128
n = input()
k = int(input())
dp = [[0] * (3 + 1) for i in range(len(n))]
dp[0][1] = int(n[0])
cnt = 1
for i in range(1, len(n)):
  m = int(n[i])
  if cnt == 1:
    dp[i][1] = 9 + dp[i - 1][1]
    dp[i][2] = (dp[i - 1][1] - 1) * 9 + dp[i - 1][2] + m
    dp[i][3] = dp[i - 1][2] * 9 + dp[i - 1][3]
  elif cnt == 2:
    dp[i][1] = 9 + dp[i - 1][1]
    dp[i][2] = dp[i - 1][1] * 9 + dp[i - 1][2]
    dp[i][3] = (dp[i - 1][2] - 1) * 9 + dp[i - 1][3] + m
  else:
    dp[i][1] = 9 + dp[i - 1][1]
    dp[i][2] = dp[i - 1][1] * 9 + dp[i - 1][2]
    dp[i][3] = dp[i - 1][2] * 9 + dp[i - 1][3]
  if m != 0:
    cnt += 1
print(dp[len(n) - 1][k])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
int dx[4]={0,1,0,-1};int dy[4]={1,0,-1,0};int N,M,D,X,Y,A,i,j,k,C[20],R[20],P[21][21];char dir[5]="NESW",c;main(){while(true){scanf("%d",&N);if(N==0){break;}memset(P,0,sizeof(P));X=Y=10;A=0;P[X][Y]=1;for(i=0;i<N;i++){scanf("%d%d",&C[i],&R[i]);}scanf("%d",&M);for(i=0;i<M;i++){std::cin>>c>>D;for(j=0;j<4;j++){if(c==dir[j]){for(k=0;k<D;k++){X+=dx[j];Y+=dy[j];P[X][Y]=1;}}}}for(i=0;i<N;i++){A+=P[C[i]][R[i]];}printf("%s\n",A==N?"Yes":"No");}}

Measured memory_bytes: 3036
#include <stdio.h>
int main ( void ) {
    int d,i,men=0,syoki;
    while(scanf("%d",&d)!=EOF){
        syoki=600-d;
        for(i=syoki;i>0;i=i-d){
            men=(i*i)*d+men;
        }
        printf("%d\n",men);
        men=0;
    }
    return 0;
}

Measured memory_bytes: 596
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int x, y, z;
    cin >> x >> y >> z;

    cout << z << ' ' << x << ' ' << y << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
vector<vector<int>> fwd;
vector<vector<int>> bwd;
vector<int> dp;

int len(int v)
{
	if(dp[v] != 0)
		return dp[v];
	int result = 0;
	for(int ne : fwd[v])
		result = max(result, len(ne)+1);
	return dp[v] = result;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	fwd.resize(n);
	bwd.resize(n);
	dp.resize(n);
	for(int i = 0; i < m; i++)
	{
		int xi,yi;
		cin >> xi >> yi;
		//cout << xi << "->" << yi << endl;
		xi--;
		yi--;
		fwd[xi].push_back(yi);
		bwd[yi].push_back(xi);
	}
	vector<int> starts;
	for(int i = 0; i < n; i++)
	{
		if(bwd[i].size() == 0 && fwd[i].size() != 0){
			starts.push_back(i);
		}
	}

	int best = 0;
	for(int v : starts)
		best = max(best, len(v));
	cout << best << endl;
}


Measured memory_bytes: 19252
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
bool ok=false,first=true;
long long cnt=0;int len;
string s;
int Last_Z(string s1)
{
	for(int i=len-1;i>=0;--i)
	if(s1[i]=='Z') return i;
}
int main()
{
  cin>>s;
  len=s.length();
  int Last=Last_Z(s);
  //cout<<Last<<endl; 
  for(int i=0;i<=Last;++i) 
  {
  	if(ok&&i!=Last) { cnt++; /*cout<<s[i];*/ }
  	if(s[i]=='A'&&first) { /*cout<<s[i];*/ first=false; ok=true; cnt++; }
  	if(s[i]=='Z'&&!first&&i==Last) { /*cout<<s[i];*/ cnt++; break; }
  }
  /*cout<<endl;*/
  cout<<cnt<<endl;
  system("pause");
  return 0;
}


Measured memory_bytes: 840
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
    int N, X;
    cin >> N >> X;
    int m[N];
    for (int i = 0; i < N; ++i) {
        cin >> m[i];
    }

    sort(m, m + N);

    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        X -= m[i];
        cnt++;
    }

    cnt += X / m[0];

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
#define maxn 85
const int pax = 80 * 80;
const int inf = 12345678 ; 
int n, m, a[maxn][maxn], b[maxn][maxn], dp[maxn][maxn][maxn * maxn * 2], Ans = inf ;
signed main() {
	n = gi(), m = gi();
	rep(i, 1, n) rep(j, 1, m) a[i][j] = gi();
	rep(i, 1, n) rep(j, 1, m) b[i][j] = gi() - a[i][j];
	dp[1][1][pax - b[1][1]] = dp[1][1][pax + b[1][1]] = 1;
	rep(i, 1, n) {
		rep(j, 1, m) {
			rep(k, 0, pax * 2) {
				if(dp[i][j][k] == 0) continue;
				dp[i + 1][j][k + b[i + 1][j]] = 1;
				dp[i + 1][j][k - b[i + 1][j]] = 1;
				dp[i][j + 1][k + b[i][j + 1]] = 1;
				dp[i][j + 1][k - b[i][j + 1]] = 1;
			}
		}
	}
	rep(k, 0, pax * 2) if(dp[n][m][k] == 1) Ans = min(Ans, abs(k - pax));
	cout << Ans;
	return 0;
}

Measured memory_bytes: 778624
n,m = gets.split(/ /).map(&:to_i)
a = gets.split(/ /).map(&:to_i).sort{|a,b| b <=> a}
sum = a.inject(&:+).to_f / (4 * m) 
result = 'Yes'
m.times do |i|
  if a[i] < sum
    result = 'No'
  end
end
puts result

Measured memory_bytes: 1788
N=int(input())

while N!=0:
    K=list(map(int,input().split()))
    K=[i for i in K if i!=0]
    K_check=[i for i in K if i>=2]
    if len(K_check)==0:
        print("NA")
    else:
        print(len(K)+1)
    N=int(input())


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

int A, B, C, x, cnt;

int main(void) {
    cin >> A >> B >> C >> x;
    
    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= C; k++) {
                if (500 * i + 100 * j + 50 * k == x) {
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<(int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;

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

  int n, d;
  cin >> n >> d;
  wi x(n, vi(d));
  rep(i, n)rep(j, d)cin >> x[i][j];

  int cnt=0;
  rep(i, n){
    for(int j=i+1; j<n; j++){
      int sum=0;
      rep(k, d){
        sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      rep(k, 126)if((k+1)*(k+1)==sum)cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int A[N];
    for (int i=0;i<N;i++){
        cin >> A[i];
    }
    
    int m=0;
    int n= 1000000000;
    for (int i=0;i<N;i++){
        m = max(m,A[i]);
        n = min(n,A[i]);
    }
    cout << m-n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FR first
#define SE second

using namespace std;

typedef pair<int,int> pr;

int num[200005];
pr st[400005];

bool check(int n,int d) {
  int top=0;
  for(int i=1;i<=n;i++)
    if (num[i]>num[i-1]) st[++top]=pr(1,num[i]-num[i-1]);
    else {
    	int len=num[i-1];
    	while (len>num[i])
    	  if (len-st[top].SE>=num[i]) len-=st[top--].SE;
    	  else {
    	  	st[top].SE-=len-num[i];
    	  	break;
		  }
		while (top&&st[top].FR==d) len-=st[top--].SE;
		if (!top) return 0;
		if (st[top].SE>1) {
			st[top].SE--;
			st[++top]=pr(1,1);
		}
		st[top].FR++;
		if (len<num[i]) st[++top]=pr(1,num[i]-len);
	}
  return 1;
}

int main() {
  int n;
  scanf("%d",&n);
  bool v=1;
  for(int i=1;i<=n;i++) {
    scanf("%d",&num[i]);
    if (num[i]<=num[i-1]) v=0;
  }
  if (v) {
  	puts("1");
  	return 0;
  }
  int l=2,r=n;
  while (l<r) {
  	int m=((l+r)>>1);
  	if (check(n,m)) r=m; else l=m+1;
  }
  printf("%d\n",l);
  return 0;
}

Measured memory_bytes: 1536
o=->a,n{n<1?1:a**n[0]*o[a,n/2]**2%M}
eval'N,A,B='+`dd`.split*?,
a=o[A*=t=o[A+B,-2+M=10**9+7],N]
b=o[B*=t,N]
f=k=1,*(1..N-1).map{|i|k=k*i%M}
g=k
N.times{|i|$.=($.+o[g*f[i],M-2]*(a+b)*100*t*k=k*(N+i)%M)%M
a=a*B%M
b=b*A%M}
p$.

Measured memory_bytes: 3716
#include<stdio.h>
int fun(int x)
{
    return x*x;
}
int main()
{
    int n,s[102];
    while(~scanf("%d",&n))
    {
        int i,minn=101,maxx=-101;
        for(i=1;i<=n;i++)
        {
            scanf("%d",&s[i]);
            if(s[i]>maxx)maxx=s[i];
            if(s[i]<minn)minn=s[i];
        }
        int zz,minnn=9999999;
        zz=(maxx-minn)/100;
        for(i=minn+zz;i<=maxx-zz;i++)
        {
            int j,sum=0;
            for(j=1;j<=n;j++)
            {
                sum+=fun(s[j]-i);
            }
            if(sum<=minnn)minnn=sum;
        }
        printf("%d\n",minnn);
    }
}


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

int main(){
  char a[7];
  for(int i=0;i<6;i++){
    cin>>a[i];
  }
  if(a[0]==a[5]&&a[1]==a[4]&&a[2]==a[3]){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#define INF 1e8
using namespace std;

int n;
string str[14];
vector<string> name;
bool ok[14];

int data[14][14];
int dp[1<<14][15];

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin >> str[i];
		}
		name.clear();
		memset(ok,true,sizeof(ok));
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(str[j].size()<str[i].size())continue;
				for(int k=0;k<str[j].size()-str[i].size();k++){
					string st=str[j].substr(k,str[i].size());
					if(st==str[i])ok[i]=false;
				}
			}
		}
		for(int i=0;i<n;i++){
			if(ok[i])name.push_back(str[i]);
		}
		n=name.size();
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i==j)continue;
				string st=name[i];
				while(st.size()>0){
					if(st==name[j].substr(0,st.size()))break;
					st=st.substr(1);
				}
				data[i][j]=st.size();
			}
		}
		for(int i=0;i<(1<<n);i++){
			for(int j=0;j<n;j++){
				dp[i][j]=INF;
			}
		}
		dp[0][n]=0;
		for(int i=0;i<(1<<n);i++){
			for(int j=0;j<=n;j++){
				if(dp[i][j]!=INF){
					for(int k=0;k<n;k++){
						if(i>>k & 1)continue;
						int len=name[k].size();
						if(j==n){
							dp[1<<k][k]=len;
						}else{
							dp[i|(1<<k)][k]=min(dp[i|(1<<k)][k],dp[i][j]+len-data[j][k]);
						}
					}
				}
			}
		}
		int res=dp[(1<<n)-1][0];
		for(int i=1;i<n;i++){
			res=min(dp[(1<<n)-1][i],res);
		}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 2212
#include<stdio.h>
int main(void){
	int a,b,c;
	int x;
	int i;
	scanf("%d %d %d",&a,&b,&c);
	for(x = a;x <= b;x++){;
		if(c % x == 0){
			i++;
		}
	}
	printf("%d\n",i);
	return 0;
}


Measured memory_bytes: 2000
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

int main(){
  int sx, sy, tx, ty;
  scanf("%d %d %d %d", &sx, &sy, &tx, &ty);

  int x = tx - sx;
  int y = ty - sy;
  REP(i, 0, y){
    printf("U");
  }
  REP(i, 0, x){
    printf("R");
  }
  REP(i, 0, y){
    printf("D");
  }
  REP(i, 0, x){
    printf("L");
  }

  printf("L");
  REP(i, 0, y + 1){
    printf("U");
  }
  REP(i, 0, x + 1){
    printf("R");
  }
  printf("D");
  printf("R");
  REP(i, 0, y + 1){
    printf("D");
  }
  REP(i, 0, x + 1){
    printf("L");
  }
  printf("U\n");

  return 0;
}


Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  return 1110-next();
}

Measured memory_bytes: 7372
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

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

void main() {
    int a, b, c; scan(a, b, c);

    int ans = c - min(a - b, c);
    writeln(ans);
}


Measured memory_bytes: 256
use std::io;

/// 一行を読み込んで、空白で区切ったベクタにして返す
#[allow(dead_code)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect()
}

/// n行を読み込んで、数字を空白で区切って二次元のベクタにして返す
#[allow(dead_code)]
fn read_table<T>(n: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut ret: Vec<Vec<T>> = Vec::new();
    for _ in 0..n {
        ret.push(read::<T>());
    }
    ret
}

/// n行を読み込んで、1文字ずつを二次元のベクタにして返す
#[allow(dead_code)]
fn read_char_table(n: usize) -> Vec<Vec<char>> {
    let mut ret: Vec<Vec<char>> = Vec::new();
    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let chr = buf.trim().chars().collect();
        ret.push(chr);
    }
    ret
}

/// n行を読み込んで、一次元のベクタにして返す
#[allow(dead_code)]
fn read_array<T>(n: usize) -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut array = Vec::new();

    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        array.push(buf.trim().parse().unwrap());
    }
    array
}



fn main() {

    // 文字テーブル
    let mut buf1 = String::new();
    io::stdin().read_line(&mut buf1).unwrap();

    let sc = buf1.chars().collect::<Vec<char>>();
    let count = buf1.chars().count();

    let mut buf2 = String::new();
    io::stdin().read_line(&mut buf2).unwrap();
    let tc = buf2.chars().collect::<Vec<char>>();
    
    let mut c = Vec::<(char,char)>::with_capacity(1024);

    
    for i in 0..count {
        let mut  flag = true;
        for cc in &c {
            if cc.0 == sc[i] && cc.1 == tc[i] {
                flag = false;
            }
             
            if sc[i] != tc[i] {
                if cc.0 == sc[i] && cc.1 != tc[i] {
                    println!("No");
                    return;
                } else if cc.0 != sc[i] && cc.1 == tc[i] {
                    println!("No");
                    return;
                } 
            }

        }
        
        if flag { 
            c.push((sc[i], tc[i]));
        }
    }

    println!("Yes");

}

Measured memory_bytes: 6396
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int A, B;
  cin >> A >> B;
  cout << max(max(A+B, 2*A-1), 2*B-1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll fc[200010];
ll ifc[200010];

ll add(ll x, ll y){return (x+y)%MOD;}
ll mlt(ll x, ll y){return (x*y)%MOD;}
ll power(ll x, ll n){
  ll ans=1;
  while(n>0){
    if(n%2!=0)ans=mlt(ans, x);
    x=mlt(x,x);n/=2;
  }
  return ans;
}

ll inv(ll x){return power(x, MOD-2);}

void fct(){
  fc[0]=1;
  for (int i=0;i<200009;++i){fc[i+1]=mlt(fc[i], i+1);}
}

void ifct(){
  ifc[200009]=inv(fc[200009]);
  for (int i=200009;i>=1;--i){ifc[i-1]=mlt(ifc[i], i);}
}

ll comb(int n, int k){return mlt(fc[n], mlt(ifc[k], ifc[n-k]));}

int main(){
  int N, A, B, C, D;cin>>N>>A>>B>>C>>D;

  fct();ifct();
  ll dp[1010][1010]={};dp[N][A-1]=1;

  for (int j=A;j<=B;++j){
    for (int i=N;i>=0;--i){
      dp[i][j]=dp[i][j-1];

      ll factor=1;
      for (int k=0;k++<C-1;){
        factor=mlt(factor, comb(i+j*k, j));
      }

      for (int k=C;k<=D;++k){
        if(i+j*k>N) break;
        factor=mlt(factor, comb(i+j*k,j));
        dp[i][j]=add(dp[i][j], mlt(dp[i+j*k][j-1],mlt(factor, ifc[k])));
      }
    }
  }

  cout << dp[0][B] << endl;
  return 0;
}

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

int in[1000001];
int dist[1000001];
bool vis[1000001];
vector<int> adj[1000001];

void dfs(int node){
    vis[node] = 1;
    for(int child: adj[node]){
        dist[child] = max(dist[child], dist[node] + 1);
        in[child]--;
        if(in[child] == 0)
            dfs(child);
    }
}

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    
    while(m--){
        int a, b;
        scanf("%d%d", &a, &b);
        adj[a].push_back(b);
        in[b]++;
    }
    
    for(int i = 1; i <= n; i++){
        if(!vis[i] && in[i] == 0)
            dfs(i);
    }
    
    int ans = 0;
    for(int i = 1; i <= n; i++)
        ans = max(ans, dist[i]);
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 35692
#include<iostream>
using namespace std;
int main(){
  int n,i[1000],p[1000],q[1000],r[1000];
  int P,Q,R,C,count;

  while(cin >> n && n!=0){
    count=0;
    for(int j=0;j<n;j++){
      
      cin >> i[j] >> p[j] >> q[j] >> r[j];
      
      
    }
    cin >> P >> Q >> R >> C;

    for(int j=0;j<n;j++){ 
    if(4*p[j]+9*q[j]+4*r[j]<=C &&p[j]<=P &&q[j]<=Q && r[j]<=R){
      cout <<i[j] << endl;
	count++;}
    else if(j==n-1 && count==0){
      cout << "NA" << endl;}
  }
  }
  

      
   

	return 0;
  	
}

Measured memory_bytes: 1172
#include<iostream>
#include<string.h>

using namespace std;

int main(){
	char kata[10];
	cin >> kata;
	if(kata[2] == kata[3] && kata[4] == kata[5]){
			cout << "Yes" << endl;
	}else{
		cout <<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3004
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int d[100000], n;
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> d[i];
	sort(d, d + n);
	n /= 2;
	cout << d[n] - d[n - 1]  << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include <algorithm>
#include <functional>
using namespace std;

long gcd(long a,long b){
	while(a!=b){
		if(a>b){
			a-=b;
		}else{
			b-=a;
		}
	}
	return a;
}

int main(){

	long a,b,c;

	while(cin >> a){
		cin >> b;
		c = gcd(a,b);
		printf("%d %d\n",c,a/c*b);
	}
	return 0;
}

Measured memory_bytes: 1136
#include <stdio.h>

int main()
{
	int n, a, tes;
	
	scanf("%d %d", &n, &a);
	
	int i;
	for(i=0; i<n; i++) {
		scanf("%d",&tes);
	}
	
	i=0;
	if((n-1)%(a-1)!=0) i=1;
	printf("%d", i+(n-1)/(a-1));
	
	return 0;
}


Measured memory_bytes: 128
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
ng = set([int(input()) for _ in range(M)])
ans = [0, 1] 
for i in range(1, N+1):
  if i in ng:
    ans.append(0)
  else:
    ans.append((ans[-2] + ans[-1]) % MOD)
print(ans[-1] % MOD)



Measured memory_bytes: 13124
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
ll fact[1000007]={0}; // returns factorial of that number
bool sv[maxx]={0};    // returns if a num is prime or not
int sp[maxx]={0};     // gives smallest prime factor of the number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
void Sieve() {for(int i= 2; i< maxx; i+= 2)sp[i] = 2;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
*/
using namespace std;
signed main(){
  fast;
  //usefile;
  //test
  {
    int n,temp;
    unordered_set<int> s;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        s.insert(temp);
    }
    // cout<<s.size();
    if(s.size()==n)
        cout<<"YES";
    else
    {
        cout<<"NO";
    }
    
  }
  //time("");
  return 0;
}

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

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define pf push_front
#define pb push_back
#define FST first
#define SEC second
#define sz(obj) ((int)(obj).size())

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

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

  int n;
  
  while (cin >> n, n){
    int dp[35] = {0};
    int cnt = 0, ans;

    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 2;

    for (int i = 3; i <= n; i++){
      dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
    }
    ans = dp[n] / 3650;
    if (dp[n] % 3650) ans += 1;
    cout << ans << endl;
  }
}

Measured memory_bytes: 1192
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

long long comb(long long n, long long r) {
    long long r_buf = (r <= n/2) ? r : n-r;
    if (r_buf == 0) return 1;
    else return (n-r_buf+1) * comb(n, r_buf-1) / r_buf;
}

int main() {
    int n = 0, p = 0;
    cin >> n >> p;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
       cin >> a.at(i);
    }
    int odd = 0, even = 0;
    for (int i=0; i<n; i++) {
       if (a.at(i)%2 == 0) {
           even++;
       }
       else {
           odd++;
       }
    }
    ll ans = 0;
    while (p <= odd) {
        ans += comb(odd, p);
        p += 2;
    }
    ll buf = 1;
    while (even > 0) {
        buf *= 2;
        even--;
    }
    cout << ans * buf << endl;
    return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int m, n;
int xm[210], ym[210], xn[1010], ynn[1010], x, y;
typedef pair<int, int> P;
typedef map<P, int> mp;
int main(){
  while(1){
    mp p;
    cin >> m;
    if(m == 0) break;
    for(int i = 0; i < m; i++){
      cin >> xm[i] >> ym[i];
    }
    cin >> n;
    for(int i = 0; i < n; i++){
      cin >> xn[i] >> ynn[i];
    }
    for(int i = 0; i < m; i++){
      for(int j = 0; j < n; j++){
	p[P(xn[j] - xm[i], ynn[j] - ym[i])]++;
	x = xn[j] - xm[i];
	y = ynn[j] - ym[i];
	if(p[P(xn[j] - xm[i], ynn[j] - ym[i])] == m) break;
      }
    }
    cout << x << " " << y << endl;
  }
}

Measured memory_bytes: 13636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = 0;

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                var rev = input.Reverse().ToArray();

                if (input == new string(rev)) count++;
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 9292
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	ll x; int p; cin >> x >> p;
	cout << fixed << setprecision(7);
	if (x % 2) {
		cout << (ld)50 * (x + 1) / p << endl;
	}
	else {
		cout << (ld)50 * x / p << endl;
	}
	return 0;
}

Measured memory_bytes: 256
open System

let [|n; x|] = stdin.ReadLine().Split() |> Array.map int
let a = 
    stdin.ReadLine().Split() 
    |> Array.map int 
    |> Array.sort 
    |> List.ofArray

let rec f k = function 
    | [x] -> if k = x then 1 else 0
    | x :: xs -> if k >= x then 1 + f (k-x) xs else 0

printfn "%d" <| f x a



Measured memory_bytes: 14812
import sys
from collections import deque


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    A = list(map(int, input().split()))

    dp = [[0] * (N + 1) for _ in range(N + 1)]

    for i in range(N):
        dp[i][i] = A[i]

    for k in range(1, N):  # distance
        for i in range(N):  # start grid
            if i + k >= N:
                break
            dp[i][i + k] = max(A[i + k] - dp[i][i + k - 1], A[i] - dp[i + 1][i + k])

    print(dp[0][N-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 132960
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N;
    cin >> N;
    VI p(N);
    REP(i, N) cin >> p[i];

    VI p_sorted = p;
    SORT(p_sorted);

    int diff = 0;
    REP(i, N) diff += p[i] != p_sorted[i];

    cout << (diff == 0 || diff == 2 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n,a,b,c;
    cin >> n >> a >> b >> c;
    vector <char> ans;
    string s[n];
    for(int i=0;i<n;i++)
        cin >> s[i];
    for(int i=0;i<n;i++){
        string st=s[i];
        if(st=="AB"){
            if(a==1 and b==1 and i<n-1){
                if(s[i+1][0]=='A')
                    ans.push_back('A'),a++,b--;
                else
                    ans.push_back('B'),a--,b++;
            }
            else if(a<b){
                ans.push_back('A');
                a++,b--;
            }
            else{
                ans.push_back('B');
                b++,a--;
            }
        }
        if(st=="AC"){
            if(a==1 and c==1 and i<n-1){
                if(s[i+1][0]=='A')
                    ans.push_back('A'),a++,c--;
                else
                    ans.push_back('C'),a--,c++;
            }
            else if(a<c){
                ans.push_back('A');
                a++,c--;
            }
            else{
                ans.push_back('C');
                a--,c++;
            }
        }
        if(st=="BC"){
            if(b==1 and c==1 and i<n-1){
                if(s[i+1][1]!='C')
                    ans.push_back('B'),b++,c--;
                else
                    ans.push_back('C'),b--,c++;
            }
            else if(b<c){
                ans.push_back('B');
                b++,c--;
            }
            else{
                ans.push_back('C');
                b--,c++;
            }
        }
        if(a<0 or b<0 or c<0){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes\n";
    for(auto i:ans)
        cout << i << '\n';
}

Measured memory_bytes: 6920
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::{i32, i64, i128, u32, u64, u128, f64};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};
#[allow(unused_imports)]
use proconio::marker::{Isize1, Usize1, Bytes, Chars};
use core::f64::consts::PI;

#[proconio::fastout]
fn main() {
    proconio::input!{
        a: i32,
        b: i32,
        h: i32,
        m: i32,
    }
    let (a, b, h, m) = (a as f64, b as f64, h as f64, m as f64);
    let h = h + m / 60.0;
    let (xh, yh) = (a * (2.0 * PI * h / 12.0).cos(), a * (2.0 * PI * h / 12.0).sin());
    let (xm, ym) = (b * (2.0 * PI * m / 60.0).cos(), b * (2.0 * PI * m / 60.0).sin());
    println!("{}", (xh - xm).hypot(yh - ym));
}


Measured memory_bytes: 2972
x,y,z = map(int,input().split())
n = sorted([x,y,z])
a = n[0]
b = n[1]
c = n[2]
count = 0
count += (c-a)//2
a += ((c-a)//2)*2
count += (c-b)//2
b += ((c-b)//2)*2
if a==b and a==c:
    print(count)
elif a!=b:
    print(count+2)
else:
    print(count+1)

Measured memory_bytes: 38484
#include <stdio.h>

int gcd(int a, int b) {
	while (b > 0) {
		int r = a % b;
		a = b;
		b = r;
	}
	return a;
}

#define MAX 1123456

int N;
int A[MAX];

int era[MAX];
int exists[MAX];

int main(void) {
	int i, j;
	int good = 1;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	for (i = 2; i < MAX; i++) {
		if (era[i] == 0) {
			era[i] = i;
			for (j = i + i; j < MAX; j += i) {
				if (era[j] == 0) era[j] = i;
			}
		}
	}
	for (i = 0; i < N; i++) {
		if (A[i] > 1) {
			if (exists[era[A[i]]] > 0 && exists[era[A[i]]] < i + 1) good = 0;
			exists[era[A[i]]] = i + 1;
			j = A[i] / era[A[i]];
			while (j > 1) {
				if (exists[era[j]] > 0 && exists[era[j]] < i + 1) good = 0;
				exists[era[j]] = i + 1;
				j /= era[j];
			}
		}
	}
	if (good) {
		puts("pairwise coprime");
	} else {
		int g = A[0];
		for (i = 1; i < N; i++) g = gcd(g, A[i]);
		printf("%s coprime\n", g == 1 ? "setwise" : "not");
	}
	return 0;
}

/*

2 * 3  * 7 = 42
5 * 7 = 35

2
42 35

3
3 3 4

*/


Measured memory_bytes: 13868
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main(void) {
	int n, a, b, c = 0;
	cin >> n;
	vector<int> p(n), q(n), x(n);
	rep(i, 0, n)cin >> p[i];
	rep(i, 0, n)cin >> q[i];
	rep(i, 0, n)x[i] = i + 1;
	do {
		bool ok = true;
		rep(i, 0, n) {
			if (p[i] != x[i]) { ok = false; break; }
		}
		if (ok)a = c;
		ok = true;
		rep(i, 0, n) {
			if (q[i] != x[i]) { ok = false; break; }
		}
		if (ok)b = c;
		c++;
	} while (next_permutation(all(x)));
	printf("%d\n", abs(a - b));
	return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

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

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

bool solve() {
	int W, D; cin >> W >> D;
	if (W == 0 && D == 0) return (false);
	vint h1(W), h2(D); cin >> h1 >> h2;
	for (int i = 0; i < W; i++) {
		for (int j = 0; j < D; j++) {
			if (h1[i] == h2[j]) { 
				h2[j] = 0;
				break;
			}
		}
	}
	int sum = 0;
	for (auto &v : h1) sum += v;
	for (auto &v : h2) sum += v;
	cout << sum << el;
	return (true);
}

void Main() {
	while (solve());
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}



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

#define MAX 123456
bool isPrime[MAX * 2 + 1];
int primes[MAX * 2 + 1] = {0};

int main() {
	for (int i = 0; i <= MAX * 2; i++) {
		isPrime[i] = true;
	}
	isPrime[0] = isPrime[1] = false;
	for (int i = 2; i <= MAX * 2; i++) {
		if (isPrime[i]) {
			for (int j = 2 * i; j <= MAX * 2; j += i) {
				isPrime[j] = false;
			}
		}
	}

	int p = 0;
	for (int i = 2; i <= MAX * 2; i++) {
		if (isPrime[i]) p++;
		primes[i] = p;
	}

	int n;
	while (cin >> n, n != 0) {
		cout << primes[2 * n] - primes[n] << endl;
	}
}

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

ans = []

ans.append(
        int((sum(s) * 0.5 - sum(s[1::2]))*2)
        )
for i in range(n-1):
    ans.append(int((s[i]-ans[i]/2)*2))

print(*ans)

Measured memory_bytes: 14032
/* be name khoda */

// #define stream_enable
#define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl;
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl;
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl;
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl;
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl;
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = (a + (b)) % MOD
#define Mul(a, b) a = (a * (b)) % MOD

stringstream sss;

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

const ll maxn = 100010;

void MAIN() {

    ll n, m;
    cin >> n >> m;
    if (m < n) swap(n, m);
    fori (i, m) {
        cout << n;
    }
    cout << '\n';

}

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

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(

    )";
    MAIN();
    return 0;
}


Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
//#define int ll
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 1e5 + 123;
int n,q;

main(){
//	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n , a , b;
	cin >> n >> a >> b;
	if((b - a)%2 == 1)
		cout << "Borys\n"; 
	else ret("Alice");
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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 <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        if (a[i - 1] > a[i]) {
            ans += a[i - 1] - a[i];
            a[i] = a[i - 1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4852
package main

import (
    "bufio"
    "fmt"
    "os"
)

var r = bufio.NewReader(os.Stdin)

func main() {
    var a,b,c int
    fmt.Fscan(r,&a)
    fmt.Fscan(r,&b)
    fmt.Fscan(r,&c)
    if a <= b&&b <= c{
        fmt.Println(a, b, c)
    }else if a <= c&&c <= b{
        fmt.Println(a, c, b)
    }else if b <= a&&a <= c{
        fmt.Println(b, a, c)
    }else if b <= c&&c <= a{
        fmt.Println(b, c, a)
    }else if c <= a&&a <= b{
        fmt.Println(c, a, b)
    }else if c <= b&&b <= a{
        fmt.Println(c, b, a)
    }
}


Measured memory_bytes: 1144
def resolve():
    # 想定解：bitを選択しない行列(変化しない)での"#"個数を数える
    H, W, K = map(int, input().split())
    G = [list(input()) for _ in range(H)]

    ans = 0
    for bit_i in range(1<<H):
        for bit_j in range(1 << W):
            cnt = 0
            for i in range(H):
                for j in range(W):
                    if (bit_i>>i & 1) or (bit_j>>j & 1):
                        continue
                    if G[i][j] == "#":
                        cnt += 1
            if cnt == K:
                ans += 1
    print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9128
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
  int n;
  cin >> n;
  map<int,int> cnt;
  for(int x=1;x<=100;x++){
    for(int y=1;y<=100;y++){
      for(int z=1;z<=100;z++){
        int m=x*x+y*y+z*z+x*y+y*z+z*x;
        if(cnt.count(m)){
          cnt.at(m)++;
        }
        else{
          cnt[m]=1;
        }
      }
    }
  }
  rep(i,n){
    if(cnt.count(i+1))cout << cnt.at(i+1)<< endl;
    else cout << 0 << endl;
  }
}


Measured memory_bytes: 5384