akhauriyash/Code-Regression huggingface dataset:
//g++ -std=c++14 test.cpp -o test.out
//問題URL:
//https://atcoder.jp/contests/abc164/tasks/abc164_e

//参考：
//https://drken1215.hatenablog.com/entry/2020/04/27/190000

//ポイント：
//グラフそのものにレイヤーをイメージするという考え方

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,M,S;
vector<vector<tuple<LL,LL,LL>>> adj;
LL C[51],D[51];

LL ans[51];

void solve(){
	S = min(2500LL,S);
	//レイヤー分けされたグラフを考えダイクストラ 
	//tuple<点iに残り銀貨j枚で到達するための最短距離,i,j>
	priority_queue<tuple<LL,LL,LL>,vector<tuple<LL,LL,LL>>,greater<tuple<LL,LL,LL>>> q;
	q.push(tuple<LL,LL,LL>(0,1,S));
	//わかっている中での、点iに残り銀貨j枚で到達するための最短距離をdist[i][j]とする
	vector<vector<LL>> dist(N+1,vector<LL>(2501,INF));
	dist[1][S] = 0;
	while(!q.empty()){
		LL dist_ij = get<0>(q.top());//点iに残り銀貨j枚で到達するための最短距離
		LL i = get<1>(q.top());//点i
		LL j = get<2>(q.top());//残り銀貨j枚
		q.pop();
		if(dist[i][j]<dist_ij) continue;
		//銀貨を補充
		if(j+C[i]<=2500){
			LL next_j = j + C[i];
			if(dist[i][next_j]>dist[i][j]+D[i]){
				dist[i][next_j] = dist[i][j]+D[i];
				q.push(tuple<LL,LL,LL>(dist[i][next_j],i,next_j));
			}
		}
		//列車に乗る
		for(auto next:adj[i]){
			LL next_i = get<0>(next);
			LL silver_required = get<1>(next);
			LL time_required = get<2>(next);

			LL next_j = j-silver_required;
			if(next_j<0) continue;

			if(dist[next_i][next_j]>dist[i][j]+time_required){
				dist[next_i][next_j] = dist[i][j]+time_required;
				q.push(tuple<LL,LL,LL>(dist[next_i][next_j],next_i,next_j));
			}
		}
	}

	for(int i=2;i<=N;i++){
		ans[i] = INF;
		for(int j=0;j<=2500;j++){
			ans[i] = min(ans[i],dist[i][j]);
		}
	}
}

int main(){
    cin >> N >> M >> S;
    adj = vector<vector<tuple<LL,LL,LL>>>(N+1);
    for(int i=0;i<M;i++){
    	LL u,v,a,b;cin >> u >> v >> a >> b;
    	adj[u].push_back(tuple<LL,LL,LL>(v,a,b));
    	adj[v].push_back(tuple<LL,LL,LL>(u,a,b));
    }
    for(int i=1;i<=N;i++) cin >> C[i] >> D[i];

    solve();

    for(int i=2;i<=N;i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 6936
import java.io.*;
import java.util.*;

class Main{
    public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
    
        int N = Integer.parseInt(br.readLine());
        
        if((N % 2) == 0){
          System.out.println(N/2);
        }else{
          System.out.println((N/2) + 1);   
        }

      }
    }
}

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

