akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};

ll f(ll n){
  if(n%2==0)return n/2;
  else return 3*n+1;
}

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll s;
  cin >> s;
  llvec a(1000000);
  set<ll> b;
  rep(i, 1000000){
    if(i==0)a[i]=s;
    else{
      a[i]=f(a[i-1]);
    }
    cerr << a[i]<<endl;
    if(b.count(a[i])>0){
      cout << i+1;
      return 0;
    }
    
    b.insert(a[i]);
  }
  return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

struct Node{
	int s,t,c;
	bool operator< (Node a) const { return c < a.c; }
};

Node node[50010];
bool used[50010];

vector<pii> tree[510];
int n,m;

class UF{
	public:
		void init(int n){
			par.resize(n);
			rank.resize(n);
			rep(i,n) par[i]=i,rank[i]=0;
			return;
		}
		int find(int x){
			if(par[x]==x)
				return x;
			else
				return par[x]=find(par[x]);
		}
		void unite (int x,int y){
			x=find(x);
			y=find(y);
			if(x==y) return ;
			if(rank[x]<rank[y]){
				par[x]=y;
			}else{
				par[y]=x;
				if(rank[x]==rank[y]) rank[x]++;
			}
		}
		bool same(int x,int y){
			return find(x)==find(y);
		}
		private:	
			vi par,rank;
};

bool dfs(int v,int p,int c,int r){
	if(v==r)
		return true;
	bool ok=false;
	rep(i,tree[v].size()){
		int v2=tree[v][i].first;
		if(v2!=p){
			bool ok2=dfs(v2,v,c,r);
			if(ok2&&node[tree[v][i].second].c==c)
				used[tree[v][i].second]=false;
			ok|=ok2;
		}
	}
	return ok;
}

int main(void){
	cin >> n >> m;
	
	rep(i,m) {
		cin >> node[i].s >> node[i].t >> node[i].c;
		node[i].s--;node[i].t--;
		if(node[i].t < node[i].s) swap(node[i].s,node[i].t);
	}

	sort(node,node+m);

	UF uf;
	uf.init(n);

	rep(i,m){
		Node e=node[i];
		if(uf.same(e.s,e.t)){
			dfs(e.t,-1,e.c,e.s);
		}else{
			uf.unite(e.s,e.t);
			pii in; 
			in.first=e.t; in.second=i;
			tree[e.s].pb(in);
			in.first=e.s; 
			tree[e.t].pb(in);
			used[i]=true;
		}
	}
	int ai=0;
	int ac=0;
	rep(i,m){
		if(used[i]){
			ai++;
			ac+=node[i].c;
		}
	}
	cout << ai <<" "<< ac << endl;
	return 0;
}

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

int D[100][6];

void spin(int n,char c)
{
    if(c=='E'){
        swap(D[n][0],D[n][3]);swap(D[n][3],D[n][5]);swap(D[n][5],D[n][2]);
    }
    else if(c=='W'){
        swap(D[n][0],D[n][2]);swap(D[n][2],D[n][5]);swap(D[n][5],D[n][3]);
    }
    else if(c=='S'){
        swap(D[n][0],D[n][1]);swap(D[n][0],D[n][4]);swap(D[n][4],D[n][5]);
    }
    else if(c=='N'){
        swap(D[n][0],D[n][1]);swap(D[n][1],D[n][5]);swap(D[n][5],D[n][4]);
    }
}

int main() {
    int ans = 0;
    int n;
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        for (int j = 0; j < 6; ++j) {
            cin >> D[i][j];
        }
    }
    for (int i = 0; i < n ; ++i) {
        for (int j = i + 1 ; j <= n ; ++j) {
            char SWS[8]={"SSSWSSS"};
            for(int k=0; k < 8; ++k){
                if(D[i][1] == D[j][1])break;
                spin(j,SWS[k]);
            }
            for(int k=0;k<4;++k){
                if(D[i][0] == D[j][0]){
                    if(D[i][1] == D[j][1] && D[i][2] == D[j][2] && D[i][3]==D[j][3] && D[i][4] == D[j][4] && D[i][5] == D[j][5])
                        ans++;
                }
                spin(j,'W');
            }
        }
    }

    if (ans == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1160
x=[int(input()) for i in range(5)]
x.sort()
ans=0
rem=[]
for t in x:
    ans+=(t-t%10)
    rem.append(t%10)
    rem.sort()
f=0
for r in rem:
    if r==0:
        pass
    else:
        if f==0:
            ans+=r
            f=1
        else:
            ans+=10
print(ans)

Measured memory_bytes: 3060
// 6/13
// 3-2-3. 反転
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;

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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
    combination comb(200000);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    if (N == 1) cout << 0 << endl;

    sort(A.begin(), A.end());

    mint res = 0;

    // 最小値
    rep(i, N) {
        int rest = N - i - 1;  // この中からk-1個選ぶ。
        if (rest < K - 1) continue;

        res -= comb(rest, K - 1) * A[i];
    }

    // 最大値
    rep(i, N) {
        int rest = N - i - 1;
        if (rest < K - 1) continue;

        res += comb(rest, K - 1) * A[N - 1 - i];
    }

    cout << res.x << endl;
}

