akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define fi first 
#define se second

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

const ll HMOD = (ll)1e9 + 7;
const ll LMOD = 998244353;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;
const long double EPS = 1e-10;


void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}


int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	int vx = c - a, vy = d - b;
	cout << a + vx + -vy << " " << b + vy + vx << " " << a + -vy << " " << b + vx << endl;
	
	return 0;
}



Measured memory_bytes: 256
s = int(input())
maxv = -100000000000000000
minv = 10000000000000000

for i in range(s):
    x = int(input())
    maxv = max(maxv,x-minv)
    minv = min(minv,x)



if x >= 0:
    print(maxv)
else:
    print("-1")



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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main(){

    int n;
    cin >> n;

    for(ll i=1; i<=3500; i++){
        for(ll j=1; j<=3500; j++){
            ll w1=4*i*j-n*i-n*j;
            if(w1<=0) continue;
            ll w2=n*i*j;
            // cout << w1 << ' ' << w2 << endl;
            if(w1==0) continue;
            if(w2%w1==0){
                cout << i << ' ' << j << ' ' << w2/w1 << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string A, B, C, *next;
	char ans;

	cin >> A >> B >> C;
	next = &A;

	while (!next->empty()) {
		ans = (*next)[0];
		next->erase(next->begin());
		if (ans == 'a') next = &A;
		else if (ans == 'b') next = &B;
		else next = &C;
	}

	printf("%c\n", ans - 0x20);

	return 0;
}


Measured memory_bytes: 256
#define watch5(a,b,c,d,e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d << " | "<<#e<<": "<<e<<endl;
#define watch4(a,b,c,d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define watch3(a,b,c) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sharingan cerr << "\n-------------------------------------------\n\n";
#define watch2(a,b) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<< endl;
#define Yup ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(a) cerr <<#a<<": "<<a<<endl;
#define __gcd(a, b) __algo_gcd(a, b)
#define PI 3.14159265358979323846
#define mod 1000000007
#include<set>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<array>
#include<cstdio>
#include<bitset>
#include<vector>
#include<utility>
#include<sstream>
#include<cstring>
#include <climits>
#include <fstream>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include <unordered_map>
using namespace std;

#define endl "\n"
#define int long long

int w, n;
int ans = 0;
int dp[100001];
int wt[101], v[101];

int32_t main(){
    Yup;
    cin >> n >> w;
    for( int i = 0; i < n; i++ ){
        cin >> wt[i] >> v[i];
    }
    for( int i = 0; i <= 100000; i++ ){
        dp[i] = INT_MAX;
    }
    dp[0] = 0;
    for( int i = 0; i < n; i++ ){
        for( int j = 100000-v[i]; j >= 0; j-- ){
            dp[j+v[i]] = min(dp[j+v[i]], dp[j]+wt[i]);
        }
    }
    int ans = 0;
    for( int i = 0; i <= 100000; i++ ){
        if( dp[i] <= w )ans = max(ans, i*1LL);
    }
    cout << ans;
}


Measured memory_bytes: 1152
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;


#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

class Point {
 public:
  double x, y;

  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x+p.x, y+p.y); }
  Point operator - (Point p) { return Point(x-p.x, y-p.y); }
  Point operator * (double a) { return Point(a*x, a*y); }
  Point operator / (double a) { return Point(x/a, y/a); }

  double norm() { return x*x+y*y; }
  double abs() { return sqrt(norm()); }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

typedef Point Vector;
typedef vector <Vector> Polygon;

class Segment {
 public:
  Point p1, p2;

  Segment(Point p1 = Point(), Point p2 = Point()): p1(p1), p2(p2) {}
};

double norm(Vector a) {
  return a.x*a.x+a.y*a.y;
}

double abs(Vector a) {
  return sqrt(norm(a));
}

// ?????????|a||b|cos
double cross(Vector a, Vector b) {
  return a.x*b.y-a.y*b.x;
}
// ?????????|a||b|sin
double dot(Vector a, Vector b) {
  return a.x*b.x+a.y*b.y;
}

// 1:???????¨??????? -1:????¨??????? 2:p2-p0-p1 -2:p0-p1-p2 0:p2???p0-p1???
int ccw(Point p0, Point p1, Point p2) {
  Vector a = p1-p0;
  Vector b = p2-p0;
  if (cross(a, b) > EPS) return 1;
  if (cross(a, b) < -EPS) return -1;
  if (dot(a, b) < -EPS) return 2;
  if (a.norm() < b.norm()) return -2;

  return 0;
}

int main() {
  Vector p0, p1;
  cin >> p0.x >> p0.y >> p1.x >> p1.y;
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    Vector p2;
    cin >> p2.x >> p2.y;
    int ccwret = ccw(p0, p1, p2);
    if (ccwret == 1) {
      cout << "COUNTER_CLOCKWISE" << endl;
    }
    if (ccwret == -1) {
      cout << "CLOCKWISE" << endl;
    }
    if (ccwret == 2) {
      cout << "ONLINE_BACK" << endl;
    }
    if (ccwret == -2) {
      cout << "ONLINE_FRONT" << endl;
    }
    if (ccwret == 0) {
      cout << "ON_SEGMENT" << endl;
    }
  }
}

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

int main(void)
{
    int n,ans=0;

    scanf("%d",&n);

    switch (n%4)
    {
    case 1:
        if(n>=21) ans=1;
        break;

    case 2:
        if(n>=14) ans=1;
        break;

    case 3:
        if(n>=7) ans=1;
        break;

    case 0:
        ans=1;
        break;
    
    default:
        break;
    }

    if(ans==1) printf("Yes");
    else printf("No");

    return 0;
}

Measured memory_bytes: 128
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

fn main() {
    input! {
        mut s:Chars,
    }
    let mut ans = 0i64;
    let mut cb = 0i64;
    for i in 0..s.len() {
        if s[i] == 'B' {
            cb += 1;
        } else {
            ans += cb;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2948
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define INF 1000000000
#define fore(i,a,b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i,a,b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i,a,b) for (int i = (a), _b = (b); i >= (_b); --i)
#define N 3003

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<viii> vviii;

int f[N][N];
string a, b;

template <typename T> void amax(T &a, T b) {
    a = max(a, b);
}

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> a >> b;
    vviii f((int)a.size() + 2, viii((int)b.size() + 2, iii(-INF, ii(0, 0))));
    f[0][0] = iii(0, ii(0, 0));
    fore(i, 0, (int)a.size()) fore(j, 0, (int)b.size()) {
        if (a[i] == b[j]) amax(f[i + 1][j + 1], iii(f[i][j].fi + 1, ii(i, j)));
        amax(f[i][j + 1], iii(f[i][j].fi, ii(i, j)));
        amax(f[i + 1][j], iii(f[i][j].fi, ii(i, j)));
    }
    iii res;
    fort(i, 0, (int)a.size()) fort(j, 0, (int)b.size()) amax(res, iii(f[i][j].fi, ii(i, j)));
    ii cur = res.se;
    string s;
    while (!(cur.fi == 0 || cur.se == 0)) {
        int i = cur.fi;
        int j = cur.se;
        ii prev = f[i][j].se;
        if (prev == ii(i - 1, j - 1)) {
            s += a[i - 1];
        }
        cur = prev;
    }
    reverse(s.begin(), s.end());
    cout << s << '\n';
    return 0;
}


Measured memory_bytes: 105984
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const ll LINF=0x3f3f3f3f3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n,m;
ll S;
const int Maxn=55;
ll C[Maxn],D[Maxn];
vector<pair<int,pair<ll,ll> > >G[Maxn];
ll dp[Maxn][2505];
#define mp make_pair
ll ans[Maxn];
int main(){
	scanf("%d%d%lld",&n,&m,&S);
	if(S>(ll)n*50)S=(ll)n*50;
//	printf("S:%lld\n",S);
	for(int i=1;i<=m;i++){
		int U,V;
		ll A,B;
		scanf("%d%d%lld%lld",&U,&V,&A,&B);
		G[U].push_back(mp(V,mp(A,B)));
		G[V].push_back(mp(U,mp(A,B)));
	}
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&C[i],&D[i]);
	}
	rep(i,Maxn)rep(j,2505)dp[i][j]=LINF;
	dp[1][S]=0;
	priority_queue<pair<ll,pair<int,ll> > >q;
	q.push(mp(0,mp(1,S)));
	while(!q.empty()){
		ll ti=-q.top().first,silver=q.top().second.second;
		int city=q.top().second.first;
		q.pop();
//		printf("ti:%lld city:%d silver:%lld\n",ti,city,silver);
		if(dp[city][silver]<ti)continue;
		rep(i,SZ(G[city])){
			int to=G[city][i].first;
			ll costS=G[city][i].second.first,costT=G[city][i].second.second;
			if(silver>=costS&&dp[to][silver-costS]>dp[city][silver]+costT){
				dp[to][silver-costS]=dp[city][silver]+costT;
				q.push(mp(-dp[to][silver-costS],mp(to,silver-costS)));
			}
		}
		for(int i=1;i<=n*50/C[city]&&silver+i*C[city]<=n*50;i++){
			if(dp[city][silver+i*C[city]]>dp[city][silver]+D[city]*i){
				dp[city][silver+i*C[city]]=dp[city][silver]+D[city]*i;
				q.push(mp(-dp[city][silver+i*C[city]],mp(city,silver+i*C[city])));
			}
		}
	}
	rep(i,Maxn)ans[i]=LINF;
	for(int i=2;i<=n;i++){
		for(int j=0;j<=n*50;j++){
			if(dp[i][j]<ans[i]){
				ans[i]=dp[i][j];
			}
		}
	}
	for(int i=2;i<=n;i++){
		printf("%lld\n",ans[i]);
	}
//	printf("%lld\n",dp[1][2]);
	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    vector<int> a(n),b(n-1);
    for(int i=0;i<n-1;i++) cin>>b[i];
    a[0]=b[0],a[n-1]=b[n-2];
    for(int i=1;i<n-1;i++){
        a[i]=min(b[i],b[i-1]);
    }
    ll ans=0;
    rep(i,n)
        ans+=a[i];
    cout<<ans;
}

Measured memory_bytes: 3620
import java.util.*;
public class Main{
	int n;

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//N人の生徒
		//3<=話し合う人
		Main m = new Main();//インスタンス化
		m.n = sc.nextInt();
		System.out.println(m.maxGroup(m.n));
	}

	int maxGroup(int n){
		int groupnumber = n / 3;
		//int groupremainder = n % 3;
		if(n % 3 == 0){

		return groupnumber;

		}else if(n % 3 < 3){

		return groupnumber;
		
		}
		return 0;
	}
}


