akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define for1(i, m, n) for (int i = m; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int h, w;
        cin >> h >> w;
        if (h == 0 && w == 0) {
            break;
        }
        rep(i, h) {
            rep(j, w) {
                if (i == 0 || i == h - 1) {
                    cout << '#';
                } else {
                    if (j == 0 || j == w - 1) {
                        cout << '#';
                    } else {
                        cout << '.';
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3048
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void YN(int a){if(a==1)printf("Yes\n");if(a==0)printf("No\n");}
LL lpow(LL a,LL n){LL ans=pow(a,n)*10;if(ans%10<5)return ans/10;return ans/10+1;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL N,R,i,ans=0;
  scanf("%lld%lld",&N,&R);
  if(N<10)R+=100*(10-N);

  printf("%lld\n",R);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+5;
int a[26],b[26];
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	for(int i=0;i<s1.length();i++)
	{
		a[s1[i]-'a']++;
		b[s2[i]-'a']++;
	}
	for(int i=0;i<=25;i++)
	{
		for(int j=0;j<=25;j++)
		{
			if(a[i]==b[j])
			{
				a[i]=0;
				b[j]=0;
			}
		}
	}
	int flag=1;
	for(int i=0;i<=25;i++)
	{
		if(a[i]!=0)
		{
			flag=0;
			break;
		}
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 776
import std.stdio, std.string, std.conv;
import std.math;

void main() {
    auto pt = getStdin!(string[])[0].split(" ").to!(double[]);
	double dist = sqrt(pow(pt[2] - pt[0], 2) + pow(pt[3] - pt[1], 2));
	"%.8f".writefln(dist);
}

T getStdin(T)() {
    string[] cmd;
    string line;
    while ((line = chomp(stdin.readln())) != "") cmd ~= line;
    return to!(T)(cmd);
}

Measured memory_bytes: 2584
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define mp make_pair
#define maxn 100005
using namespace std;
const int inf = 0x3f3f3f3f;
const int neginf = 0xc0c0c0c0;
typedef long long ll;
typedef pair<int,int> P;
int n,x[maxn];
int gcd(int x,int y){
	if(y == 0) return x;
	return gcd(y,x % y);
}
int main(){
	scanf("%d%d",&n,&x[0]);
	for(int i=1;i<=n;i++){
		scanf("%d",&x[i]);
	}
	sort(x,x + n + 1);
	int ans = x[1] - x[0];
	for(int i=2;i<=n;i++){
		ans = gcd(ans,x[i] - x[i - 1]);
	}
	printf("%d\n",ans);
	return 0;
}


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

int main() {
  int n,m;
  cin >>n>>m;
  vector<int> saki(n+1,0);
  vector<int> ato(n+1,0);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    if(a==1)saki[b]=1;
    if(b==n)ato[a]=1;
  }
  for(int i=1;i<=n;i++){
    if(saki[i]==1&&ato[i]==1){
      cout<<"POSSIBLE"<<endl;
      return 0;
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 1792
// agin progrmaing contest 2019

#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

// AISing programming contest
bool visited[405][405];
int main() {
  int h,w; cin >> h >> w;
  vector<string> maze(h);
  rep(i,h) cin >> maze[i];

  vector<P> groups;
  auto bfs = [&](ii xy) {
    ll black = 0, white = 0;
    queue<ii> q;
    q.push(xy);
    visited[xy.second][xy.first] = true;
    while (q.size()) {
      int x = q.front().first;
      int y = q.front().second;
      q.pop();
      if (maze[y][x] == '#') black++;
      else white++;
      int dx[] = {0,1,0,-1};
      int dy[] = {1,0,-1,0};
      rep(i, 4) {
        int nx = x+dx[i];
        int ny = y+dy[i];
        if ( ny<0 || ny >= h || nx < 0 || nx >= w || visited[ny][nx]) continue;
        if (maze[y][x] == maze[ny][nx]) continue;
        q.emplace(nx, ny);
        visited[ny][nx] = true;
      }
    }
    groups.emplace_back(black, white);
  };

  rep(i,h) rep(j,w) {
    if (!visited[i][j]) {
      // cout << j << " "<< i << endl;
      bfs({j,i});
    }
  }
   
  ll ans = 0;
  for (auto p: groups) {
    ans += p.first * p.second;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 7848
import java.util.Scanner;
import java.util.TreeSet;

class Main{

	public static void main(String[] args) {


		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		int[] pArray = new int[N];
		int[] x = new int[M];
		int[] y = new int[M];
		for(int i = 0;i < N;i++){
			pArray[i] = scan.nextInt()-1;
		}
		UnionFind uf = new UnionFind(N);
		for(int i = 0;i < M;i++){
			x[i] = scan.nextInt()-1;
			y[i] = scan.nextInt()-1;
			uf.unite(x[i], y[i]);
		}
		int count = 0;
		for(int i = 0;i < N;i++){
			if(uf.same(i, pArray[i])){
				count++;
			}
		}
		System.out.println(count);

	}


}

class UnionFind{
	int[] parent;
	public UnionFind(int N){
		this.parent = new int[N];
		for(int i = 0; i < N;i++){
			parent[i] = i;
		}
	}
	public int root(int x){			//根要素を取得
		if(parent[x] == x){			//初期状態
			return x;
		}else{
			return parent[x] = root(parent[x]);    	//再帰によって根を取得
		}
	}
	public void unite(int x,int y){ 	//統合メソッド
		if(same(x,y)){					//同じ根なら終了
			return;
		}
		int xroot = root(x);
		int yroot = root(y);
		parent[xroot] = yroot;			//統合
		return;

	}
	
	public boolean same(int x,int y){			//根が同じか（同じグループに属しているか）を判定
		return(root(x) == root(y));
	}
}






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

int main(){
    using namespace std;
    vector<long> v(5);
    for(auto& i : v)cin >> i;
    sort(v.begin(), v.end(), [](auto a, auto b){return ((a + 9) % 10) < ((b + 9) % 10);});
    long a((v[0] + 9) % 10 - 9);
    for(auto& i : v)i = (i + 9) / 10;
    cout << a + accumulate(v.begin(), v.end(), 0L) * 10 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<set>
using namespace std;
#define N 200500
long long as=0;
int n,head[N],cnt,is[N],id[N],a;
struct sth{int a,b;friend bool operator <(sth a,sth b){if(1ll*a.a*b.b==1ll*a.b*b.a)return a.a<b.a;return 1ll*a.a*b.b<1ll*a.b*b.a;}};
multiset<sth> st[N];
struct edge{int t,next;}ed[N*2];
void adde(int f,int t){ed[++cnt]=(edge){t,head[f]};head[f]=cnt;ed[++cnt]=(edge){f,head[t]};head[t]=cnt;}
void dfs(int u,int fa)
{
	id[u]=u;
	for(int i=head[u];i;i=ed[i].next)
	if(ed[i].t!=fa)
	{
		dfs(ed[i].t,u);
		if(st[id[ed[i].t]].size()>st[id[u]].size())id[u]^=id[ed[i].t]^=id[u]^=id[ed[i].t];
		for(set<sth>::iterator it=st[id[ed[i].t]].begin();it!=st[id[ed[i].t]].end();it++)
		st[id[u]].insert(*it);
	}
	sth tp1=(sth){is[u],!is[u]};
	while(!st[id[u]].empty())
	{
		if(tp1<*st[id[u]].begin())break;
		sth tp2=*st[id[u]].begin();st[id[u]].erase(st[id[u]].find(tp2));
		as+=1ll*tp1.a*tp2.b;
		tp1.a+=tp2.a;tp1.b+=tp2.b;
	}
	st[id[u]].insert(tp1);
}
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++)scanf("%d",&a),adde(a,i);
	for(int i=1;i<=n;i++)scanf("%d",&is[i]);
	dfs(1,0);
	int su1=0;
	while(!st[id[1]].empty())
	{
		sth tp2=*st[id[1]].begin();st[id[1]].erase(st[id[1]].find(tp2));
		as+=1ll*su1*tp2.b;su1+=tp2.a;
	}
	printf("%lld\n",as);
}

Measured memory_bytes: 33920
//
// Created by Hideaki Imamura on 2020-03-25.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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 EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N;
vector<queue<int>> a;

int main() {
    cin >> N;
    a.assign(N, queue<int>());
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N - 1; ++j) {
            int tmp;
            cin >> tmp;
            a[i].push(tmp - 1);
        }
    }

    set<i_i> q;
    auto check = [&](int i) {
        if (a[i].size() == 0) return;
        int j = a[i].front();
        if (a[j].size() == 0) return;
        if (a[j].front() == i) {
            i_i p(i, j);
            if (p.second < p.first) swap(p.first, p.second);
            q.insert(p);
        }
    };

    for (int i = 0; i < N; ++i) check(i);

    int ans = 0;
    while (!q.empty()) {
        ans++;
        set<i_i> prev_q;
        swap(prev_q, q);
        for (i_i p : prev_q) {
            int i = p.first, j = p.second;
            a[i].pop();
            a[j].pop();
        }
        for (i_i p : prev_q) {
            int i = p.first, j = p.second;
            check(i);
            check(j);
        }
    }
    for (int i = 0; i < N; ++i) {
        if (a[i].size() != 0) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4736
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author IncubatorMan
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define long long long
typedef pair < long , long > pii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
class EYutori {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n,k,c;
	    string data;
	    in>>n>>k>>c>>data;
	    int cnt=0;
	    vector<int> ff;
	    for(int i=0;i<n;){
	        if(cnt==k) break;
	        if(data[i]=='x'){
	            i++;
                continue;
	        }
	        cnt++;
	        ff.push_back(i+1);
	        i+=c;
	        i++;
	    }

	    vector<int>ans;
	    cnt=0;

	    for(int i=n-1;i>=0;){
            if(cnt==k) break;
            if(data[i]=='x'){
                i--;
                continue;
            }
            cnt++;
            ans.push_back(i+1);
            i-=c;
            i--;
	    }
	    for(int i=0;i<k;i++){
	        if(ff[i]==ans[k-1-i]) out<<ff[i]<<endl;
	    }

	}
};


int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
	EYutori solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3468
package main

import "fmt"

func main() {
	var A, B, C, D int
	fmt.Scan(&A, &B, &C, &D)
	res := 0
	if A <= C {
		if B <= C {
			res = 0
		} else {
			if B <= D {
				res = B - C
			} else {
				res = D - C
			}
		}
	} else {
		if D <= A {
			res = 0
		} else {
			if D <= B {
				res = D - A
			} else {
				res = B - A
			}
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int n;
    cin >> n;
    vector<ll> a(n*3);
    REP(i, n*3) cin >> a[i];
    sort(ALL(a));

    ll sum = 0;
    REP(i, n) sum += a[n*3 - (2*i+1) - 1];
    cout << sum << endl;
    return 0;
}


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

int main()
{
	string c;
	bool flag=false;
	cin >> c;

	for (int i=0; i<c.size();i++) {
	char target=c[i];
		if (target == 'a' || target == 'i' || target == 'u' || target == 'e' || target == 'o') {
			flag = true;
		}
	}

	if (flag) {
		cout << "vowel";
	}else {
		cout << "consonant";
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define mp make_pair

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;

int dp[101][76];

int main() {
	int d;
	cin >> d;
	string s = "Christmas";
	if (d == 24) {
		s += " Eve";
	}
	if (d == 23) {
		s += " Eve Eve";
	}
	if (d == 22) {
		s += " Eve Eve Eve";
	}
	cout << s << en;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)

	m := make(map[string]struct{})
	list := make([]string, 0)
	for i := 0; i < k; i++ {
		var d int
		fmt.Scanf("%d", &d)
		for j := 0; j < d; j++ {
			var w string
			fmt.Scanf("%s", &w)
			if _, ok := m[w]; !ok {
				m[w] = struct{}{}
				list = append(list, w)
			}
		}
	}
	fmt.Printf("%d\n", n-len(list))
}


Measured memory_bytes: 2512
s=int(input())
b=[s]
ct=1
while 1:
    if b[-1]%2==0:
        a=(b[-1]//2)
    else:
        a=((b[-1]*3)+1)
    ct+=1
    if a in b:
        print(ct)
        break
    else:
        b.append(a) 

Measured memory_bytes: 38384
#include<cstdio>
#include<iostream>
#include <algorithm>
using namespace std;
int intwo(int num);
int main(){
    int n,ans=0;
    int a[10000];
    // int two[10000];
    
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        // two[i]=intwo(a[i]);
        ans+=intwo(a[i]);
    }

    // int kisuu=0;
    // int guusu=n;

    // for(int tr=1;tr<=n;tr++){
    //     if(two[tr]==0){
    //         kisuu++;
    //     }
    // }
    // guusu=n-kisuu;

    // while(guusu!=0){
    //     int mana=0;
    //     for(int k=1;k<=n;k++){
    //         mana=max(mana,two[k]);
    //     }
    //     for(int k=1;k<=n;k++){
    //         if(mana==two[k]){
    //             two[k]--;
    //             if(two[k]==0){
    //                 kisuu++;
    //             }
    //             break;
    //         }
    //     }
        

    //     guusu=n-kisuu;
    //     ans++;
    // }
    // if(ans>0){ans--;}
    cout<<ans<<endl;
    return 0;
}
int intwo(int num){
    int ret=0;
    while(num%2 == 0){
        ret++;
        num/=2;
    }
    return ret;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int A, B, T;
	cin >> A >> B >> T;
	int dem = A;
	int tong = 0;
	while (dem <= T)
	{
		tong = tong + B;
		dem = dem + A;
	}

	cout << tong;
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	tree := make([]int, n)
	colors := make([]int, n)
	pp := make(Points, n)
	cx := make([]int, int(1e5))
	cy := make([]int, int(1e5))
	ux := make([]int, int(1e5))
	uy := make([]int, int(1e5))

	for i := 0; i < n; i++ {
		tree[i] = i
		pp[i].x = getNextInt(scanner) - 1
		pp[i].y = getNextInt(scanner) - 1
		pp[i].i = i
		pp[i].sk = pp[i].x
		cx[pp[i].x]++
		cy[pp[i].y]++
	}

	sort.Sort(pp)

	for i := 1; i < n; i++ {
		if pp[i].sk == pp[i-1].sk {
			tree[root(pp[i].i, tree)] = root(pp[i-1].i, tree)
		}
	}
	for i := 0; i < n; i++ {
		pp[i].sk = pp[i].y
	}
	sort.Sort(pp)

	for i := 1; i < n; i++ {
		if pp[i].sk == pp[i-1].sk {
			tree[root(pp[i].i, tree)] = root(pp[i-1].i, tree)
		}
	}
	for i := 0; i < n; i++ {
		pp[i].sk = pp[i].i
	}
	sort.Sort(pp)

	var exists int64
	color := 0
	for i := 0; i < n; i++ {
		if cx[pp[i].x] > 1 && cy[pp[i].y] > 1 {
			r := root(pp[i].i, tree)

			if colors[r] == 0 {
				color++
				colors[r] = color
			}
		}
	}
	for i := 0; i < n; i++ {
		r := root(pp[i].i, tree)
		ux[pp[i].x] = colors[r]
		uy[pp[i].y] = colors[r]
		if colors[r] > 0 {
			exists++
		}
	}

	imx := IntMap{}
	imy := IntMap{}

	for i := 0; i < int(1e+5); i++ {
		if ux[i] > 0 {
			imx.increment(ux[i])
		}
		if uy[i] > 0 {
			imy.increment(uy[i])
		}
	}

	var sum int64
	for k, c := range imx {
		sum += int64(c) * int64(imy.get(k))
	}

	fmt.Fprintln(writer, sum-exists)

	writer.Flush()
}

type Point struct {
	i, x, y, sk int
}

type Points []Point

func (a Points) Len() int           { return len(a) }
func (a Points) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Points) Less(i, j int) bool { return a[i].sk < a[j].sk }

func root(i int, tree []int) int {
	if i == tree[i] {
		return i
	}
	tree[i] = root(tree[i], tree)
	return tree[i]
}

// IntMap ...
type IntMap map[int]int

func (m IntMap) get(key int) int {
	if _, ok := m[key]; ok {
		return m[key]
	}
	return 0
}

func (m IntMap) increment(key int) {
	m[key] = m.get(key) + 1
}


Measured memory_bytes: 11464
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll dp1[110][40000];//小さい方
ll dp2[110][40000];//大きい方
int main(){
	ll n,k;
	scanf("%lld%lld",&n,&k);
	ll sqN=sqrt(n);
	int n1=sqN;
	int n2=sqN-1+(sqN*(sqN+1)<=n);
	rep(i,1,n1+1)dp1[1][i]=1;
	rep(i,1,n2+1)dp2[1][i]=n/i-n/(i+1);
	rep(c,1,k){
		ll m=0;//小さい方
		rep(i,1,n1+1)m=(m+dp1[c][i])%MOD;
		rep(i,1,n1+1)dp1[c+1][i]=m;
		for(int i=n2;i>=1;i--){
			m=(m-dp1[c][i+1])%MOD;
			dp2[c+1][i]=m*(n/i-n/(i+1))%MOD;
		}
		ll M=0;//大きい方
		rep(i,1,n2+1)M=(M+dp2[c][i])%MOD;
		rep(i,1,n1+1){
			dp1[c+1][i]=(dp1[c+1][i]+M)%MOD;
			M=(M-dp2[c][i])%MOD;
		}
	}
	ll ans=0;
	rep(i,1,n1+1)ans=(ans+dp1[k][i])%MOD;
	rep(i,1,n2+1)ans=(ans+dp2[k][i])%MOD;
	printf("%lld",(ans+MOD)%MOD);
}

Measured memory_bytes: 67072
using System;
using System.Collections.Generic;
using System.Linq;
class ilds1_3_b{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    int n = int.Parse(str[0]);
    int qms = int.Parse(str[1]);
    int sum_time = 0;
    Queue<String> queue = new Queue<String>();
    for(int i=0; i<n; i++){
      queue.Enqueue(Console.ReadLine());
    }
    while(queue.Count != 0){
      String[] s = queue.Dequeue().Split(' ');
      String name = s[0];
      int time = int.Parse(s[1]);
      if(time <= qms){
        sum_time += time;
        Console.WriteLine("{0} {1}",name,sum_time);
      }
      else{
        time -= qms;
        queue.Enqueue(name + " " + time.ToString());
        sum_time += qms;
      }
    }
  }
}



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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int ans;
string S;

void dfs(int n,int s,int p){
    if(n==S.size()){
        ans+=s+p;
    return;
    }

    int d=S[n]-'0';
    if(p)dfs(n+1,s+p,d);
    dfs(n+1,s,p*10+d);
}

signed main(){
    cin>>S;
    dfs(0,0,0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    long long a, b; std::cin >> a >> b;
    long long ans = 0;
    auto func = [](long long u, long long t) {
        long long ret = u / (2 * t) * t;
        ret += std::max(0LL, u % (2 * t) - t + 1);
        return ret;
    };
    for (int i = 0; i < 60; i++) {
        long long t = 1LL << i;
        ans += t * ((func(b, t) - func(a - 1, t)) & 1);
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

int main(void){
	scanf("%d %d",&n,&m);
	a[n]=1;
	a[m]=1;
	for(int i=1;i<=3;i++){
		if(a[i]==0)printf("%d\n",i);
	}
	return 0;
}



Measured memory_bytes: 256
n = int(input())
arr = {"AC":0,
       "WA":0,
       "TLE":0,
       "RE":0,}
for i in range(n):
  arr[str(input())]+=1

print("AC x " + str(arr["AC"]))
print("WA x " + str(arr["WA"]))
print("TLE x " + str(arr["TLE"]))
print("RE x " + str(arr["RE"]))    

Measured memory_bytes: 9196
n=int(input())
a=list(map(int,input().split()))
def gcd(x, y):
    if x<y:x,y=y,x
    while x % y != 0:
        x, y = y, x % y
    return y
left=[]
right=[]
for i in range(n):
    if i==0:
        left.append(a[i])
        right.append(a[-i-1])
    else:
        left.append(gcd(a[i],left[i-1]))
        right.append(gcd(a[-i-1],right[i-1]))
ans=max(left[n-2],right[n-2])
for i in range(n-2):
    ans=max(ans,gcd(left[i],right[n-i-3]))
print(ans)

Measured memory_bytes: 14076
s=raw_input()
i=0
j=len(s)-1
ans=0
while i<j:
    if s[i]==s[j]:
        i+=1
        j-=1
    elif s[i]!='x' and s[j]!='x':
        ans=-1
        break
    elif s[i]=='x':
        ans+=1
        i+=1
    elif s[j]=='x':
        ans+=1
        j-=1
print ans


Measured memory_bytes: 2692
#include<iostream>
#include<cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
ll a,b,ans;
void solve()
{
    ans=0;
    while(a<=b)a*=2,ans++;
}
main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>a>>b;
    solve();
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        System.out.println(a*a);

    }




}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25380
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}

int main(){
    int N; cin >> N;
    vector<pair<int,int>> res;
    if(N%2==1) {
        FOR(i,1,N) FOR(j,i+1,N+1) {
            if(i+j != N) res.push_back(make_pair(i,j));
        }
    }
    else {
        FOR(i,1,N) FOR(j,i+1,N+1) {
            if(i+j != N+1) res.push_back(make_pair(i,j)); 
        }
    }
    cout << res.size() << endl;
    for(auto p:res) cout << p.first << " " << p.second << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;

int main() {
	string s; cin >> s;
	int i, j, n = s.size();
	for (i = (n & 1 ? 1 : 2); i < n - 2; i += 2) {
		for (j = 0; j < (n - i) / 2; ++j)
			if (s[j] != s[j + (n - i) / 2]) break;
		if (j == (n - i) / 2) break;
	}
	cout << n - i << endl;

	return 0;
}

Measured memory_bytes: 256
/* B - Battle */

#include <stdio.h>

int main(void){
  int A, B, C, D,takahashi = 1, aoki = 0;
  scanf("%d %d %d %d", &A, &B, &C, &D);
  while(A > 0 && C > 0){
    if(takahashi == 1 && aoki == 0){
      C -= B;
      takahashi = 0;
      aoki = 1;
    }else{
      A -= D;
      takahashi = 1;
      aoki = 0;
    }
  }

  if(takahashi == 0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 1636
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<vector>
#include<iostream>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
int main() {
	int n, a;
	int s = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a);
		if(a % 2 != 0) s = 1;
	}
	if(s == 1) printf("first\n");
	else printf("second\n");		
	return 0;
}



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

using namespace std;

int main(void) {

	int n, l[1000], r[1000], ans = 0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> l[i] >> r[i];
		ans += r[i] - l[i] + 1;
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 768
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

ll a,b,H,W;
ll cnt[10];
map<pair<ll, ll>, ll> mp;
int N,i,j,k;
ll sm;
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  cin>>H>>W>>N;
  REP(i,N){
    cin>>a>>b;
    a--;b--;
    for(j=-2;j<=0;j++){
      for(k=-2;k<=0;k++){
        if(a+j<0 || a+j+2>H-1 || b+k<0 || b+k+2>W-1)continue;
        // cout<<i<<" "<<a+j<<" "<<b+k<<endl;
        mp[make_pair(a+j, b+k)]++;
      }
    }
  }
  sm = (H - 2) * (W - 2);
  for(auto itr=mp.begin(); itr!=mp.end();++itr){
    // cout<<(itr->first).first<<" "<<(itr->first).second<<" "<<(itr->second)<<"\n";
    for(i=1;i<=9;i++){
      if((itr->second)==i)cnt[i]++;
    }
  }
  for(i=1;i<=9;i++){
    sm-=cnt[i];
  }
  cnt[0]=sm;
  REP(i,10)cout<<cnt[i]<<endl;
  return 0;
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    vector<string> S(N);
    for (int i = 0; i < N; i++)
    {
        cin >> S.at(i);
    }
    for (int i = 0; i < N; i++)
    {
        if (S.at(i) == "WA"){
            wa++;
        } else if (S.at(i) == "AC")
        {
            ac++;
        } else if (S.at(i) == "TLE")
        {
            tle++;
        } else if (S.at(i) == "RE")
        {
            re++;
        }
        
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}

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

int main() {
    int k,t,sum=0, ai;
    cin >> k >> t;

    int a, amax, ans;
    cin >> amax;
    for (int i=0; i<t-1; i++) {
        cin >> a;
        if (amax < a) amax = a;
    }

    if (amax-1-k+amax > 0) cout << amax-1-k+amax << endl;
    else cout << 0 << endl;
}

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

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

# Nが奇数ならNo
if N % 2 != 0:
    print('No')
else:
    s_first = S[:int(N/2)]
    s_second = S[int(N/2):]

    if s_first == s_second:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

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

    ll N;
    cin >> N;
    set<ll> st;
    rep(i, N){
        ll a;
        cin >> a;
        st.insert(a);
    }

    ll l = len(st);
    print(l - (l % 2 == 0));

    return 0;
}

Measured memory_bytes: 4992
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll a, b; cin >> a >> b;
	if(a%2 != b%2) { println("IMPOSSIBLE"); return 0; }
	else println((a+b)/2);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
long int a,b,k,d,e;
     cin>>a>>b>>k;
     if(a<k){
         d=0;
         if(k-a>b){
            e=0; 
         }
         else{
             e=b+a-k;
         }
     }
     else{
         d=a-k;
         e=b;
     }
     cout<<d<<" "<<e<<endl;

   
    
}


Measured memory_bytes: 256
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

typedef long long ll;
const int INF=1<<30;

int main()
{
//	freopen("std.in","r",stdin);
	int n,m;cin>>n>>m;
	puts(n==m?"Yes":"No");
	return 0;
}


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

#define rep(i, n) for(int i=0; i < (int)n; i++)

using namespace std;
using ll = long long;
using ushort = unsigned short;
using uint = unsigned int;
using ulong = unsigned long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;


template <typename T>
T permutation(T n, T r);

template <typename T>
T combination(T n, T r);

template <typename T>
T factorial(T n);

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

  cout << combination(N, 2) + combination(M, 2) << endl;

  return 0;
}

template <typename T>
T permutation(T n, T r) {
  if (r == 1)
    return n;
  else
    return n * permutation(n-1, r-1);
}

template <typename T>
T combination(T n, T r) {
  return permutation(n, r) / factorial(r);
}

template <typename T>
T factorial(T n) {
  if (n == 0)
    return 1;
  else
    return n * factorial(n-1);
}


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

int n,arr[100000],cnt[100000];
int main() {
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",arr+i);
    sort(arr,arr+n);
    int c=0;
    for(int i=0;i<n;i++) {
        if(i==0 || arr[i-1]!=arr[i]) {
            arr[c++]=arr[i];
            cnt[c-1]=1;
        } else {
            cnt[c-1]++;
        }
    }

    int A=0,B=0;
    for(int i=c-1;i>=0;i--) {
        while(!B && cnt[i]>=2) {
            if(A==0) A=arr[i];
            else B=arr[i];
            cnt[i]-=2;
        }
    }
    printf("%lld\n",1ll*A*B);
    
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x;
        
        if(a < b){
            if(c < b){ 
                x = b;
                b = c;
                c = x;
                if(b < a){
                    x = b;
                    b = a;
                    a = x;
                }
            }
        }else{
            x = b;
            b = a;
            a = x;
            if(c < b){ 
                x = b;
                b = c;
                c = x;
                if(b < a){
                    x = b;
                    b = a;
                    a = x;
                }
            }
            
        }
        System.out.println(a +" "+ b +" "+ c);
        
    }
}


Measured memory_bytes: 26148
// atc.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <string>
#include    <algorithm>
using namespace std;

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

	vector<int> A(n);
	vector<int> B(n);

	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> B[i];
	}

	int max = 0, tmp = 0;

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

		for (int j = 0; j < i+1; j++) {
			tmp += A[j];
		}
		for (int k = i; k < n; k++) {
			tmp += B[k];
		}

		if (tmp > max) max = tmp;
		
		tmp = 0;

	}

	cout << max;


	system("pause");

	return 0;

}


Measured memory_bytes: 504
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, x: "List[int]", y: "List[int]"):
    balls = [1 for i in range(N)]
    red = [False for i in range(N)]
    red[0] = True

    for i in range(M):
        if red[x[i]]:
            if balls[x[i]] == 1:
                red[x[i]] = False
            red[y[i]] = True
        balls[x[i]] -= 1
        balls[y[i]] += 1
    
    print(sum(red))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    x = [int()] * (M)  # type: "List[int]" 
    y = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        x[i] = int(next(tokens))-1
        y[i] = int(next(tokens))-1
    solve(N, M, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12568
#include <cstdio>

using namespace std;

int main(){
	int i,j,n,m,a[101][101],b[101],c;

	scanf("%d %d",&n,&m);
	for(i=0; i<n; i++){
		for(j=0; j<m; j++) scanf("%d",&a[i][j]);
	}
	for(i=0; i<m; i++) scanf("%d",&b[i]);

	for(i=0; i<n; i++){
		c=0;
		for(j=0; j<m; j++){
			c+=a[i][j]*b[j];
		}
		printf("%d\n",c);
	}

	return 0;
}

Measured memory_bytes: 2708
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<math.h>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const int mod=10007;
#define ll  long long

int main(){
	int n;
	cin>>n;
	vector<ll>a(n);
	ll sum=0,sum1=0;
	rep(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	bool even=false;
	if(sum%2==0){even=true;}
	ll ans;
	int tmp;
	rep(i,n){
		if(sum1<=sum/2){
			sum1+=a[i];
			if(sum1==sum/2&&even){
				cout<<0<<endl;
				return 0;
			}
			tmp=i;
		}
	}
	sum1-=a[tmp];
	ll sum2=sum1+a[tmp];
	ll num1=sum-sum1,num2=sum-sum2;
	ll ans1=abs(sum1-num1),ans2=abs(num2-sum2);
	ans=min(ans1,ans2);
	cout<<ans<<endl;
}

Measured memory_bytes: 1920
#include<stdio.h>
int main(void){
    int a,b,x;
    char op;
        while(1){
            scanf("%d %c %d" ,&a, &op, &b);
            if( op == '+'){
                x = a + b;
            }
            else if( op == '-'){
                x = a - b;
            }
            else if( op == '*'){
                x = a * b;
            }
            else if( op == '/'){
                x = a / b;
            }
            else{
                break;
            }
            printf("%d\n",x);
        }
return 0;        
}
 

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

long long n, a[100005], b[100005], c[100005], dp[100005][5], ans[100005];

int main(){
	cin>>n;
	for(int i=1; i<=n; i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	dp[0][1]=0;
	dp[0][2]=0;
	dp[0][3]=0;
	for(int i=1; i<=n; i++){
		dp[i][1]=max(dp[i-1][2], dp[i-1][3])+a[i];
		dp[i][2]=max(dp[i-1][1], dp[i-1][3])+b[i];
		dp[i][3]=max(dp[i-1][2], dp[i-1][1])+c[i];
		ans[i]=max(dp[i][1], max(dp[i][2], dp[i][3]));
		//cout<<ans[i]<<endl;
	}
	cout<<ans[n]<<endl;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

str s;
ll n2,k;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s;
    s = " "+s;
    for(int i=1;i<s.size();i++){
        if(s[i]!='1'){n2=i;break;}
    }
    s[0]='1';
    cin>>k;
    if(k>=n2){cout<<s[n2]<<newl;}
    else cout<<1<<newl;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
	int n;
	int a[3];
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	for(int i = 1; i <= 100000000; i++){
		bool ok = true;
		for(int j = 0; j < n; j++){
			if(a[j]%i != 0) ok = false;
		}
		if(ok) printf("%d\n", i);
	}
}

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

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

const ll INF = ll(1e18);

typedef pair<int,ll> edge;

vector<ll> bellman_ford(int s,vector<vector<pair<int,ll> > > const & g){
    int n = g.size();
    vector<ll> dist(n,INF*(-1));
    dist[s]=0;
    for(int i=0;i<n;i++){
        for(int v=0;v<n;v++){
            for(auto e : g[v]){
                   if(dist[v]!=INF)dist[e.first] = max(dist[e.first],dist[v] + e.second);
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int v=0;v<n;v++){
            for(auto e : g[v]){
                if(dist[v]==INF||dist[e.first]<dist[v]+e.second){
                    dist[e.first] = INF;
                }
            }
        }
    }
    return dist;
}

int main(){
    int n,m;
    cin >> n >> m;    
    vector<vector<edge> > g(n);
    rep(i,m){
        int a,b;ll c;
        cin >> a >> b >> c;
        a--,b--;
        g[a].push_back(make_pair(b,c));
    }

    ll ans = bellman_ford(0,g)[n-1];

    if(ans==INF){
        cout << "inf" << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

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

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

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    ll N;
    ll ex = -1;
    ll tar = 0;
    cin >> N;
    for(int i = 1; i <= N; i++){
        tar = i;
        ll sum = i*(i+1)/2;
        if(sum > N){
            ex = sum - N;
            break;
        }
    }
    for(int i = 1; i <= tar; i++){
        if(i != ex) cout << i << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    deque<char>q;
    rep(i,s.length()){
        if(s[i]=='0'||s[i]=='1'){
            q.push_back(s[i]);
        }
        else{
            if(q.empty()){
                continue;
            }
            else{
                q.pop_back();
            }
        }
    }
    for(char ss:q){
        cout<<ss;
    }
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

ans=sum(b)
for i in range(n-1):
    if a[i]+1 == a[i+1]:
        ans+=c[a[i]-1]
print(ans)

Measured memory_bytes: 3064