Measured memory_bytes: 3712
INF=float('inf')
from collections import deque
def mbfs(G,sh,sw,H,W):
    dist=[[INF]*W for i in range(H)]
    dist[sh][sw]=0

    d=deque()
    d.append([sh,sw])
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]
    while(len(d)!=0):
        h=d[0][0]
        w=d[0][1]
        d.popleft()
        for dir in range(4):
            nh=h+dx[dir]
            nw=w+dy[dir]
            if(nh>H-1 or nh<0 or nw>W-1 or nw<0):
                continue
            if(G[nh][nw]=='#'):
                continue
            if dist[nh][nw]>dist[h][w]:
                dist[nh][nw]=dist[h][w]
                d.appendleft([nh,nw])
        for i in range(h-2,h+3):
            for j in range(w-2,w+3):
                if (i>H-1 or i<0 or j>W-1 or j<0):
                    continue
                if (G[i][j]=='#'):
                    continue
                if dist[i][j]>dist[h][w]+1:
                    dist[i][j]=dist[h][w]+1
                    d.append([i,j])
    return dist

H,W=map(int,input().split())
Ch,Cw=map(lambda x:int(x)-1,input().split())
Dh,Dw=map(lambda x:int(x)-1,input().split())
G=[list(input()) for i in range(H)]

dist=mbfs(G,Ch,Cw,H,W)
if dist[Dh][Dw]!=INF:
    print(dist[Dh][Dw])
else:
    print(-1)

Measured memory_bytes: 148488
n = int(input())
l = list(map(int, input().split()))
l.sort()
count = 0
for i in range(n):
  for j in range(i + 1, n):
    for k in range(j + 1, n):
      if l[i] != l[j] and l[j] != l[k] and l[j] + l[i] > l[k]:
         count += 1
print(count)

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

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll d,t,s; cin>>d>>t>>s;
  if(t*s>=d) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}

Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
using namespace std;
int main(){

  int a,b,c;

  cin>>a>>b;
  if(a<b) swap(a,b);
  while(a%b!=0){
    c=a%b;
    a=b;
    b=c;
  }
  cout<<b<<endl;

}



Measured memory_bytes: 3044
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cstdlib>

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cout << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi pair     <int,int>
#define vss vector  <string>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define PI  3.141592654
#define OO (ll)1e18
#define mod(x,m) (x%m + m )%m
using namespace std;

pii swapii( pii pr ){ return { pr.S , pr.F }; }
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 2e7 + 9;

ll x ,y; ll d = 2019;

bool isOk( ll n , ll k )
{
    ll nwN = x , nwK = y;

    ll nMod = x%d;
    nwN += n%d - nMod;

    ll kMod = y%d;
    nwK += k%d - kMod;

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

int main()
{
    FASTIO

    cin >> x >> y;

    ll mn = OO;
    for ( int i = 1; i <= 2019; ++i )
        for ( int j = 1; j <= 2019; ++j )
        {
            if ( isOk(i , j) )
            {
                mn = min( mn , (i*j)%d );
            }
        }

    cout << mn;
    return 0;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i ++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i --)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return 1;}return 0;}

constexpr ll INF = (1ll << 60);
constexpr ll MOD = 1000000007ll;


