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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
const int INF = 0x3f3f3f3f;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

struct Node {
    int value;
    Node *next;
    Node *prev;
};
Node *nil;

void init() {
    nil = new Node();
    nil->next = nil;
    nil->prev = nil;
}

void insert_node(int x) {
    Node *p = new Node;
    p->value = x;

    p->next = nil->next;
    nil->next->prev=p;
    nil->next=p;
    p->prev=nil;
}

Node* search_node(int x) {
    Node *cur = nil->next;
    while(cur != nil && cur->value != x) cur = cur->next;
    return cur;
}

void delete_node(Node *p) {
    if(p == nil) return;
    p->prev->next=p->next;
    p->next->prev=p->prev;
    delete p;
}
void delete_first_node() {
    delete_node(nil->next);
}
void delete_last_node() {
    delete_node(nil->prev);
}
void delete_key_node(int x) {
    delete_node(search_node(x));
}

int main() {
    ios::sync_with_stdio(false);
    init();
    int n;
    string q;
    cin>>n;
    while(n--) {
        int x;
        cin>>q;
        if(q=="insert") {
            cin>>x;
            insert_node(x);
        }
        else if(q=="delete") {
            cin>>x;
            delete_key_node(x);
        }
        else if(q=="deleteFirst") {
            delete_first_node();
        }
        else if(q=="deleteLast") {
            delete_last_node();
        }
    }
    int t=0;
    Node *cur = nil->next;
    while(cur != nil) {
        if(t++) cout<<" ";
        cout<<cur->value;
        cur=cur->next;
    }
    cout<<endl;
    
    return 0;
}

Measured memory_bytes: 34396
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

signed main()
{
  string S;
  cin >> S;
  int N = S.size();
  
  int ans = INF;
  for (int i = 0; i < abc.size(); i++)
  {
    char key = abc.at(i);
    int opp = 0;
    int opp0 = 0;
    for (int j = 0; j <= N; j++)
    {
      if (j == N || S.at(j) == key)
      {
        chmax(opp, opp0);
        opp0 = 0;
      }
      else opp0++;
    }
    chmin(ans, opp);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f(0, []).
f(X, ['+'|Cs]) :- f(X2, Cs), X is X2 + 1, !.
f(X, ['-'|Cs]) :- f(X2, Cs), X is X2 - 1, !.

main :-
	get_string(S),
    string_chars(S, S2),
    f(X, S2),
    writeln(X).


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

using namespace std;

int main() {
  int n; cin >> n;
  multiset <int> s;
  for(int i = 0; i < n; i++) {
    int x; cin >> x;
    auto cur = s.lower_bound(x);
    if(cur == s.begin()) {
      s.insert(x);
    } else {
      cur--;
      s.erase(cur);
      s.insert(x);
    }
  }
  cout << s.size() << '\n';
}

Measured memory_bytes: 4992
def solve():
    Ss = input().rstrip()
    Ts = input().rstrip()

    lenS, lenT = len(Ss), len(Ts)

    dp = [[0]*(lenT+1) for _ in range(lenS+1)]
    for iS, S in enumerate(Ss, start=1):
        dp0 = dp[iS-1]
        dpi = dp[iS]
        for jT, T in enumerate(Ts, start=1):
            if S == T:
                dpi[jT] = dp0[jT-1] + 1
            else:
                dpi[jT] = dpi[jT-1]
                if dp0[jT] > dpi[jT]:
                    dpi[jT] = dp0[jT]

    anss = ''
    iS, jT = lenS, lenT
    while True:
        if Ss[iS-1] == Ts[jT-1]:
            anss += Ss[iS-1]
            iS, jT = iS-1, jT-1
        elif dp[iS-1][jT] >= dp[iS][jT-1]:
            iS -= 1
        else:
            jT -= 1
        if iS == 0 or jT == 0:
            break

    print(anss[::-1])


solve()


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

int main() {
  while(1) {
    int n;
    cin >> n;
    if(n == -1) break;

    double rad;
    double x = 0, y = 0;
    for(int i = 0; i < n; i++) {
      if(i == 0) rad = 0;
      else       rad -= M_PI/2;
      x += cos(rad);
      y += sin(rad);
      rad = atan2(-y, -x);
    }
    printf("%.2f\n%.2f\n", x, y);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define INF (1LL<<50)
#define s second
#define f first
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;
typedef pair<ll,P> PP;
ll G[200][200][2];
int n,m,r,z[1000];

void WF(){
  for(int k=0;k<n;k++)
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++){
	G[i][j][0]=min(G[i][j][0],G[i][k][0]+G[k][j][0]);
	G[i][j][1]=min(G[i][j][1],G[i][k][1]+G[k][j][1]);
      }
}


ll dijkstra(){
  vector<vector<ll> > D(n,vector<ll>(r,INF));
  priority_queue<PP,vector<PP>,greater<PP> > Q;
  Q.push(PP(0,P(z[0],0)));
  D[z[0]][0] = 0;

  while(!Q.empty()){
    PP t=Q.top();Q.pop();
    ll cost=t.f,ship=t.s.f,idx=t.s.s,pos=z[idx];
    if(idx==r-1)return cost;
    if(D[ship][idx]<cost)continue;
    
    int npos=z[idx+1];
    ll ncost=cost+G[pos][npos][0];
    if(D[ship][idx+1]>ncost)Q.push(PP(ncost,P(ship,idx+1))),D[ship][idx+1]=ncost;

    for(int i=0;i<n;i++){
      ncost=cost+G[pos][ship][0]+G[ship][i][1]+G[i][npos][0];
      if(D[i][idx+1]>ncost)Q.push(PP(ncost,P(i,idx+1))),D[i][idx+1]=ncost;
    }
  }
  assert(0);
} 

int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m)break;
    for(int i=0;i<n;i++) 
      for(int j=0;j<n;j++) G[i][j][0]=G[i][j][1]=INF*(i!=j);
    
    for(int i=0,x,y,c,idx;i<m;i++){
      char ch;
      cin>>x>>y>>c>>ch;x--,y--;
      idx=(ch=='S');
      G[x][y][idx]=G[y][x][idx]=min(G[x][y][idx],(ll)c);
    }
    cin>>r;
    for(int i=0;i<r;i++)cin>>z[i],z[i]--;
    WF();
    cout <<dijkstra()<<endl;
  }
  return 0;
}