Measured memory_bytes: 22740
#include <stdio.h>
#include<string.h>

int main( void ) {
    char S[101];
    int i;
    int flg;

    scanf("%s", S);

    flg = 1;
    for (i=0;i<101;++i){
        if ( S[i] == '\0' ) {
            break;
        }
        if ( i % 2 == 1 ){  // 偶数番目
            if ( S[i] == 'R' ) {
                flg = 0;
                break;
            }
        } else {
            if ( S[i] == 'L' ) {
                flg = 0;
                break;
            }
        }
    }

    if (flg == 1) {
        printf("Yes");
    } else {
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200500;
typedef long long ll;
ll a[maxn];
int gcd(int x,int y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
int main()
{
    ll x,y;
    cin>>x>>y;
    if(abs(x-y)<=1)
        cout << "Brown" <<endl;
    else
        cout << "Alice" <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
#define LL long long
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
inline int read() {
	char c=getchar();int x=0;while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-48,c=getchar();return x;
}
const int maxn=5e5+5;
int q[maxn],dp[maxn],pos[maxn];
int n,D,Q;
inline int ABS(int x) {return x>=0?x:-x;}
int main() {
	n=read();D=read();
	for(re int i=1;i<=n;i++) q[i]=read();
	dp[n+1]=1;
	for(re int i=n;i;--i) {
		if(q[i]>=2*dp[i+1]) {
			dp[i]=dp[i+1];
			if(q[i]>2*dp[i+1]) dp[i]=min(dp[i],q[i]-dp[i+1]);
		}
		else dp[i]=dp[i+1]+q[i];
	} 
	pos[0]=D;
	for(re int i=1;i<=n;i++) 
		pos[i]=min(ABS(pos[i-1]-q[i]),pos[i-1]);
	Q=read();int x;
	while(Q--) {
		x=read();
		if(dp[x+1]<=pos[x-1]) puts("YES");else puts("NO");	
	}
	return 0;
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll n, m, x;
  cin >> n >> m >> x;
  vector<ll> cs(n, 0);
  vector<vector<ll> > as(n, vector<ll>(m, 0));
  rep(i,n) {
    cin >> cs[i];
    rep(j,m) cin >> as[i][j];
  }
  ll inf = ll(1e18);
  ll ans = inf;
  rep(i,1<<n) {
    ll cur_c = 0;
    vector<ll> cur_as(m, 0);
    rep(j,n) if(i&(1<<j)) {
      cur_c += cs[j];
      rep(k,m) cur_as[k] += as[j][k];
    }
    bool ok = true;
    rep(k,m) if(cur_as[k] < x) ok = false;
    if(ok) chmin(ans, cur_c);
  }
  if(ans == inf) cout << -1 << "\n";
  else cout << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3680
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
input=input-0;
var str="";
for(var i=3;i<=input;i++){
if(i%3==0)str+=" "+i;
if(i%3!=0 && (i+"").match(/3/))str+=" "+i;
}
console.log(str);

Measured memory_bytes: 10964
#include<iostream>
#include<ios>
#include<iomanip>
#include<cmath>
#include<vector>

int main(){

    size_t n;
    std::cin >> n;

    std::vector<double> x(n), y(n);

    for(auto&& e : x){
        std::cin >> e;
    }

    for(auto&& e : y){
        std::cin >> e;
    }

    double ans1 = 0.0;
    for(size_t i = 0; i < n; i++){
        ans1 += std::abs(x[i] - y[i]);
    }

    double ans2 = 0.0;
    for(size_t i = 0; i < n; i++){
        ans2 += std::pow(std::abs(x[i] - y[i]), 2.0);
    }
    ans2 = std::sqrt(ans2);

    double ans3 = 0.0;
    for(size_t i = 0; i < n; i++){
        ans3 += std::pow(std::abs(x[i] - y[i]), 3.0);
    }
    ans3 = std::pow(ans3, 1.0 / 3.0);

    double ans4 = 0.0;
    for(size_t i = 0; i < n; i++){
        ans4 = std::max(ans4, std::abs(x[i] - y[i]));
    }

    std::cout << std::fixed << std::setprecision(6) << ans1 << std::endl << ans2 << std::endl << ans3 << std::endl << ans4 << std::endl;

    return 0;
}



Measured memory_bytes: 3436
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    long long X, Y, ans, div=0;

    cin >> X >> Y;

    if(X % Y == 0){
        cout << -1 << endl;
    }

    else{
        ans = X;

        div = ans % Y;
        while(div == 0){
            ans += X;
            div = ans % Y;
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
 
typedef long long ll;
 
 
int main(){
	int n;
	cin >> n;
	
	cout << n * n <<endl;
	
	return 0;
}



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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N; cin >> N;
    //まあ貪欲にやりましょう
    vector<int> nodes[N];
    vector<int> use(N, 0);
    rep(i, N){
        string S; cin >> S;
        rep(j, N){
            if(S[j] == '1'){
                nodes[i].push_back(j);
            }
        }
    }

    int ans = -1;
    rep(i, N){
        //V_0 = {i}とする
        vector<vector<int>> st;
        vector<int> zero(1); zero[0] = i;
        st.push_back(zero);
        vector<int> one;
        rep(j, nodes[i].size()) {one.push_back(nodes[i][j]); use[nodes[i][j]] = 1;}
        st.push_back(one);

        //rep(j, one.size()) cout << one[j] << " "; cout << endl;

        use[i] = 1;
        int cnt = 2;
        bool cont = false;
        rep(j, N){
            if(use[j] == 0){
                cont = true;
                break;
            }
        }

        while(cont){
            //operation
            vector<int> temp;
            rep(j, st[cnt-1].size()){
                rep(k, nodes[st[cnt-1][j]].size()) temp.push_back(nodes[st[cnt-1][j]][k]);
            }

            sort(temp.begin(), temp.end());
            int temp_judge[N] = {};
            vector<int> kakutei;
            rep(j, st[cnt-2].size()) temp_judge[st[cnt-2][j]] = 1;
            rep(j, temp.size()){
                if(j < temp.size()-1 && temp[j] == temp[j+1]) continue;
                if(temp_judge[temp[j]] == 0) kakutei.push_back(temp[j]);
            }
            // temp = temp - st[cnt-2];
            rep(j, kakutei.size()) use[kakutei[j]] = 1;

            //judge cont
            cont = false;
            rep(i, N){
                if(use[i] == 0){
                    cont = true;
                    break;
                }
            }

            st.push_back(kakutei);
            cnt++;
        }
        
        bool ok = true;
        //judge ok
        vector<int> temp;
        //st[cnt-1]の要素から伸びてる辺を全部入れたものはst[cnt-2]に含まれる
        rep(j, st[cnt-1].size()){
            rep(k, nodes[st[cnt-1][j]].size()) temp.push_back(nodes[st[cnt-1][j]][k]);
        }

        int work_judge[N] = {};
        rep(j, st[cnt-2].size()) work_judge[st[cnt-2][j]] = 1;
        rep(j, temp.size()) if(work_judge[temp[j]] == 0) ok = false;

        if(ok){
            if(cnt > ans) ans = cnt;
        }
        rep(i, N) use[i] = 0;
    }
    cout << ans << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 920
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n;
  cin >> n;
  string ans = "";
  while (n > 0) {
    int x = n % 26;
    char c = 'a' + x - 1;
    if (x == 0) {
      n--;
      c = 'z';
    }
    ans += c;
    n /= 26;
  }
  reverse(all(ans));
  cout << ans << endl;
  return 0;
}

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

#define INF 10000000

struct pa {
	int first, second;
	pa(int a, int b) {
		first = a; second = b;
	}
};

bool operator<(pa a, pa b) {
	if(a.first != b.first)
		return a.first > b.first;
	else
		return a.second > b.second;
}

int main() {
	int w, h;

	while(cin >> w >> h, w || h) {
		cin.ignore();
		vector<string> v;
		for(int i = 0; i < h * 2 - 1; i++) {
			string str;
			getline(cin, str);
			str += "   ";
			v.push_back(str);
		}
		/* table */
		int table[32 * 32][32 * 32];
		bool visited[32 * 32];
		for(int i = 0; i < 32 * 32; i++) {
			for(int j = 0; j < 32 * 32; j++) {
				table[i][j] = INF;
			}
			table[i][i] = 0;
			visited[i] = false;
		}
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				if(i > 0)
					table[w * i + j][w * (i - 1) + j] = table[w * (i - 1) + j][w * i + j] = v[i * 2 - 1][j * 2] == '1' ? INF : 1;
				if(i < h - 1)
					table[w * i + j][w * (i + 1) + j] = table[w * (i + 1) + j][w * i + j] = v[i * 2 + 1][j * 2] == '1' ? INF : 1;
				if(j > 0)
					table[w * i + j][w * i + j - 1] = table[w * i + j - 1][w * i + j] = v[i * 2][j * 2 - 1] == '1' ? INF : 1;
				if(j < w - 1)
					table[w * i + j][w * i + j + 1] = table[w * i + j + 1][w * i + j] = v[i * 2][j * 2 + 1] == '1' ? INF : 1;
			}
		}

		priority_queue<pa> q;
		q.push(pa(0, 0));
		bool flag = true;
		while(!q.empty()) {
			pa tmp(0,0);
			tmp = q.top(); q.pop();
			if(visited[tmp.second])
				continue;
			visited[tmp.second] = true;

			if(tmp.second == h * w - 1) {
				if(tmp.first >= INF) {
					break;
				}
				flag = false;
				cout << tmp.first + 1 << endl;
			}
			if(tmp.second / w > 0) q.push(pa(tmp.first + table[tmp.second][tmp.second - w], tmp.second - w));
			if(tmp.second / w < h - 1) q.push(pa(tmp.first + table[tmp.second][tmp.second + w], tmp.second + w));
			if(tmp.second % w > 0) q.push(pa(tmp.first + table[tmp.second][tmp.second - 1], tmp.second - 1));
			if(tmp.second % w < w - 1) q.push(pa(tmp.first + table[tmp.second][tmp.second + 1], tmp.second + 1));
		}

		if(flag) {
			cout << 0 << endl;
		}
	}
}

Measured memory_bytes: 5352
#include<bits/stdc++.h>
using namespace std;
int n,a[105];
double s;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		s+=1.0/a[i];
	}
	printf("%lf",1.0/s);
}

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

int main() {
    int N; cin >> N;
    map<string, int> m;
    for (int i = 0; i < N; i++) {
        string a; cin >> a;
        m[a]++;
    }
    cout << m.size() << endl;
}

Measured memory_bytes: 19180
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
  string s;cin>>s;
  string ans = "";
  bool pre = (1<=stoi(s.substr(0, 2)) && stoi(s.substr(0, 2))<=12);
  bool last = (1<=stoi(s.substr(2, 2)) && stoi(s.substr(2, 2))<=12);
  if(pre && last){
    ans = "AMBIGUOUS";
  }else if(pre){
    ans = "MMYY";
  }else if(last){
    ans = "YYMM";
  }else{
    ans = "NA";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

struct UnionFind {
private:
    vector<int> par,ran;
    int n;
public:
    vector<int> edge,size;
    UnionFind(int x){
      n=x;
      par.resize(n,0);
      ran.resize(n,0);
      edge.resize(n,0);
      size.resize(n,1);
      rep(i,n){
        par[i]=i;
      }
    }
    int find(int x) {
        if (par[x]==x)return x;
        else return par[x]=find(par[x]);
    }
    void unite(int x, int y) {
        x=find(x),y=find(y);
        if (x==y){
            edge[x]++;
            return;
        }
        if (ran[x]<ran[y]) {
            par[x]=y;
            size[y]+=size[x];
            edge[y]+=edge[x]+1;
        }
        else {
            par[y]=x;
            size[x]+=size[y];
            edge[x]+=edge[y]+1;
            if (ran[x]==ran[y])ran[x]++;
        }
    }
    bool same(int x,int y) {
        return find(x)==find(y);
    }
    
};

int n,m,k;
vector<int> G[100010],G_[100010];

void solve(){
    cin >> n >> m >> k;
    UnionFind uf(n);
    rep(i,m){
        int a,b;cin >> a >> b;
        a--;b--;
        uf.unite(a,b);
        G_[a].push_back(b);
        G_[b].push_back(a);
    }
    rep(i,k){
        int c,d;cin >> c >> d;
        c--;d--;
        G[c].push_back(d);
        G[d].push_back(c);
    }
    rep(i,n){
        int ans=uf.size[uf.find(i)]-1;
        //cout << ans << endl;
        ans-=G_[i].size();
        for(int t:G[i]){
            //cout << i << " " << t << endl;
            if(uf.same(t,i)) ans-=1;
        }
        cout << ans << " ";
    }
    cout << "" << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 13432
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,K; cin>>N>>K;
    cout<<1+(N-K+K-2)/(K-1)<<endl;
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		StringTokenizer tokenizer;
		int a = Integer.parseInt(reader.readLine());
		int n = Integer.parseInt(reader.readLine());
		int[] nums = new int[a];
		for (int i = 0; i < a; i++) {
			nums[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			tokenizer = new StringTokenizer(reader.readLine(), ",");
			int x = Integer.parseInt(tokenizer.nextToken()) - 1;
			int y = Integer.parseInt(tokenizer.nextToken()) - 1;
			int tmp = nums[x];
			nums[x] = nums[y];
			nums[y] = tmp;
		}
		for (int i = 0; i < a; i++) {
			builder.append(nums[i]).append('\n');
		}
		System.out.print(builder);

	}

}

Measured memory_bytes: 16872
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

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

int main()
{
	int n;
	cin>>n;
	ll l[100000], r[100000];
	multiset<P> ls, rs;
	for(int i=0; i<n; i++){
		cin>>l[i]>>r[i];
		ls.insert(P(l[i], r[i]));
		rs.insert(P(r[i], l[i]));
	}
	ll x=0, ans=0;
	for(int i=0; i<n; i++){
		if(i%2==0){
			auto itr1=ls.end();
			itr1--;
			ll d1=max((*itr1).first-x, 0ll);
			ans+=d1;
			x+=d1;
			ll l1=(*itr1).first, r1=(*itr1).second;
			ls.erase(itr1);
			auto itr=rs.lower_bound(P(r1, l1));
			rs.erase(itr);
		}else{
			auto itr2=rs.begin();
			ll d2=max(x-(*itr2).first, 0ll);
			ans+=d2;
			x-=d2;
			ll l1=(*itr2).second, r1=(*itr2).first;
			rs.erase(itr2);
			auto itr=ls.lower_bound(P(l1, r1));
			ls.erase(itr);
		}
	}
	ans+=abs(x);
	for(int i=0; i<n; i++){
		ls.insert(P(l[i], r[i]));
		rs.insert(P(r[i], l[i]));
	}
	x=0;
	ll ans2=0;
	for(int i=0; i<n; i++){
		if(i%2==1){
			auto itr1=ls.end();
			itr1--;
			ll d1=max((*itr1).first-x, 0ll);
			ans2+=d1;
			x+=d1;
			ll l1=(*itr1).first, r1=(*itr1).second;
			ls.erase(itr1);
			auto itr=rs.lower_bound(P(r1, l1));
			rs.erase(itr);
		}else{
			auto itr2=rs.begin();
			ll d2=max(x-(*itr2).first, 0ll);
			ans2+=d2;
			x-=d2;
			ll l1=(*itr2).second, r1=(*itr2).first;
			rs.erase(itr2);
			auto itr=ls.lower_bound(P(l1, r1));
			ls.erase(itr);
		}
	}
  	ans2+=abs(x);
	cout<<max(ans, ans2)<<endl;
	return 0;
}

Measured memory_bytes: 14336
# https://atcoder.jp/contests/abc154/tasks/abc154_a

read row ; row=($row) ; S=${row[0]} ; T=${row[1]}
read row ; row=($row) ; a=$((${row[0]})) ; b=$((${row[1]}))
read U
if [ $U = $S ] ; then
  a=$(($a-1))
fi
if [ $U = $T ] ; then
  b=$(($b-1))
fi
echo $a $b


Measured memory_bytes: 376
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();	
	int n , k ;
	cin >> n >> k;
	long double ans = 0;
	for(int i = 1; i <= n; i++){
		if(i >= k){
			setprecision(20);
			ans += 1.0;
			continue;
		}
		long double curr = 0;
		setprecision(20);
		
		
		int cnt = 1;
		while(i*(1ll<<cnt) <= k-1){
			cnt++;
		}

		curr =  ((long double)1/(long double)(1ll<<cnt));

		ans += curr;
	}

	setprecision(20);
	ans = (long double)ans/(long double) n;
	cout << prec(20) << ans;
}

Measured memory_bytes: 3676
#include <stdio.h>
#include <math.h>
int main()
{
    int n,m,a[100005]={0};
    char b[3];
    int c=0,d=0,j;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {
        scanf("%d %s",&j,b);
        if(b[0]=='W'&&a[j]!=-1)
        {
            a[j]++;
        }
        if(b[0]=='A'&&a[j]!=-1)
        {
            c++;
            d+=a[j];
            a[j]=-1;
        }
    }
    printf("%d %d",c,d);
    return 0;
}


Measured memory_bytes: 512
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void ioup() { cin.tie(0); ios::sync_with_stdio(false); }

int n, a, b[100001];

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		b[a]++;
		if (a > 0)
			b[a - 1]++;
		if (a < 100000)
			b[a + 1]++;
	}
	sort(b, b + 100001);

	cout << b[100000] << endl;

	return 0;
}

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

