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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  int m,t,p,r;
  while(true){
    cin >>m >> t >> p >> r;//???????????°???????????°?????¬???????????°
    if(t==0) break;
    int seikai[t+1]={0},penalty[t+1]={0},gotou[t+1][p+1]={0};
    for(int i=0;i<r;i++){
      int j,tID,pID,time;
      cin >> time>> tID >> pID >> j;
      if(j==0){
        seikai[tID]++;
        penalty[tID] += gotou[tID][pID]*20+time;
      }
      else{
        gotou[tID][pID]++;
      }
    }
    bool checked[t+1]={false};
    int preseikai=-1,prepena=-1;
    for(int i=t;i>=1;i--){
      int team,seikaimax=-1,pena=INF;
      for(int j=t;j>=1;j--){
        if(!checked[j]){
          if(seikaimax<seikai[j]){
            seikaimax=seikai[j];
            team=j;
            pena=penalty[j];
          }
          else if(seikaimax==seikai[j]){
            if(pena>penalty[j]){
              team=j;
              pena=penalty[j];
            }
          }
        }
      }
      checked[team]=true;
      if(prepena==-1) cout << team ;
      else if(prepena==pena && preseikai==seikaimax) cout << "=" << team;
      else cout << "," << team;
      preseikai=seikaimax,prepena=pena;
    }
    cout << endl;
  }
}

Measured memory_bytes: 3128
# https://atcoder.jp/contests/abc093/tasks/abc093_b


A, B, K = gets.split.map(&:to_i)

if A + K > B - K
  A.upto(B) { |i| puts i }
else
  A.upto(A + K - 1) { |i| puts i }
  (B - K + 1).upto(B) { |i| puts i }
end


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

