akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.InputMismatchException;

public class Main {
	void run() {
		MyScanner sc = new MyScanner();

		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			long sum = 0;
			for (int i = 1; i * i <= n; i++) {
				if (n % i == 0) {
					sum += i;
					if (i * i != n) {
						sum += n / i;
					}
				}
			}
			sum -= n;

			if (n < sum) {
				System.out.println("abundant number");
			} else if (sum < n) {
				System.out.println("deficient number");
			} else {
				System.out.println("perfect number");
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

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

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

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

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

Measured memory_bytes: 18540
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mset(x, y) memset((x), (y), sizeof(x))
#define sz(x) ((int)(x).size())
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define cerr cout
#define endl '\n'
using namespace std;

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

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

	string s, t;
	int ans = 1e9, cnt = 0, i, j;
	cin >> s >> t;
	for(i = 0; i + sz(t) <= sz(s); i++)
	{
		cnt = 0;
		string st = s.substr(i, sz(t));
		//pr(st, t);
		for(j = 0; j < sz(t); j++)
		{
			if(st[j] != t[j])
				cnt++;
		}
		ans = min(ans, cnt);
	}
	cout << ans;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string str;
	cin>>str;
	int year = 1000 * int(str[0] - '0') + 100 * int(str[1] - '0') + 10 * int(str[2]-'0') + int(str[3] - '0');
	int month = 10 * int(str[5] - '0') + int(str[6] - '0');
	int day = 10 * int(str[8] - '0') + int(str[9] - '0');
	if(year<=2019 && month <=4 && day<=30)
		cout<<"Heisei"<<endl;
	else
		cout<<"TBD"<<endl;
		
	return 0;
}

Measured memory_bytes: 256
/**   
 *   Author:    @glaucoacassioc
 *   Created on 11.09.2020, 15:32:16
**/
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
vector<vii> AdjList;

vi pai, color, dist, ts;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, item_popular, soma = 0, contador = 0;

	cin >> n >> m;
	vi v(n);
	for(int i=0; i < n; i++)
	{
		cin >> v[i];
		soma+= v[i];
	}

	item_popular = 4 * m;
	bool popular = false;
	for(int i=0; i<n; i++)
	{
		if(v[i]* 1LL * item_popular >= soma) contador++;
		if(contador == m)
		{ 
			popular = true;
			break;
		}
	}
	popular ? cout << "Yes\n" : cout << "No\n";
	return 0;
}

Measured memory_bytes: 3644
//abc107_b.cpp
//Sat Aug 25 20:19:28 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int h,w;
	cin >> h >> w;

	char masu[h][w];
	int draw[h][w];
	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
			draw[i][j] = 1;
			masu[i][j] = '.';
		}
	}

	for (int i=0;i<h;i++){
		string temp;
		cin >> temp;
		int flag = 0;
		for (int j=0;j<w;j++){
			if (temp[j] == '.'){
				masu[i][j] = '.';
			}else{
				masu[i][j] = '#';
				flag = 1;
			}
		}
		if (flag == 0){
			for (int k=0;k<w;k++){
				draw[i][k] = 0;
			}
		}
	}

	for (int j=0;j<w;j++){
		int flag = 0;
		for (int i=0;i<h;i++){
			if (masu[i][j] == '#'){
				flag = 1;
			}
		}
		if (flag == 0){
			for (int k=0;k<h;k++){
				draw[k][j] = 0;
			}
		}
	}

	for (int i=0;i<h;i++){
		int flag = 0;
		for (int j=0;j<w;j++){
			if (draw[i][j] == 1){
				cout << masu[i][j];
				flag = 1;
			}
		}
		if (flag == 1){
			printf("\n");
		}
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int taxi_fee = sc.nextInt();
        int train_fee = N*A;
        if (taxi_fee > train_fee) {
            System.out.println(train_fee);
        } else {
            System.out.println(taxi_fee);
        }
    }
}


Measured memory_bytes: 22996
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const x = Number(inputs[0]);

  let a = 0;
  let num = 0;

  if (x === 0) {
    showLog(0, 0);
    return;
  }

  while (num !== x) {
    a++;
    for (let b = -1 * a + 1; b < a; b++) {
      num = calc(a, b);
      if (num === x) {
        showLog(a,b);
        return;
      }
    }
  }
}

function showLog(a: number, b: number): void {
  console.log(a + ' ' + b);
}

function calc(a: number, b: number): number {
  return Math.pow(a, 5) - Math.pow(b, 5);
}


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

ll n;
void func(ll cur,int use,int &ans){
    if(cur > n)return;
    if(use == 0b111)ans++;
    func(cur*10+7,use | 0b001,ans);
    func(cur*10+5,use | 0b010,ans);
    func(cur*10+3,use | 0b100,ans);
}