Measured memory_bytes: 5284
#include <bits/stdc++.h>
#define Maxn 207
using namespace std;
int T,n;
long long a[Maxn];
int op[Maxn];
long long r[62];
bool add(long long x)
{
    for (int i=60;i>=0;i--)
        if (x&(1LL<<i))
        {
            if (r[i]) x^=r[i];
            else
            {
                r[i]=x;
                return true;
            }
        }
    return false;
}
void solve()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for (int i=1;i<=n;i++)
    {
        char ch=getchar();
        while (ch!='0'&&ch!='1') ch=getchar();
        if (ch=='0') op[i]=0; else op[i]=1;
    }
    memset(r,0,sizeof(r));
    for (int i=n;i;i--)
    {
        if (op[i]==0) add(a[i]);
        else if (op[i]==1&&add(a[i]))
        {
            printf("%d\n",1);
            return;
        }
    }
    printf("%d\n",0);
}
int main()
{
    scanf("%d",&T);
    while (T--) solve();
    return 0;
}

Measured memory_bytes: 3808
N=int(input())
A=list(map(int,input().split()))

mod=10**9+7
A=sorted(A)
possible=1
if N%2==1:
    if A[0]!=0:
        possible=0
    for i in range(1,N):
        if A[i]!=i+i%2:
            possible=0
            break
    if possible==1:
        ans=2**((N-1)//2)%mod
    else:
        ans=0
else:
    for i in range(N):
        if A[i]!=i+(i+1)%2:
            possible=0
            break
    if possible==1:
        ans=2**(N//2)%mod
    else:
        ans=0
print(ans)

Measured memory_bytes: 13880
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

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

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
キュー　queue<int> q;
   q.push(7);　//７が入る
   cout << q.front() << endl;  // 先頭の値を出力
   q.pop();  // 先頭の値を削除
   q.empty();
*/
//座標　corrdinateト深さヲ保持スルタメノ構造体
struct Coor{
  ll y;
  ll x;
  ll depth;
};
 ll N,M;  
 ll sy,sx,gy,gx;
 ll y,x,depth;//キューから取り出した座標
vector<string> vec;
queue<Coor> q;
vector<ll> y_vec={0,0,-1,+1};//technique
vector<ll> x_vec={-1,+1,0,0};

int BFS(){
  while(!q.empty()){
    Coor now=q.front();q.pop();//キューの先頭を取り出す
    y=now.y,x=now.x,depth=now.depth;
    
    //停止条件
    if(y==gy&&x==gx){return depth;}
    
    //上下左右４方向を探索、進むことができればキューに格納
    for(int i=0;i<4;i++){
      Coor next={y+y_vec[i],x+x_vec[i],depth+1};
      if(0<=next.y&&next.y<=N-1&&0<=next.x&&next.x<=M-1&&vec[next.y][next.x]=='.'){
        vec[next.y][next.x]='x';//同じ場所を探索しないようにする
        q.push(next);
      }
    }
  }
  return 0;
}
                   
  


int main(void){
cout<<fixed<<setprecision(14);
//cin.tie(0); ios::sync_with_stdio(false);

int a,b,c;cin>>a>>b>>c;
  int counter=0;
  if(a!=b)counter++;
   if(b!=c)counter++;
   if(c!=a)counter++;
  
if(counter==0)counter++;
  
  cout<<counter<<endl;
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<pair<int, int> > lines;
    for (int i=0; i < 3*n; i++){
        lines.push_back({0, 0});
        lines.push_back({0, 1});
    }
    if (s[0] != '0') lines.push_back({0, 0});
    for (int i=0; i < n-1; i++){
        if (s[i] != s[i+1]){
            lines.push_back({i+1, s[i] - '0'});
        }
    }
    if (s[s.size() - 1] == '1') lines.push_back({n, 1});
    for (int i=0; i < 3*n; i++){
        lines.push_back({n, 0});
        lines.push_back({n, 1});
    }
    string t;
    cin >> t;
    vector<pair<int, int> > lw;
    for (int i=0; i < n; i++){
        lw.push_back({0, 0});
        lw.push_back({0, 1});
    }
    if (t[0] != '0') lw.push_back({0, 0});
    for (int i=0; i < n-1; i++){
        if (t[i] != t[i+1]){
            lw.push_back({i+1, t[i] - '0'});
        }
    }
    if (t[t.size() - 1] == '1') lw.push_back({n, 1});
    for (int i=0; i < n; i++){
        lw.push_back({n, 0});
        lw.push_back({n, 1});
    }
    int ans = 1e18;
    //for (int i=0; i < lines.size();i++) cout << lines[i].first << " " << lines[i].second << endl;
    for (int i=0; i <= lines.size()-lw.size();i++){
        int tet=0;
        if (lines[i].second != lw[0].second) continue;
        for (int j=0; j < lw.size(); j++) tet += abs(lw[j].first - lines[i+j].first);
        ans = min(ans, tet);
        //cout << i << " " << tet << endl;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 2164
# 入力を受け取る
ary = gets.chomp.split.map(&:to_i)
n = ary[0]
y = ary[1]
flg = nil
# 全ての通りを調べてyと一致したらbreak
for i in 0..n do
  for j in 0..(n-i) do
    # sumを初期化
    sum = 0
    # sumを計算
    sum = i*10000+j*5000+1000*(n-i-j)
    if sum == y then
      puts(i.to_s+" "+j.to_s+" "+(n-i-j).to_s)
      flg = 0
      break
    end
  end
  if flg
    break
  end
end
if flg==nil
  puts("-1 -1 -1")
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

ll o[100005];

int main()
{
	FAST;
	string s;
	cin >> s;
	ll n = s.length(), i;
	vl r, l;
	fr(i,0,n)
	{
		if(s[i] == 'L')
			l.pb(i);
		else
			r.pb(i);
	}
	ll lp = 0, rp = 0;
	fr(i,0,n)
	{
		if(s[i] == 'R')
		{
			while(1)
			{
				if(l[lp] > i)
					break;
				lp++;
			}
			ll tmp = l[lp] - i;
			if(tmp % 2 == 0)
				o[l[lp]]++;
			else
				o[l[lp] - 1]++;
		}
		if(s[i] == 'L')
		{
			while(1)
			{
				if(r[rp] > i)
					break;
				rp++;
				if(rp == r.size())
					break;
			}
			rp--;
			ll tmp = i - r[rp];
			if(tmp % 2 == 0)
				o[r[rp]]++;
			else
				o[r[rp] + 1]++;
		}
	}
	fr(i,0,n)
		cout << o[i] << " ";
}


Measured memory_bytes: 2372
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())


n = I()
a = LI()
ans = a[0]
if 0 in a:
    print(0)
    sys.exit()

for ai in a[1:]:
    ans *= ai
    if ans > 10 ** 18:
        ans = -1
        break

print(ans)


Measured memory_bytes: 85404
#include<iostream>

#include<set>
#include<algorithm>

using namespace std;

int main(){
	int n,g,g2,ans=0,ans2=0;
	char a='a';
	string s;
	cin>>n>>s;
	for(int j=0;j<n;j++){
		for(int i=0;i<26;i++){
			for(int x=0;x<n;x++){
				if(x<=j && s[x]==a)g=1;
				if(x>j && s[x]==a)g2=1;
			}
			a++;
			if(g==1 && g2==1){
				ans++;
			}
			g=0;
			g2=0;
		}
		ans2=max(ans,ans2);
		ans=0;
		a='a';
	}
	cout<<ans2<<endl;		
	
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;

typedef long long signed int ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(obj) (obj).begin(),(obj).end()

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
string S;
string t;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>S;
	int tmp = 0;
	REP(i, 4) {
	    tmp=0;
		REP(j, 4) {
			if (S[i] == S[j]) {
				tmp++;
			}
		}
		if (tmp != 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

int main() {
  int n,x;
  cin>>n>>x;
  vector<int> a(n);
  
  for (int i = 0; i < n; i++) {
  cin>>a[i];
  }
  
  sort(a.begin(),a.end());
  
  int sum=0;
  int ans=0;
  
  for(int i=0;i<n;i++){
    sum+=a[i];
    if(x>=sum)ans++;
    else break;
  }
  
  if(x>sum)ans--;
  
  cout<<ans<<endl;
  
  
  
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

#define max_n 100

int v[max_n][max_n]; //上面にかかれた数
int h[max_n][max_n]; //サイコロの高さ
int geta = max_n/2; //中央(geta,geta)
int p[7][7] = {};

void fall(int x, int y, int top, int front, int side){

    for(int i = 6; i >= 4; i--){
        if(top != i && top != 7-i){//iが側面にある
            if(front == i){
                if(h[x-1][y] >= h[x][y])continue;
                fall(x-1, y, 7-front, top, p[7-front][top]);
            }else if(front == 7-i){
                if(h[x+1][y] >= h[x][y])continue;
                fall(x+1, y, front, 7-top, p[front][7-top]);
            }else if(side == i){
                if(h[x][y+1] >= h[x][y])continue;
                fall(x, y+1, 7-side, front, top);
            }else if(side == 7-i){
                if(h[x][y-1] >= h[x][y])continue;
                fall(x, y-1, side, front, 7-top);
            }
            return;
        }
    }


    h[x][y]++;
    v[x][y] = top;
}

int main(void) {
    int i,j;
    int n;

    p[1][2] = 3;
    p[1][3] = 5;
    p[1][4] = 2;
    p[1][5] = 4;

    p[2][1] = 4;
    p[2][3] = 1;
    p[2][4] = 6;
    p[2][6] = 3;

    p[3][1] = 2;
    p[3][2] = 6;
    p[3][5] = 1;
    p[3][6] = 5;

    p[4][1] = 5;
    p[4][2] = 1;
    p[4][5] = 6;
    p[4][6] = 2;

    p[5][1] = 3;
    p[5][3] = 6;
    p[5][4] = 1;
    p[5][6] = 4;

    p[6][2] = 4;
    p[6][3] = 2;
    p[6][4] = 5;
    p[6][5] = 3;

    while(cin >> n, n){
        rep(i,max_n)rep(j,max_n){
            v[i][j] = 0;
            h[i][j] = 0;
        }

        rep(i,n){
            int t,f;
            cin >> t >> f;

            fall(geta,geta,t,f,p[t][f]);

        }

        vi ans(6,0);
        rep(i,max_n)rep(j,max_n)if(v[i][j] >= 1 && v[i][j] <= 6){
            ans[v[i][j] - 1]++;
        }

        rep(i,6){
            cout << ans[i];
            if(i<5) cout << " ";
            else cout << endl;
        }

    }
}



Measured memory_bytes: 3140
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;

#define MP make_pair
#define F first
#define S second

int main(){
	string S;
  	cin >> S;
    if(S[2]==S[3]&&S[4]==S[5]){
    	cout << "Yes" << endl;
    }else{
      	cout << "No" << endl;
    }  	
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll n;
  cin >> n;
  cout << n * (n - 1) / 2 << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
    #define int long long
    int n,W;
    cin>>n>>W;
    int w[n],v[n];
    int vsum=0;
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
        vsum=vsum+v[i];
    }
    
    int dp[n+1][vsum+1];
    dp[0][0]=0;
    for(int i=0;i<=n;i++)
    for(int j=0;j<=vsum;j++)
     dp[i][j]=(int)INT_MAX*(int)INT_MAX;
    dp[0][0]=0;
  

    for(int i=1;i<=n;i++){
        for(int j=0;j<=vsum;j++){
            dp[i][j]=min(dp[i-1][j],dp[i][j]);
            if(j>=v[i-1])
            dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1]);
            
        }
    }
    
    /*
   for(int i=0;i<=n;i++){
        for(int j=0;j<=vsum;j++)
            cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    int ret=0;
    for(int i=0;i<=vsum;i++){
        if(dp[n][i]<=W)
            ret=i;
    }
    
    /*
    for(int i=0;i<n;i++)
    cout<<a[i]<<" ";
    cout<<endl;
    */
    cout<<ret<<endl;
    
}

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

using namespace std;

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

vector<ll> a(1, 1), p(1, 1);

ll dfs(ll n, ll x) {
	if (n == 0)
		return (x <= 0) ? 0 : 1;
	else if (x <= 1 + a[n-1])
		return dfs(n-1, x-1);
	else
		return p[n-1] + 1 + dfs(n-1, x-2-a[n-1]);
}

int main()
{
	ll n, x;

	cin >> n >> x;

	rep (i, n) {
		a.push_back(a[i] * 2 + 3);
		p.push_back(p[i] * 2 + 1);
	}

	cout << dfs(n, x) << endl;
}



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

#define max(a, b) ((a > b) ? a : b)
#define min(a, b) ((a < b) ? a : b)

#define forn(n) for(int i = 0; i < n; i++)
#define fork(k, n) for(int i = k; i < n; i++)

#define pb(n) push_back(n);

typedef long long ll;
typedef double dbl;

const int MX = 1e6;
const int MOD = 1e9 + 7;
const string ALPHA = "abcdefghijklmnopqrstuvwxyz";
const double PI = 3.1415926535;


int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
	//Code here bby
  string s;
  cin>>s;
  int sum = 0;
  for(char idx :  s){
    sum += idx - '0';
  }
  sum%9 ? cout<<"No"<<endl : cout<<"Yes"<<endl;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll r,d,x;
    scanf("%lld%lld%lld",&r,&d,&x);
    for(int i=1;i<=10;i++)
    {
        x=r*x-d;
        printf("%lld\n",x);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K, x, S;
  cin >> N >> K;
  x = 0;
  for( int i=0; i<N; i++){
    cin >> x;
    if(x < K-x) {
      S += x*2;
    }
    else{
      S += (K-x)*2;
    }
  }
  cout << S << endl;
}

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

int main(){
  long long int N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  
  long long int ans, min_c = min({A, B, C, D, E});
  ans = N / min_c + 5;
  if(N % min_c == 0) ans--; 
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>


int main(void){
  long n, l;
  std::cin >> n >> l;

  long sum = 0;
  for(int i=1; i<=n; i++){
    sum += l+i-1;
  }
  if(l+n-1<0) sum -= l+n-1;
  else if(l<0) sum -= 0;
  else sum -= l;

  std::cout << sum << std::endl;

  return 0;
}


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

int main(){
	int a,b,c,buf;
	cin >> a >> b >> c;
	if(a>b){
		buf=a;
		a=b;
		b=buf;
	}
	if(b>c){
		buf=b;
		b=c;
		c=buf;
	}
	if(a>b){
		buf=a;
		a=b;
		b=buf;
	}
	cout << a << " "<< b << " " << c << endl;
	
	return 0;
}



Measured memory_bytes: 3104
def check(mid,a,b,x,border)
  if mid <= border 
    area = a*b - a*(a*Math.tan(mid/180.0*Math::PI))/2.0
  else
    area = b*(b*Math.tan((90.0-mid)/180.0*Math::PI))/2.0
  end
  #p [mid,a,b,x,border,area,x/a]
  return x/a < area
end

def bsearch(a,b,x)
  ok,ng = 0.0, 90.0
  border = 90.0 - Math.atan2(a,b)/(Math::PI)*180.0
  mid = 45.0
  5000.times do
    mid = (ok+ng)/2.0
    if check(mid,a,b,x,border)
      ok = mid
    else
      ng = mid
    end
  end
  return mid
end

a,b,x = gets.split.map(&:to_f)
p bsearch(a,b,x)

Measured memory_bytes: 1788
### constants

INF = 1 << 30

### subroutines

def vsub(v0, v1)
  [v0[0] - v1[0], v0[1] - v1[1]]
end

def dotp(v0, v1)
  v0[0] * v1[0] + v0[1] * v1[1]
end

def crossp(v0, v1)
  v0[0] * v1[1] - v0[1] * v1[0]
end

def overwrap?(p0, p1, p2, p3)
  v01 = vsub(p1, p0)
  v23 = vsub(p3, p2)
  return false if crossp(v01, v23) != 0

  v02 = vsub(p2, p0)
  return false if crossp(v01, v02) != 0

  d023 = dotp(vsub(p2, p0), vsub(p3, p0))
  d123 = dotp(vsub(p2, p1), vsub(p3, p1))
  d201 = dotp(vsub(p0, p2), vsub(p1, p2))
  d301 = dotp(vsub(p0, p3), vsub(p1, p3))

  if d023 < 0 || d123 < 0 || d201 < 0 || d301 < 0 ||
      (d023 == 0 && d123 == 0 && d201 == 0 && d301 == 0)
    #p ["adj?", p0, p1, p2, p3, d023, d123, d201, d301]
    return true
  end

  false
end

def adj?(ces0, ces1)
  ces0.each do |ce0|
    ces1.each do |ce1|
      return true if overwrap?(*ce0, *ce1)
    end
  end
  false
end

def rec(k, nc)
  if k >= $ncids
    $minc = nc if $minc > nc
    return
  end

  for c in (0..nc)
    ng = false
    for u in $nbrs[k]
      cu = $cols[u]
      if cu && cu == c
        ng = true
        break
      end
    end
    next if ng

    nc0 = (c == nc) ? nc + 1 : nc
    next if nc0 > $minc

    $cols[k] = c
    rec(k + 1, nc0)
    $cols[k] = nil
  end
end

### main

loop do
  n = gets.to_i
  break if n == 0

  cids = {}
  $ncids = 0
  cedges = []

  n.times do
    cname = gets.strip
    if cids[cname].nil?
      cids[cname] = $ncids
      cedges[$ncids] = []
      $ncids += 1
    end

    pts = []
    loop do
      line =gets.strip
      break if line == '-1'
      pts << line.split.map(&:to_i)
    end
    pts << pts.first

    ces = cedges[cids[cname]]
    pts.each_cons(2) do |p0, p1|
      ces << [p0, p1]
    end
  end
  #p cids
  #p cedges

  $nbrs = $ncids.times.map{[]}

  for i in (0...$ncids)
    cedgesi = cedges[i]
    for j in ((i + 1)...$ncids)
      cedgesj = cedges[j]
      if adj?(cedgesi, cedgesj)
        #p ["adj?", i, j]
        #$nbrs[i] << j
        $nbrs[j] << i
      end
    end
  end
  #p $nbrs

  $cols = [nil] * $ncids
  $minc = INF

  rec(0, 0)

  puts $minc
end

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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<vector<int> > ivve;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back`
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define up         upper_bound
#define setp       setprecision
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define spc(x)     cout<<fixed<<setp(x)

const   long long  inf = 1e18;
const   long long  cs =  200005;
const   long long  mod = 1000000007;
const   double     PI =  2 * acos(0.0);
ll v1[cs],v2[cs];
void solve()
{
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;   
    
    cin>>n;
    lve v(n+1,0);
    for(i=1;i<=n;i++)
    {
        cin>>a;
        v[a]=i;
    }
    for(i=1;i<=n;i++)
        cout<<v[i]<<sp;
    cout<<endl;

}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3992
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
//#include <unordered_map>
//#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

ll mul_inv(ll a, ll b = MOD) {
	ll t1 = a, t2 = b, t3;
	ll v1 = 1, v2 = 0, v3;
	while (t2 != 1) {
		ll x = t1 / t2;
		t3 = t1 - x*t2;
		v3 = v1 - x*v2;
		t1 = t2, t2 = t3;
		v1 = v2, v2 = v3;
	}
	return (v2 + b) % b;
}

ll F[8050];
ll Finv[8050];
int sum[4050][4050];
int in[200050][2];
int main() {
	int N, i, j;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%d %d", &in[i][0], &in[i][1]);
		sum[2001 - in[i][0]][2001 - in[i][1]]++;
	}

	for (i = 1; i <= 4002; i++) {
		for (j = 1; j <= 4002; j++) {
			sum[i][j] = (sum[i][j] + sum[i - 1][j]) % MOD;
			sum[i][j] = (sum[i][j] + sum[i][j - 1]) % MOD;
		}
	}

	F[0] = 1;
	for (i = 1; i <= 8020; i++) F[i] = F[i - 1] * i % MOD;
	for (i = 0; i <= 8020; i++) Finv[i] = mul_inv(F[i]);

	ll ans = 0;
	for (i = 1; i <= N; i++) ans = (ans + sum[2001 + in[i][0]][2001 + in[i][1]]) % MOD;
	for (i = 1; i <= N; i++) {
		ll v = F[in[i][0] * 2 + in[i][1] * 2];
		v = v * Finv[in[i][0] * 2] % MOD;
		v = v * Finv[in[i][1] * 2] % MOD;
		ans = (ans - v + MOD) % MOD;
	}
	return !printf("%lld\n", ans * mul_inv(2) % MOD);
}

Measured memory_bytes: 65920
import math

N = int(input())
X = list(map(int, input().split()))

P = math.floor(sum(X)/N)

e = 0
for x in X:
    e += abs(x-P)**2

P = math.ceil(sum(X)/N)

ea = 0
for x in X:
    ea += abs(x-P)**2

answer = e if e<ea else ea
print(answer)

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;

const int N = 305;

int n, cnt[4];
double dp[N][N][N];

double solve(int a, int b, int c) {
    int s = a + b + c;
    if(s == 0)
        return 0;
    if(dp[a][b][c] != -1) return dp[a][b][c];
    double ans = (double)(n) / (double)(a + b + c), tempa = (double)(a) / (double)(s), tempb = (double)(b) / (double)(s), tempc = (double)(c) / (double)(s);
    dp[a][b][c] = 0;
    if(a > 0)
        dp[a][b][c] +=  tempa * (solve(a - 1, b, c) + ans);
    if(b > 0)
        dp[a][b][c] += tempb * (solve(a + 1, b - 1, c) + ans);
    if(c > 0)
        dp[a][b][c] += tempc * (solve(a, b + 1, c - 1) + ans);
    return dp[a][b][c];
}

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            for(int k = 0; k < N; k++)
                dp[i][j][k] = -1;
        }
    }
    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        cnt[x]++;
    }
    cout << fixed << setprecision(10) << solve(cnt[1], cnt[2], cnt[3]);
}


Measured memory_bytes: 222080
N = int(input())
A = list(map(int, input().split()))
nowp = 0
cost = []
allcost = 0
for i in range(N):
  allcost += abs(nowp - A[i])
  nowp = A[i]
allcost += abs(A[-1])

for i in range(N):
  cost.append(allcost)
  if i != 0 and i != N-1:
    cost[i] += abs(A[i-1]-A[i+1]) - abs(A[i-1]-A[i]) - abs(A[i]-A[i+1])
  elif i == 0:
    cost[i] += abs(0-A[i+1]) - abs(0-A[i]) - abs(A[i]-A[i+1])
  else:
    cost[i] -= abs(A[i-1]-A[i]) + abs(A[i]) - abs(A[i-1])
for i in range(N):
  print('%d ' %cost[i])

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

int main() {
    string o, e;
    cin >> o;
    cin >> e;

    rep(i,(int)e.size()) {
        cout << o.at(i);
        cout << e.at(i);
    }
    if (o.size()>e.size()) {
        cout << o.at(o.size()-1);
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bitset>
#include <iostream>

#define MAX_N 2000

using namespace std;

bitset<MAX_N> dpl[MAX_N];
bitset<MAX_N> dpr[MAX_N];

bitset<MAX_N> A[MAX_N];

int main( int argc, char **argv )
{
    // input
    int N;
    cin >> N;

    for ( int i = 1; i < N; i++ )
    {
        string S;
        cin >> S;

        for ( int j = 0; j < i; j++ )
        {
            if ( S[j] == '1' )
                A[i][j] = true;
            else
                A[j][i] = true;
        }
    }

    for ( int i = 0; i < N; i++ ) dpl[i][i] = dpr[i][i] = true;

    // solve
    for ( int d = 0; d < N; d++ )
    {
        for ( int i = 0; i + d < N; i++ )
        {
            int j = i + d;
            if ( ( dpl[j - 1] & dpr[i] & A[j] ).any() ) dpr[i][j] = 1;
            if ( ( dpl[j] & dpr[i + 1] & A[i] ).any() ) dpl[j][i] = 1;
        }
    }

    int ans = ( dpl[N - 1] & dpr[0] ).count();
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int K,N,A[100001],MAX=0,cnt=0,sum=0,B[100],T[100001],Ah[100001],Th[100001],M[100001];
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> T[i];
    }
    for(int i=0;i<N;i++)
        cin >> A[i];
    Th[0] = 1;
    M[0] = T[0];
    for(int i=0;i<N;i++)
        M[i] = 0;
     for(int i=0;i<N-1;i++){
        if(T[i] == T[i+1]){
            Th[i+1] = T[i];
        }else{
            M[i+1] = T[i+1];
            Th[i+1] = 1;
        }
    }
    long long int res=1;
    Ah[N-1] = 1;
    if(M[N-1] != 0 && A[N-1] < M[N-1])
        res = 0;
    for(int i=N-1;i>0;i--){
        if(A[i] == A[i-1]){
            Ah[i-1] = A[i];
        }else{
            Ah[i-1] = 1;
        }
        if(M[i-1] != 0 && A[i-1] < M[i-1])
                res = 0;

    }
    
    for(int i=0;i<N;i++){
        res = (res*min(Ah[i],Th[i]))%1000000007;
    }
    if(T[N-1] != A[0])
        res = 0;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4096
n = int(input())
lis = list(map(int,input().split()))
lis[0]-=1

for i in range(n-1):
  if lis[i] < lis[i+1]:
    lis[i+1] -= 1
  elif lis[i] > lis[i+1]:
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 63984
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    var ans = 0
    var f = false
    var n = 1
    var i = 0
    while (i < A.size) {
        if (A[i] == n) {
            n += 1
            f = true
        } else {
            ans += 1
        }
        i += 1
    }
    println(if (f) ans else -1)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }

Measured memory_bytes: 82972
#include <stdio.h>
//#include <string.h>

int main(void){
  int a,b;
  scanf("%d %d", &a, &b);
  //sum = a*b;
  
  if(a<2*b){
      printf("0");
  }
  else
    printf("%d", a-2*b);

  return 0;
}

  

Measured memory_bytes: 1708
N = int(input())
h = list(map(int,input().split()))
count = 0
i = 0
while sum(h) > 0:
    if h[i] > 0:
        j = i
        count += 1
        while j < N and h[j] > 0:
            h[j] = h[j] - 1
            j += 1
    else:
        i += 1
print(count)

Measured memory_bytes: 3060
#B問題
W,H,N = map(int,input().split())

R = 0
L = W
U = 0
D = H
for i in range(N):
    x,y,a = map(int,input().split())
    
    if a == 1:
        R = max(R,x)
    if a == 2:
        L = min(L,x)
    if a == 3:
        U = max(U,y)
    if a == 4:
        D = min(D,y)
        
dw = max(0,L-R)
dh = max(0,D-U)
print(dw*dh)
    


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

// @author: pashka

void solve_test() {
    int n;
    cin >> n;
    vector<long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    string s;
    cin >> s;
    vector<long> c;
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == '0') {
            long x = a[i];
            for (long y : c) {
                x = min(x, x ^ y);
            }
            if (x > 0) {
                c.push_back(x);
                sort(c.rbegin(), c.rend());
            }
        } else {
            long x = a[i];
            for (long y : c) {
                x = min(x, x ^ y);
            }
            if (x > 0) {
                cout << "1\n";
                return;
            }
        }
    }
    cout << "0\n";
}

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        solve_test();
    }

    return 0;
}

Measured memory_bytes: 3656
fun main(args: Array<String>) {
    val (x1, y1, x2, y2) = readInputLine().split(" ").map { it.toInt() }
    
    val dx = x2 - x1
    val dy = y2 - y1
    
    // 座標移動と90度回転移動をうまいことやる
    println("${dx - dy + x1} ${dx + dy + y1} ${-dy + x1} ${dx + y1}")
}

fun readInputLine(): String {
    return readLine()!!
}


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

using namespace std;

int main()
{
    int a[3][3], x[3][3];
    int n, b;

    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> a[i][j];
            x[i][j] = false;
        }
    }

    cin >> n;

    for (int k = 0; k < n; k++)
    {
        cin >> b;

        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (b == a[i][j])
                    x[i][j] = true;
            }
        }
    }

    bool ans = false;

    if (x[0][0] && x[0][1] && x[0][2])
        ans = true;
    if (x[1][0] && x[1][1] && x[1][2])
        ans = true;
    if (x[2][0] && x[2][1] && x[2][2])
        ans = true;

    if (x[0][0] && x[1][0] && x[2][0])
        ans = true;
    if (x[0][1] && x[1][1] && x[2][1])
        ans = true;
    if (x[0][2] && x[1][2] && x[2][2])
        ans = true;

    if (x[0][0] && x[1][1] && x[2][2])
        ans = true;
    if (x[0][2] && x[1][1] && x[2][0])
        ans = true;

    if (ans)
        cout << "Yes";
    else
        cout << "No";

    cout << "\n";

    return 0;
}

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

using namespace std;

long long fun(long long r, long long D, long long x_i){
  
  return r*x_i - D;
}

int main(){
  long long r,D,x200;
  cin >> r >> D >> x200;

  long long res = fun(r,D,x200);
  int cnt =0;
  while(1){
    if(cnt == 10){
      break;
    }
    cout << res << endl;
    res = fun(r,D,res);
    cnt++;
  }
  
  return 0;

}



Measured memory_bytes: 256
n=int(input())
A=[int(x) for x in input().split()]

u=10**6+1
C=[0]*u
D=[0]*2+[1]*(u-2)

def e():
  n=4
  while n<u:
    D[n]=0
    n+=2
  i=3
  while i*i<u:
    if D[i]:
      n=i*2
      while n<u:
        D[n]=0
        n+=i
    i+=2

def gcd(a,b):
   while a%b:
     a,b=b,a%b
   return b

for a in A:
  C[a]+=1
e()
for i in [x for x in range(2,u) if D[x]==1]:
  if sum(C[i::i])>1:
    break
else:
  print('pairwise coprime')
  exit()

c=A[0]
for a in A:
  c=gcd(c,a)
  if c==1:
    break
else:
  print('not coprime')
  exit()

print('setwise coprime')


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

using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define INF 1000000007
typedef int64_t in;
typedef long long ll;

int n;
int m[105][105] = {};
int color[105] = {};
int d[105] = {};
int f[105] = {};
int u,k;
int v;
int t=0;
int nt[105] = {};

int next(int u){
    REP(v, nt[u], n){
        nt[u] = v + 1;
        if(m[u][v]) return v;
    }
    return -1;
}

void dfs(int u){
    rep(u,n){
        if(color[u] == 0){
            stack<int> S;
            color[u] = 1;
            d[u] = ++t;
            S.push(u);

            while(!S.empty()){
                u = S.top();
                v = next(u);
                if(v != -1){
                    if(color[v] == 0){
                        S.push(v);
                        color[v] = 1;
                        d[v] = ++t;
                    }
                }else{
                    S.pop();
                    color[u] = 2;
                    f[u] = ++t;
                }
                
            }
        }
    }

    rep(i,n){
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main(){
    cin >> n;
    
    /*rep(i,n){
        color[i] = 0;
    }*/

    rep(i,n){
        cin >> u >> k;
        for(int i=0; i<k; i++){
            cin >> v;
            m[u-1][v-1] = 1;
        }
    }

    dfs(0);
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,W;cin>>N>>W;
        if(N+W==0) break;
        int ma=0,masi=0;
        vector<int> cnt(20);
        
        for(int i=0;i<N;i++){
            int a;cin>>a;
            cnt[a/W]++;
            ma=max(ma,a/W);
            masi=max(masi,cnt[a/W]);
        }
        
        double ans=0.0;
        
        for(int i=0;i<=ma;i++){
            if(ma!=0) ans+=double(cnt[i])/double(masi)*double(ma-i)/double(ma);
            else ans+=double(cnt[i])/double(masi);
        }
        
        cout<<setprecision(25)<<ans+0.01<<endl;
    }
    
}



Measured memory_bytes: 3260
N,M=map(int,input().split())
H=list(map(int,input().split()))
L=[1]*N
for i in range(M):
	A,B=map(int,input().split())
	if H[A-1]==H[B-1]:
		L[A-1]=0
		L[B-1]=0
	elif H[A-1]>H[B-1]:
		L[B-1]=0
	elif H[A-1]<H[B-1]:
		L[A-1]=0
print(L.count(1))


Measured memory_bytes: 20120
import sys
n,m = map(int,input().split())
lis = [-1] * n

for i in range(m):
    s,c = map(int,input().split())
    
    if lis[s-1] == -1 or lis[s-1] == c:
        lis[s-1] = c
    else:
        print(-1)
        sys.exit()
if n == 1:
    if lis[0] != -1:
        print(lis[0])
    else:
        print(0)
elif lis[0] == 0:
    print(-1)
elif lis[0] == -1:
    lis[0] = 1
    for i in lis:
        if i == -1:
            print(0, end="")
        else:
            print(i,end="")
else:
    for i in lis:
        if i == -1:
            print(0, end="")
        else:
            print(i,end="")


Measured memory_bytes: 3064
marks = ["S","H","C","D"]
deck = dict()
for mark in marks:
    deck.setdefault(mark, dict())
    for i in range(1, 14):
        deck[mark].setdefault(i, False)

for i in range(int(input())):
    mark,number = input().split()
    number = int(number)
    deck[mark][number] = True

for mark in marks:
    for i in range(1, 14):
        if not deck[mark][i]:
            print(f"{mark} {i}")


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

int main(){
  char A;
  cin >> A;
  if(A >= 'A' && A <= 'Z') {
    cout << "A" << endl;
  }
  else if(A >= 'a' && A <= 'z'){
    cout << "a" << endl;
  }
}

Measured memory_bytes: 3632
#include"bits/stdc++.h"
using namespace std;


void Main() {
  int d, g;
  cin >> d >> g;
  int p[d], c[d];
  for (int i = 0; i < d; i++) {
    cin >> p[i] >> c[i];
  }
  int ans = 10000;

  for (int bit = 0; bit < (1 << d); bit++) {
    int sum = 0;
    int num = 0;
    for (int i = 0; i < d; i++) {
      if (bit & (1 << i)) {
        sum += 100 * (i + 1) * p[i] + c[i];
        num += p[i];
      }
    }
    if (sum >= g) {
      ans = min(ans, num);
      continue;
    }
    int more = 0;
    for (int i = d - 1; i >= 0; i--) {
      if (!(bit & (1 << i))) {
        for (int j = 1; j <= p[i]; j++) {
          if (100 * (i + 1) * j + sum >= g) {
            more = j;
            num += j;
            ans = min(ans, num);
            break;
          }
        }
      }
      if (more > 0) {
        break;
      }
    }
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define int long long
#define F first
#define S second
#define pb push_back
#define p2(n) (1<<(n))
#define lg2(n) __lg(n)
using namespace std;
using pii = pair<long long,long long>;
using ld = long double;
mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);

int sc[8] = {599,799,999,1199,1399,1599,1799,1999};
int x;

void solve(){
    cin >> x;
    cout << 8-(lower_bound(sc,sc+8,x)-sc) << '\n';
}

signed main(){
    Rushia_mywife
    solve();
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <string.h>
int main(void){
    int n,l,i,j;
    char word[101][101], tmp[101];
    scanf("%d %d",&n,&l);
    for(i=0;i<n;i++)
        scanf("%s",word[i]);
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            if(strcmp(word[i],word[j])>0){
                strcpy(tmp,word[i]);
                strcpy(word[i],word[j]);
                strcpy(word[j],tmp);
            }
        }
    }
    for(i=0;i<n;i++)
        printf("%s",word[i]);
    printf("\n");
}


Measured memory_bytes: 128
#!/usr/bin/env python3
# DSL_1_B: Weighted Union Find Trees


class WeightedUnionFind:
    def __init__(self, n):
        self.n = n
        self.nodes = [i for i in range(n)]
        self.weights = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def connected(self, i, j):
        wi, ri = self.root(i)
        wj, rj = self.root(j)
        return ri == rj

    def union(self, i, j, w):
        wi, ri = self.root(i)
        wj, rj = self.root(j)
        if ri == rj:
            return

        if self.size[ri] < self.size[rj]:
            self.nodes[ri] = rj
            self.weights[ri] = wj - wi + w
            self.size[rj] += self.size[ri]
        else:
            self.nodes[rj] = ri
            self.weights[rj] = wi - wj - w
            self.size[ri] += self.size[rj]

    def weight(self, i, j):
        wi, ri = self.root(i)
        wj, rj = self.root(j)
        if ri != rj:
            raise ValueError('{} and {} is not connected'.format(i, j))

        return wi - wj

    def root(self, i):
        r = self.nodes[i]
        w = self.weights[i]
        while r != self.nodes[r]:
            w += self.weights[r]
            r = self.nodes[r]
        return w, r


def run():
    n, q = [int(i) for i in input().split()]
    wuf = WeightedUnionFind(n)

    for _ in range(q):
        com, *args = input().split()
        if com == '0':
            wuf.union(*[int(i) for i in args])
        elif com == '1':
            x, y = [int(i) for i in args]
            if wuf.connected(x, y):
                print(wuf.weight(x, y))
            else:
                print('?')


if __name__ == '__main__':
    run()



Measured memory_bytes: 11476
#include<bits/stdc++.h>
using namespace std;
string s;
bool cal(int l,int r) {
    for(int i=l;i<=r;i++) {
        if(s[i]!=s[r+l-i]) return false;
    }
    return true;
}
int main() {
    cin>>s;
    int x=s.size()-1,f=0;
    if(!cal(0,x)) f=1;
    if(!cal(0,(x-1)/2)) f=1;
    if(!cal((x+3)/2,x)) f=1;
    if(f==0) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256