int main() {
  int n,k,ans;
  ans = 0;
  cin >> n >> k;
  vector<int> v(n,0);
  for(int i=0;i<n;i++){
    cin >> v.at(i);
  }
  for(int i=0;i<n;i++){
    if(v.at(i)<k){v.at(i)=0;}
  }
  for(int i=0;i<n;i++){
  if(v.at(i) != 0){ans++;}
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int solve(){
  string s;
  cin >> s;
  int ans = 0,n = s.size();
  rep(i,n){
    if(s[i] != s[n - i - 1])ans++;
  }
  cout << ans / 2 << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

string s;

int main()
{
	ios::sync_with_stdio(false);
	cin >> s;
	bool check = (s == "keyence");
	for (int l = 0; l < (int)s.length(); l++)
		for (int r = l; r < (int)s.length(); r++)
		{
			string t = s.substr(0, l) + s.substr(r + 1);
			check |= (t == "keyence");
		}
	cout << (check ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/stdc++.h>

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define mod 1000000007
#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define FOR(i, x, y) for (int i = x; i <= y; i++)
//#define tr(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

//using namespace __gnu_pbds;

using namespace std;

//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n;

ll v[1004], ans = 1;

bool pr(int x)
{
	FOR (i, 2, x-1)
		if (x%i == 0)
			return 0;
	return 1;
}

int main()
{
	cin >> n;
	
	if (n == 1) {
		cout << "1";
		return 0;
	}
	
	FOR (i, 2, n) {
		int x = i;
		FOR (h, 2, x)
			while (x%h == 0)
				x/=h, v[h]++;
		if (x > 1)
		 	v[x]++;
	}
	
	FOR (i, 2, n)
		v[i]++, ans *= v[i], ans%=mod;
	
	cout << ans;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    E[a - 1].append(b - 1)
    E[b - 1].append(a - 1)

C = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    C[p-1] += x

Q = [(0, -1)]
while Q:
    v, p = Q.pop()
    for x in E[v]:
        if x == p: # 孫と祖で一致していないかのチェック
            continue
        C[x] += C[v] # 親から子へ
        Q.append((x, v))

print(*C)


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

using namespace std;
pair<string,int>p[100005];
map<pair<string,int>,int>mp;
bool cmp(pair<string,int>a,pair<string,int>b){
	if(a.first!=b.first)return a.first<b.first;
	else return a.second>b.second;
}
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>p[i].first>>p[i].second;
		mp[p[i]]=i+1;
	}
	sort(p,p+n,cmp);
	for(int i=0;i<n;i++){
		cout<<mp[p[i]]<<endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    int n , m , c;
    cin>>n>>m>>c ;
    int a[m] ;
    for(int i = 0 ; i < m ; ++i)
        cin>>a[i] ;
    int ans = 0 ;
    for(int i = 0 ; i < n ; ++i)
    {
        int now = 0 ;
        for(int j = 0 ; j < m ; ++j)
        {
            int x ;
            cin>>x ;
            now += x * a[j] ;
        }
        now += c ;
        ans += (now > 0) ;
    }
    return cout<<ans<<"\n" , 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, X, L[100];
    cin >> N >> X;
    REP(i, N) cin >> L[i];
    REP(i, N - 1) L[i + 1] += L[i];
    int ans = 1;
    REP(i, N) {
        if (L[i] > X) break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

// x未満の組合せがK個未満か
bool isOk(const vector<ll> &A, ll x, ll k) {
  ll total = 0;
  for (ll i = 0; i < (ll)A.size(); i++) {
    if (A[i] > 0) {
      ll ok = -1;
      ll ng = A.size();

      while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (A[i] * A[mid] < x) {
          ok = mid;
        } else {
          ng = mid;
        }
      }

      total += ok + 1;
      // total += ng;

    } else {
      // A[i]が負の；場合、okより右側が全部満たす
      ll ok = A.size();
      ll ng = -1;

      while (abs(ng - ok) > 1) {
        ll mid = (ng + ok) / 2;
        if (A[i] * A[mid] < x) {
          ok = mid;
        } else {
          ng = mid;
        }
      }

      total += A.size() - (ok);
      // total += A.size() - ng;
    }

    // 自分自身とのかけざんはなし
    if (A[i] * A[i] < x) {
      total--;
    }
  }

  total /= 2;

  return total < k;
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  ll N, K;
  cin >> N >> K;

  vector<ll> A(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }

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

  const ll INF = (ll)(1e18) + 1;
  ll ok = -INF;
  ll ng = INF;

  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    // mid「未満」の組合せがK個「未満」か
    // ok => okがK番目
    if (isOk(A, mid, K)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  cout << ok << endl;

  return 0;
}


Measured memory_bytes: 1792
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc165
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_abc165A();
            Console.Out.Flush();
        }

        public static void solve_abc165B()
        {
        }

        public static void solve_abc165A()
        {
            int k = Convert.ToInt32(Console.ReadLine());
            int[] ab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            bool ok = false;
            for (int i = ab[0]; i <= ab[1]; i++)
            {
                if (i % k == 0)
                {
                    ok = true;
                    break;
                }
            }
            Console.WriteLine(ok ? "OK" : "NG");
        }
    }
}


Measured memory_bytes: 28516
// C program for insertion sort
#include <stdio.h>
#include <math.h>
 
/* Function to sort an array using insertion sort*/
void insertionSort(int arr[], int n)
{
   int i, key, j;
   for (i = 1; i < n; i++)
   {
       key = arr[i];
       j = i-1;
 
       /* Move elements of arr[0..i-1], that are
          greater than key, to one position ahead
          of their current position */
       while (j >= 0 && arr[j] > key)
       {
           arr[j+1] = arr[j];
           j = j-1;
       }
       arr[j+1] = key;
   }
}
 

 
 
/* Driver program to test insertion sort */
int main()
{
   int sum=0,i,n;
   scanf("%d",&n);
   int arr[n*2];
   for(i=0;i<n*2;i++)
   {
   	scanf("%d",&arr[i]);
   }
    insertionSort(arr, n*2);
    for(i=0;i<n;i++)
    {
    	sum=sum+arr[2*i];
	}
	printf("%d",sum);
    return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
	if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T & ref, const T value) {
	if (ref < value) ref = value;
}

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    int n = min(s.size(), t.size());
    rep(i, n) {
        if (s[i] > t[i]) {
            cout << "No" << endl;
            return 0;
        }
        if (s[i] < t[i]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (s.size() < t.size()) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3600
def main():
    h, w = map(int, input().split())
    mp = [input() for _ in range(h)]
    
    i_cnt = [[0] * w for _ in range(h)]
    o_cnt = [[0] * w for _ in range(h)]
    
    for x in range(w):
        if mp[h - 1][x] == "I":
            i_cnt[h - 1][x] = 1
    
    for y in range(h):
        if mp[y][w - 1] == "O":
            o_cnt[y][w - 1] = 1
    
    ans = 0
    for y in range(h - 2, -1, -1):
        for x in range(w - 2, -1, -1):
            if mp[y][x] == "I":
                i_cnt[y][x] = i_cnt[y + 1][x] + 1
                o_cnt[y][x] = o_cnt[y][x + 1]
            elif mp[y][x] == "O":
                i_cnt[y][x] = i_cnt[y + 1][x]
                o_cnt[y][x] = o_cnt[y][x + 1] + 1
            else:
                i_cnt[y][x] = i_cnt[y + 1][x]
                o_cnt[y][x] = o_cnt[y][x + 1]
                ans += i_cnt[y][x] * o_cnt[y][x]
    
    print(ans)

main()




Measured memory_bytes: 365444
#include<iostream>

int main(){
    int a, b;
    std::cin >> a >> b;
    if(a<b){
        std::cout << "a < b" << std::endl;
    }else if(a==b){
        std::cout << "a == b" << std::endl;
    }else
    std::cout << "a > b" << std:: endl;
    return 0;
}


Measured memory_bytes: 3104