int main(){
    cin >> n;
    int ans = 0;
    func(0,0,ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char a[4];
	scanf("%s",a);
	int i;
	for(i=0;i<3;i++){
		if(a[i]=='1'){
			printf("9");
		}
		else if(a[i]=='9'){
			printf("1");
		}
		else printf("%c",a[i]);
	}
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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


	int cnt = 0;
	for (int ii = 0; ii < s.size(); ++ii){
		if (s[ii] == 'o'){
			cnt++;
		}
	}	

	int rem = 15 - s.size();

	if (cnt + rem >= 8){
		cout << "YES" << "\n";
	} else {
		cout << "NO" << "\n";		
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    string s;
    cin>>s;
    //debug(s);
    string com;
    int l,r;
    codefor{
        in(com,l,r);
        if(com=="replace"){
            cin>>com;
            int a=l;
            for(l;l<=r;l++){
                s[l]=com[l-a];
            }
        }else if(com=="reverse"){
            reverse(s.begin()+l,s.begin()+r+1);
        }else{
            cout<<s.substr(l,r-l+1)<<endl;
        }
        //debug(s);
    }
}


Measured memory_bytes: 3236
#include <iostream>
#include <algorithm>

using namespace std;

struct Ver{
  int x;
  int y;
  int z;
};

int xdir[13] = {-1, 0, 1, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1};
int ydir[13] = {-1, -1, -1, 0, -1, -1, -1, 0, 0, 0, 1, 1, 1};
int zdir[13] = {0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1};

bool search(int a[9][9][9], int x, int y, int z, int dx, int dy, int dz, int m, int c, int clr)
{
  if(c == m){
    return true;
  }

  if(a[x+dx][y+dy][z+dz] == clr){
    return search(a, x+dx, y+dy, z+dz, dx, dy, dz, m, c+1, clr);
  }

  return false;
}

bool func(int a[9][9][9], int ct[9][9], int n, int m, int clr, Ver vr[344], int k)
{
  bool f = false;

  for(int i = ((clr==1)?1:2); i <= k; i+=2){
    for(int j = 0; j < 13; j++){
      int s=vr[i].x+xdir[j], t=vr[i].y+ydir[j], u=vr[i].z+zdir[j];
      if(a[s][t][u] == clr){
	f = search(a, s, t, u, xdir[j], ydir[j], zdir[j], m, 2, clr);
	if(f){
	  break;
	}
      }
      s=vr[i].x-xdir[j];
      t=vr[i].y-ydir[j];
      u=vr[i].z-zdir[j];
      if(a[s][t][u] == clr){
	f = search(a, s, t, u, -xdir[j], -ydir[j], -zdir[j], m, 1, clr);
	if(f){
	  break;
	}
      }
    }
    if(f){
      break;
    }
  }

  return f;
}

int main()
{
  int n, m, p, s, t, u, a[9][9][9], ct[9][9];
  Ver vr[344];

  while(1){
    cin >> n >> m >> p;
    if(n == 0 && m == 0 && p == 0){
      break;
    }
    fill(&a[0][0][0], &a[8][8][8], 0);
    fill(&ct[0][0], &ct[8][8], 1);
    u = 1;
    bool f = false;
    for(int k = 1; k <= p; k++){
      cin >> s >> t;
      if(f){
	continue;
      }
      vr[k].x = s;
      vr[k].y = t;
      vr[k].z = ct[s][t];
      a[s][t][ct[s][t]++] = u;
      if(func(a, ct, n, m, u, vr, k)){
	cout << ((u == 1)? "Black ":"White ") << k << endl;
	f = true;
	continue;
      }
      u = -u;
    }

    if(!f){
      cout << "Draw" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 872
while 1:
    n,p = map(int,input().split())
    if n==0:break
    man =  [0]*n
    ball,a = p,0
    while 1:
        a%=n
        if ball >0:
            ball-=1
            man[a]+=1
        elif ball == 0:ball,man[a] = man[a],ball
        if man[a]==p:break
        a+=1
        
    print(a)                

Measured memory_bytes: 7580
#include<bits/stdc++.h>
using namespace std;
int a,b,k;
int main()
{
	scanf("%d%d%d",&a,&b,&k);
	for(int i=a;i<=b;i++)
	{
		if(i<a+k||i>b-k) cout<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;


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



int main(){
	
	int a[25];
	int n[6];
	
	int L;
	int i,j;
	int t,mi,ma;
	bool f;
	
	
	while(true){
		scanf("%d %d",&a[0],&L);
		
		if(L==0)break;
		
		f=false;
		rep(i,24){
			t=a[i];
			
			rep(j,L){
				n[j]=t%10;t/=10;
			}
			sort(n,n+L);
			ma=mi=0;
			rep(j,L){
				mi=mi*10+n[j];
				ma=ma*10+n[L-j-1];
			}
			a[i+1]=ma-mi;
			
			//printf("   %6d %6d %6d  %6d   i:%d\n",a[i],ma,mi,a[i+1],i);
			
			rep(j,i+1){
				if(a[j]==a[i+1]){
					//printf("%d %d %d\n",i+1,a[i+1],i-j+1);
					printf("%d %d %d\n",j,a[i+1],i-j+1);
					
					f=true;break;
				}				
			}
			if(f)break;
		}
	}
	return 0;
}

Measured memory_bytes: 1044
#include<iostream>

using namespace std;

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

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }
    int c[n];
    rep(i, n) c[i] = 0;
    int b = 0;
    int ans = 0;
    while(c[b] == 0){
        c[b] = 1;
        b = a[b];
        ans++;
        if(b == 1){
            cout << ans << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

int main(){
    int x;
    cin >> x;
    vector<bool> expo(x+1);

    expo.at(1) = 1;
    for(int b = 2; b <= x; b++){
        int v = b * b;
        while(v <= x){
            expo.at(v) = 1;
            v *= b;
        }
    }
    for(int i = x; i >= 1; i--){
        if(expo[i]){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
S=input()
if S=='SAT':
  print(1)
elif S=='FRI':
  print(2)
elif S=='THU':
  print(3)
elif S=='WED':
  print(4)
elif S=='TUE':
  print(5)
elif S=='MON':
  print(6)
else:
  print(7)

Measured memory_bytes: 2940
N = int(input())
S = list(map(int,input().split()))
import numpy as np
get_DP  = [[-np.inf for i in range(3)] for j in range(N)]
pass_DP = [[-np.inf for i in range(3)] for j in range(N)]
for i in range(N):
    # 常にとるやつ
    get_DP[i][0] = (pass_DP[i-1][0] if i>0 else 0) + S[i] 
    pass_DP[i][0] = get_DP[i-1][0]
    if i>0:
        get_DP[i][1] = (pass_DP[i-1][1] if i!=1 else 0) + S[i]
        pass_DP[i][1] = max(pass_DP[i-1][0], get_DP[i-1][1])
    if i>1:
        get_DP[i][2] = (pass_DP[i-1][2] if i!=2 else 0) + S[i]
        pass_DP[i][2] = max(pass_DP[i-1][1], get_DP[i-1][2])

    
print(max(get_DP[-1]+pass_DP[-1][:1+N%2]))

Measured memory_bytes: 129176
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 80005
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
string s;
string tar = "keyence";
void Solve() {
	cin >> s;
	int p = 0;
	while(s[p] == tar[p]) ++p;
	int q = 0;
	while(s[s.length() - 1 - q] == tar[tar.length() - 1 - q]) ++q;
	if(p + q >= tar.length()) puts("YES");
	else puts("NO");
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


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



#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};



// 隣接リストで使う辺を表す型
struct Edge {
  int to, cost;  // 辺の接続先頂点, 辺の重み
  Edge(int to, int cost) : to(to), cost(cost) {}  // コンストラクタ
};

typedef vector<vector<Edge> > AdjList;  // 隣接リストの型
AdjList graph;  // グラフの辺を格納した構造体
                // graph[v][i]は頂点vから出るi番目の辺Edge

vector<int> dist; // 最短距離

// 戻り値がtrueなら負の閉路を含む
bool bellman_ford(int n, int s) { // nは頂点数、sは開始頂点
  dist = vector<int>(n, INF);
  dist[s] = 0; // 開始点の距離は0
  for (int i = 0; i < n; i++) {
    for (int v = 0; v < n; v++) {
      for (int k = 0; k < graph[v].size(); k++) {
        Edge e = graph[v][k];
        if (dist[v] != INF && dist[e.to] > dist[v] + e.cost) {
          dist[e.to] = dist[v] + e.cost;
          if (i == n - 1) return true; // n回目にも更新があるなら負の閉路が存在
        }
      }
    }
  }
  return false;
}

signed main() {
  int n, m,r;
  cin >> n >> m>>r;

  graph = AdjList(n);

  for (int i = 0; i < m; i++) {
    int from, to, cost;
    cin >> from >> to >> cost;
    graph[from].push_back(Edge(to, cost));
  }

  if(bellman_ford(n, r)){
      cout<<"NEGATIVE CYCLE"<<endl;
      return 0;
  }

  for (int i = 0; i < n; i++) {
    if (dist[i] != INF)
      cout <<dist[i] << endl;
      else cout<<"INF"<<endl;
  }

  return 0;
}


Measured memory_bytes: 3156
#include "bits/stdc++.h"
using namespace std;
int32_t main(){
  size_t n; cin>>n;
  vector<uint32_t> a(n), b(n); for(auto&& e:a) cin>>e;
  const size_t k=10'001;
  vector<uint32_t> c(k, 0);
  for(const auto& e:a) ++c[e];
  size_t i=0;
  for(size_t j=0; j<k; ++j){
    for(auto l=i; i<l+c[j]; ++i) a[i]=j;
  }
  const char* dlm="";
  for(const auto& e:a) cout<<exchange(dlm, " ")<<e;
  cout<<'\n';
}


Measured memory_bytes: 18324
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int i,j,k,m,n,x;
	int p,odd=0,even=0;
	scanf("%d%d",&n,&p);
	for(i=1;i<=n;i++){
		scanf("%d",&x);
		if(x%2)odd++;
		else even++;
	}
	long long ans=1;
	for(i=1;i<=even;i++)
		ans*=2;
	if(odd!=0)
		for(i=1;i<odd;i++)
			ans*=2;
	else if(odd==0 && p==1)
		ans=0;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#define endl '\n'
//#define ll long long
#define mod 1000000007
#define NCONS 100001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
#define int long long
//#define double long double
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
typedef long long ll;

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

#define YYYY cout << "YES" << endl
#define NNNN cout << "NO" << endl
#define yyyy cout << "Yes" << endl
#define nnnn cout << "No" << endl

int32_t main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int ret = 0;
    string s, t; cin >> s >> t;
    for(int i = 0; i < 3; i++)
    {
        if(s[i] == t[i])
            ret += 1;
    }
    
    cout << ret << endl;
  
      
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long 
#define pb push_back
#define mk make_pair
using namespace std;

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

	lld sum=0;

	for(int i=1;i<=n;i++)
	{
		if(i%3!=0 && i%5!=0)
			sum+=i;
	}

	cout<<sum<<endl;
}

Measured memory_bytes: 3632
n, m, q = map(int, input().split())
abcd = [[] for j in range(q)]
for i in range(q):
    abcd[i] = list(map(int, input().split()))
l = [1] * n


def plus():
    l[n - 1] += 1
    while m + 1 in l:
        a = l.index(m + 1)
        l[a - 1] += 1
        for i in range(a, n):
            l[i] = l[a - 1]


ans = 0
while l[0] <= m:
    score = 0
    for i in range(q):
        if l[abcd[i][1] - 1] - l[abcd[i][0] - 1] == abcd[i][2]:
            score += abcd[i][3]
    if ans < score:
        ans = score
    plus()

print(ans)

Measured memory_bytes: 68680
import java.io.IOException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int[][][] array = new int[4][3][10];
		for(int i=0;i<x;i++) {
			int t = sc.nextInt();
			int k = sc.nextInt();
			int b = sc.nextInt();
			int p = sc.nextInt();
			array[t-1][k-1][b-1] += p;
		}

		for(int i=0;i<4;i++) {
			for(int j=0;j<3;j++) {
				for(int k=0;k<10;k++) {
					System.out.print(" " + array[i][j][k]);
				}
				System.out.println();
			}
			if(i!=4-1) {
				System.out.println("####################");
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 29268
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	map<string,int> ct;
	for (int i=0; i<n; i++) {
		string s; cin>>s;
		ct[s]++;
	}	
	vector<string> key={"AC","WA","TLE","RE"};
	for (auto x:key)
	cout<<x<<" "<<"x"<<" "<<ct[x]<<endl;
	return 0;
}


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

int main() {
  string N; cin >> N;
  for(int i = 1; i < 10; i++) {
    if(N.at(0) - '0' <= i) {
      if(N.at(1) - '0' <= i) {
        if(N.at(2) - '0'<= i) {
          cout << i * 100 + i * 10 + i << endl;
          break;
        }
      }
      else  {
        i++;
        cout << i * 100 + i * 10 + i << endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.io.PrintWriter;

import java.util.ArrayList;

class Pair {
    long first;
    long second;

    Pair (long first, long second) {
        this.first = first;
        this.second = second;
    }
}

@SuppressWarnings("unchecked")
public class Main {
    // 約数
    static void divisor(ArrayList<Pair> div, long N) {
        long n;
        long i = 1;

        n = N;

        while (i <= Math.sqrt(n)) {
            if (n % i == 0) div.add(new Pair(i, n / i));
            i++;
        }
    }

    public static void main(String[] args) throws IOException {
        final String s;

        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            s = reader.readLine();
        }

        PrintWriter out = new PrintWriter(System.out);

        final String[] sl = s.split(" ");
        int N = Integer.parseInt(sl[0]);
        int M = Integer.parseInt(sl[1]);

        ArrayList<Pair> div = new ArrayList<>();
        divisor(div, M);

        long MAX = M / N + 1;

        long ans = 0;

        for (Pair p : div) {
            long first = p.first;
            long second = p.second;

            if (first < MAX && ans < first) ans = first;
            if (second < MAX && ans < second) ans = second;
        }

        out.println(ans);

        out.flush();
    }
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007;

int n,val[_],loc[_]={0},f[_]={0};

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	n=ty();
	for(int i=1;i<=n;i++)val[i]=ty(),loc[val[i]]=i;

	int ans=n;
	for(int i=1;i<=n;i++)
	{
		if(loc[i]>loc[i-1])f[i]=f[i-1]+1;
		else f[i]=1;
		ans=min(ans,n-f[i]);
	}

	cout<<ans<<lf;
	
	return 0;
}


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

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

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

	const int N = 100010;

	vector<int> o(N);
	vector<int> e(N);
	int o_maxNum_first = 0;
	int o_maxNum_second = 0;
	int o_maxValue;
	int e_maxNum_first = 0;
	int e_maxNum_second = 0;
	int e_maxValue;

	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			o[v[i]]++;
		}
		else {
			e[v[i]]++;
		}
	}

	for (int j = 0; j < N; j++) {

		if (o_maxNum_first <= o[j]) {
		
			o_maxNum_second = o_maxNum_first;
			o_maxNum_first = o[j];
			o_maxValue = j;
		
		}
		else if (o_maxNum_second <= o[j] ) {

			o_maxNum_second = o[j];
		}
		
		if (e_maxNum_first <= e[j]) {

			e_maxNum_second = e_maxNum_first;
			e_maxNum_first = e[j];
			e_maxValue = j;

		}	
		else if (e_maxNum_second <= e[j]) {

			e_maxNum_second = e[j];
		}


	}

	int ans;

	if (o_maxValue != e_maxValue) {

		ans = n - o_maxNum_first - e_maxNum_first;

	}
	else { //  o_maxValue == e_maxValue

		ans = min(n - o_maxNum_first - e_maxNum_second, n - e_maxNum_first - o_maxNum_second);

	}

	cout << ans << endl;

}


Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>

using namespace std;
const int N=2e5+10,inf=1e9;
int dp[N][2];
char s[N];

int main(){
    int R,G,B,N,N_R,N_G,sub,sub_B,ans=0;
    cin >> R >> G >> B >> N;
    N_R = N/R;
    N_G = N/G;
    for(int i=0;i<=N_R;i++){
        for(int j=0;j<=N_G;j++){
            sub=N-R*i-G*j;
            if(sub<0)continue;
            sub_B=sub%B;
            //cout << "i=" << i << " j=" << j << endl;
            //cout << sub_B << endl;
            if(sub_B == 0){
                ans++;
            }
        }
    }

	cout << ans << endl;
}


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

int main() {
	string s;
	int k;
	cin >> s >> k;
	int cnt1 = 0;
	string tmp = s;
	for(int i = 1; i < tmp.size(); i++){
		if(tmp[i] == tmp[i-1]){
			cnt1++;
			tmp[i] = '0';
		}
	}
	if(k == 1){
		cout << (ll) cnt1 * k << endl;
		return 0;
	}
	if(s[s.size()-1] != s[0]){
		cout << (ll) cnt1 * k << endl;
		return 0;
	}
	if(tmp[tmp.size()-1] == '0'){
		cout << (ll) cnt1 * k << endl;
		return 0;
	}
	tmp = s + s;
	int cnt2 = 0;
	for(int i = 1; i < tmp.size(); i++){
		if(tmp[i] == tmp[i-1]){
			cnt2++;
			tmp[i] = '0';
		}
	}
	if(tmp[tmp.size()-1] == '0'){
		if(k % 2 == 0) cout << (ll) cnt2 * k / 2  << endl;
		else cout << (ll)cnt2 * (k-1) / 2 + cnt1  << endl;
		return 0;
	}
	tmp = s;
	int l = 1, r = 1;
	for(int i = 0; i < tmp.size(); i++){
		if(tmp[i] == tmp[i+1]) l++;
		else break;
	}
	for(int i = tmp.size()-1; i > 0; i--){
		if(tmp[i] == tmp[i-1]) r++;
		else break;
	}
	if(l % 2 == 1){
		cout << (ll) cnt1 * k + (k - 1) << endl;
		return 0;
	}else{
		cout << (ll) cnt1 * k << endl;
		return 0;
	}
	return 0;
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}


int main() {
  int R,G,B,N; cin >> R >> G >> B >> N;

  lint ans=0;
  for(int r=0;r*R<=N;r++) {
    for(int g=0;r*R+g*G<=N;g++) {
      if((N-r*R-g*G)%B == 0 && N-r*R+g*G >= 0) {
        ans++;
      }
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int k,x;cin>>k>>x;
	k--;
	vector<int> ans;
	for(int i=max(-1000000,x-k);i<=x;i++) 
		ans.push_back(i);
	for(int i=x+1;i<=min(1000000,x+k);i++)
		ans.push_back(i);
	for(int i=0;i<ans.size();i++){
		if(i) cout<<' ';
		cout<<ans[i];
	}
	cout<<endl;
	return 0;
}

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

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,x,t;
    cin >> n >> x >> t;

    cout << (n+x-1)/x * t << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define Mod 1000000007
int main()
{
    string a, b;
    cin>>a>>b;
    ll prev=0;
    string res="";
    ll dp[a.size()+1][b.size()+1]={};
    for(ll i=1; i<=a.size(); i++)
        for(ll j=1; j<=b.size(); j++)
        {
            if(a[i-1]==b[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    ll i=a.size(), j=b.size();
    while(i && j)
    {
        if(dp[i-1][j]==dp[i][j])
            i-=1;
        else if(dp[i][j-1]==dp[i][j])
            j-=1;
        else
        {
            res+=a[i-1];
            i-=1;
            j-=1;
        }
    }
    reverse(res.begin(),res.end());
    cout<<res<<endl;
}


Measured memory_bytes: 73912
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, k;
int main() {
	read(n), read(k);
	int ans = 1;
	n -= k;
	ans += n / (k - 1);
	n %= (k - 1);
	if (n != 0) ans++;
	writeln(ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define here cout<<"here\n"
#define pb push_back
#define mp make_pair
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define pf printf
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
using namespace std;

const ll mod = 1e9+7;

const int MAX = 100005;

ll modexp(ll x, ll n)
{
    if(n==0)
        return 1LL;
    if(n%2==0)
    {
        ll y = modexp(x,n/2)%mod;
        return (y*y)%mod;
    }
    return (x*modexp(x,n-1)%mod)%mod;
}

ll powr(ll x, ll n)
{
    ll ans = 1;
    for(int i=1;i<=n;i++)
        ans=ans*x;
    return ans;
}

int dp[MAX][3],a[MAX][3];

int solve(int flag,int idx, int n)
{
    if(idx==n)
        return 0;
    if(dp[idx][flag]!=-1)
        return dp[idx][flag];
    if(flag==0)
        dp[idx][flag] = a[idx][0]+max(solve(1,idx+1,n),solve(2,idx+1,n));
    else if(flag==1)
        dp[idx][flag] = a[idx][1]+max(solve(0,idx+1,n),solve(2,idx+1,n));
    else
        dp[idx][flag] = a[idx][2]+max(solve(0,idx+1,n),solve(1,idx+1,n));
    return dp[idx][flag];
}

void destruct(int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            dp[i][j] = -1;
        }
    }
}

int main()
{
    int n;
    si(n);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            si(a[i][j]);
            dp[i][j] = -1;
        }
    }
    int ans = solve(0,0,n);
    destruct(n);
    ans = max(ans,solve(1,0,n));
    destruct(n);
    ans = max(ans,solve(2,0,n));
    pfi(ans);
    return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define int long long
#define zmrl(x) (int)((x).size())
#define pb push_back
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using pp = pair<int, pii>;
const int inf = 1e9;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin>>n;
    vector<pii> point;
    set<pp, greater<pp> > down, up;
    while (n--) {
        int x,y; cin>>x>>y;
        point.pb({x, y});
        down.insert({x+y, {x, y}});
        up.insert({x-y+inf, {x, y}});
    }
    sort(point.begin(), point.end());
    point.erase(unique(point.begin(), point.end()), point.end());
    int res = 0;
    for (auto &cur : point) {
        res = max(res, down.begin()->fi - cur.fi - cur.se);
        res = max(res, up.begin()->fi - cur.fi - inf + cur.se);
        down.erase({cur.fi+cur.se, {cur.fi, cur.se}});
        up.erase({cur.fi-cur.se+inf, {cur.fi, cur.se}});
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 31188
#include<bits/stdc++.h>
using namespace std;
using ll=int64_t;
using vll=vector<ll>;
using vi=vector<int>;
int main(){
  int n,i,m=0,c=0;
  cin>>n;
  vi h(n);
  for(i=0;i<n;i++){
    cin>>h.at(i);
    m=max(m,h.at(i));
    if(h.at(i)==m) c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
typedef struct{
  int A;
  char B;
  int No;
}cards;
 
cards card[100000];
 
int partition(int, int);
void quickSort(int, int);
int stateJudge(int);
main(){
  int k, r, mid, p = 0;
  int i;
 
  scanf("%d", &k );
 
  for(i = 0; i < k; i++){
 
    scanf("%s%d",&card[i].B, &card[i].A);
 
    card[i].No = i;
     
    // printf("%c %d", card[q].B, card[q].A);
     
  }
   
   
  r = k - 1;
   
   
  quickSort(p, r);
   
  if( stateJudge(r) == 1 )printf("Stable\n");
  else printf("Not stable\n");
 
   
  for(i = 0; i < k; i++){
     
    printf("%c %d\n", card[i].B, card[i].A);
   
  }
   
  return 0;
   
}
 
 
int partition(int p, int r){
   
  int i = 0 , j;
  cards ch;
  i = p;
   
  for(j = p; j < r; j++){
    // printf("%d\n",i);
    if(card[j].A <= card[r].A ){
       
      ch = card[i];
      card[i] = card[j];
    card[j] = ch;
    i++;
     
    } 
  }
  ch = card[r];
  card[r] = card[i];
  card[i] = ch;
  //  printf("%d\n",i);
  return i;
   
}
 
 
void quickSort(int p, int r){
  int q;
  if(p < r){q = partition(p, r);
    //    printf("%c %d\n", card[q].B, card[q].A);
    quickSort(p, q-1) ;
     
    quickSort(q+1, r);
     
  }
}
 
int stateJudge(int r){
  int i;
  for(i = 0; i < r; i++){
     
    if(card[i].A == card[i+1].A){
       
      if(card[i].No > card[i+1].No)
    {
      return 0;
    }   
    }
  }
 return 1;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-4;
const int MAX=1e5+10;
const ll mod=1e9+7;
/***************************************  head  **********************************************/
struct node
{
	ll id,v;
	node(){}
	node(ll a,ll b) :id(a),v(b){}
	friend bool operator <(node a,node b)
	{
		return a.v>b.v;
	}
};
vector<node> mp[2][MAX];
ll flag[MAX],dis[2][MAX];
void dij(ll s,ll f)
{
	ll i,sz;
	priority_queue<node> q;
	node t,to;
	mem(dis[f],0x3f);
	mem(flag,0);
	dis[f][s]=0;
	q.push(node(s,0));
	while(!q.empty())
	{
		t=q.top();
		q.pop();
		if(flag[t.id]) continue;
		flag[t.id]=1;
		sz=sz(mp[f][t.id]);
		for(i=0;i<sz;i++)
		{
			to=mp[f][t.id][i];
			if(dis[f][to.id]>dis[f][t.id]+to.v)
			{
				dis[f][to.id]=dis[f][t.id]+to.v;
				q.push(node(to.id,dis[f][to.id]));
			}
		}
	}
} 
ll ans[MAX];
int main()
{
	ll n,m,s,t,a,b,i,v,w;
	while(~scanf("%lld%lld%lld%lld",&n,&m,&s,&t))
	{
		for(i=1;i<=n;i++) mp[0][i].clear(),mp[1][i].clear();
		while(m--)
		{
			scanf("%lld%lld%lld%lld",&a,&b,&v,&w);
			mp[0][a].pb(node(b,v));
			mp[0][b].pb(node(a,v));
			mp[1][a].pb(node(b,w));
			mp[1][b].pb(node(a,w));
		}
		dij(s,0);
		dij(t,1);
		ans[n+1]=-LLINF;
		for(i=n;i;i--)
		{
			ans[i]=max(ans[i+1],((ll)1e15)-(dis[0][i]+dis[1][i]));
		}
		for(i=1;i<=n;i++) printf("%lld\n",ans[i]);
	}
	return 0;
}


Measured memory_bytes: 19964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s,t; 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>s>>t;
	for(int i=0;i<s.size();i++)
	if(s[i]!=t[i]){
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
const int K = 100050;
int A[K];
typedef long long LL;
int main() {
  int k;
  scanf("%d", &k);
  for (int i = 0; i < k; ++i) scanf("%d", &A[i]);
  if (A[k - 1] != 2) return puts("-1") & 0;
  LL l = 2, r = 2;
  for (int i = k - 1; ~i; --i) {
    l = (l + A[i] - 1) / A[i] * A[i];
    r = r / A[i] * A[i] + A[i] - 1;
    if (r < l) return puts("-1") & 0;
  }
  printf("%lld %lld\n", l, r);
  return 0;
}

Measured memory_bytes: 512
// ------------------
// author: MatsuTaku
// date  : 27/02/2020
// ------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int K; cin>>K;
  unordered_set<int> mass_cands;
  for (int i = 0; i < 64; i++)
    mass_cands.insert(i);
  auto place_qween = [](unordered_set<int>& cands, int x, int y) {
    cands.insert((x*8+y)+64);
    for (int t = 0; t < 8; t++) {
      cands.erase(t*8+y);
      cands.erase(x*8+t);
      if ((x-y+t)*8+t >= 0 and (x-y+t)*8+t < 64)
        cands.erase((x-y+t)*8+t);
      if ((x+y-t)*8+t >= 0 and (x+y-t)*8+t < 64)
        cands.erase((x+y-t)*8+t);
    }
  };
  for (int i = 0; i < K; i++) {
    int x, y; cin>>x>>y;
    place_qween(mass_cands, x, y);
  }
  auto solve = [&, f=[&](auto rec, int cnt, unordered_set<int>& cands) -> bool {
    if (cnt == 8)
      return true;
    vector<int> is;
    for (auto i : cands) if (i < 64) is.push_back(i);
    for (auto i : is) {
      unordered_set<int> ccopy = cands;
      place_qween(ccopy, i/8, i%8);
      if (rec(rec, cnt+1, ccopy)) {
        cands = ccopy;
        return true;
      }
    }
    return false;
  }] {
    f(f, K, mass_cands);
  };
  solve();
  for (int i = 0; i < 64; i++) {
    cout << (mass_cands.count(i+64) > 0 ? "Q" : ".");
    if (i%8==7)
      cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3228
#include<bits/stdc++.h>
#define MAXN 15
#define MAXM 505
#define LL long long
#define P int(1e9+7)
using namespace std;

int N,M;
int G[MAXN][MAXN];

int cost[1<<15];
int dp[MAXN][1<<15];

int main(){
	
	cin>>N>>M;
	int u,v,w;
	int tot = 0;
	for(int i=1;i<=M;i++){
		cin>>u>>v>>w;
		--u; --v;
		G[u][v] = G[v][u] = w;
		tot += w;
	}
	
	for(int s=1;s<(1<<N);s++){
		for(u=0;u<N;u++){
			if(((s>>u)&1)==0) continue; 
			for(int v=u+1;v<N;v++){
				if(((s>>v)&1)==0) continue; 
				cost[s] += G[u][v];
			}
		}
		//cout<<s<<" "<<cost[s]<<endl;
	}
	
	int ans = 0;
	memset(dp, 0xf3, sizeof(dp));

	dp[0][1] = 0;
	int U = (1<<N) - 1;
	
	for(int s=1;s<(1<<N);s++){
			for(u=0;u<N;u++){
			if(((s>>u)&1)==0 || dp[u][s]<0) continue;
			//cout<<u<<" "<<s<<" "<<dp[u][s]<<endl;
			if(u==N-1) ans = max(ans, dp[N-1][s]);
			
			for(v=0;v<N;v++){
				if(((s>>v)&1)==0 && G[u][v]){
					dp[v][s|(1<<v)] = max(dp[v][s|(1<<v)], dp[u][s] + G[u][v]);
				}
			}
			
			int s1 = (U^s)|(1<<u);
			
			for(int s2=s1;s2>0;s2=(s2-1)&s1){
				dp[u][s|s2] = max(dp[u][s|s2], dp[u][s] + cost[s2]);
			}
		}
	}
	cout<<tot - ans<<endl;
	
	return 0;
}


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

counter = [0] * (10**5 + 2)
for a in A:
    counter[a - 1] += 1
    counter[a] += 1
    counter[a + 1] += 1

ans = 0
for c in counter[:-2]:
    ans = max(ans, c)
print(ans)


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

long long suusiki(string s) {}

int main() {
  string s;
  cin >> s;
  long long ans = 0;
  // ans = suusiki(s);
  for (int bit = 0; bit < (1 << (s.size() - 1)); bit++) {
    long long tmp = 0;
    for (int i = 0; i < s.size() - 1; i++) {
      tmp *= 10;
      tmp += s.at(i) - '0';
      if (bit & (1 << i)) {
        ans += tmp;
        tmp = 0;
      }
    }
    tmp *= 10;
    tmp += s.back() - '0';
    ans += tmp;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	string S;
	cin >> S;
	vl A(26);
	N = S.length();
	for (i = 0; i < N; i++) {
		A[S[i] - 'a']++;
	}
	string T = S;
	for (i = 0; i < 26; i++) {
		if (A[i] == 0) {
			ll key = 'a' + i;
			T += key;
			cout << T;
			exit(0);
		}
	}
	ll count = 0;
	do {
		if (count == 1) {
			for (i = 0; i < 26; i++) {
				if (S < T.substr(0, i + 1)) {
					cout << T.substr(0, i + 1);
					exit(0);
				}
			}
		}
		count++;
	} while (next_permutation(T.begin(), T.end()));
	cout << -1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

int main(void) {
	int n; cin >> n;
	out(n*n*n);

}




Measured memory_bytes: 256
d=dict()
wa=ans=0
N,M=map(int,input().split())
for i in range(M):
  p,s=input().split()
  if p not in d:
    d[p]=0
  if d[p]>=0 and s=="AC":
    ans+=1
    wa+=d[p]
    d[p]=-1
  elif d[p]>=0:
    d[p]+=1
print(ans,wa)

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

int main()
{
  int W, H ,x ,y ,r;
  bool ver, hor;

  cin >> W >> H >> x >> y >> r;

  hor = ((x-r >= 0) & (x+r <= W));
  ver = ((y-r >= 0) & (y+r <= H));

  if (hor & ver) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
};



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

#define pb push_back
#define mk make_pair
typedef vector<pair<int, int> > vec;

int main(){
	int n;
	while( cin >> n, n ){
		vec doll;
		for( int i = 0; i < n; i++ ){
			int h, r;
			cin >> h >> r;
			doll.pb(mk(h, r));
		}
		int m;
		cin >> m;
		for( int i = 0; i < m; i++ ){
			int h, r;
			cin >> h >> r;
			doll.pb(mk(h, r));
		}
		sort(doll.begin(), doll.end());
		vector<int> dp(n+m, 1);
		int ans = 1;
		for( int i = 0; i < n+m; i++ ){
			for( int j = i; j < n+m; j++ ){
				if( doll[i].first < doll[j].first && doll[i].second < doll[j].second ){
					dp[j] = max(dp[j], dp[i]+1);
				}
				if( ans < dp[j] ) ans = dp[j];
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n,k; cin>>n>>k;
    vector<vector<ll>> edge(n+1);
    rep(i,n-1){
        ll a,b; cin>>a>>b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    ll res=k;
    ll mod=1e9+7;
    queue<ll> que;
    que.push(1);
    vector<bool> used(n+1, false);
    used[1]=true;
    while(!que.empty()){
        ll x=que.front();
        que.pop();
        ll cnt=0;
        for(ll y: edge[x]){
            if(used[y]) continue;
            used[y]=true;
            cnt++;
            if(x==1) res*=k-cnt;
            else res*=k-1-cnt;
            res%=mod;
            que.push(y);
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 7284
import collections
n=int(input())
lis = list(map(int, input().split()))
count=collections.Counter(lis)
q=int(input())
s=sum(lis)
#print(count,s)
for _ in range(q):
    b,c=map(int, input().split())
    s = s - (b-c)*count[b]
    
    count[c]+=count[b]
    count[b]=0
    print(s)

Measured memory_bytes: 24152