// べき乗を計算　指数を計算
ll llpow(ll a, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

ll f(ll a){
    return a * a * a * a * a;
}


int main(){
    ll x;
    cin >> x;
    3982;

    PREP(a, -3982, 3983){
        PREP(b, -3982, 3983){
            if(x == f(a) - f(b)){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return -1;
}

Measured memory_bytes: 3624
package main

import (
	"fmt"
	"unicode"
)

func are_digits(s string) bool {
	for _, r := range s {
		if !unicode.IsDigit(r) {
			return false
		}
	}
	return true
}

func main() {
	var a, b int
	var s string
	fmt.Scan(&a, &b)
	fmt.Scan(&s)

	if are_digits(s[:a]) && are_digits(s[a+1:]) && s[a] == '-' {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner s = new Scanner(System.in);
    int K = s.nextInt();
    int S = s.nextInt();
    int Ans = 0;
    if (S <= K)
      Ans = (S+1) * (S+2) / 2;
    else if (K < S && S <= 2*K)
      Ans = (K+1)*(K+1) - (2*K - S +1)*(2*K - S)/2 - (S -K +1)*(S-K)/2;
    else if (2*K <= S)
      Ans = (3*K -S +1)*(3*K - S +2)/2;
    System.out.println(Ans);
  }
}


Measured memory_bytes: 21716
#include <stdio.h>

int drink(int t[],int n,int p,int x){
    int tmp[n];
    int i;
    for(i=0;i<n;i++){
        tmp[i]=t[i];
    }
    tmp[p-1]=x;
    int ans=0;
    for(i=0;i<n;i++){
        ans += tmp[i];
    }
    return ans;
}

int main(void){
    int i;

    int n;
    scanf("%d",&n);
    int t[n];
    for(i=0;i<n;i++){
        scanf("%d",&t[i]);
    }

    int m;
    scanf("%d",&m);
    int p[m],x[m];
    for(i=0;i<m;i++){
        scanf("%d %d",&p[i],&x[i]);
    }

    for(i=0;i<m;i++){
        printf("%d\n",drink(t,n,p[i],x[i]));
    }

    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <list>
#include <algorithm>
using namespace std;

int main(void){
    int q, x;
    char com[20];
    
    list<int> v;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%s",com);
        if (com[0] == 'i') {
            scanf("%d", &x);
            v.push_front(x);
        } else if (com[6] == 'L') {
            v.pop_back();
        } else if (com[6] == 'F') {
            v.pop_front();
        } else {
            scanf("%d", &x);
            for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
                if (*it == x) {
                    v.erase(it);
                    break;
                }
            }
        }
    }
    int i = 0;
    for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
        if (i++) printf(" ");
        printf("%d", *it);
    }
    printf("\n");
    return 0;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}



Measured memory_bytes: 33928
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
A = np.array(read().split(),np.int64)

Acum = A.cumsum(); S = Acum[-1]
Acum2 = Acum+Acum
I1 = np.searchsorted(Acum2,Acum)
P1 = Acum[I1]; Q1 = Acum-P1
P2 = P1 - A[I1]; Q2 = P1+Q1-P2
P = np.where(np.abs(P1-Q1) > np.abs(P2-Q2),P2,P1); Q = P1+Q1-P

A = A[::-1]
Acum = A.cumsum(); S = Acum[-1]
Acum2 = Acum+Acum
I1 = np.searchsorted(Acum2,Acum)
P1 = Acum[I1]; Q1 = Acum-P1
P2 = P1 - A[I1]; Q2 = P1+Q1-P2
R = np.where(np.abs(P1-Q1) > np.abs(P2-Q2),P2,P1); S = P1+Q1-R

R = R[::-1]; S = S[::-1]

P,Q,R,S = P[:-1],Q[:-1],R[1:],S[1:]

PQRS = np.vstack([P,Q,R,S])

PQRS

score = np.max(PQRS,axis=0) - np.min(PQRS,axis=0)
answer = score.min()
print(answer)

Measured memory_bytes: 42364
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
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;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  string S;
  cin >> S;

  cout << ((S == "AAA" || S == "BBB") ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    string S[H+2];
    S[0] = "", S[H+1] = "";
    rep(i, W+2){
        S[0] += ".";
        S[H+1] += ".";
    }
    rep2(i, 1, H+1){
        cin >> S[i];
        S[i] = "." + S[i] + ".";
    }
    queue<pair<P, int> > que;
    bool used[H+2][W+2];
    int res;
    rep(i, H+2){
        rep(j, W+2){
            if(S[i][j] == 'S'){
                que.push(make_pair(P(i, j), 0));
                used[i][j] = true;
            }
        }
    }
    while(!que.empty()){
        pair<P, int> p = que.front();
        que.pop();
        int i = p.first.first;
        int j = p.first.second;
        int k = p.second;
        int d = i-1;
        d = min(d, H-i);
        d = min(d, j-1);
        d = min(d, W-j);
        res = min(res, d);
        if(d == 0) break;
        elif(k >= K) continue;
        if(!used[i-1][j] && S[i-1][j] == '.'){
            used[i-1][j] = true;
            que.push(make_pair(P(i-1, j), k+1));
        }
        if(!used[i+1][j] && S[i+1][j] == '.'){
            used[i+1][j] = true;
            que.push(make_pair(P(i+1, j), k+1));
        }
        if(!used[i][j-1] && S[i][j-1] == '.'){
            used[i][j-1] = true;
            que.push(make_pair(P(i, j-1), k+1));
        }
        if(!used[i][j+1] && S[i][j+1] == '.'){
            used[i][j+1] = true;
            que.push(make_pair(P(i, j+1), k+1));
        }
    }
    if(res % K == 0) cout << res/K + 1 << endl;
    else cout << res/K + 2 << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(){
	 int a;
	  
	scanf("%d",&a);
	
	  if(a % 2 == 0){
			
		a /=2;  	
			printf("%d",a);   	
	  } 
	  else{
	  	
	  	a /=2;
	  		printf("%d",a+1);
	  }
	
	return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; ++i)
#define INF (2e9)

int main() {
  ll n, a[1000000], ans;
  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  ans = 1;

  for(int i = 0; i < n; i++) {
    if(ans > 1000000000000000000 / a[i]) {
      cout << -1 << endl;
      return 0;
    } else {
      ans = ans * a[i];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4408
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
if N<10:
    print(N)
elif 10<=N<100:
    print(9)
elif 100<=N<1000:
    print(9 + (N - 99))
elif 1000<=N<10000:
    print(9 + 900)
elif 10000<=N<100000:
    print(9 + 900 + (N - 9999))
else:
    print(9 + 900 + 90000)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

 

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


Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = b - a;
            int tower = 0;
            for (int i = 0; i < c; i++) tower += i;
            Console.WriteLine(tower - a);

        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;

using ll = long long;

int main()
{
    ll N;
    cin >> N;
    cout << (1000 - N % 1000) % 1000 << endl;   
    return 0;
}

Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		sc.close();
		String res = "NO";

		if(n+1 >= k*2) {
			res = "YES";
		}
		System.out.println(res);
	}

}


Measured memory_bytes: 23252
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];


int main(){
    char R;
    cin >> R;

    cout << char(R + 0x01) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    string s;cin >> s;
    rep(i,s.size()){
        cout << s[i];
        if(i == 3)cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
s = []
for i in range(n):
    s.append((a[i], i+1))
s.sort()
ns = []
for si in s:
    ns.append(si[1])
print(" ".join(map(str, ns)))

Measured memory_bytes: 25444
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int d[15][2][2][15];   // number_of_digits  less_than_n  none_0  previous
int n;
ll l,r,mid; 
bool check()
{
	memset(d,0,sizeof(d));
	d[0][0][0][0]=1;
	string s="";
	ll t=mid;
	while (t) s+=(char)(t%10+'0'),t/=10;
	reverse(s.begin(),s.end());
	for (int i=0;i<s.size();i++)  // number_of_digits
	{
		for (int j=0;j<2;j++) // less_than_n
		{
			for (int k=0;k<2;k++) // none_0
			{
				for (int it=0;it<10;it++) // previous
				{
					if (!d[i][j][k][it]) continue; 
					for (int jt=0;jt<=(j ? 9 : s[i]-'0');jt++) // now
					{
						if (!k) d[i+1][j || jt<s[i]-'0'][jt>0][jt]+=d[i][j][k][it];
						else if (abs(it-jt)<=1) d[i+1][j || jt<s[i]-'0'][1][jt]+=d[i][j][k][it];
					}
				}
			}
		}
	}
	//cout <<mid<<" #######################\n";
	ll res=0;
	for (int i=0;i<10;i++)
	{
		//cout <<res<<" ##\n";
		res+=d[s.size()][0][1][i]+d[s.size()][1][1][i];
	}
	//cout <<mid<<" "<<res<<" --\n"; 
	return res>=n;
}
int main()
{
	cin >>n;
	l=1,r=3234566667ll;
	while (l<r)
	{
		mid=(l+r)>>1;
		//cout <<l<<" "<<r<<" "<<mid<<" ##\n";
		if (check()) r=mid;
		else l=mid+1;
	}
	cout <<l;
	return 0;
} 

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))

ans = [0]*n
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] < h[b-1]:
        ans[a-1] += 1
    elif h[a-1] > h[b-1]:
        ans[b-1] += 1
    else:
        ans[a-1] += 1
        ans[b-1] += 1

print(ans.count(0))

Measured memory_bytes: 84908
import scala.io.{StdIn => in}

object Main extends App {
  val n = in.readInt
  val x = in.readLine.split(" ").map(_.toInt)
  val sx = x.sorted

  val h = n / 2
  val left = sx(h-1)
  val right = sx(h)
  val out = new java.io.PrintWriter(System.out)
  x.foreach(i => {
    if(i < right) out.println(right)
    else out.println(left)
  })
  out.flush
}

Measured memory_bytes: 63128
#include <algorithm>
#include <iostream>
#include <cstdio>
#define fi first
#define se second
using namespace std;
const int maxn = 1e5 + 5;
pair <int, int> a[maxn];
int l[maxn], r[maxn];
int main(){
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i)
        scanf("%d %d", &a[i].se, &a[i].fi);
    sort(a + 1, a + 1 + n);
    for (int i = 1; i <= n; ++ i)
        swap(a[i].fi, a[i].se);
    int mxl = a[1].fi, k = 1;
    for (int i = 2; i <= n; ++ i)
        mxl = max(mxl, a[i].fi);
    for (int i = 1; i <= n; ++ i)
        if (a[i].fi == mxl)
            k = i;
    int ans = 0;
    for (int i = 1; i <= n; ++ i)
        if (i != 1 && i != k)
            ans = max(ans, a[i].se - a[i].fi + 1);
    ans += max(a[1].se - a[k].fi + 1, 0);
    for (int i = 1; i <= n; ++ i)
        ans = max(ans, a[i].se - a[i].fi + 1);
    l[1] = a[1].fi;
    for (int i = 2; i <= n; ++ i)
        l[i] = max(l[i - 1], a[i].fi);
    r[n] = a[n].se;
    for (int i = n - 1; i; -- i)
        r[i] = min(r[i + 1], a[i].se);
    for (int i = 2; r[i] <= r[k] && i <= n; ++ i)
        ans = max(ans, max(a[1].se - l[i - 1] + 1, 0) + max(r[i] - a[k].fi + 1, 0));
    cout << ans << endl;
}


Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

    public static void main(String args[]) throws Exception {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        int A = Integer.parseInt(sc.nextLine());

        if (N%500 <= A) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <cmath>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))