int main(void) {
  int N, a;
  scanf("%d", &N);
  a = N%10;
  if (a==0){
    printf("No");
  }else if (a%9==0 || N/90==1)
  {
    printf("Yes");
  }else{
    printf("No");
  }
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(void) {
	int a, b, n;
	int ans = 0;
	cin >> a >> b;
	cin >> n;
	int s[101][2];
	s[0][0] = a, s[0][1] = b;
	for (int i = 1;i < n+1;i++)
		cin >> s[i][0] >> s[i][1];
	for (int i = 0;i < n+1;i++) {
		for (int j = 0;j < n+1;j++) {
			if (s[i][1] > s[j][0] && s[i][0]<s[j][1] && i!=j) {
				ans = 1;
				break;
			}
			else if (s[i][1] < s[j][0] && s[i][0] > s[j][1] && i != j) {
				ans = 1;
				break;
			}
		}
		if (ans == 1)break;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3108
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<usize>();
    let q = input::<usize>();
    let s = input::<String>().chars().collect::<Vec<char>>();
    let lr = (0..q)
        .map(|_| {
            let l = input();
            let r = input();
            (l, r)
        })
        .collect::<Vec<(usize, usize)>>();

    let sum = {
        let mut v = Vec::with_capacity(n);
        let mut cnt = 0;
        v.push(cnt);
        for i in 0..n - 1 {
            if s[i] == 'A' && s[i + 1] == 'C' {
                cnt += 1;
            }
            v.push(cnt);
        }
        v
    };

    let stdout_ = std::io::stdout();
    let mut stdout = std::io::BufWriter::new(stdout_.lock());
    for (l, r) in lr {
        let ans = sum[r - 1] - sum[l - 1];
        writeln!(stdout, "{}", ans).unwrap();
    }
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

std::vector<int> solve(int n, const std::vector<int> &c, const std::vector<std::vector<int> > &val) {
	auto score = [&] (const std::vector<int> &all) {
		int last[26];
		for (auto &i : last) i = -1;
		int res = 0;
		for (int i = 0; i < n; i++) {
			int cur = all[i];
			last[cur] = i;
			for (int j = 0; j < 26; j++) res -= c[j] * (i - last[j]);
			res += val[i][cur];
		}
		return res;
	};
	
	std::vector<int> cur(n);
	for (int i = 0; i < n; i++) cur[i] = i % 26;
	int cur_score = score(cur);
	
	std::random_device rnd_dev;
	std::mt19937 rnd(rnd_dev() ^ time(NULL));
	
	clock_t r0 = clock();
	while (clock() - r0 <= 1.95 * CLOCKS_PER_SEC) {
		int r0 = std::uniform_int_distribution<>(0, n - 1)(rnd);
		int r1 = std::uniform_int_distribution<>(0, n - 1)(rnd);
		r1 = std::max(r1, 0);
		r1 = std::min(r1, n - 1);
		std::swap(cur[r0], cur[r1]);
		int new_score = score(cur);
		if (new_score > cur_score) cur_score = new_score;
		else std::swap(cur[r0], cur[r1]);
	}
	
	return cur;
}

void input() {
	int n = ri();
	std::vector<int> c(n);
	for (auto &i : c) i = ri();
	std::vector<std::vector<int> > val(n, std::vector<int>(26));
	for (auto &i : val) for (auto &j : i) j = ri();
	for (auto i : solve(n, c, val)) printf("%d\n", i + 1);
}

void random_test() {
	std::random_device rnd_dev;
	std::mt19937 rnd(rnd_dev() ^ time(NULL));
	
	int n = 365;
	std::vector<int> c(n);
	for (auto &i : c) i = std::uniform_int_distribution<>(0, 100)(rnd);
	std::vector<std::vector<int> > val(n, std::vector<int>(26));
	for (auto &i : val) for (auto &j : i) j = std::uniform_int_distribution<>(0, 20000)(rnd);
	
	auto res = solve(n, c, val);
	
	
	int last[26];
	for (auto &i : last) i = -1;
	int score = 0;
	for (int i = 0; i < n; i++) {
		last[res[i]] = i;
		for (int j = 0; j < 26; j++) score -= c[j] * (i - last[j]);
		score += val[i][res[i]];
	}
	printf("%d\n", score);
}

int main() {
	// random_test();
	input();
	return 0;
}



Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pii pair<ll,ll>
#define sc(x) scanf("%lld",&x)
long double pi=3.141592653589793238;

int main(){
	long double r;
	cin>>r;
	r=2*r;
	r=r*pi;
	std::cout << std::setprecision(12) << r;
	return 0;
}


Measured memory_bytes: 3792
#include<stdio.h>
int main(void)
{
  char p[101],s[101];
  int i=0,j=0,k=0,a=0,b=0;
  int ans=0;
  for(i=0; i<101; i++){
    scanf("%c",&s[i]);
    if(s[i]=='\n')break;
  }
  for(j=0; j<101; j++){
    scanf("%c",&p[j]);
    if(p[j]=='\n')break;
  }
  for(k=0; k<i; k++){
    if(s[k]==p[0]){
      for(a=0; a<j; a++){
        b=k+a;
        if(b>=i)b-=i;
        if(s[b]!=p[a])break;
        if(a==j-1)ans=1;
      }
    }
  }
  if(ans)printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 524
#include "bits/stdc++.h"
#include "random"
#include <unistd.h>

using namespace std;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x, y) x = max(x,y)
#define chmin(x, y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i, n) for(int i = 0 ; i < n; ++i)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int Uniform_Random(int a, int b){ // (a <= x <= b)

  random_device rd;
  mt19937 mt(rd());
  
  uniform_int_distribution<int> rv1(a, b);
  return rv1(mt);
  
}
 
int main(){
  
  int n; cin >> n;
  vi v(n, 0);
  
  for (int i = 0; i < n; i++)
    cin >> v[i];
  
  sort(v.begin(), v.end());

  cout << v[n - 1] - v[0] << endl;
  
  return 0; 
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    codefestival2017qualc_c()
}

fun codefestival2017qualc_c() {
    val s = readLine()!!

    var left = 0
    var right = s.lastIndex
    var cnt = 0
    while (left < right) {
        when {
            s[left] == s[right] -> {
                left++
                right--
            }
            s[left] == 'x' -> {
                left++
                cnt++
            }
            s[right] == 'x' -> {
                right--
                cnt++
            }
            else -> return println("-1")
        }
    }

    println(cnt)
}


Measured memory_bytes: 34364
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  200005
vi a[N];
ll dis[N],st[N];
void dfs(ll node,ll p,ll cnt){
	dis[node]=cnt;
	for(auto i:a[node]){
		if(i!=p)
			dfs(i,node,cnt+1);
	}
}
int main()
{
	ios
	ll x,y,n,i,j;
	cin>>n;
	st[0]=0,st[1]=1,st[2]=0,st[3]=1;
	for(i=4;i<N;i++)
		st[i]=!(st[i-1]&st[i-2]);
	for(i=0;i<n-1;i++){
		cin>>x>>y;
		a[x].pb(y);
		a[y].pb(x);
	}
	dfs(1,0,1);
	ll id=-1,mx=0;
	for(i=1;i<=n;i++){
		if(mx<dis[i]){
			id=i;mx=dis[i];
		}
	}
	dfs(id,0,1);
	mx=0;
	for(i=1;i<=n;i++){
		if(mx<dis[i]){
			id=i;mx=dis[i];
		}
	}
	if(st[mx]==1)cout<<"First";else cout<<"Second";
	return 0;
}


Measured memory_bytes: 23680
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        //System.out.println(max(12345,5)+" "+min(12345,5));
        loop:
        while(true){
            int[] suretu = new int[21];
            int a = Integer.parseInt(sc.next());
            int L = Integer.parseInt(sc.next());
            if(a==0&&L==0)break;
            suretu[0]=a;
            for(int i=1;i<21;i++){
                suretu[i]=max(suretu[i-1],L)-min(suretu[i-1],L);
                for(int j=0;j<i;j++){
                    if(suretu[i]==suretu[j]){
                        System.out.println(j+" "+suretu[j]+" "+(i-j));
                        continue loop;
                    }
                }
            }
        } 
    }
    
    static int max(int kazu,int L){
        String retu = Integer.toString(kazu);
        char[] naraberu = retu.toCharArray();
        int[] harahetta = new int[naraberu.length];
        for(int i=0;i<naraberu.length;i++){
            harahetta[i]=Integer.parseInt(naraberu[i]+"");
        }
        Arrays.sort(harahetta);
        
        String narabeta="";
        for(int i=0;i<harahetta.length;i++){
            narabeta += Integer.toString(harahetta[harahetta.length-1-i]);
        }
        while(true){
            if(narabeta.length()==L){
                break;
            }else{
                narabeta += "0";
            }
        }
        int kaesu = Integer.parseInt(narabeta);
        return kaesu;
    }
    
    static int min(int kazu,int L){
        String retu = Integer.toString(kazu);
        char[] naraberu = retu.toCharArray();
        Arrays.sort(naraberu);
        String narabeta="";
        for(int i=0;i<naraberu.length;i++){
            narabeta += naraberu[i]+"";
        }
        
        int kaesu = Integer.parseInt(narabeta);
        
        return kaesu;
    }
    
}