int main(){
    int n;
    cin >> n;
    int A[n];
    for( int k=0 ; k<n ; k++){
        cin >> A[k];
    }
    for( int k=0 ; k<n-1 ; k++){
        cout << A[k]<< " ";
    }
    cout << A[n-1] << endl;

    for( int i=1 ; i<n ; i++ ){
        int j,v;
        v = A[i];
        j = i-1;
        while( j>= 0 && A[j]>v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        for( int k=0 ; k<n-1 ; k++){
            cout << A[k]<< " ";
        }
        cout << A[n-1] << endl;
    }
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int dp[41][401][401];
int main(){
  int n,ma,mb;cin>>n>>ma>>mb;
  int a[n],b[n],c[n];
  for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
  for(int i=0;i<41;i++){
    for(int j=0;j<401;j++){
      for(int k=0;k<401;k++){
        dp[i][j][k]=10000;
      }
    }
  }
  dp[0][0][0]=0;
  int m=10000;
  for(int i=0;i<n;i++){
    for(int j=0;j<401;j++){
      for(int k=0;k<401;k++){
        if(dp[i][j][k]<10000){
          dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
          if((j+a[i])*mb==(k+b[i])*ma){
            m=min(m,dp[i][j][k]+c[i]);
            continue;
          }
          dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
        }
      }
    }
  }
  if(m==10000)cout<<-1<<endl;
  else cout<<m<<endl;
}

Measured memory_bytes: 25984
import java.util.*;
public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		TreeSet<Integer> set = new TreeSet<Integer>();
		
		String s = sc.next(), t = sc.next();
		
		int arrs[] = new int[s.length()];
		int arrt[] = new int[t.length()];
		
		for(int i = 0; i<s.length(); i++) arrs[i] = (int)s.charAt(i);
		for(int i = 0; i<t.length(); i++) arrt[i] = (int)t.charAt(i);
		
		Arrays.sort(arrs); Arrays.sort(arrt);
		
		if(t.length() <= s.length()) {
			for(int i = 0; i<t.length(); i++) {
				if(arrs[i] > arrt[t.length()-i-1]) {
					System.out.println("No");
					System.exit(0);
				}
				else if(arrs[i] < arrt[t.length()-i-1]) {
					System.out.println("Yes");
					System.exit(0);
				}
			}
			System.out.println("No");
		}
		else {
			for(int i = 0; i<s.length(); i++) {
				if(arrs[i] > arrt[t.length()-i-1]) {
					System.out.println("No");
					System.exit(0);
				}
				else if(arrs[i] < arrt[t.length()-i-1]) {
					System.out.println("Yes");
					System.exit(0);
				}
			}
			
			System.out.println("Yes");
		}
		
		
		
		
	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int done=1;
	int n=s.size();
	for(int i=0;i<(n-1)/2;i++){
		if(s[i]!=s[n-i-1]){
			done=-1;
			break;
		}
	}
	if(done==-1){
		cout<<"No"<<endl;
	}else {
		int p=(n-1)/2;
		if(p%2==0){
				for(int i=0;i<(p)/2;i++){
		if(s[i]!=s[p-i-1]){
			//cout<<"yyly"<<endl;
			done=-1;
			break;
		}
	}
		}else {
				for(int i=0;i<(p-1)/2;i++){
		if(s[i]!=s[p-i-1]){
		//	cout<<"yyly"<<endl;
			done=-1;
			break;
		}
	}
		}
		
	
	if(done==-1){
		cout<<"No"<<endl;
	}else {
		cout<<"Yes"<<endl;
	}
	}
	return 0;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end
N=gets.to_i
a=get_i
l={}
a.each do|a_|
  l[a_]=0 if l[a_].nil?
  l[a_]+=1
end
l_=[]
l.each do|key,num|
  if num>=4
      l_.push(key)
      l_.push(key)
  elsif num>=2
      l_.push(key)
  end
end
l_.sort!{|x,y| y<=>x}
puts l_==[] ? 0 : l_[0]*l_[1]

Measured memory_bytes: 16012
#include<iostream>

using namespace std;

int main() {
	int x, y, z;
	cin >> x;
	cin >> y;
	cin >> z;
	if (x < y && y < z) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

M=1000050

dp=[0 for i in range(M)]

ans=0
for x in A:
    if dp[x]!=0:
        dp[x]=2
        continue
    for i in range(x,M,x):
        dp[i]+=1

for x in A:
    if dp[x]==1:
        ans+=1

print(ans)


Measured memory_bytes: 195604
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a)
    {
        cout << k << endl;
    }
    else if (k <= a + b)
    {
        cout << a << endl;
    }
    else
    {
        cout << a - (k - (a + b)) << endl;
    }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

double EPS = 1e-10;

// 誤差を考慮した足し算
double add(double a, double b)
{
    if (abs(a + b) < EPS * (abs(a) + abs(b))) return 0;
    return a + b;
}

// 二次元ベクトル構造体
struct P
{
    double x, y;

    P() {}

    P(double x, double y) : x(x), y(y) {}

    P operator + (P p)
    {
        return P(add(x, p.x), add(y, p.y));
    }

    P operator - (P p)
    {
        return P(add(x, -p.x), add(y, -p.y));
    }

    P operator * (double d)
    {
        return P(x * d, y * d);
    }

    // 内積
    double dot(P p)
    {
        return add(x * p.x, y * p.y);
    }

    // 外積
    double det(P p)
    {
        return add(x * p.y, -y * p.x);
    }
};

// 辞書順 比較
bool cmp_x(const P &p, const P &q)
{
    if (p.x != q.x) return p.x < q.x;
    return p.y < q.y;
}

// 凸包
vector<P> convex_hull(P *ps, int n)
{
    sort(ps, ps + n, cmp_x);

    // 凸包 頂点数
    int k = 0;

    // 凸包 構築中
    vector<P> qs(n * 2);

    // 凸包 下側
    for (int i = 0; i < n; i++)
    {
        while (k > 1
            && (qs[k - 1] - qs[k - 2]).det
            (ps[i] - qs[k - 1]) <= 0) k--;

        qs[k++] = ps[i];
    }

    // 凸包 上側
    for (int i = n - 2, t = k; i >= 0; i--)
    {
        while (k > t
            && (qs[k - 1] - qs[k - 2]).det
            (ps[i] - qs[k - 1]) <= 0) k--;

        qs[k++] = ps[i];
    }
    qs.resize(k - 1);
    return qs;
}

// ベクトルの長さを計算する
double get_vector_length(P v) {
    return pow((v.x * v.x) + (v.y * v.y), 0.5);
}

// ２つのベクトルABのなす角度θを求める
double AngleOf2Vector(P A, P B)
{
    // ベクトルAとBの長さを計算する
    double length_A = get_vector_length(A);
    double length_B = get_vector_length(B);

    // 内積とベクトル長さを使ってcosθを求める
    double cos_sita = A.dot(B) / ( length_A * length_B );

    // cosθからθを求める
    double sita = acos( cos_sita );

    if (fabs(cos_sita + 1) < EPS)
    {
        sita = 1.0;
    }

    // ラジアンでなく0～180の角度
    //sita = sita * 180.0 / PI;

    return sita;
}

map<P, double> aix;

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

    P p[N];
    P x[N];

    REP(i, N)
    {
        double x, y;
        cin >> x >> y;
        p[i] = P(x, y);
    }

    memcpy(x, p, sizeof p);
    vector<P> c = convex_hull(p, N);

    int s = c.size();
    double sm = 0.0;

    double ans[N] = {0.0};
    REP(i, s)
    {
        auto x1 = c[(i - 1  + s) % s];
        auto x2 = c[i];
        auto x3 = c[(i + 1) % s];

        auto a = AngleOf2Vector((x2 - x1), (x3 - x2));
        sm += a;

        REP(j, N)
        {
            if (x[j].x == x2.x && x[j].y == x2.y) ans[j] = a;
        }
    }

    cout << fixed;

    REP(i, N)
    {
        cout << setprecision(20) << ans[i] / sm << endl;
    }

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#define MAX 101
#define inf 1<<29
using namespace std;

typedef pair<int,int> P;

struct edge{ int to,cap,cost,rev; };

int v;
vector<edge> e[MAX];
int h[MAX];
int dist[MAX];
int prevv[MAX],preve[MAX];

void add_edge(int from,int to,int cap,int cost){
  e[from].push_back((edge){to,cap,cost,e[to].size()});
  e[to].push_back((edge){from,0,-cost,e[from].size()-1});
}

int min_cost_flow(int s,int t,int f){
  int res=0;
  fill(h,h+v,0);
  while(f>0){
    priority_queue<P,vector<P>,greater<P> > pq;
    fill(dist,dist+v,inf);
    dist[s]=0;
    pq.push(P(0,s));
    while(pq.size()){
      P p=pq.top();
      pq.pop();
      int u=p.second;
      if(dist[u]<p.first)continue;
      for(int i=0;i<e[u].size();i++){
        edge &E=e[u][i];
        if(E.cap>0 && dist[E.to]>dist[u]+E.cost+h[u]-h[E.to]){
          dist[E.to]=dist[u]+E.cost+h[u]-h[E.to];
          prevv[E.to]=u;
          preve[E.to]=i;
          pq.push(P(dist[E.to],E.to));
        }
      }
    }
    if(dist[t]==inf)return -1;
    for(int i=0;i<v;i++)h[i]+=dist[i];

    int d=f;
    for(int u=t;u!=s;u=prevv[u]){
      d=min(d,e[prevv[u]][preve[u]].cap);
    }
    f-=d;
    res+=d*h[t];
    for(int u=t;u!=s;u=prevv[u]){
      edge &E=e[prevv[u]][preve[u]];
      E.cap-=d;
      e[u][E.rev].cap+=d;
    }
  }
  return res;
}

int main()
{
  int m,f,a,b,c,d;
  
  cin>>v>>m>>f;
  for(int i=0;i<m;i++){
    cin>>a>>b>>c>>d;
    add_edge(a,b,c,d);
  }

  cout<<min_cost_flow(0,v-1,f)<<endl;

  return 0;
}

Measured memory_bytes: 1284
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    string S,T;
    ll N,ans,A;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>S>>T;
    sort(S.begin(),S.end());
    sort(T.begin(),T.end());
    reverse(T.begin(),T.end());
    cout<<(S<T?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r=min(r,n-r)

    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10 ** 9 + 7  # 出力の制限
N = 10 ** 5
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
mod =10**9+7
mi = 0
ma = 0
for i in range(n - k + 1):
    x = cmb(n - i - 1, k - 1, mod)
    mi += a[i] * x
    ma += a[n - 1 - i] * x
    mi %= mod
    ma %= mod

ans = ma - mi

print(ans % mod)

Measured memory_bytes: 67172
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		long n = scan.nextInt();
		long ac = 0;
		long wa = 0;
		long tle = 0;
		long re = 0;
		for (int i = 0; i < n; i++) {
			String st = scan.next();
			switch (st) {
			case "AC":
				ac++;
				break;
			case "WA":
				wa++;
				break;
			case "TLE":
				tle++;
				break;
			default:
				re++;

			}
		}

		System.out.println("AC x " + ac);
		System.out.println("WA x " + wa);
		System.out.println("TLE x " + tle);
		System.out.println("RE x " + re);
	}

}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream&
operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream&
operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream&
operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

int one_hot(int x) { return 1 << x; }

pii calc_arg(int dx, int dy) {
    if(dx < 0) {
        dx *= -1;
        dy *= -1;
    }
    int g = __gcd(abs(dx), abs(dy));
    dx /= g;
    dy /= g;
    if(dx == 0) dy = 1;
    else if(dy == 0) dx = 1;
    return make_pair(dx, dy);
}

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

    int N; cin >> N;
    vector<int> X(N), Y(N);
    rep(i, N) cin >> X[i] >> Y[i];
    int ans = 0;
    function<void(int, map<pii, int>&)> dfs = [&] (int used, map<pii, int> &args) {
        if(__builtin_popcount(used) == N) {
            int tmp = 0;
            for(auto &p : args) {
                tmp += p.second * (p.second - 1) / 2;
            }
            set_max(ans, tmp);
            return;
        }
        int now = -1;
        rep(i, N) if(not(used & one_hot(i))) {
            now = i;
            break;
        }
        assert(now >= 0);
        used |= one_hot(now);
        rep(i, N) {
            if(not (used & one_hot(i))) {
                pii arg = calc_arg(X[now] - X[i], Y[now] - Y[i]);
                args[arg]++;
                dfs(used | one_hot(i), args);
                if(--args[arg] == 0) args.erase(arg);
            }
        }
    };
    map<pii, int> args;
    dfs(0, args);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3216
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    A = LI()

    x = 0
    for i in A[2:]:
        x ^= i

    s = A[0] + A[1]
    if s - x < 0 or (s - x) % 2:
        print(-1)
        return

    a = (s-x)//2
    if a & x:
        print(-1)
        return

    b = 1 << (A[0].bit_length() - 1)
    while b > 0:
        if b & x and a + b <= A[0]:
            a += b
        b >>= 1
    if 0 < a <= A[0]:
        print(A[0] - a)
    else:
        print(-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 75072
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

struct L {
  int a, b, c;
  L(int a = 0, int b = 0, int c = 0): a(a), b(b), c(c) {}
};

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

signed main() {
  int N, M;
  cin >> N >> M;

  map<int, int> mx, my;
  mx[0] = 0;
  my[0] = 0;

  vector<L> xx, yy;

  REP(i, N){
    int a, b, c;
    cin >> a >> b >> c;
    mx[a] = 0;
    mx[b] = 0;
    my[c] = 0;
    xx.emplace_back(a, b, c);
  }
  REP(i, M){
    int a, b, c;
    cin >> a >> b >> c;
    mx[a] = 0;
    my[b] = 0;
    my[c] = 0;
    yy.emplace_back(a, b, c);
  }

  vector<int> xs, ys;
  for(auto& p : mx){
    p.second = xs.size();
    xs.emplace_back(p.first);
  }
  for(auto& p : my){
    p.second = ys.size();
    ys.emplace_back(p.first);
  }

  int H = xs.size()*2;
  int W = ys.size()*2;

  vector<vector<int>> d(H, vector<int>(W));
  REP(i, N){
    int a = mx[xx[i].a]*2;
    int b = mx[xx[i].b]*2;
    int c = my[xx[i].c]*2;
    FOR(j, a, b+1) d[j][c] = -1;
  }
  REP(i, M){
    int a = mx[yy[i].a]*2;
    int b = my[yy[i].b]*2;
    int c = my[yy[i].c]*2;
    FOR(j, b, c+1) d[a][j] = -1;
  }

  int sx = mx[0]*2, sy = my[0]*2;

  queue<pair<int, int>> q;
  q.emplace(sx, sy);

  d[sx][sy] = 1;

  while(!q.empty()){
    auto [x, y] = q.front(); q.pop();
    REP(i, 4){
      int nx = x+dx[i];
      int ny = y+dy[i];
      if(OUT(0, nx, H) || OUT(0, ny, W)) continue;
      if(d[nx][ny] != 0) continue;
      d[nx][ny] = 1;
      q.emplace(nx, ny);
    }
  }

  int ans = 0;
  REP(i, H) REP(j, W){
    if(d[i][j] != 1) continue;
    if(i == 0 || i == H-1 || j == 0 || j == W-1){
      cout << "INF" << "\n";
      return 0;
    }

    if(i%2 == 0 || j%2 == 0) continue;
    int ex = xs[i/2+1]-xs[i/2];
    int ey = ys[j/2+1]-ys[j/2];
    ans += ex*ey;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 285356
N = int(input())
res = []
while N != 0:
    if N % -2 != 0:
        res.append("1")
    else:
        res.append("0")
    
    if N == 1:
        break

    if N % -2 != 0:
        N -= 1
    N //= -2

if N != 0:
    print("".join(reversed(res)))
else:
    print(0)

Measured memory_bytes: 3060
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	type city struct {
		pref int
		year int
	}
	cities := make([]city, m)
	years := make([]int, m)
	yearPref := map[int]int{}
	for i := 0; i < m; i++ {
		var p, y int
		fmt.Scan(&p, &y)
		cities[i] = city{pref: p, year: y}
		years[i] = y
		yearPref[y] = p
	}
	sort.Ints(years)
	yearCount := map[int]int{}
	prefCount := map[int]int{}
	for _, y := range years {
		p := yearPref[y]
		prefCount[p]++
		yearCount[y] = prefCount[p]
	}
	for _, c := range cities {
		s := fmt.Sprintf("%06d%06d", c.pref, yearCount[c.year])
		fmt.Println(s)
	}
}


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


int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    
    for(int i= 0;i < n; i++){
        cin >> a.at(i);
    }
    
    vector<long long> b(n),c(n);
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(a.at(i) > a.at(j)){
                if(i < j){
                    b.at(i)++;
                    c.at(i)++;
                }else{
                    c.at(i)++;
                }
            }
        }
    }
    
    long long answer=0;
    
    for(int i = 0; i < n; i++){
        answer += b.at(i) * (long long)k;
        answer %= 1000000007;
        long long tmp = (long long) k * (long long) (k - 1) / 2;
        tmp %= 1000000007;
        answer += c.at(i) * tmp;
        answer %= 1000000007;
    }
    
    cout << answer << endl;
    
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
mod = 10**9 + 7

def comb_mod(n, r, mod):
    num = 1
    den = 1
    for i in range(r):
        num = (num * (n-i)) % mod
        den = (den * (i+1)) % mod
    return num * pow(den, mod-2, mod)

ans = pow(2, n, mod) - comb_mod(n, a, mod) - comb_mod(n, b, mod) - 1
print(ans%mod)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdlib>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

class results {
public:
  int orgNum;
  int tTime;
  int tSolved;

  bool operator<(const results& right) const {
    if(tSolved < right.tSolved) {
      return 0;
    }
    else if(tSolved > right.tSolved) {
      return 1;
    }
    else {
      if(tTime < right.tTime) {
	return 1;
      }
      else if(tTime > right.tTime) {
	return 0;
      }
      else {
	if(orgNum > right.orgNum) {
	  return 1;
	}
	else {
	  return 0;
	}
      }
    }
  };

  void init(int num) {
    orgNum = num;
    tTime = 0;
    tSolved = 0;
  }
  void update(int t) {
    tTime += t;
    tSolved += 1;
  }
};

class problems {
public:
  int pTime;
  int pSolved;

  void init() {
    pTime = 0;
    pSolved = 0;
  }
  void init(int t, int s) {
    if(s == 0) {
      pTime = t;
      pSolved = 1;
    }
    else {
      pTime = 20;
      pSolved = 0;
    }
  }
  void update(int t, int s) {
    //pTime += t;
    if(s == 0) {
      pTime += t;
      pSolved = 1;
    }
    else {
      pTime += 20;
    }
  }
};

int main() {
  int m, t, p, r;
  while(cin>>m>>t>>p>>r && m>0) {
    map<pair<int, int>, problems> inputs;
    int tmpM, tmpT, tmpP, tmpJ;
    for(int i=0; i<r; i++) {
      cin>>tmpM>>tmpT>>tmpP>>tmpJ;
      tmpT--;
      tmpP--;
      if(!inputs.count(make_pair(tmpT, tmpP))) {
	problems tmpData;
	tmpData.init(tmpM, tmpJ);
	inputs.insert(make_pair(make_pair(tmpT, tmpP), tmpData));
      }
      else {
	inputs[make_pair(tmpT, tmpP)].update(tmpM, tmpJ);
      }
    }

    vector<results> ans;
    for(int i=0; i<t; i++) { // team
      results tmp;
      tmp.init(i);
      //for(int j=0; j<inputs.size(); j++) { // problem
      for(int j=0; j<p; j++) {
	map<pair<int, int>, problems>::iterator itr;
	//auto itr = inputs.find(make_pair(i,j)); // C++11
	itr = inputs.find(make_pair(i,j)); // チーム i の問題 j を確認
	if(itr != inputs.end()) {
	  if(inputs[itr->first].pSolved == 1) { // ???
	    tmp.update(inputs[itr->first].pTime);
	  }
	}
      }
      //cout<<tmp.orgNum<<" "<<tmp.tSolved<<" "<<tmp.tTime<<endl;
      ans.push_back(tmp);
    }

    // print
    /*
    for(int i=0; i<ans.size(); i++) {
      cout<<ans[i].orgNum<<" "<<ans[i].tSolved<<" "<<ans[i].tTime<<endl;
    }
    */

    sort(ans.begin(), ans.end());
    /*
    for(int i=0; i<ans.size(); i++) {
      cout<<ans[i].orgNum<<" "<<ans[i].tSolved<<" "<<ans[i].tTime<<endl;
    }
    */

    for(int i=0; i<ans.size()-1; i++) {
      cout<<ans[i].orgNum+1;
      if(ans[i].tSolved==ans[i+1].tSolved && ans[i].tTime==ans[i+1].tTime) {
	cout<<"=";
      }
      else {
	cout<<",";
      }
    }
    //int tmp = ans.size();
    cout<<ans[ans.size()-1].orgNum+1<<endl;
  }
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int dp[1<<10][MAX];

int main(){
    int n; cin >> n;
    vector<int> v(n+1), w(n+1);
    rep(i, n) cin >> v[i+1] >> w[i+1];
    
    int q; cin >> q;
    vector<int> u(q), l(q);
    rep(i, q) cin >> u[i] >> l[i];

    int k = 0;
    while(n > 0){
        n /= 2; k++;
    }
    k /= 2;
    repn(i, 1<<k) dp[i][0] = 0;
    rep(x, MAX) dp[0][x] = 0;

    repn(i, 1<<k) repn(x, 100000){
        dp[i][x] = max(dp[i/2][x], dp[i][x-1]);
        if(x-w[i]>=0) dp[i][x] = max(dp[i][x], dp[i/2][x-w[i]]+v[i]);
    }

    rep(i, q){
        vector<int> s;
        while(u[i] >= (1<<k)){
            s.push_back(u[i]);
            u[i] /= 2;
        }
        int res = 0;
        rep(j, 1<<(s.size())){
            int sv = 0, sw = 0;
            rep(d, s.size()){
                if(j & (1<<d)){
                    sv += v[s[d]];
                    sw += w[s[d]];
                }
            }
            if(sw > l[i]) continue;
            res = max(res, sv + dp[u[i]][l[i]-sw]);
        }
        out(res);
    }
}


Measured memory_bytes: 206540
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int n, m, a, b, deg[100010], ans[100010];
vector<int> g[100010];

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

  cin >> n >> m;
  for(int i = 0; i < n - 1 + m; ++i) {
    cin >> a >> b;
    g[a].push_back(b);
    ++deg[b];
  }

  int root;
  for(int i = 1; i <= n; ++i) if(deg[i] == 0) root = i;

  queue<int> q;
  q.push(root);
  while(q.size()) {
    int v = q.front(); q.pop();
    
    for(int nv : g[v]) {
      --deg[nv];
      if(deg[nv] == 0) {
        q.push(nv);
        ans[nv] = v;
      }
    }
  }
  for(int i = 1; i <= n; ++i) cout << ans[i] << '\n';
  return 0;
}

Measured memory_bytes: 7040
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int X = scn.nextInt();
		int ans = 0;
		for(int i = 0;i < N;i++) {
			int x =Math.abs(scn.nextInt() - X);
			if(i == 0) {
				ans = x;
			}else {
				ans = yaku(ans,x);
			}
		}
		System.out.println(ans);
		scn.close();
	}
	public static int yaku(int a,int b) {
		if(a > b) {
			int buf = a;
			a = b;
			b = buf;
		}
		while(b%a !=0) {
			int buf = b%a;
			b = a;
			a = buf;
		}
		return a;
	}
}