#define min(X, Y) ((X) < (Y) ? (X) : (Y))
#define abs(X) ((X) < 0 ? -1 * (X) : (X))

using namespace std;

typedef long long ll;

int main()
{
    int n;

    cin >> n;
    while (!((n / 100) == ((n / 10) % 10) &&
           ((n / 10) % 10) == (n % 10))) {
        n++;
    }

    cout << n << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
vector<int> G[MAX_N];
int dp[MAX_N];

pi loop(int v, int p) {
	pi res = pi(0, v);
	rep(i, 0, sz(G[v])) {
		int n = G[v][i];
		if(n == p) continue;
		pi t = loop(n, v);
		t.fst++;
		MAX(res, t);
	}
	return res;
}

int dia() {
	pi p = loop(0, -1);
	pi q = loop(p.sec, -1);
	return q.fst;
}

void solve() {
	cin >> N;
	rep(i, 0, N - 1) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	dp[0] = 0;
	dp[1] = 1;
	dp[2] = 0;
	rep(i, 3, N + 1) {
		dp[i] |= (dp[i - 1] ^ 1);
		dp[i] |= (dp[i - 2] ^ 1);
	}
	// debug(vi(dp, dp + N + 1));
	int d = dia(); d++;
	debug(d);
	if(dp[d] == 0) cout << "Second\n";
	else cout << "First\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 33024
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    string s;
    cin >> n >> s;
    for (int i=0;i<s.size();i++) {
        for (int j=0;j<n;j++) {
            s[i]++;
            if (s[i] > 'Z') s[i] = 'A';
        }
    }
    cout << s << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

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

int main()
{
    int n, m;

    cin >> n >> m;

    int s[m + 5];
    char c[m + 5];
    string a = "";

    for(int i = 0; i < n; i++) a += 'a';

    for(int i = 0; i < m; i++){
        int x;
        char y;

        cin >> x >> y;

        x--;

        s[i] = x;
        c[i] = y;

        if(a[x] == 'a') a[x] = y;
        else{
            if(a[x] != y){
                cout << -1 << endl;
                return 0;
            }
        }
    }

    if(a[0] == '0'){
        if(n != 1) cout << -1 << endl;
        else cout << 0 << endl;

        return 0;
    }

    if(a[0] == 'a'){
        if(n != 1) a[0] = '1';
        else a[0] = '0';
    }

    for(int i = 0; i < n; i++){
        if(a[i] == 'a') cout << 0;
        else cout << a[i];
    }

    cout << endl;

    /*char mn = 'a';

    if(n == 1){
        for(int i = 0; i < m; i++) mn = min(mn, c[i]);

        if(mn == 'a') cout << 0 << endl;
        else cout << mn << endl;

        return 0;
    }

    for(int i = 0; i < m; i++){
        if(s[i] == 0 && c[i] != '0') mn = min(mn, c[i]);
    }

    a[0] = mn;

    if(mn == 'a') cout << -1 << endl;
    else cout << a << endl;*/

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

struct Mod {
    static constexpr auto kMod = 1000000007L;

    // can be implicitly converted
    Mod(int64_t n) : n(n) {}

    Mod operator*(Mod m) const { return (n * (m.n % kMod)) % kMod; }

    Mod& operator*=(Mod m) {
        *this = *this * m;
        return *this;
    }

    Mod pow(int64_t p) {
        if (p == 0) {
            return 1;
        }
        if (p == 1) {
            return n;
        }

        int64_t r = this->pow(p / 2).n;
        if (p % 2 == 0) {
            return r * r % kMod;
        } else {
            return (r * r % kMod) * n % kMod;
        }
    }

    Mod operator/(Mod m) const {
        if (n == 0) {
            return 0;
        }

        return *this * m.pow(kMod - 2);
    }

    Mod& operator/=(Mod m) {
        *this = *this / m;
        return *this;
    }

    Mod operator+(Mod m) const { return (n + m.n) % kMod; }

    Mod& operator+=(Mod m) {
        *this = *this + m;
        return *this;
    }

    Mod operator-(Mod m) const { return (kMod + n - m.n) % kMod; }

    Mod& operator-=(Mod m) {
        *this = *this - m;
        return *this;
    }

    int64_t n;
};

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

    auto a = Mod(n - k + 1);

    cout << a.n << endl;
    for (auto i : irange(2L, k + 1)) {
        a = a * (n - k - i + 2) / i * (k - i + 1) / (i - 1);
        cout << a.n << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

const int MOD = 1e9 + 7;

inline int add(int x, int y){
	int res = x + y;	
	while(res >= MOD)res-=MOD;
	return res;
}

inline int mul(int x,int y){
	return (1LL * x * y) % MOD;
}

int modpow(int x,int p){
	int res = 1;
	while(p){
		if(p&1)gmul(res,x);
		gmul(x,x);
		p/=2;
	}
	return res;
}

inline int invert(int x){
	return modpow(x,MOD - 2);
}

const int N = 2e6 + 10;

int fac[N], inv[N];

void init(int n){
	fac[0] = inv[0] = 1;
	for(int i = 1;i < n; ++i){
		fac[i] = mul(fac[i-1], i);	
		inv[i] = invert(fac[i]); 
	}
}

int comb(int n,int k){
	return mul(fac[n],mul(inv[k], inv[n-k]));	
}


int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	init(N);
	int k;
	cin >> k;
	string s;
	cin >> s;
	int n = s.length();
	int mult = 1;
	int other = modpow(25,k);
	int inv = invert(25);
	int ans = 0;
	rep(i,0,k+1){
		int val = mul(mul(comb(n-1+k-i,k-i),other),mult);
		gadd(ans, val);
		gmul(mult,26);
		gmul(other,inv);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 19888
s = int(input())
checked = [s,]
for i in range(10**7):
    if checked[i] % 2 == 0:
        a_i = checked[i] // 2
    else:
        a_i = 3 * checked[i] + 1
    if a_i in checked:
        print(i+2)
        break
    checked.append(a_i)
#print(checked)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define mp make_pair
#define pii pair<int,int>
typedef long long ll;
using namespace std;
int n;
long long cnt;
string s1[305],s2[305];
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>s1[i];
		s2[i]=s1[i];
	}
	for (int l=0;l<n;l++){
		for (int i=0;i<n;i++){
			for (int j=0;j<n;j++){
				s2[(i+l)%n][j]=s1[i][j];
			}
		}
		bool ig=1;
		for (int i=0;i<n && ig;i++){
			for (int j=i;j<n && ig;j++){
				if (s2[i][j]!=s2[j][i]) ig=0;
			}
		}
		if (ig){
			cnt+=n-l;
		}
	}
	for (int l=1;l<n;l++){
		for (int i=0;i<n;i++){
			for (int j=0;j<n;j++){
				s2[i][(j+l)%n]=s1[i][j];
			}
		}
		bool ig=1;
		for (int i=0;i<n && ig;i++){
			for (int j=i;j<n && ig;j++){
				if (s2[i][j]!=s2[j][i]) ig=0;
			}
		}
		if (ig){
			cnt+=n-l;
		}
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int a, b, c, d;
    bool isTakwin;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    while(true){
        c -= b;
        if(c <= 0){isTakwin = true; break;}
        a -= d;
        if(a <= 0){isTakwin = false; break;}
    }
    if(isTakwin) printf("Yes");
    else printf("No");
}

Measured memory_bytes: 3752
#include <stdio.h>
#include <iostream>
#include <algorithm> 
using namespace std;
int a[3][31];
int d[31][31];
int c[501][501];
struct node{
 int p,x;	
	
	
}b0[31],b1[31],b2[31];
int cmp(node q,node w){
return q.p<w.p;
}
int main(){
	int as=1000000000;
	int i,j,k,l,m,n,C;	
	scanf("%d%d",&n,&C);
	for(i=1;i<=C;i++){
			for(j=1;j<=C;j++){
		scanf("%d",&d[i][j]);
	}
}
for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
		scanf("%d",&c[i][j]);	
}	
}
for(i=1;i<=C;i++){
for(j=1;j<=n;j++){
for(k=1;k<=n;k++)
{a[(k+j)%3][i]+=d[c[j][k]][i];
	}
}

}
for(i=1;i<=C;i++){
b0[i].p=a[0][i];
b0[i].x=i;
}
for(i=1;i<=C;i++){
b1[i].p=a[1][i];
b1[i].x=i;
}
for(i=1;i<=C;i++){
b2[i].p=a[2][i];
b2[i].x=i;
}
sort(b0+1,b0+C+1,cmp);
sort(b1+1,b1+C+1,cmp);
sort(b2+1,b2+C+1,cmp);
for(i=1;i<=3;i++){
for(j=1;j<=3;j++){
	 
for(k=1;k<=3;k++){
if((b1[j].x!=b2[k].x)&&(b0[i].x!=b2[k].x)&&(b0[i].x!=b1[j].x)){
if(b1[j].p+b0[i].p+b2[k].p<as)as=b1[j].p+b0[i].p+b2[k].p;
}
}
}
} 
printf("%d",as);
return 0;
}

Measured memory_bytes: 1280
import sys
input = sys.stdin.readline

N = int(input())
S = input()

if N % 2 != 0:
    print('No')
else:
    for i in range(N // 2):
        if S[i] == S[i + N // 2]:
            continue
        else:
            print('No')
            exit()
    print('Yes')

Measured memory_bytes: 38740
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define int long long
#define double long double
#define all(a) a.begin(), a.end()
#define debug(x) cout << #x << " = " << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(void){

    int a, b, c; cin >> a >> b >> c;
    if((a < c and c < b) or (a > c and c > b))cout << "Yes" << endl;
    else cout << "No" << endl;

}

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

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

  int maxH = 0;
  int cnt;

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

    if(i == 0 || h >= maxH){
      cnt++;
      maxH = h;
    }
  }

  cout << cnt << endl;

  return 0;

}


Measured memory_bytes: 256
n,m=map(int,input().split())
g=[[] for _ in range(n)]
cnt=[0]
for _ in range(m):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
def dfs(z,s):
    if sum(z)==n:
        cnt[0]+=1
    else:
        for i in g[s]:    
            if z[i]==0:
                dfs(z[:i]+[1]+z[i+1:],i)

dfs([1]+[0]*(n-1),0)
print(*cnt)

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

int main() {
  
  string b;
  
  cin>> b;
  
  if(b=="A"){
    cout<< "T" <<endl;
  }
    if(b=="T"){
    cout<< "A" <<endl;
  }
    if(b=="C"){
    cout<< "G" <<endl;
  }
    if(b=="G"){
    cout<< "C" <<endl;
  }
  
}


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

signed main() {
  string S, T; cin >> S >> T;
  T.erase(T.size()-1);
  if(S==T) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{
  int X;
  cin>>X;
  if(X<1200)
  {
    cout<<"ABC"<<endl;
  }
  else if(X < 2800)
  {
    cout<<"ARC"<<endl;
  }
  else
  {
    cout<<"AGC"<<endl;
  }
  
  
  
  return;
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=j;i<=k;i++)
int read(){
	int x=0,l=1; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') l=-1; ch=getchar();}
	while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
	return x*l;
}
using namespace std;
char s[200005]; int l,dp[1<<26],an,zt; bool fl[26];
int main(){
	scanf("%s",s+1); int n=strlen(s+1);
	memset(dp,127,sizeof(dp));
	zt=1<<(s[1]-97); dp[0]=0; dp[zt]=1;
	For(j,2,n){
		zt=zt^(1<<(s[j]-97));
		For(i,0,25){
			l=zt^(1<<i); dp[zt]=min(dp[zt],dp[l]+1);
		}
		if (j==n) an=dp[zt];
	}
	printf("%d\n",max(an,1));
	return 0;
}

Measured memory_bytes: 262528
n,l=map(int, input().split())
ll = sorted(list(map(lambda x: x+l-1, list(range(1,n+1)))))
tmp, ind = 10 ** 8, 10 ** 8
for i, ringo in enumerate(ll):
    if abs(ringo) < tmp:
        ind = i
        tmp = abs(ringo)
ll.pop(ind)
print(sum(ll))

Measured memory_bytes: 3064
import java.io.*;
    import java.util.*;
    public class Main {
    	
    	public static void main(String[] args) {
    		InputReader in = new InputReader();
    		int n = in.nextInt();
    		int d = in.nextInt();
    		
    		int[][] pts = new int[n][d];
    		for (int i=0; i<n; i++)
    			for (int j=0; j<d; j++)
    				pts[i][j] = in.nextInt();
    		
    		int res = 0;
    		for (int i=0; i<n-1; i++) {
    			for (int j=i+1; j<n; j++) {
    				int inside = 0;
    				for (int k=0; k<d; k++)
    					inside += (pts[i][k]-pts[j][k])*(pts[i][k]-pts[j][k]);
    				double dist = Math.sqrt(inside);
    				if (isInteger(dist))
    					++res;
    			}
    		}
    		System.out.println(res);
    	}
    	
    	static final double EPSILON = 1e-6;
    	public static boolean isInteger(double d) {
    		for (int i=(int)(d-3); i<(int)(d+3); i++)
    			if (Math.abs(d - i)  < EPSILON)
    				return true;
    		return false;
    	}
     
    	static class InputReader {
    		public BufferedReader br;
    		public StringTokenizer st;
    		
    		public InputReader() {
    			br = new BufferedReader(new InputStreamReader(System.in));
    			st = null;
    		}
    		
    		public String next() {
    			while (st == null || !st.hasMoreTokens()) {
    				try {
    					st = new StringTokenizer(br.readLine());
    				}
    				catch (IOException e) {
    					throw new RuntimeException(e);
    				}
    			}
    			return st.nextToken();
    		}
    		
    		public int nextInt() {
    			return Integer.parseInt(next());
    		}
    	}
    }

Measured memory_bytes: 23252
#include<bits/stdc++.h>
//n个人，k个糖果
//高桥会对没有糖果的人做恶作剧。
//问有几人？
using namespace std;
int n, k, d, ans, a[105], f[105];
int main()
{
    cin>> n>> k;
    for(int i=1; i<=k; i++){
        cin>> d;
        for(int j=1; j<=d; j++){
            cin>> a[i];
            f[a[i]]++;
        }
    }
    for(int i=1; i<=n; i++){
        if(f[i]==0)
            ans++;
    }
    cout<< ans;
    return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>
 
int main(){

    int x,a,b,c,d;
    scanf("%d %d %d",&x,&a,&b);
    
    c = x >= a ? x - a : a - x;
    d = x >= b ? x - b : b - x;
    
    if(c<d) {
        printf("A\n");
    }
    else { 
        printf("B\n");
    }

  return 0;
}

Measured memory_bytes: 1636
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    S = list(_ for _ in input())
    # print(S)
    if S[0] != 'A':        
        print('WA')
        return
    S.pop(0)
    # print(S)
    if S[1:-1].count('C') != 1:
        print('WA')
        return
    S.pop(S.index('C',1,-1))
    # print(S)
    for s in S:
        if s.isupper():
            print('WA')
            return
    print('AC')
    return
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572