Measured memory_bytes: 23500
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define dump(x) cerr << #x << " : " << x << '\n'
#define MOD(x, y) (((y) + (x) % (y)) % (y))

int main(int argc, char* argv[])
{
	int A, B;
	char S[20];
	scanf("%d%d", &A, &B);
	scanf("%s", S);
	for (int i = 0; i < A + B + 1; i++) {
		char c = S[i];
		if (i == A) {
			if (c != '-') {
				printf("No\n");
				return 0;
			}
		} else {
			if (c > '9' || c < '0') {
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");

	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = set(list(int(input()) for i in  range(m)))

p = 10**9+7
dp = [0]*(n+1)
dp[0] = 1

for i in range(1, n+1):
    dp[i] = (dp[i-1] + dp[i-2])%p
    if i in a:
        dp[i] = 0
print(dp[n])



Measured memory_bytes: 18936
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3+10;
char a[N][N];
int vectex[N][N], edgeH[N][N], edgeW[N][N];

int main(){
    int n, m, q;
    scanf("%d %d %d\n",&n,&m,&q);
    for(int i = 0; i < n; i ++){
        scanf("%s",a[i]);
    }
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < m; j ++){
            vectex[i+1][j+1] = (a[i][j] == '1') + vectex[i+1][j] + vectex[i][j+1] -vectex[i][j];
            edgeH[i+1][j+1] = (a[i+1][j] == '1' && a[i][j] == '1') + edgeH[i+1][j] + edgeH[i][j+1] - edgeH[i][j];
            edgeW[i+1][j+1] = (a[i][j+1] == '1' && a[i][j] == '1') + edgeW[i+1][j] + edgeW[i][j+1] - edgeW[i][j];
        }
    }
    while(q--){
        int x1, x2, y1, y2;
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        x1--;y1--;
        int vec = vectex[x2][y2] - vectex[x2][y1] - vectex[x1][y2] + vectex[x1][y1];
        int edg = edgeH[x2-1][y2] - edgeH[x2-1][y1] - edgeH[x1][y2] + edgeH[x1][y1] +
                    edgeW[x2][y2-1] - edgeW[x2][y1] - edgeW[x1][y2-1] + edgeW[x1][y1];
        printf("%d\n",vec - edg);
    }
    return 0;
}


Measured memory_bytes: 53120
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int t = n;
  int sum =0;
  while(t>0){
    sum += t%10;
    t/=10;
  }
  if(n%sum == 0){
    cout << "Yes"<< endl;
  }else{
    cout <<"No"<< endl;
  }
}
    

Measured memory_bytes: 256
#include <stdio.h>

#define N 100

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

  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[i] = 0;
    for(j = 0; j < m; j++){
      c[i] += a[i][j] * b[j];
    }
    printf("%d\n", c[i]);
  }
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();

		//SS
		char[] ans = new char[n];

		fill(ans, 'S','S',s);

		if(!(ans[n-2]=='S' ^ ans[n-1]=='S' ^ s.charAt(n-1)=='o' ^ ans[0]=='S')
				&& !(ans[n-1]=='S' ^ ans[1]=='S' ^ s.charAt(0)=='o' ^ ans[0]=='S')) {
			System.out.println(new String(ans));
			return;
		}

		fill(ans,'S','W',s);

		if(!(ans[n-2]=='S' ^ ans[n-1]=='S' ^ s.charAt(n-1)=='o' ^ ans[0]=='S')
				&& !(ans[n-1]=='S' ^ ans[1]=='S' ^ s.charAt(0)=='o' ^ ans[0]=='S')) {
			System.out.println(new String(ans));
			return;
		}

		fill(ans,'W','S',s);

		if(!(ans[n-2]=='S' ^ ans[n-1]=='S' ^ s.charAt(n-1)=='o' ^ ans[0]=='S')
				&& !(ans[n-1]=='S' ^ ans[1]=='S' ^ s.charAt(0)=='o' ^ ans[0]=='S')) {
			System.out.println(new String(ans));
			return;
		}

		fill(ans,'W','W',s);

		if(!(ans[n-2]=='S' ^ ans[n-1]=='S' ^ s.charAt(n-1)=='o' ^ ans[0]=='S')
				&& !(ans[n-1]=='S' ^ ans[1]=='S' ^ s.charAt(0)=='o' ^ ans[0]=='S')) {
			System.out.println(new String(ans));
			return;
		}

		System.out.println(-1);

	}

	static void fill(char[] ans, char a, char b, String s) {
		ans[0]=a;
		ans[1]=b;
		for (int i=1;i<ans.length-1;i++) {
			if(ans[i-1]=='S' ^ ans[i]=='S' ^ s.charAt(i)=='o') {
				ans[i+1]='S';
			} else {
				ans[i+1]='W';
			}
		}
	}

}