Measured memory_bytes: 48112
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,u,v,tot,dep[N],lg[N],fa[N][20],head[N],nex[N<<1],to[N<<1];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
void dfs(int u,int p)
{
    dep[u]=dep[p]+1;fa[u][0]=p;
    for(int i=1;1<<i<=dep[p];i++)
        fa[u][i]=fa[fa[u][i-1]][i-1];
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==p) continue;
        dfs(v,u);
    }
}
int LCA(int u,int v)
{
    if(dep[u]<dep[v]) swap(u,v);
    while(dep[u]>dep[v]) u=fa[u][lg[dep[u]-dep[v]]];
    if(u==v) return u;
    for(int i=lg[dep[u]];i>=0;i--)
        if(fa[u][i]!=fa[v][i])
        u=fa[u][i],v=fa[v][i];
    return fa[u][0];
}
int DIS(int u,int v)
{
    return dep[u]+dep[v]-2*dep[LCA(u,v)];
}
int main()
{
    for(int i=1;i<N;i++) lg[i]=lg[i-1]+(1<<lg[i-1]==i);
    for(int i=1;i<N;i++) lg[i]--;
    scanf("%d%d%d",&n,&u,&v);
    for(int i=1;i<n;i++)
    {
        int u,v;scanf("%d%d",&u,&v);
        add(u,v);add(v,u);
    }
    dfs(1,0);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(DIS(u,i)>=DIS(v,i)) continue;
        int len=DIS(v,i)-1;
        ans=max(ans,len);
    }
    cout<<ans;
}
/*
8 1 5
1 2
2 3
3 4
4 5
3 6
6 7
7 8
*/


