akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    map<string, int> mp;
    REP(i, N) {
        cin >> S;
        mp[S]++;
    }
    vector<pair<int, string>> x;
    for (auto tmp : mp) {
        x.push_back({tmp.second, tmp.first});
    }
    sort(x.rbegin(), x.rend());
    dump(x);
    int tmp = x[0].first;
    vector<string> b;
    REP(i, x.size()) {
        if (x[i].first < tmp) {
            break;
        }
        b.push_back(x[i].second);
    }
    sort(ALL(b));
    REP(i, b.size()) {
        cout << b[i] << endl;
    }
}

Measured memory_bytes: 31984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct seg
{
    struct node
    {
        ll tag, mx;
    };
    int n;
    vector<node> t;
    void init(int _n)
    {
        n = _n;
        t.assign(2 * n - 1, {0, 0});
    }
    void dat(int o, ll v)
    {
        t[o].tag += v;
        t[o].mx += v;
    }
    void push(int o, int z)
    {
        if (t[o].tag) {
            dat(o + 1, t[o].tag);
            dat(z, t[o].tag);
            t[o].tag = 0;
        }
    }
    void pull(int o, int z)
    {
        t[o].mx = max(t[o + 1].mx, t[z].mx);
    }
    void add(int i, int j, ll v, int o, int l, int r)
    {
        if (j <= l || r <= i)
            return;
        if (i <= l && r <= j) {
            dat(o, v);
            return;
        }
        int m = l + (r - l) / 2;
        int z = o + (r - l) / 2 * 2;
        push(o, z);
        add(i, j, v, o + 1, l, m);
        add(i, j, v, z, m, r);
        pull(o, z);
    }
    ll qry(int i, int j, int o, int l, int r)
    {
        if (j <= l || r <= i)
            return LLONG_MIN;
        if (i <= l && r <= j)
            return t[o].mx;
        int m = l + (r - l) / 2;
        int z = o + (r - l) / 2 * 2;
        push(o, z);
        ll ret = qry(i, j, o + 1, l, m);
        return max(ret, qry(i, j, z, m, r));
    }
    void add(int l ,int r, ll v)
    {
        add(l - 1, r, v, 0, 0, n);
    }
    ll qry(int l, int r)
    {
        return qry(l - 1, r, 0, 0, n);
    }
} t;
const int N = 2e5 + 87;
vector<pair<int,int>> ev[N];
ll dp[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    t.init(n);
    for (int i = 0; i < m; ++i) {
        int l, r, a;
        cin >> l >> r >> a;
        ev[r].emplace_back(l, a);
    }
    for (int i = 1; i <= n; ++i) {
        for (const auto & p : ev[i])
            t.add(p.first, i, p.second);
        dp[i] = max(0ll, t.qry(1, i));
        t.add(i + 1, i + 1, dp[i]);
    }
    cout << dp[n] << endl;
}


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

using namespace std;

using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int INF = 1<<30;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    llong n;
    cin >> n;

    llong ans = 0;
    for (llong i = 1; i <= n; ++i) {
        llong k = n/i;
        ans += k*(2*i + (k - 1)*i)/2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3544
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////
//#include<bits/stdc++.h>
using namespace std;
#define Base1   101LL
#define Base2   10000079LL
#define Base3   10000103LL
#define MOD1    1000000007LL
#define MOD2    1000000009LL
#define MOD3    1000000021LL
#define mx 100000//Number of charter of main string
#define mx1 25000// Number off character of total charcater
#define mx2 500// Number of pattern and number of ch of each pattern
 
 int main(){
    int n;
    I(n);
    vector<int>a,b;
    for(int i=1;i<=n;i++){
        int x;
        I(x);
        a.push_back(x);
    }
    for(int i=1;i<=n;i++){
        int x;
        I(x);
        b.push_back(x);
    }
    vector<int>an;
    for(int i=1;i<=n;i++)an.push_back(i);
    vector<int>ans;
    int cnt =0;
    do{
        cnt++;
        if(an==a)ans.push_back(cnt);
        if(an==b)ans.push_back(cnt);
    }while(next_permutation(an.begin(),an.end()));
    cout<<abs(ans[0]-ans[1])<<endl;

     return 0;
 }

Measured memory_bytes: 256
N,L = map(int,input().split())
T = []
for i in range(N):
  T.append(L+i)
if max(T) >= 0 and min(T) <= 0:
  print(sum(T))
else:
  if max(T) < 0:
    print(sum(T)-max(T))
  else:
    print(sum(T)-min(T))

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1};
int dx[] = {1, -1, 0, 0};