Measured memory_bytes: 25788
#include <map>
#include <string>
#include <iostream>
using namespace std;
string s; int r, f; map<string, int> d;
int solve(int l, int r) {
	int pos = l, ret = 0;
	while (pos != r) {
		if (isupper(s[pos])) {
			int res = 0; string val;
			if (islower(s[pos + 1])) val = s.substr(pos, 2), pos += 2;
			else val = s.substr(pos, 1), pos++;
			if (d[val] == 0) f = 1;
			res += d[val];
			int cur = pos;
			while (isdigit(s[pos])) pos++;
			ret += res * (pos - cur ? stoi(s.substr(cur, pos - cur)) : 1);
		}
		else {
			int cur = pos, br = 1; pos++;
			while (br) {
				if (s[pos] == '(') br++;
				if (s[pos] == ')') br--;
				pos++;
			}
			int res = solve(cur + 1, pos - 1); cur = pos;
			while (isdigit(s[pos])) pos++;
			ret += res * stoi(s.substr(cur, pos - cur));
		}
	}
	return ret;
}
int main() {
	while (cin >> s, s.size() < 3) cin >> r, d[s] = r;
	while (cin >> s, s != "0") {
		s += " ", f = 0;
		int res = solve(0, s.size() - 1);
		if (f) cout << "UNKNOWN" << endl;
		else cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.141592653289793;
using namespace std;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define lld long double
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> vp;
typedef vector<tuple<ll, ll, ll>> vt;
//vector<vector<ll>> vv(n, vector<ll>(n));

int main()
{
	int a, b, c, d, e, f;
	int anss = 0, answ = 0;
	double conc = 0.0;
	set<int> sets, setw;
	vi vw, vs;
	cin >> a >> b >> c >> d >> e >> f;
	int limw = f / 100;
	for (int wa = 0; wa <= limw; wa += a)
	{
		for (int wb = 0; wa + wb <= limw; wb += b)
		{
			setw.insert((wa + wb) * 100);
		}
	}
	setw.erase(0);
	for (auto i : setw)
	{
		vw.push_back(i);
	}
	sort(ALL(vw), greater<int>());
	int lims = vw.front() / 100 * e;
	for (int sa = 0; sa <= lims; sa += c)
	{
		for (int sb = 0; sa + sb <= lims; sb += d)
		{
			sets.insert(sa + sb);
		}
	}
	for (auto i : sets)
	{
		vs.push_back(i);
	}
	sort(ALL(vs), greater<int>());
	for (double water : vw)
	{
		vi::iterator itr = vs.begin();
		double sugar = 0;
		while (itr != vs.end())
		{
			if (water + *itr <= f && *itr <= water / 100 * e)
			{
				sugar = *itr;
				break;
			}
			++itr;
		}
		double newconc = sugar / (water + sugar);
		if (conc < newconc)
		{
			conc = newconc;
			answ = water;
			anss = sugar;
		}
	}
	if (!answ) cout << a * 100 << " 0" << endl;
	else cout << answ + anss << " " << anss << endl;
}

Measured memory_bytes: 384
M,D=map(int,input().split())
count=0
for m in range(1,M+1):
    for d in range(1,D+1):
        d1=d-(d//10)*10
        d10=d//10
        if (d1>=2) and (d10>=2) and (d1*d10==m):
            count+=1
print(count)

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

class Union_Find{
private:
  vector<int64_t> par;
  vector<int64_t> rank;
  vector<int64_t> num;

  int64_t find(int64_t x){
    if(par.at(x)==x){
      return x;
    }else{
      return par.at(x)=find(par.at(x));
    }
  }

public:
  Union_Find(int64_t n){
    par.resize(n);
    rank.resize(n,0);
    num.resize(n,1);
    for(int64_t i=0;i<n;i++){
      par.at(i)=i;
    }
  }

  void unite(int64_t x,int64_t y){
    x=find(x);
    y=find(y);
    if(x==y){
      return;
    }
    if(rank.at(x)<rank.at(y)){
      par.at(x)=y;
      num.at(y)+=num.at(x);
    }else if(rank.at(x)>rank.at(y)){
      par.at(y)=x;
      num.at(x)+=num.at(y);
    }else{
      par.at(x)=y;
      rank.at(y)++;
      num.at(y)+=num.at(x);
    }
  }

  bool same(int64_t x,int64_t y){
    return find(x)==find(y);
  }

  int64_t size(int64_t x){
    return num.at(find(x));
  }

};

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> a(M),b(M);
  for(int i=0;i<M;i++){
    cin >> a.at(i) >> b.at(i);
  }
  int ans=0;
  for(int i=0;i<M;i++){
    Union_Find uf(N+1);
    for(int j=0;j<M;j++){
      if(i==j){
        continue;
      }
      uf.unite(a.at(j),b.at(j));
    }
    if(uf.size(1)!=N){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

  int cnt = 0;
  for(int i = 1; i < n-1; i++) {
    if((max({p[i-1], p[i], p[i+1]}) != p[i]) && 
       (min({p[i-1], p[i], p[i+1]}) != p[i])) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,n) for(int i=0;i<n;++i)
#define pie 3.141592653589793238462643383279
#define mod 1e9+7
int x[100000],y[100000];
signed main(){
	int n;
	cin>>n;
	f(i,n){
		cin>>x[i];
	}
	sort(x,x+n);
	f(i,n){
		y[i]=x[i];
		if(i) y[i]+=y[i-1];
	}
	for(int i=n-2;i>=0;i--){
		if(y[i]*2<x[i+1]){
			cout<<n-i-1<<endl;
			return 0;
		}
	}
	cout<<n<<endl;
}


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

using namespace std;

const int N = 1e5 + 3;
char a[N];
int n, k;

int main() {
	scanf("%d%d", &n, &k);
	scanf("%s", a + 1);
	typedef pair<int, int> ii;
	vector<ii> fl;
	fl.push_back(ii(0, 0));
	for (int i = 1, j; i <= n;) {
		j = i + 1;
		while (j <= n && a[j] == a[i]) ++j;
		fl.push_back(make_pair(j - i, int(a[i] - '0')));
		i = j;
	}
	int res = 0;
	for (int i = 1; i < int(fl.size()); ++i)
		fl[i].first += fl[i - 1].first;
	for (int i = 1; i < int(fl.size()); ++i) {
		if (fl[i].second == 0) {
			res = max(res, fl[i].first - fl[max(1, i - (2 * k - 1)) - 1].first);
		}
		else {
			res = max(res, fl[i].first - fl[max(1, i - (2 * k - 0)) - 1].first);
		}
	}
	printf("%d", res);
	return 0;
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int N;
	vector<llong> A,B,C;

	cin >> N;
	A.resize(N);
	B.resize(N);
	C.resize(N);
	A.push_back(-inf);
	for(int i = 0; i < N; i++)
		cin >> A[i];
	for(int i = 0; i < N; i++)
		cin >> B[i];
	for(int i = 0; i < N; i++)
		cin >> C[i];

	sort(BE(A));
	sort(BE(B));
	sort(BE(C));

	// cerr << endl;
	// for(auto x : A)
	// 	cerr << x << " ";
	// cerr << endl;
	// for(auto x : B)
	// 	cerr << x << " ";
	// cerr << endl;
	// for(auto x : C)
	// 	cerr << x << " ";
	// cerr << endl;

	llong ans = 0;
	for(int i = 0; i < N; i++){
		llong tg = B[i];
		auto Ait = lower_bound(BE(A), tg);
		auto Cit = upper_bound(BE(C), tg);
		Ait--;

		// cerr << tg << endl;
		// cerr << *Ait << " " << Ait - A.begin() << endl;
		// cerr << *Cit << " " << C.end() - Cit << endl << endl;

		ans += (Ait - A.begin())*(C.end() - Cit);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(void){
  ll int N;
  cin >> N;
  ll int ans = 0;
  if(N%2 == 0){
    ll int mul = 5;
    for(int i=1; i<26; i++){
      ans += (N/mul)/2;
      mul *= 5;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> num(n);
    rep(i,k){
        int d;
        cin >> d;
        vector<int> a(d);
        rep(i,d) cin >> a.at(i);
        rep(i,d){
            rep(j,n+1){
                if(a.at(i) == j+1) num.at(j)++;
            }
        }
    }
    int ans = 0;
    rep(i,n){
        if(num.at(i) == 0) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
def solve(N):
  if N<=4:
    print(0)
    return 0
  X=[]
  if N&1:
    X=[13305600,45718704,-15523260,-8918200,281505,538692,93135,7200,270,4]
  else:
    X=[-25704000,1155744,11833500,-1132660,-1022385,-27048,27825,3960,210,4]
  N=(N>>1)<<1
  Y=[1]
  for i in range(10):
    Y.append(Y[i]*N)
  P=1
  for i in range(6):
    P*=N+i+i
  Q=0
  for i in range(10):
    Q+=Y[i]*X[i]
  Q*=P
  Q//=167382319104000
  print(Q%(10**9+7))

for i in range(int(input())):
  solve(int(input()))

Measured memory_bytes: 63532
#include<bits/stdc++.h>
//#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1000000007;
const int INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
 
signed main(){
    int r, g;   cin >> r >> g;
    cout << 2 * g - r << endl;
}

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

int main(){
  int N;
  cin >> N;
 
  vector<int> H(N);
  for( int i = 0; i < N; i++ ) cin >> H.at(i);
  
  int move = 0;
  int max_move = 0;
  
  for( int i = 1; i < N; i++ ){
    if( H.at( i-1 ) >= H.at( i ) ){
      move++;
      max_move = max( max_move, move );
    }else{
      move = 0;
    }
  }
  cout << max_move;
  return 0;
}


Measured memory_bytes: 640
from collections import defaultdict

d = defaultdict(int)

n = int(input())
for i in range(n):
    s = input()
    d[s] += 1

m = max(d.values())

ans = []
for key, value in d.items():
    if value == m:
        ans.append(key)
ans.sort()

print(*ans, sep="\n")


Measured memory_bytes: 98092
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  ll sum = 0; rep(i, N) sum += a[i];
  ll x1 = sum;
  for (int i = 1; i < N; i += 2){
    x1 -= 2 * a[i];
  }
  cout << x1 << " ";
  for (int i = 0; i < N - 1; ++i){
    x1 = 2 * a[i] - x1;
    cout << x1 << " ";
  }
  cout << endl;
}


Measured memory_bytes: 2048
N_list = [int(x) for x in input().split()]
char_list = []
for i in range(N_list[0]):
    char_list.append(input())
    
start_line = '#' * (N_list[1] + 2)
print(start_line)
for i in range(N_list[0]):
    print('#' + char_list[i] + '#')
print(start_line)

Measured memory_bytes: 3060
#14:50
#チョイ見た
scale = 20
#scale = 3
n = int(input())
raw = list(map(int,input().split()))
a = [[] for _ in range(scale)]
for i in range(n):
  x = raw[i]
  for d in range(scale):
    a[d].append(x%2)
    x //= 2
#print(a)
c = []
for d in range(scale):
  b = []
  tmp = 0
  for i in range(n):
    if a[d][i] == 1:
      tmp += 1
      if tmp == 2:
        b.append(i)
        break
  else:
    b += [n for _ in range(n)]
    c.append(b)
    continue
  for i in range(1,n):
    if a[d][i-1] == 0:
      b.append(b[-1])
      continue
    for j in range(b[-1]+1,n):
      if a[d][j] == 1:
        b.append(j)
        break
    else:
      b += [n for _ in range(i,n)]
      break
  c.append(b)
#print(c)
ans = []
for l in range(n):
  now = []
  for d in range(scale):
    now.append(c[d][l])
  ans.append(min(now)-l)
#print(ans)
print(sum(ans))

Measured memory_bytes: 147116
X, Y, Z, K = [int(x) for x in input().split()]
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
C = sorted(C, reverse=True)
ABC = []
for a in range(len(A)):
    for b in range(len(B)):
        if (a+1)*(b+1) > K:
            break
        for c in range(len(C)):
            if (a+1)*(c+1) > K:
                break
            elif (b+1)*(c+1) > K:
                break
            elif (a+1)*(b+1)*(c+1) > K:
                break
            ABC.append(A[a] + B[b] + C[c])
ABC = sorted(ABC, reverse=True)
for i in range(K):
    print(ABC[i])

Measured memory_bytes: 9544
/*for better*/
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define M 998244353
using namespace std;

ll n,h[100005],dp[100005];

ll fun(int i)
{
	if(i==n-1)
		return 0;
	if(dp[i]!=-1)
		return dp[i];
	if(i>=n)
		return 1e9;
	return dp[i]=min(abs(h[i]-h[i+1])+fun(i+1),abs(h[i]-h[i+2])+fun(i+2));
}

int main()
{
    fast; 
    int i;
    cin>>n;
    f(i,0,n)
    	cin>>h[i];
    memset(dp,-1,sizeof(dp));
    cout<<min(fun(0),fun(0));
}


Measured memory_bytes: 3328
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <vector>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll nmax=50;

bool visited[nmax+1][nmax+1];
ll field[nmax+1][nmax+1];

ll h,w;

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

map<ll,ll> mp;

void factor(ll n){
    for(ll i=2;i<=floor(sqrt(n));i++){
        if(n%i==0){
            while(n%i==0){
            mp[i]++;
            n/=i;
            }
        }
    }
    if(n!=1)mp[n]++;
}

int main() {
    ll n,len;
    cin>>n;

    for(ll i=2;i<=n;i++){
        factor(i);
    }
    vector<ll> v;
    ll up;
    ll lis[5]={3,5,15,25,75};
    v.push_back(1);
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {

        if(itr->second+1>=75)up=5;
        else if(itr->second+1>=25)up=4;
        else if(itr->second+1>=15)up=3;
        else if(itr->second+1>=5)up=2;
        else if(itr->second+1>=3)up=1;
        else up=0;
        len=v.size();
        for(ll i=0;i<up;i++){
            for(ll j=0;j<len;j++){
                v.push_back(v[j]*lis[i]);
            }
        }

      }
      ll ct=0;
      for(ll i=0;i<v.size();i++){
          //cout<<v[i]<<" ";
          if(v[i]==75)ct++;
      }
      //cout<<endl;
      cout<<ct<<endl;
    return 0;
}


Measured memory_bytes: 132480
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<bitset>
using namespace std;
typedef long long ll;
#define N 600006
vector<int>v[2002];
int n,m,a[N][2],id[2002][2002],id1[2002],id2[2002];
bool vis[2002],to[2002][2002],ao[2002][2002];
void df5(int anc,int te)
{
    for(int i=0;i<v[te].size();i++)
    {
        int j=v[te][i];to[anc][j]=1;
        if(!vis[j])
        {
            vis[j]=1;df5(anc,j);
        }
    }
}
void dfs(int anc,int te,int wh)
{
    for(int i=0;i<v[te].size();i++)
    {
        int j=v[te][i];if(te==anc)wh=i+1;
        if(!vis[j])
        {
        if(id1[j]&&id1[j]!=wh)ao[anc][j]=1;id1[j]=wh;
            vis[j]=1;dfs(anc,j,wh);
        }
    }
}
void dfss(int anc,int te,int wh)
{
    for(int i=((int)v[te].size())-1;~i;i--)
    {
        int j=v[te][i];if(te==anc)wh=i+1;
        if(!vis[j])
        {
        if(id1[j]&&id1[j]!=wh)ao[anc][j]=1;id1[j]=wh;
            vis[j]=1;dfss(anc,j,wh);
        }
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int x,y;scanf("%d%d",&x,&y);
        v[x].push_back(y);a[i][0]=x,a[i][1]=y,id[x][y]=i;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)vis[j]=0;vis[i]=1;
        df5(i,i);
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)vis[j]=id1[j]=id2[j]=0;
        vis[i]=1;dfs(i,i,0);
        for(int j=1;j<=n;j++)vis[j]=0;
        vis[i]=1;dfss(i,i,0);
    }
    for(int i=1;i<=m;i++)
    {
        if(to[a[i][1]][a[i][0]]^ao[a[i][0]][a[i][1]])puts("diff");
        else puts("same");
    }
}


Measured memory_bytes: 18456
# from sys import exit
# A,B,C = [int(n) for n in input().split()]
N = int(input())
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
# exit()
# print(bin(N))
print(len(bin(N))-2 if N > 0 else 0)



Measured memory_bytes: 5584
object Main {
  import java.util.Scanner

  implicit class RichScanner(sc: Scanner) {
    def readStrings(n: Int): Array[String] = Array.fill(n) { sc.next() }
    def readInts(n: Int): Array[Int] = Array.fill(n) { sc.nextInt() }
    def readLongs(n: Int): Array[Long] = Array.fill(n) { sc.nextLong() }
    def readLineStrings: Array[String] = sc.nextLine().split(' ')
    def readLineInts: Array[Int] = readLineStrings.map(_.toInt)
    def readLineLongs: Array[Long] = readLineStrings.map(_.toLong)
  }

  def main(args: Array[String]): Unit = solve(new Scanner(System.in))

  def solve(sc: Scanner): Unit = {
    val S = sc.nextLine()
    val upper = S.take(2).toInt
    val lower = S.drop(2).toInt
    val upperCanBeMM = upper > 0 && upper < 13
    val lowerCanBeMM = lower > 0 && lower < 13

    val result = {
      if (upperCanBeMM) {
        if (lowerCanBeMM) {
          "AMBIGUOUS"
        } else {
          "MMYY"
        }
      } else {
        if (lowerCanBeMM) {
          "YYMM"
        } else {
          "NA"
        }
      }
    }
    println(result)
  }
}


Measured memory_bytes: 27320
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1e9;
#define MOD 1e9+7;
#define INF64 1e18;


using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 cnt = 0;
	SINT32 mi = INF;
	SINT64 ANS = 0;

	cin >> N;

	vector<SINT32> DATA(N);
	
	rep(i,0,N) {
		cin >> DATA[i];
		if (DATA[i] < 0) {
			cnt++;
			DATA[i] = DATA[i]*(-1);
		}
		mi = MIN(mi,DATA[i]);
	}

	rep(i,0,N) {
		ANS = ANS + DATA[i];
	}

	if ((cnt % 2) != 0) {
		ANS = ANS - (mi*2);
	}

	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));　//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n, 0);
    vector<int> b(n, 0);

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

    vector<int> c(n, 0);
    for(int i = 0; i < n; i++){
        c[i] = a[i] - b[i];
    }

    sort(c.begin(), c.end(), greater<int>());
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(c[i] >= 0){
            ans += c[i];
        }
        else {
            break;
        }
    }
    cout << ans << endl;

    //cout << a[n-1] + a[n-2] - b[0] - b[1] << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func resolve(str string) bool {

	var keyword = []string{"k", "e", "y", "e", "n", "c", "e"}
	typen := make(map[int]map[int]string)

	for i := 0; i < len(keyword); i++ {
		typen[i] = make(map[int]string)
		for j := 0; j <= i; j++ {
			typen[i][0] += keyword[j]
		}
		for k := i + 1; k <= len(keyword)-1; k++ {
			typen[i][1] += keyword[k]
		}
		if i == 6 {
			typen[i][1] = " "
		}
	}

	ans := false
	if str[:7] == "keyence" || str[len(str)-7:] == "keyence" {
		return true
	}
	for i := 0; i < 7; i++ {
		if str[:i+1] == typen[i][0] && str[len(str)-1-(7-i)+2:] == typen[i][1] {
			ans = true
		}

	}
	return ans
}
func main() {
	var str string
	fmt.Scanf("%s", &str)
	if resolve(str) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,k,a[200010],s[200010];
map<int,int> m;
long long ans=0;
int main() {
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		s[i]=(s[i-1]+a[i])%k;
	}
	m[0]++;
	for(int i=1;i<=n;i++) {
		if(i-k>=0) m[((s[i-k]-(i-k))%k+k)%k]--; //最长长度为k 
		ans+=(long long)m[((s[i]-i)%k+k)%k]++;
	}
	cout<<ans;
	return 0; 
}

Measured memory_bytes: 11136
#include <iostream>

using namespace std;

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

    for(int i = 1; i <= 50000; ++i){
        double X = i;
        if((int)(X*1.08) == N){
            cout << (int)X << endl;
            return 0;
        }
    }
    cout << ":(" << endl;

    return 0;
}

Measured memory_bytes: 256
while 1:
    n = int(input())
    if n == 0:
        break
    L = []
    for i in range(n):
        L += [list(map(int,input().split()))+[0]]
    L += [[0]*(n+1)]
    for r in range(n):
        for c in range(n):
            L[r][n] += L[r][c]
            L[n][c] += L[r][c]
            L[n][n] += L[r][c]
    for f in range(n+1):
        for h in range(n+1):
            L[f][h] = str(L[f][h]).rjust(5)
        print (''.join(L[f]))



Measured memory_bytes: 5600
#include<cstdio>
using namespace std;
long long a,b,x;
int main()
{
  scanf("%lld%lld%lld",&a,&b,&x);
  a=a%x?a/x+1:a/x,b=b/x;
  printf("%lld",b-a+1);
  return 0;
}

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

int main() {
  int w,h,n;cin>>w>>h>>n;
  int xl=0,xu=w,yl=0,yu=h;
  int x,y,a;
  rep(i,n) {
    cin>>x>>y>>a;
    if (a==1) xl = max(xl, x);
    else if (a==2) xu = min(xu, x);
    else if (a==3) yl = max(yl, y);
    else if (a==4) yu = min(yu, y);
  }
  int s = max(0, xu-xl) * max(0, yu-yl);
  cout << s;
  
}


Measured memory_bytes: 256
import sys
INF = float("inf")
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from functools import reduce
from operator import xor
from itertools import product
def resolve():
    n = int(input())
    A = list(map(int, input().split())) + [0]
    a = A[0]
    s = sum(A[:2])
    u = reduce(xor, A[2:])

    if s < u or (s + u) & 1:
        print("-1")
        return

    v = (s - u) // 2
    # find maximum x s.t. 0 <= x <= a and there exists y s.t. x ^ y = u and x & y = v
    dp = [0, -INF]
    for d in range(60, -1, -1):
        ndp = [-INF, -INF]
        ad = a >> d & 1
        ud = u >> d & 1
        vd = v >> d & 1
        for lt, xd, yd in product(range(2), repeat = 3):
            if (not lt) and ad < xd:
                continue
            if xd ^ yd != ud:
                continue
            if xd & yd != vd:
                continue
            nlt = max(lt, ad > xd)
            ndp[nlt] = max(ndp[nlt], dp[lt] + (xd << d))
        dp = ndp

    pile = max(dp)
    if pile <= 0:
        print(-1)
    else:
        print(a - pile)
resolve()

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

int main()
{
	int n;
  	cin >> n;
  	int a[n],b[n];
  	for(int i=0;i<n;i++){
      cin >> a[i];
      b[a[i]-1] = i+1;}
  	for(int i=0;i<n;i++)
      cout << b[i] << " ";
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    int N;
    cin >> N;
    int a, b, c, d;
    a = N/1000;
    N %= 1000;
    b = N/100;
    N %= 100;
    c = N/10;
    N %= 10;
    d = N;
    if((a == b && b == c) || b == c && c == d) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let mut x: usize = scan(tokens);
    let mut ans: usize = 0;
    ans += x / 500 * 1000;
    x %= 500;
    ans += x / 5 * 5;
    println!("{}", ans);
}


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

using namespace std;

/*long long abs(long long x)	{
  return (x <= 0 ? -x : x);
}*/

int main()	{
  int n, m;
  cin >> n >> m;
  long long sx[n] = {0}, sy[n] = {0}, cx[m] = {0}, cy[m] = {0};
  for (int i = 0; i < n; i++)	
    cin >> sx[i] >> sy[i];
  for (int i = 0; i < m; i++)
    cin >> cx[i] >> cy[i];
  long long checkpoint[n] = {0};
  for (int i = 0; i < n; i++)	{
    for (int j = 0; j < m; j++)	{
      if (abs(sx[i] - cx[checkpoint[i]]) + abs(sy[i] - cy[checkpoint[i]]) > abs(sx[i] - cx[j]) + abs(sy[i] - cy[j]))	{
      	checkpoint[i] = j;
      }
    }
    cout << checkpoint[i] + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3640
inpt = input()
x = int(inpt.split()[0])
n = int(inpt.split()[1])
all = set(range(-1, 102))
ipt = set()
inpt = input().split()
for i in inpt:
    ipt.add(int(i))

sub = all - ipt
if len(sub) > 0:
    sub = list(sub)
    sub.sort()
now = int(100)
for i in sub:
    if (abs(x-i) < now):
        now = min(abs(x-i), now)
        ans = i


print(ans)


Measured memory_bytes: 9208
import java.util.Arrays;
import java.util.Scanner;

import org.omg.PortableServer.ID_ASSIGNMENT_POLICY_ID;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		int[] array = splitInt(sc.nextLine(), " ");
		int[] array2 = splitInt(sc.nextLine(), " ");
		int sum =0;
		for(int i=0;i<n;i++) {
			if(array[i]>array2[i]) {
				sum += array[i]-array2[i];
			}
		}
		System.out.println(sum);
	}
	public static int[] splitInt(String str, String split) {
		String[] array = str.split(split);
		int[] array2 = new int[array.length];
	
		for(int i=0; i<array.length; i++) {
				array2[i] = Integer.parseInt(array[i]);
		}
		return array2;
	}
}



Measured memory_bytes: 24916
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vll A(N);
    rep(i, N) cin >> A[i];
    ll ans = 0;
    rep(i, N) ans += A[i];

    map<ll, ll> ele2num;
    rep(i, N) ele2num[A[i]]++;
    int Q;
    cin >> Q;
    rep(q, Q) {
        ll B, C;
        cin >> B >> C;
        ll num = ele2num[B];
        ans -= num * B;
        ele2num[B] = 0;
        ele2num[C] += num;
        ans += num * C;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 10000
N,X = map (int,input().split())

a = [int(input()) for i in range(N)]
mina = min(a)
asorted = sorted(a)
sum = 0
for i in asorted:
    if X - i <=0:
        break
    else:
        X = X- i
        sum+=1
while X >=mina:
    X = X-mina
    sum+=1

print(sum)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    string s;
    cin>>s;
    ll n=s.size();
    bool ok=true;
    ll cnt=0;
    if(s[0]!='A') ok=false;
    rep2(i,2,n-1){
        if(s[i]=='C') cnt++;
    }
    if(cnt!=1) ok=false;
    if(s[1]-'a'>=0&&s[1]-'a'<=25){}
    else ok=false;
    if(s[n-1]-'a'>=0&&s[n-1]-'a'<=25){}
    else ok=false;
    if(ok) cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


Measured memory_bytes: 256