Measured memory_bytes: 13440
#include<bits/stdc++.h>
int n,r,i,j,a[100];
main(){
scanf("%d",&n);
for(;i<n;i++)scanf("%d",a+i);
for(i=0;i<n;i++){
for(j=0;j<i;j++){
if(a[i]<a[j])r++;
}
}
std::sort(a,a+n);
for(int i=0;i<n;i++){if(i)printf(" ");printf("%d",a[i]);}
printf("\n%d\n",r);
}

Measured memory_bytes: 3228
h,w = [],[]
while True:
	a,b = map(int,input().split())
	if a == 0 and b == 0:
		break
	else:
		h.append(a)
		w.append(b)
for i in range(len(h)):
	print("#"*w[i])
	for k in range(h[i]-2):
		print("#{}#".format("."*(w[i]-2)))
	print("#"*w[i])
	print("")


Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void yn(bool j){cout << (j ? "Yes" : "No") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> long long bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}

ll N, M ,Q;
ll ans = 0;
vector<ll> a(155, 1), b(155, 1), c(155, 0), d(155, 0);


void dfs(vector<ll> t){
    if (t.size() == N){
        ll cnt = 0;
        rep(i, Q){
            if (t[b[i] - 1] - t[a[i] - 1] == c[i]){
                cnt += d[i];
            }
        }
        chmax(ans, cnt);
    }else{
        for(ll i = *(end(t) - 1); i <= M; i++){
            vector<ll> ti = t;
            ti.push_back(i);
            dfs(ti);
        }
    }
}