struct Node {
    int parent = -1, sibling = -1, degree = 0,
     depth = 0, height = 0, left = -1, right = -1;
    
    string pos = "internal node";
};
Node node[25];
void Depth(int i, int now, int dep) {
    //cout << i << " " << now << " " << dep << endl;
    if (node[now].parent == -1) {
        node[i].depth = dep;
        return;
        
    }
    if (dep > 100) return;
    Depth(i, node[now].parent, dep + 1);
}
void dfs(int i, int now, int dep) {
    if (node[now].left != -1) dfs(i, node[now].left, dep + 1);
    if (node[now].right != -1) dfs(i, node[now].right, dep + 1);
    node[i].height = max(node[i].height, dep);
    return;
}

void pre(int now) {
    cout << " ";
    cout << now;
    
    if (node[now].left != -1) pre(node[now].left);
    if (node[now].right != -1) pre(node[now].right);
}
void in(int now) {
    
    if (node[now].left != -1) in(node[now].left);
    cout << " ";
    cout << now;
    
    if (node[now].right != -1) in(node[now].right);
}
void post(int now) {
    if (node[now].left != -1) post(node[now].left);
    
    if (node[now].right != -1) post(node[now].right);
    cout << " ";
    cout << now;
    
}
int main() {
    int n; cin >> n;
    rep(i, n) {
        int id, l, r; cin >> id >> l >> r;
        node[id].left = l;
        node[id].right = r;
        if (l != -1) {
            node[l].parent = id;
            node[l].sibling = r;
            node[id].degree++;

        }
        if (r != -1) {
            node[r].parent = id;
            
            node[r].sibling = l;
            node[id].degree++;

        }
        
    }
    rep(i, n) {
        if (node[i].degree == 0) {
            node[i].pos = "leaf";
        }
        if (node[i].parent == -1) {
            node[i].pos = "root";
        }
        Depth(i, i, 0);
    }
    rep(i, n) { //全てのdepが求まってから
        dfs(i, i, 0);
    }
    
    rep(i, n) {
        if (node[i].parent == -1) {
            cout << "Preorder" << endl;
            pre(i);
            cout << endl;
            
            cout << "Inorder" << endl;
            in(i);
            cout << endl;
            
            cout << "Postorder" << endl;
            post(i);
            cout << endl;
        }
    }
    
    
    
    
}



Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	string s; cin >> s;
	sort(s.begin(), s.end());
	cout << (s[0] == s[1] && s[2] == s[3] && s[1] != s[2] ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define endl '\n';
const int maxn=2e5+5;
int32_t main(){
	ios::sync_with_stdio(0); 
	cin.tie(0); 
	cout.tie(0);
	string s,t;
	cin>>s>>t;
	int n=s.size();
	if(s == t.substr(0,n)){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  string s;
  cin>>s;
  int n=s.size();
  int a=0,b=0,c=0;
  REP(i,n){
    if(s[i]=='a'){
      a++;
    }else if(s[i]=='b'){
      b++;
    }else{
      c++;
    }
  }
  if(max(a,max(b,c))-min(a,min(b,c))<=1){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


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

h, w = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
a = [list(map(int, input().split())) for _ in range(h)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

ans = 0
for row in a:
    for ele in row:
        if ele == -1:
            continue
        else:
            ans += c[ele][1]

print(ans)


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

#define pi 2*acos(0.00)
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl '\n'
#define null '\0'

using namespace std;

int main()
{
    fastio;

    int n,p,x;
    cin>>n>>p;
    x=n-p+1;
    cout<<x<<nl;

}

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

int main(){
  ll q,h,s,d,n;
  cin >>q >>h >>s >>d >>n;
  h = min(2*q, h);
  s = min(2*h, s);
  ll ans = n/2*min(2*s,d) + n%2*s;
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 3644
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
for number in b:
    for i in range(3):
        if number in a[i]:
            a[i][a[i].index(number)] = 0
if a[0][0] == a[1][1] == a[2][2] == 0 or a[2][0] == a[1][1] == a[0][2] == 0:
    print('Yes')
else:
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2] == 0:
            print('Yes')
            break
        elif a[0][i] == a[1][i] == a[2][i] == 0:
            print('Yes')
            break
    else:
        print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,v[SZ],ff[SZ],fa[SZ];pii rs[SZ]; ll ans;
int gf(int x) {return ff[x]?ff[x]=gf(ff[x]):x;}
//a is fa of b
void uni(int a,int b)
{
	a=gf(a);b=gf(b); if(a==b) throw "GG";
	ff[b]=a; ans+=rs[a].se*(ll)rs[b].fi;
	rs[a].fi+=rs[b].fi; rs[a].se+=rs[b].se;
}
vector<int> ch[SZ];
struct cmp
{
bool operator () (int a,int b)
{
	ll dt=rs[a].fi*(ll)rs[b].se-rs[b].fi*(ll)rs[a].se;
	if(dt) return dt>0; return a<b;
}
};
set<int,cmp> t;
int main()
{
	scanf("%d",&n);
	for(int i=2,f;i<=n;++i)
		scanf("%d",&f),ch[f].pb(i),fa[i]=f;
	for(int i=1;i<=n;++i)
		scanf("%d",v+i);
	for(int i=1;i<=n;++i)
	{
		if(v[i]) rs[i].se=1; else rs[i].fi=1;
		t.insert(i);
	}
	while(!t.empty())
	{
		int x=*t.begin(); t.erase(t.begin());
		if(x==1) continue;
		int f=gf(fa[x]); t.erase(f);
		uni(f,x); t.insert(f);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 40704
// Knapsack 2 ==> (Attempt 69.69)

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

class Main {
	public static long INF = Long.MAX_VALUE;
	public static void knapsack2(long[] w, long[] p, long k, int n) {
		long sum = sum(p);
		long[][] dp = new long[n+1][(int)sum+1];

		for(int i = 0; i <= n; i++) {
			Arrays.fill(dp[i], INF);
			// System.out.println(Arrays.toString(dp[i]));
		}

		for(int i = 0; i <= n; i++) {
			dp[i][0] = 0;
		}

		for(int i = 1; i <= sum; i++) {
			dp[0][i] = INF;
		}

		long max = Long.MIN_VALUE;
		for(int i = 1; i <= n; i++) {
			for(long j = 1; j <= sum; j++) {
				if(p[i-1] == j) {
					dp[i][(int)j] = min(w[i-1], dp[i-1][(int)j]);
				}
				else if(p[i-1] > j) {
					dp[i][(int)j] = dp[i-1][(int)j];
				}
				else {
					long temp = dp[i-1][(int)Math.abs(j-p[i-1])];
					if(temp != INF) {
						dp[i][(int)j] = min(dp[i-1][(int)j], w[i-1]+temp);
					}
					else {
						dp[i][(int)j] = min(dp[i-1][(int)j], INF);
					}
				}
				if(dp[i][(int)j] <= k) {
					if(j > max) {
						max = j;
					}
				}
				// if(dp[i][(int)j] == INF) {
				// 	System.out.print("*  ");
				// }
				// else {
				// 	System.out.print(dp[i][(int)j] + "  ");
				// }
			}
			// System.out.println();
		}
		System.out.println(max);
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");
		
		int n = Integer.parseInt(s[0]);
		long k = Long.parseLong(s[1]);

		long[] w = new long[n];
		long[] p = new long[n];

		for(int i = 0; i < n; i++) {
			String[] s1 = br.readLine().split(" ");
			w[i] = Long.parseLong(s1[0]);
			p[i] = Long.parseLong(s1[1]);
		}

		knapsack2(w, p, k, n);
	}

	public static long min(long...arr) {
		long min = Long.MAX_VALUE;
		for(long i: arr)
			if(i < min)
				min = i;

		return min;
	}

	public static long sum(long...arr) {
		long sum = 0;
		for(long i: arr)
			sum += i;

		return sum;
	}
}


Measured memory_bytes: 167740
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
s = input()
s = s[:k-1] + s[k-1].lower() + s[k:]
print(s)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vint vector<int> 
#define inf 1000000000
#define mod 1000000007

int power(int a, int b)
{
    int prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a);
        a = (a*a);
        b >>= 1;
    }
    return prod;
}

int main()
{
	int n , k;
	cin >> n >> k;
	int a[n];
	for(int i = 0 ; i < n ; i++)
		cin >> a[i];
	
	int dp[k+1][2];
	dp[0][0] = 1;
	dp[0][1] = 0;

	for(int i = 1 ; i <= k ; i++)
	{
		for(int j = 0 ; j < 2 ; j++)
		{
			int flag = j^1;
			for(int w = 0 ; w < n ; w++)
			{
				if(i - a[w] >= 0 && dp[i-a[w]][j^1] == j){
					flag = j;
					break;
				}

			}
			dp[i][j] = flag;
		}
	}

	cout << (dp[k][0] ? "Second" : "First");
 	return 0;

}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define LOCAL 0
#define lli long long int
const int mod=(int)(1e8);
const lli pINF=(lli)(1e15);
const lli nINF=-LLONG_MAX;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
const int INT=1000000000;
const int INF=0x3f3f3f3f;
#define Pa pair<int,int>
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define ld long double
#define printli(n) printf("%lld\n",n)
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}

int main() 
{
    int a,b;
    cin>>a>>b;
    
    if(a+b==15) cout<<'+'<<endl;
    else if(a*b==15) cout<<'*'<<endl;
    else cout<<"x"<<endl;
	return 0;
}

Measured memory_bytes: 256
import math
def Wit(y,m,d):
    if m == 1 or m == 2:
        y -= 1
        m += 12
    e = math.floor((26 * (m + 1)) / 10)
    Y = y % 100
    C = math.floor(y / 100)
    f = math.floor(C / 4)
    g = math.floor(Y / 4)
    h = d + e + Y + f + g + 5 * C
    h = int(h % 7)
    return h
while True:

    y = 2004
    m,d = map(int,input().split())
    if m == 0 and d == 0:
        break
    You = Wit(y,m,d)
    if You == 1:
        print("Sunday")
    elif You == 3:
        print("Tuesday")
    elif You == 2:
        print("Monday")
    elif You == 4:
        print("Wednesday")
    elif You == 5:
        print("Thursday")
    elif You == 6:
        print("Friday")
    elif You == 0:
        print("Saturday")

Measured memory_bytes: 7800
#include <iostream>

using namespace std;

int main() {
  int n;
  int dp[45];

  // 初期化
  dp[0] = 1;
  dp[1] = 1;

  //入力
  cin >> n;

  // DP
  for(int i = 2; i <= n; i++) dp[i] = dp[i-1] + dp[i-2];

  // 出力
  cout << dp[n] << endl;

  return 0;
}



Measured memory_bytes: 3088
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d)cout<<"Yes"<<endl;
  else if(abs(a-b)<=d&&abs(b-c)<=d)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n = sc.read();
    let a = (0..2).map(|_| sc.vec::<usize>(n)).collect::<Vec<_>>();
    let mut dp = vec![vec![0; n]; 2];
    dp[0][0] = a[0][0];
    dp[1][0] = dp[0][0] + a[1][0];

    for i in 1..n {
        dp[0][i] = dp[0][i-1] + a[0][i];
    }
    for i in 1..n {
        dp[1][i] = cmp::max(dp[0][i], dp[1][i-1]) + a[1][i];
    }
    println!("{}", dp[1][n-1]);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

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

using namespace std;

const int Nmax = 2e4 + 5;
typedef long long ll;
typedef pair<ll, ll> Pair;

vector<Pair> v, w;
vector<ll> A;
ll p10[20];

vector<Pair> best(vector<Pair> v)
{
    vector<Pair> ans;
    sort(v.begin(), v.end());

    ll l = -1, r = -1;
    for(auto it : v)
        if(it.first <= r)
            r = max(r, it.second);
        else
        {
            if(l != -1) ans.push_back({l, r});
            l = it.first;
            r = it.second;
        }
    ans.push_back({l, r});
    return ans;
}

bool solve(int p, int c)
{
    w.clear();
    w.push_back({p10[p] * c, p10[p] * (c+1) - 1});

    ll x, y;
    for(auto val : A)
    {
        v.clear();
        for(auto seg : w)
        {
            x = seg.first;
            y = seg.second;
            v.push_back({x, y});

            val %= p10[p+1];
            x -= val;
            y -= val;

            if(x<=0 && y>=0) return 1;

            if(x<0 && y<0) x += p10[p+1], y += p10[p+1];
            v.push_back({x, y});
        }

        w = best(v);
    }

    return 0;
}

int main()
{
  //  freopen("input", "r", stdin);
  //  freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    int i, c, ans = 0, n;

    cin >> n;
    A.resize(n);
    for(auto &it : A) cin >> it;

    p10[0] = 1;
    for(i=1; i<=17; ++i) p10[i] = (ll) p10[i-1] * 10;

    for(i=0; i<17; ++i)
        for(c=9; c; --c)
            if(solve(i, c))
            {
                ans += c;
                break;
            }
    cout << ans << '\n';
    return 0;
}


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

int main(){
    int S;
    cin>>S;
    for(int s=0;s<S;s++){
        uint32_t N[9];
        for(int i=0;i<9;i++)cin>>hex>>N[i];
        uint32_t K=0;
        for(int b=0;b<32;b++){
            uint32_t sum=0;
            uint32_t mask=1<<b;
            for(int i=0;i<8;i++) sum+=N[i];
            if((sum&mask)!=(N[8]&mask)){
                K^=mask;
                for(int i=0;i<9;i++){
                    N[i]^=mask;
                }
            }
        }
        cout<<hex<<K<<endl;
    }

    return 0;
}

Measured memory_bytes: 3048
N = [int(i) for i in input()]
n = len(N)
K = int(input())
lis = [0]*3
foo = 0
for i in range(n):
    if N[i]!=0:
        lis[foo] = i
        foo += 1
    if foo==3:
        break



if n < K:
    print(0)
else:
    if K ==3:
        ans = (n-1)*(n-2)*(n-3)*9**3//6
        ans += (N[0]-1)*(n-1)*(n-2)*9**2 //2
        if lis[1]!=0:
            ans += (n-1-lis[1])*(n-2-lis[1])*9**2//2
        if lis[2]!=0:
            ans += (N[lis[1]]-1)*(n-1-lis[1])*9 +(n-1-lis[2])*9 +N[lis[2]]
    elif K ==2:
        ans = (n-1)*(n-2)//2 *9**2 +(N[0]-1)*(n-1)*9
        if lis[1]!=0:
            ans += (n-1-lis[1])*9 +N[lis[1]]
    elif K ==1:
        ans = 9*(n-1) +N[0]

    print(max(0,ans))


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int v[3], ans[] = {5,5,7};

  for (int i = 0; i < 3; i++)
    cin >> v[i];

  sort(v, v + 3);

  int cnt = 0;
  for (int i = 0; i < 3; i++)
    cnt += v[i] == ans[i];

  cout << (cnt == 3 ? "YES" : "NO") << endl;

  return 0;
}


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

int main() {
    long long K,A,B;
    cin >> K >> A >> B;
    if(B - A < 3 || 1 + K < A) {
        cout << 1 + K << endl;
        return 0;
    }
    cout << A + (B - A) * ((K - A + 1) / 2) + ((K - A + 1) % 2) << endl;
    return 0;
}

Measured memory_bytes: 256
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string S;
    cin >> S;
    int m = (S[5]-'0')*10 + (S[6]-'0');
    int d = (S[8]-'0')*10 + (S[9]-'0');
    bool ok = true;
    if(m < 4) ok = false;
    else if(m == 4 && d <= 30) ok = false;
    cout << (!ok ? "Heisei":"TBD") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>

#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <random>
#include <complex>
#include <utility>
#include <tuple>
#include <memory>

#include <array>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <csignal>
#include <cstdint>
#include <cstddef>

#ifdef ONLINE_JUDGE
#define NDEBUG
#endif
#include <cassert>
#include <stdexcept>
#include <exception>

// << pair
template <typename T1, typename T2>
std::ostream&operator<<(std::ostream&os,const std::pair<T1,T2>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
// << container
template <typename C>
std::ostream&_debug_go(std::ostream&os,const C&v) {bool first=true;os<<"[";for(auto i:v){if(!first)os<<", ";os<<i;first=false;}return os<<"]";}
// << {vector, set, map} delegating to _debug_go
template<typename T> std::ostream&operator<<(std::ostream&os,const std::vector<T>&v){return _debug_go(os, v);}
template<typename T> std::ostream&operator<<(std::ostream&os,const std::set<T>&v){return _debug_go(os, v);}
template<typename T1, typename T2> std::ostream&operator<<(std::ostream&os,const std::map<T1,T2>&v){return _debug_go(os, v);}
struct Debugger{template<typename T>Debugger&operator,(const T&v){std::cerr<<v<<" "; return *this;}} dbg;
#ifndef NDEBUG
#define debug(args...) do {dbg,args; cerr << "\n";} while(0)
#else
#define debug(args...)
#endif

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ITER(i, s, e) for (auto i((s)); i != (e); ++i)
#define IT(i, c) ITER(i, (c).begin(), (c).end())

using namespace std;

using ui = uint32_t;
using ll = int64_t;
using ull = uint64_t;
template <typename T = int> using Pt = complex<T>;

template <typename T>
T cross(const Pt<T>& a, const Pt<T>& b) { return a.real() * b.imag() - a.imag() * b.real(); }

template <typename T>
bool cmpPt(const Pt<T>& a, const Pt<T>& b) {
    return a.real() < b.real() || (a.real() == b.real() && a.imag() < b.imag());
}
// END TEMPLATE

int solve(int N, const vector<int>& A) {
    set<pair<int, int>> ends;
    REP(i, N) {
        auto it = ends.lower_bound({A[i], -1});
        if (it != ends.begin()) {
            --it;
            ends.erase(it);
        }
        ends.emplace(A[i], i);
    }
    return ends.size();
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    vector<int> A(N);
    for (int& a : A) cin >> a;
    cout << solve(N, A) << '\n';

    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

template <class T, class T2>
class LazySegTree {
    using F = function<T(T, T)>;
    using G = function<T(T, T2)>;
    using H = function<T2(T2, T2)>;
    using P = function<T2(T2, int)>;
    int n;
    vector<T> data;
    vector<T2> lazy;
    const F f;
    const G g;
    const H h;
    const P p;
    const T e;
    const T2 e2;

public:
    LazySegTree(const vector<T>& as, const F f, const G g, const H h, const P p, const T& e, const T2 e2) : f(f), g(g), h(h), p(p), e(e), e2(e2) {
        n = 1;
        while (n < as.size()) n <<= 1;
        data.assign(2 * n, e);
        lazy.assign(2 * n, e2);
        for (int i = 0; i < as.size(); i++) {
            data[n + i] = as[i];
        }
        for (int i = n - 1; i > 0; i--) {
            data[i] = f(data[2 * i], data[2 * i + 1]);
        }
    }

    void propagate(int k, int len) {
        if (lazy[k] != e2) {
            if (k < n) {
                lazy[2 * k] = h(lazy[2 * k], lazy[k]);
                lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
            }
            data[k] = g(data[k], p(lazy[k], len));
            lazy[k] = e2;
        }
    }

    T update(int a, int b, const T2& x, int k, int l, int r) {
        propagate(k, r - l);
        if (r <= a || b <= l) {
            return data[k];
        } else if (a <= l && r <= b) {
            lazy[k] = h(lazy[k], x);
            propagate(k, r - l);
            return data[k];
        } else {
            return data[k] = f(update(a, b, x, 2 * k, l, (l + r) >> 1), update(a, b, x, 2 * k + 1, (l + r) >> 1, r));
        }
    }

    T update(int a, int b, const T2& x) {
        return update(a, b, x, 1, 0, n);
    }

    T query(int a, int b, int k, int l, int r) {
        propagate(k, r - l);
        if (r <= a || b <= l) {
            return e;
        } else if (a <= l && r <= b) {
            return data[k];
        } else {
            return f(query(a, b, 2 * k, l, (l + r) >> 1), query(a, b, 2 * k + 1, (l + r) >> 1, r));
        }
    }

    T query(int a, int b) {
        return query(a, b, 1, 0, n);
    }
};

int main() {
    int n;
    cin >> n;
    vi as(n, (i64(1) << 31) - 1);

    // RUQ, RMQ
    auto f = [](i64 a, i64 b) {return min(a, b);};
    auto g = [](i64 a, i64 b) {return b < 0 ? a : b;};
    auto h = [](i64 a, i64 b) {return b < 0 ? a : b;};
    auto p = [](i64 a, int b) {return a;};
    LazySegTree<i64, i64> tree(as, f, g, h, p, 1e18, -1);

    int q;
    cin >> q;
    while (q--) {
        int c;
        cin >> c;
        if (c == 0) {
            int s, t, x;
            cin >> s >> t >> x;
            tree.update(s, t + 1, x);
        } else {
            int s;
            cin >> s;
            cout << tree.query(s, s + 1) << endl;
        }
    }
}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

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

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

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


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define uset unordered_set
#define pq(T) priority_queue<T>
#define rpq(T) priority_queue<T, vector<T>, greater<T> >
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;



int main() {
  io();
  
  int k, x;
  cin >> k >> x;
  if(k*500 >= x) cout << "Yes";
  else cout << "No";
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    string ans;
    REP(i,s.size()){
        if(s[i] == 'B'){
            if(ans.size() > 0) ans.pop_back();
        }else{
            ans += s[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import itertools, math, collections, sys
input = sys.stdin.readline
H, W, K = [int(_) for _ in input().split()]
A = [input() for _ in range(H)]
for h in range(H):
    if 'S' in A[h]:
        w = A[h].index('S')
        break
visited = [[False] * W for _ in range(H)]
ans = min([h, H - 1 - h, w, W - 1 - w])
res = K - 1
Q = collections.deque([[h - 1, w, res], [h + 1, w, res], [h, w - 1, res],
                       [h, w + 1, res]])
while Q:
    h, w, res = Q.popleft()
    if 0 <= h < H and 0 <= w < W and A[h][w] == '.' and not visited[h][w]:
        visited[h][w] = True
        ans = min([ans, h, H - 1 - h, w, W - 1 - w])
        if res:
            res -= 1
            Q += [[h - 1, w, res], [h + 1, w, res], [h, w - 1, res],
                  [h, w + 1, res]]
print(1 + math.ceil(ans / K))


Measured memory_bytes: 90204
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using ulint = unsigned long long int;
using uint = unsigned int;

int main() {
  int N, T;
  cin >> N >> T;
  int c = 1111, t = 1111, ans = 1111;
  for (int i = 0; i < N; ++i) {
    cin >> c >> t;
    if (t <= T) {
      ans = min(ans, c);
    }
  }
  if (ans == 1111) {
    cout << "TLE" << endl;
  } else {
    cout << ans << endl;;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int A[n] ={};
    for (int i=0;i<n;i++){
        cin >> A[i];
    }
    int a;
    int count =0;
    for (int i=0;i<n;i++){
        int mini=i;
        for (int j=i;j<n;j++){
            if(A[j]<A[mini]){
                mini = j;
            }
            
        }
        if (A[i] != A[mini]) count+=1;
        a = A[i];
        A[i] = A[mini];
        A[mini] = a;
    }
    
    for (int i=0;i<n;i++){
        cout << A[i];
        if (i!=n-1) cout <<" ";
        
        
    }
    cout << endl << count << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
typedef long long ll;


int main()
{
	for (int i = 1; i <= 5; i++) {
		int temp;
		cin >> temp;
		if (temp == 0) cout << i;
	}
	
	
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

using namespace std;
typedef long long ll;

signed main() {
  int k, x;
  cin >> k >> x;
  if(500 * k >= x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 100005
using namespace std;
char s[maxn];
int n,cnt;
int main()
{
	scanf("%s",s);
	n=strlen(s);
	for(int i=0;i<n;i++)
		if(s[i]=='p') cnt++;
	printf("%d\n",n/2-cnt);
}

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

bool isint(long double d) {
    return (ceil(d) == floor(d));
}

int main() { 
    int n, d;
    cin >> n >> d;
    vector<int> a[n];
    for (int i = 0; i < n; ++i) {
        int x;
        for (int _ = 0; _ < d; ++_) {
            cin >> x;
            a[i].push_back(x);
        }
    }
    map<pair<int, int>, int> m;
    for (int i = 0; i <= 10; ++i) {
        for (int j = 0; j <= 10; ++j) {
            m[{i, j}] = 0;
            m[{j, i}] = 0;
        }
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (i != j and m[{i, j}] != 1 and m[{j, i}] != 1) {
                long long val = 0LL;
                for (int k = 0; k < d; ++k) {
                    val += pow((a[i][k] - a[j][k]), 2);
                }
                long double r = sqrt(val);
                if (isint(r)) ++cnt;
                m[{i, j}] = 1;
                m[{j, i}] = 1;
            }
            m[{i, j}] = 1;
            m[{j, i}] = 1;
        }
    }
    cout << cnt << ' ';
}

Measured memory_bytes: 256
# 1枚ポーカー 1が強く2が弱い勝敗判定

A, B = map(int, input().split())

if A == 1:
    A = 14
if B == 1:
    B = 14

if A == B:
    print('Draw')
elif A > B:
    print('Alice')
else:
    print('Bob')

Measured memory_bytes: 9076
#include <iostream>

using namespace std;

#define HH 100002
#define MOD 1000000007

int n, m;
int two[HH];
bool del[HH];
int ans;

int mod(int x) {
	while (x < 0)
		x += MOD;
	return x % MOD;
}

int parent[HH];
int find(int x) {
	return x == parent[x] ? x : parent[x] = find(parent[x]);
}
void merge(int x, int y) {
	if (find(x) != find(y))
		parent[parent[x]] = parent[y];
}

void sol() {
	for (int i = 0; i <= n; i++)
		parent[i] = i;
	int iso = n;

	int hit = 0;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;

		if ((!del[a] || !del[b]) || (del[a] && del[b] && find(a) != find(b))) {
			iso--;
			merge(a, b);
		}

		del[a] = del[b] = true;
	}

	ans = two[iso] + (iso == n ? 0 : 1);
	ans = mod(ans);
	cout << ans << endl;

	for (int i = 0; i <= n; i++) {
		parent[i] = i;
		del[i] = false;
	}
}

int main() {
	two[0] = 1;
	for (int i = 1; i < HH; i++)
		two[i] = (two[i - 1] * 2) % MOD;
	
	while (cin >> n >> m && (n || m))
		sol();
}

Measured memory_bytes: 2040
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<int> l(n);
    for (int i = 0; i < n; i++)
        cin >> l[i];
    int A = 0, B = 1, C = 2;
    vector<vector<int>> dp(1 << n, vector<int>(3, INF));
    for (int i = 1; i < (1 << n); i++)
    {
        int cnt = 0, sum = 0;
        for (int j = 0; j < n; j++)
        {
            if ((i >> j) & 1)
            {
                cnt++;
                sum += l[j];
            }
        }
        dp[i][A] = abs(a - sum) + 10 * (cnt - 1);
        dp[i][B] = abs(b - sum) + 10 * (cnt - 1);
        dp[i][C] = abs(c - sum) + 10 * (cnt - 1);
    }
    int ret = INF;
    for (int i = 1; i < (1 << n); i++)
    {
        for (int j = 1; j < (1 << n); j++)
        {
            for (int k = 1; k < (1 << n); k++)
            {
                if ((i & j) || (j & k) || (k & i))
                    continue;
                ret = min(ret, dp[i][A] + dp[j][B] + dp[k][C]);
            }
        }
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n,cnt=0;
  long long d,x,y;
  int i;
  
  scanf("%d%lld",&n,&d);
  d*=d;
  for(i=0;i<n;i++){
    scanf("%lld%lld",&x,&y);
    if(x*x+y*y<=d)
      cnt++;
  }
  
  printf("%d\n",cnt);
  
  return 0;
}

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

int n, m, a, b, u, v, disu[100001], disv[100001];
vector<int> G[100001];

void dfsu(int x, int y, int d) {
  disu[x] = d;
  for (int i = 0; i < G[x].size(); i++) {
    if (G[x][i] != y) {
      dfsu(G[x][i], x, d + 1);
    }
  }
}

void dfsv(int x, int y, int d) {
  disv[x] = d;
  for (int i = 0; i < G[x].size(); i++) {
    if (G[x][i] != y) {
      dfsv(G[x][i], x, d + 1);
    }
  }
}

int main() {
  int ans = 0;
  cin >> n >> u >> v;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfsu(u, -1, 0);
  dfsv(v, -1, 0);
  for (int i = 1; i <= n; i++) {
    if (disu[i] < disv[i]) {
      ans = max(ans, disv[i] - 1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 11648
K = gets.to_i
ary = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
index = -1

while (ary.size <= K) do
    index += 1
    s = ary[index][-1]
    if s == "0"
        ary.push(ary[index] + "0")
        ary.push(ary[index] + "1")
    elsif s == "9"
        ary.push(ary[index] + "8")
        ary.push(ary[index] + "9")
    else
        ary.push(ary[index] + (s.to_i - 1).to_s)
        ary.push(ary[index] + (s.to_i).to_s)
        ary.push(ary[index] + (s.to_i + 1).to_s)
    end
end

puts ary[K - 1]

Measured memory_bytes: 9340
#include <iostream>

 

using namespace std;

 

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = i / 60 - 60*h ; 
   s = i % 60;
   cout << h << ":" << m << ":" << s << endl;

 

   
   return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>
int main(void){
  int q,i,c,a,n,s;
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d %d %d",&c,&a,&n);
    s=0;
    while(1){
      if(c>=1&&a>=1&&n>=1){
    c--;
    a--;
    n--;
    s++;
      }
      else if(c>=2&&a>=1){
    c-=2;
    a--;
    s++;
      }
      else if(c>=3){
    c-=3;
    s++;
      }
      else
    break;
    }
    printf("%d\n",s);
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
int main()
{
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if (b - a > k || c - b > k || d - c > k || e - d > k ||c -a > k || d - a > k|| e-a >k|| d- b >k|| e- b>k|| e-c >k)
    {
        cout << ":(" << endl;
    }
    else if (b - a <= k && c - b <= k && d - c <= k && e - d <= k && c-a <=k && d-a <=k && e-a<=k && d-a<=k && e-a<=k && d-b<=k && e- b<=k && e-c<=k )
    {
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
s = list(map(int,input().split()))
count5 = 0
count7 = 0
for i in range(3):
    if s[i] == 5:
      count5 += 1
    if s[i] == 7:
      count7 +=1
if count7 == 1 and count5 == 2:
   print("YES")
else:
    print("NO")

Measured memory_bytes: 2940
# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()

import re
N = input()
match = re.search(r'[A-Z]',N)
if match:
  print('A')
else:
  print('a')

Measured memory_bytes: 70608
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(a, b) << " ";
  if (n < a + b)
    cout << a + b - n;
  else
    cout << 0;
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
	string x[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
	string s;
	cin >> s;
  	for (int i = 0;; i++) {
  		if (x[i] == s) {
  			cout << 7-i << endl;
  			break;
  		}
  	}
}

Measured memory_bytes: 256