int main(){
    cin >> N >> M >> Q;
    rep(i, Q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    rep(i, M){
        vector<ll> t(1, i + 1);
        dfs(t);
    }
    pt(ans);
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){
	
	fastio;
	string s;
	cin >> s;
	int sum = 0;
	for(auto it:s){
		sum+=(it-48);
	}
	cout << (	sum%9?"No":"Yes") << "\n";
	
}


Measured memory_bytes: 3768
import java.util.*;
public class Main {

	class Athlete implements Comparable<Athlete>{
		int num;
		double record;
		Athlete() {};
		Athlete(int num, double record) {
			this.num = num;
			this.record = record;
		}

		public int compareTo(Athlete as) {
			if(this.record < as.record){
				return -1;
			}
			if(this.record > as.record){
				return 1;
			}
			return 0;
		}

	}

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		Athlete [][] array = new Athlete[3][8];
		for(int i=0; i < 3; i++){
			for(int j=0; j < 8; j++){
				int number = sc.nextInt();
				double time = sc.nextDouble();
				array[i][j] = new Athlete(number, time);
			}
			Arrays.sort(array[i]);
		}

		for(int i=0; i < 3; i++){
			System.out.printf("%d %1.2f\n",array[i][0].num,array[i][0].record);
			System.out.printf("%d %1.2f\n",array[i][1].num,array[i][1].record);
		}

		Athlete [] array2 = new Athlete[6];
		for(int i=0; i < 6; i+= 2){
			int number = array[i/2][2].num;
			double time = array[i/2][2].record;
			array2[i] = new Athlete(number,time);
			number = array[i/2][3].num;
			time = array[i/2][3].record;
			array2[i+1] = new Athlete(number,time);
		}
		Arrays.sort(array2);

		for(int i=0; i < 2; i++){
			System.out.printf("%d %1.2f\n",array2[i].num, array2[i].record);
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

Measured memory_bytes: 0
//In The Name of ALLAH//

/*      ______     _    _______
       |  ___ \   | |  |  ____/   /\
       | |   \ \  | |  | |       /  \
       | |___/ /  | |  | |___   / /\ \
       |     _/   | |  |  __/  / /__\ \
       | |\ \     | |  | |    / ______ \
       | | \ \    | |  | |   / /      \ \
       |_|  \_\   |_|  |_|  /_/        \_\
*/

#include<bits/stdc++.h>

//#define FILEIO
#define ll long long

using namespace std;

const int SZ = 52;
const int LIM = 1000000000;
const double EPS = 1e-9;
const int MOD = 100000008;
const int INF = ( 1 << 30 ) - 1;
const double PI = 2 * acos( 0.0 );

template <class T> T MIN(T a, T b) { return (a < b) ? a : b; }
template <class T> T MAX(T a, T b) { return (a > b) ? a : b; }
template <class T> void SWAP(T &a, T &b) { T c; c = a; a = b; b = c; }
template <class T> T GCD(T a, T b) { T c; while(b > 0) { c = a % b; a = b; b = c; } return a; }

bool CMP(int a, int b)
{
    return (a > b);
}

ll ans, mn, mx, n, x, len, sum, i, cnt, j, a[SZ];
string s, t;

void solve()
{
    cin >> s;
    scanf("\n");
    cin >> t;
    cnt = 0;
    for(i = 0; i < s.size(); i++)
    {
        if(s[i] != t[i])
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}
int main()
{
    #ifdef FILEIO
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ll tc, t = 0;

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

    return 0;
}


Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  ll n,k;cin>>n>>k;
  ll c=k;
  rep(i,n-1)c*=(k-1LL);
  cout<<c<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=105,INF=0x3f3f3f3f;
int n,v,ansNum,G[N][N],ans[N],Map[N];
signed main(void){
	ios::sync_with_stdio(false);
	while(cin>>n&&n!=0){
		v=0;
		ansNum=1;
		memset(G,0x3f,sizeof(G));
		memset(Map,0,sizeof(Map));
		memset(ans,0,sizeof(ans));
		for(int i=1,x,y,w;i<=n;i++){
			cin>>x>>y>>w;
			if(Map[x]==0)
				Map[x]=++v;
			x=Map[x];
			if(Map[y]==0)
				Map[y]=++v;
			y=Map[y];
			G[x][y]=G[y][x]=min(G[x][y],w);
		}
		for(int i=1;i<=v;i++)
			G[i][i]=0;
		for(int k=1;k<=v;k++)
			for(int i=1;i<=v;i++)
				for(int j=1;j<=v;j++)
					if(G[i][j]>G[i][k]+G[k][j])
						G[i][j]=G[i][k]+G[k][j];
		for(int i=1;i<=v;i++)
			for(int j=1;j<=v;j++)
				ans[i]+=G[i][j];
		for(int i=1;i<=v;i++)
			if(ans[i]<ans[ansNum])
				ansNum=i;
		for(int i=0;i<N;i++)
			if(Map[i]==ansNum){
				ansNum=i;
				break;
			}
		cout<<ansNum<<" "<<ans[Map[ansNum]]<<endl;
	}
}

Measured memory_bytes: 1248
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i;
    char p[3][100];
    for(i=0;i<3;i++)
    {
        scanf("%s",p[i]);
    }
    printf("%c%c%c",p[0][0],p[1][1],p[2][2]);
    return 0;
}


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

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;
const long long High = 1e16;

void solve()
{
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> B(m);
  vector<vector<int>> A(n, vector<int>(m));
  for (int i = 0; i < m; ++i)
    cin >> B[i];
  int ans = 0;
  for (int i = 0; i < n; ++i)
  {
    int sum = c;
    for (int j = 0; j < m; ++j)
    {
      cin >> A[i][j];
      sum += B[j]*A[i][j];
    }
    if(sum>0) ans++;
  }
  cout << ans;
}

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  int t = 1;
  //  cin >> t;
  while (t--)
    solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d)); //n*dの二次元配列
    for(int i = 0; i < n; i++){ //n
        for(int j = 0; j < d; j++){ //d
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < i; j++){ // j < i を全て
            int sq = 0;
            for(int k = 0; k < d; k++){
                int s = x[i][k] - x[j][k];
                sq += s*s; //平方根の中身
            }
            int s = sqrt(sq) + 0.5; //intは切り捨てられるので誤差を気にする
            if(s*s == sq) ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<cstdlib>
#include<map>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include <iostream>
#define ll long long
using namespace std;
int main()
{
    int a[100];
    int n;
    int sum=0;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=0; i<n-1; i++)
        for(int j=i+1; j<n; j++)
            sum+=a[i]*a[j];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    char c;
    bool fc=0;
    while(cin>>c){
        if(c=='C'&&!fc)
            fc=1;
        if(c=='F'&&fc){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
program main
 implicit none
 integer a(32)
 integer i

 read *,i

a=(/1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51/)

print '(i0)',a(i)

endprogram main


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


int pie(int x) {
	int y=x*(x + 1) / 2;
	return y;
}

int main() {
	int a;
	int sum = 0;
	while (cin >> a) {
		int sum = pie(a);
		sum += 1;
		cout << sum << endl;
		sum = 0;
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359;
#define inf (1 << 21);
#define mod 1000000007;

int main() {
    ll L, R; cin >> L >> R;
    ll Lm = L % 2019, Rm = R % 2019;
    ll Lq = L / 2019, Rq = R / 2019;
    ll ans = inf;
    if (Lq == Rq) {
        if (Lm <= 3 && Rm >= 673) {
            ans = 0;
        }
        else {
            for (ll i = Lm; i < Rm; i++) {
                for (ll j = i + 1; j <= Rm; j++) {
                    ans = min(ans, (i * j) % 2019);
                }
            }
        }
    }
    else {
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int SumOfDigits(int n) {
    int sum = 0;
    while(n >0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int N, a, b;
    cin >> N >> a >> b;
    int sum;
    int total = 0;
    for (int i = 1; i <= N; i++) {
        sum = SumOfDigits(i);
        //cout << i<< "," << sum << endl;
        if (sum >= a && sum <= b) {
            total += i;
        }
    }
    cout << total << endl;
}


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

using namespace std;

bool distance (vector<int> from, vector<int> to) {
    int d = 0;
    for (int i = 0; i < from.size(); i++) {
        d += abs(to[i]-from[i])*abs(to[i]-from[i]);
    }
    
    for (int i = 0; i*i <= d; i++) {
        if (i*i == d) {
            return true;
        }
    }

    return false;
}

int main(int argc, char* argv[])
{
    int N, D; cin >> N >> D;
    vector<int> chart[N];

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            int x; cin >> x;
            chart[i].push_back(x);
        }
    }

    int ret = 0;

    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            if (distance(chart[i], chart[j])) {
                ret++;
            }
        }
    }

    cout << ret << endl;
    return 0;
}

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

Measured memory_bytes: 580
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int N, M;
    cin >> N >> M;
    vb ans(M, true);
    for (int j = 0; j < N; j++) {
        int K;
        cin >> K;
        vi data(K);
        for (int i = 0; i < K; i++) {
            cin >> data.at(i);
        }
        for (int i = 0; i < M; i++) {
            if (!ans.at(i)) {
                continue;
            }
            bool finished = false;
            for (int k = 0; k < K; k++) {
                if (i == data.at(k) - 1) {
                    finished = true;
                    break;
                }
            }
            if (!finished) {
                ans.at(i) = false;
            }
        }
    }
    int count = 0;
    for (bool b : ans) {
        if (b) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  string s;
  cin>>s;
  vector<int> abc(26,0);
  bool ans=true;
  for(char c:s){
    abc[c-'a']++;
    if(abc[c-'a']>1) ans=false;
  }
  if(ans) cout<<"yes"<<endl;
  else cout<<"no"<<endl;
  return 0;
}


Measured memory_bytes: 256
#!python3

INF = -(10 ** 17)

# input
N = int(input())
A = list(map(int, input().split()))


def main():
    if N % 2 == 0:
        dp = [[INF] * 2 for _ in range(N)]
        dp[0][0] = A[0]
        dp[1][1] = A[1]
        for i in range(2, N):
            dp[i][0] = dp[i - 2][0] + A[i]
            if i > 2:
                dp[i][1] = max(dp[i - 2][1] + A[i], dp[i - 3][0] + A[i])
        
        ans = max(dp[-1][1], dp[-2][0])
        print(ans)
    else:
        dp = [[INF] * 3 for _ in range(N)]
        dp[0][0] = A[0]
        dp[1][1] = A[1]
        dp[2][0] = A[0] + A[2]
        dp[2][2] = A[2]
        for i in range(3, N):
            dp[i][0] = dp[i - 2][0] + A[i]
            dp[i][1] = max(dp[i - 2][1] + A[i], dp[i - 3][0] + A[i])
            if i > 3:
                a = dp[i - 2][2] + A[i]
                b = dp[i - 3][1] + A[i]
                c = dp[i - 4][0] + A[i]
                dp[i][2] = max(a, b, c)
        
        ans = max(dp[-1][2], dp[-2][1], dp[-3][0])
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 66528
/**
*    created: 12.05.2020 09:32:25
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int main() {
    int n;
    cin >> n;
    if(n%10==9||n/10==9) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 10000007
ll dp[3005][3005];
int main()
{
    string s,d;
    cin>>s>>d;

    ll n=s.size();
    ll m=d.size();
    //memset(dp,0,sizeof(dp));
    for(int i=n-1;i>=0;i--)
    {
        for(int j=m-1;j>=0;j--)
        {
           if(s[i]==d[j])
           {
               dp[i][j]=1+dp[i+1][j+1];
           }
           else
           {
               ll op1=dp[i+1][j];
               ll op2=dp[i][j+1];

               dp[i][j]=max({dp[i][j],op1,op2});
           }
        }
    }
    //cout<<dp[0][0]<<endl;
    int i=0,j=0;
    string k;
    while(i<n && j<m)
    {
        if(s[i]==d[j])
        {
            k.push_back(s[i]);
            i++;
            j++;
        }
        else if(dp[i+1][j]==dp[i][j])
        {
            i++;
        }
        else
        {
            j++;
        }

    }
   cout<<k<<endl;
   /*
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
        {
            //cout<<i<<"->"<<endl;
            //cout<<j<<"->"<<endl;
            cout<<dp[i][j]<< " ";
            //cout<<endl;
        }
        cout<<endl;
    }
    cout<<endl;
    //cout<<dp[2][6]<<endl;*/
}

Measured memory_bytes: 74068