akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void)
{
	int H;
	int W;
	int i;
	int j;
	
	while(1){
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0){
			break;
		}
		
		for(i = 0;i < H;i++){
			for(j = 0;j < W;j++){
				if(i == 0 || i + 1 == H){
					printf("#");
				}
				else if(j == 0 || j + 1 == W){
					printf("#");
				}
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return (0);
}

Measured memory_bytes: 572
n = int(input())

l = list(map(int,input().split()))
l.sort()
t = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i] == l[j] or l[j] == l[k] or l[i] == l[k]:
                continue
            else:
                if l[i] + l[j] > l[k]:
                    t += 1
print(t)

Measured memory_bytes: 9188
#include <iostream>
using namespace std;
int main(){
  int n, b, f, r, a, v[4][3][10];
  bool x[4][3][10] = {};
  cin >> n;
  for(int i=0; i<n; i++){
   cin >> b >> f >> r >> a;
   if(x[b-1][f-1][r-1])
    v[b-1][f-1][r-1] += a;
   else{
   x[b-1][f-1][r-1] = true;
   v[b-1][f-1][r-1] = a;
   }
  }
  for(int s=0; s<4; s++){
   for(int j=0; j<3; j++){
    for(int t=0; t<10; t++){
      if(x[s][j][t])
       cout << ' ' << v[s][j][t];
      else
       cout << ' ' << 0;
    }
    cout << endl;
  }
  if(s == 3)
   break;
  cout << "####################" << endl;
 }
  return 0;
}

Measured memory_bytes: 3112
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n;
  cin >> n;
  double t,a;
  cin >> t >> a;
  double dif = 1e9;
  int ans = 0;
  for(int i=0;i<n;i++){
    double x;
    cin >> x;
    double temp = t - x*0.006;
    double cur = abs(temp-a);
    if(cur<dif){
      ans = i+1;
      dif = cur;
    }
  }
  cout << ans << endl;

return 0;
}
///....


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}



signed main() {
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n - i; j++) {
			if (10000 * i + 5000 * j + 1000 * (n - i - j) == y) {
				cout << i << " " << j << " " << n - i - j << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	getchar(); getchar();
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl

typedef long long LL;
typedef long double LD;

int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  s[k-1]=s[k-1]-'A'+'a';
  cout << s << endl;
  return 0;
}


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

int main(void){
    int N;
    cin >> N;
    
    vector<int> d(N);
    for(int i = 0 ; i < N ; i++){
        cin >> d.at(i);
    }
    
    int sum = 0;
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < N ; j++){
            if(i != j){
                sum += d.at(i) * d.at(j);
            }
        }
    }
    cout << sum/2 << endl;
    return 0;
}

Measured memory_bytes: 3616
// AtCoder ABC108: B - Ruined Square
// 2019.9.11 bal4u

#include <stdio.h>

typedef struct { int x, y; } PP;
PP vadd(PP p1, PP p2) { PP r; r.x = p1.x + p2.x, r.y = p1.y + p2.y; return r; }
PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
PP vmul(PP p1, PP p2) { PP r;
	r.x = p1.x * p2.x - p1.y * p2.y, r.y = p1.x * p2.y + p1.y * p2.x; return r; }
PP one = {0,1};

int main()
{
	int x1, y1, x2, y2;
	PP p1, p2, p12, t, p3, p4;
	
	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
	p1.x = x1, p1.y = y1, p2.x = x2, p2.y = y2;
	p12 = vsub(p2, p1), t = vmul(p12, one);
	p3 = vadd(t, p2), t = vmul(t, one);
	p4 = vadd(t, p3);
	printf("%d %d %d %d\n", p3.x, p3.y, p4.x, p4.y);
	return 0;
}


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

int main(){
    int N;
    int A[20];
    int B[20];
    int C[20];
    int sum;
    int count;
    cin >> N;
    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-1;i++) cin >> C[i];

    for(int i=0;i<N;i++){
        sum+=B[A[i]-1];
        if(i!=0){
            if(A[i]==A[i-1]+1) sum+=C[A[i-1]-1];
        }
    }
    cout << sum;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
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; }

// 0-1bfs問題
const int MAX_N = 2000;

int h, w;
typedef pair<int, int> P;
vector<vector<char> > maze(MAX_N, vector<char>(MAX_N));
int sx, sy, gx, gy;

vector<vector<ll> > d(MAX_N, vector<ll>(MAX_N));

vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};

ll bfs(){
    deque<P> que;
    // すべての点をINFで初期化
    rep(x, w)
        rep(y, h) d.at(x).at(y) = INF;
    // スタート地点をqueに入れ、その点距離を0とする
    que.push_front(P(sx,sy));
    d.at(sx).at(sy) = 0;

    // queが空になるまでループ
    while(que.size()){
        //　キューの先頭を取り出す
        P p = que.front();
        que.pop_front();
        if(p.first == gx && p.second == gy) break;
        //　４方向をループ
        rep(i, 4){
            int nx = p.first + dx.at(i), ny = p.second + dy.at(i);
            //　移動が可能かどうかの判定とすでに訪れたことがあるかどうかの判定
            if(0 <= nx && nx < w && 0 <= ny && ny < h && maze.at(nx).at(ny) == '.' && (d.at(nx).at(ny) == INF ||  d.at(nx).at(ny) > d.at(p.first).at(p.second))){
                //　移動可能ならばキューに追加、点の距離を+0して確定させる
                que.push_front(P(nx,ny));
                d.at(nx).at(ny) = d.at(p.first).at(p.second);
            }
        }
        for(int cy = -2; cy <= 2; cy++){
            for(int cx = -2; cx <= 2; cx++){
                int nx = cx + p.first;
                int ny = cy + p.second;
                if(0 <= nx && nx < w && 0 <= ny && ny < h && d.at(nx).at(ny) == INF && maze.at(nx).at(ny) == '.') {
                    que.push_back(P(nx, ny));
                    d.at(nx).at(ny) = d.at(p.first).at(p.second) + 1;
                }
            }
        }
    }
    return d.at(gx).at(gy);
}

int main(){
    cin >> h >> w >> sy >>sx >> gy >> gx;
    sx--; sy--; gx--; gy--;
    vector<vector<char> > s(w, vector<char>(h));
    rep(y, h){
        rep(x, w){
            cin >> maze.at(x).at(y);
        }
    }
    ll a = bfs();
    if(a == INF) cout << -1 << endl;
    else cout << a << endl;

}

Measured memory_bytes: 39896
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a == 1) {
    a = 14;
  }
  if (b == 1) {
    b = 14;
  }

  if (a > b) {
    cout << "Alice" << endl;
  } else if (a < b) {
    cout << "Bob" << endl;
  } else {
    cout << "Draw" << endl;
  }
}

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

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

        int[] ints = Arrays.stream(inputText.split("/")).mapToInt(Integer::parseInt).toArray();
        int month = ints[1];
        
        if(month <= 4){
            System.out.println("Heisei");
        }else {
            System.out.println("TBD");
        }
    }
}

Measured memory_bytes: 28244
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,k;
    int r,s,p;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    //vector<vector<ll>> dp(100010,vector<ll>(3,0));
    //vector<ll> tt;
    ll ans = 0;
    for(int i=0 ; i<k ; i++){
        //cout<<"new!!!"<<endl;
        //tt.clear();  dp.clear();
        //vector<vector<ll>> dp(t.size(),vector<ll>(3,0));
        vector<ll> tt;
        for(int j=i ; j<t.size() ; j+=k){
            tt.push_back((int)t[j]);
        }
        //rep(o,tt.size())cout<<tt[o];
        //cout<<endl;
        //cout<<"dpstart"<<endl;
        vector<vector<ll>> dp(tt.size(),vector<ll>(3,0));
        for(int w=0 ; w<tt.size() ; w++){
            if(w==0){ //最初
                if(tt[0]=='r'){
                    dp[0][2]=p, dp[0][1]=0, dp[0][0]=0;
                }
                if(tt[0]=='s'){
                    dp[0][2]=0, dp[0][1]=0, dp[0][0]=r;
                }
                if(tt[0]=='p'){
                    dp[0][2]=0, dp[0][1]=s, dp[0][0]=0;
                }
                continue;
            }
            for(int j=0;j<3;j++){
                //cout<<i<<" "<<j<<" ";
                //j =  0 : r, j = 1 : s, j = 2 : p
               if(j==0){
                    int pre=max(dp[w-1][1],dp[w-1][2]);
                    if(tt[w]==(int)'s') {
                        //cout<<"win!!"<<endl;
                        dp[w][j]=pre+r;
                    }
                    else dp[w][j]=pre;
                }
                if(j==1){
                    int pre=max(dp[w-1][0],dp[w-1][2]);
                    if(tt[w]==(int)'p') {
                        //cout<<"win!!"<<endl;
                        dp[w][j]=pre+s;
                    }
                    else dp[w][j]=pre;
                }
                if(j==2){
                    int pre=max(dp[w-1][0],dp[w-1][1]);
                    if(tt[w]==(int)'r') {
                        //cout<<"win"<<endl;
                        dp[w][j]=pre+p;
                    }
                    else dp[w][j]=pre;
                }
                //cout<<dp[w][j]<<endl;
            }
        }
        /*
        rep(ff,tt.size()){
            rep(fff,3){
                cout<<dp[ff][fff]<<" ";
            }
            cout<<endl;
        }
        */
        ans+=max({dp[tt.size()-1][0],dp[tt.size()-1][1],dp[tt.size()-1][2]});
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 6516
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000

int m[100][100],n;

int prim(){
  int u,minv;
  int d[100],p[100],c[100];
  for(int i=0;i<n;i++){
    d[i]=INF;
    p[i]=-1;
    c[i]=0;
  }
  d[0]=0;
  while(1){
    minv=INF;
    u=-1;
    for(int i=0;i<n;i++){
      if(minv>d[i] && c[i]!=2){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1) break;
    c[u]=2;
    for(int i=0;i<n;i++){
      if(c[i]!=2 && m[u][i]!=INF){
	if(d[i]>m[u][i]){
	  d[i]=m[u][i];
	  p[i]=u;
	  c[i]=1;
	}
      }
    }
  }
  int sum=0;
  for(int i=0;i<n;i++){
    if(p[i]!=-1) sum+=m[i][p[i]];
  }
  return sum;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int e;
      cin>>e;
      m[i][j]=(e==-1)?INF:e;
    }
  }
  cout<<prim()<<endl;
  return 0;
}



Measured memory_bytes: 3136
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main(){
	int n;
	scanf("%d",&n);
	
	int a[100001]={0};
	int daburi=0;
	int i;
	int temp;
	
	for(i=0;i<n;i++){
		scanf("%d",&temp);
		if(a[temp]==0){
			a[temp]=1;
		}else{
			daburi++;
		}
	}
	
	//printf("daburi:%d\n",daburi);
	//printf("move:%d\n",daburi/2+daburi%2);
	int move = daburi/2+daburi%2;
	printf("%d\n",n-move*2);
	
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e14;
const int ZERO = 0;
const int MOD = 1000000007;
const double PI = 3.1415926535897;

struct edge{
	int to,cost;
};
typedef pair<int,int> P; //firstは最短距離、secondは頂点の番号

int V; //頂点数
vector<edge> G[200010];
int d[200010]; //頂点sからの最短距離

void dijkstra(int s) {
	//greater<P>を指定することでfirstが小さい順に取り出せる
	priority_queue<P,vector<P>,greater<P>> que;
	fill(d,d + V,INF);
	d[s] = 0;
	que.push(P(0,s));

	while(!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) {
			continue;
		}
		for(int i = 0;i < G[v].size();i++) {
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}

signed main() {
    cin >> V;
    int M;
    cin >> M;
    for(int i = 0;i < M;i++) {
        int A,B;
        cin >> A >> B;
        int ONE = 1;
        G[A - 1].push_back(edge{B - 1,ONE});
    }
    dijkstra(0);
    if(d[V - 1] == 2) {
        cout << "POSSIBLE" << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 14192
import java.io.*;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=1;//sc.nextInt();
		while(t-->0) {
			String n=sc.next();
			long val=0;
			for(int i=0;i<n.length();i++) {
				val+=(n.charAt(i)-'0');
			}
			if(val%9==0) System.out.println("Yes");
			else System.out.println("No");
		}

	}

}
/*class Reader{
	BufferedReader reader;
	Reader(){
		reader=new BufferedReader(new InputStreamReader(System.in));
	}
	int nextInt() throws IOException{
		String in=reader.readLine().trim();
		return Integer.parseInt(in);
	}
	long nextLong() throws IOException{
		String in=reader.readLine().trim();
		return Long.parseLong(in);
	}
	String next() throws IOException{
		return reader.readLine().trim();
	}
	String[] stringArray() throws IOException{
		return reader.readLine().trim().split("\\s+");
	}
	int[] intArray() throws IOException{
		String[] inp=this.stringArray();
		int[] arr=new int[inp.length];
		int i=0;
		for(String s:inp) {
			arr[i++]=Integer.parseInt(s);
		}
		return arr;
	}
}*/




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

int main() {
    int N;
    cin >> N;
    vector<long long> S(N);
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        sum += b;
        S[i] = a + b;
    }
    sort(S.begin(), S.end(), greater<long long>());

    long long res = -sum;
    for (int i = 0; i < N; i += 2) {
        res += S[i];
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
ll MOD = 1000000007ll;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define Se second
#define Fi first
#define rep(i, n) for(int i=0;i<n;i++)
#define pb(x) push_back(x)

const int MX = 1;
const int MM = 1000000007;

vector<pii> L;
int main()
{
	ll A, B, C, D;
	scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
	for(int i = 1; i <= D+5; i++){
		if(1 <= i && i < A) L.push_back(pii(i, A));
		if(1 <= i && i < B) L.push_back(pii(i, B));
		if(1 <= i && i < C) L.push_back(pii(i, C));
		
		if(1 <= i && i < A) L.push_back(pii(A-i, A));
		if(1 <= i && i < B) L.push_back(pii(B-i, B));
		if(1 <= i && i < C) L.push_back(pii(C-i, C));
	}
	int sz = L.size();
	for(int i = 0; i < sz; i++){
		pii c = L[i];
		ll v = c.first * A / c.second;
		if(1 <= v && v < A ) L.push_back(pii(v, A));
		if(1 <= v+1 && v+1 < A ) L.push_back(pii(v+1, A));

		v = c.first * B / c.second;
		if(1 <= v && v < B ) L.push_back(pii(v, B));
		if(1 <= v+1 && v+1 < B ) L.push_back(pii(v+1, B));

		v = c.first * C / c.second;
		if(1 <= v && v < C ) L.push_back(pii(v, C));
		if(1 <= v+1 && v+1 < C ) L.push_back(pii(v+1, C));
	}

	sort(L.begin(), L.end(), [](pii l, pii r){
		return (ll)l.first * r.second < (ll)r.first * l.second;
	});

	L.resize(unique(L.begin(), L.end()) - L.begin());

	ll x = 0, y = 0, z = 0;
	ll ans = (ll)min(D+1, A) * min(D+1, B) * min(D+1, C) % MM;
	for(pii c : L){
		ll dx = min(A-1, x+D) - max(0ll, x-D) + 1;
		ll dy = min(B-1, y+D) - max(0ll, y-D) + 1;
		ll dz = min(C-1, z+D) - max(0ll, z-D) + 1;
		if(c.second == A){
			ans += dy*dz%MM * max(0ll, min((ll)c.first, A-D-1) - x);
			x = c.first;
		}
		if(c.second == B){
			ans += dx*dz%MM * max(0ll, min((ll)c.first, B-D-1) - y);
			y = c.first;
		}
		if(c.second == C){
			ans += dx*dy%MM * max(0ll, min((ll)c.first, C-D-1) - z);
			z = c.first;
		}
		ans %= MM;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 35172
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  long long S;
  std::cin >> S;

  // Main
  long long x1 = std::ceil(std::sqrt(S));
  long long y2 = std::ceil(std::sqrt(S));


  long long rem = x1 * y2 - S;

  // std::cout << x1 << " " << y2 << std::endl;
  // std::cout << x1 * y2 << std::endl;
  // std::cout << rem << std::endl;

  int y1 = 1;
  int x2 = rem;

  std::cout << 0 << " " << 0 << " " << x1 << " " << y1 << " " << x2 << " " << y2
            << std::endl;

  return 0;
}


Measured memory_bytes: 256
import numpy as np
from collections import deque
h,w = map(int,input().split())
s =["#"*(w+2)] + ["#" + str(input()) + "#" for i in range(h)] + ["#"*(w+2)]
s = np.array(s)
opt = [(1,0),(0,1),(-1,0),(0,-1)]
ans = 0

for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j] == ".":
            temp = [[0]*(w+2) for i in range(h+2)]
            temp[i][j] = 1
            dq = deque([(i,j)])
            
            while dq:
                x,y = dq.popleft()
                for k in opt:
                    x1,y1 = x+k[0],y+k[1]
                    if s[x1][y1] == "." and temp[x1][y1] == 0:
                        temp[x1][y1] = temp[x][y] + 1
                        dq.append((x1,y1))
            ans = max(ans,np.max(temp))
print(ans-1)

Measured memory_bytes: 12440
import itertools

n, m = map(int, input().split())
am = [[False]*n for _ in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    am[a-1][b-1] = True
    am[b-1][a-1] = True

ans = 0
for p in itertools.permutations(list(range(n)), n):
    if p[0] != 0:
        continue

    isok = True
    for i in range(len(p)-1):
        if not am[p[i]][p[i+1]]:
            isok = False
            break

    if isok:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    string S;
    io.read(S);
    string ans = "No";
    if(S[0] != S[1] && S[1] != S[2] && S[2] != S[0]) {
        ans = "Yes";
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <functional>
#include <string>
#include <vector>
#include <set>
using namespace std;

#define int long long
#define rep(n, i) for (int i = 0; i < n; i++)
#define rep2(m, n, i) for (int i = m; i < n; i++)
#define rep_r(n, i) for (int i = n - 1; i >= 0; i--)

const int INF = 1LL << 60;
const int MOD = 1e9 + 7;

signed main() {
    int n, m;
    cin >> n >> m;
    int a[m];
    bool danger[n + 1];
    fill(danger, danger + n + 1, false);
    rep(m, i) {
        cin >> a[i];
        danger[a[i]] = true;
    }
    int dp[n + 1];
    fill(dp, dp + n + 1, 0);
    dp[0] = 1;
    if (!danger[1]) {
        dp[1] = 1;
    }
    rep2(2, n + 1, i) {
        if (danger[i]) continue;
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
    }
    cout << dp[n] << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

ll n,k;

int main(){
	cin >> n >> k;
	if(k > n/2 + n%2)cout << "NO" << endl;
	else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
#define LIM 100000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;

class AOJ0137{
private:
  int val;
public:

  AOJ0137(int val):val(val){}

  string itos(int v){
    stringstream ss;
    ss << v;
    return ss.str();
  }

  void run(){
    rep(i,10){
      val *= val;
      string pre = itos(val);
      if(pre.size() < 8){	
	string p = string(8-pre.size(),'0')+pre;
	pre.clear(),pre = p;
      }
      string next = pre.substr(2,4);
      val = (atoi)(next.c_str());
      cout << val << endl;
    }
  }

};

int main(){
  int n;
  cin >> n;
  rep(i,n){
    
    int val;
    cin >> val;
    AOJ0137 ans(val);
    cout << "Case " << i+1 << ":" << endl;
    ans.run();
  }
return 0;
}

Measured memory_bytes: 1236
fn main() {
    let mut buf=String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut buf=buf.split_whitespace();

    let a:i32;
    let b:i32;
    
    a=buf.next().unwrap().parse().unwrap();
    b=buf.next().unwrap().parse().unwrap();
    let mut ans=0;
    let mut cnt = 1;
    while cnt < b {
        cnt-=1;
        cnt+=a;
        ans+=1;
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = sc.next();
        if(s.length()%2==1){
            System.out.println("No");
            return;
        }
        for(int i = 0;i<(s.length()/2);i++){
            if(s.charAt(i)!=s.charAt(i+s.length()/2)){
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
        sc.close();
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

vector<vector<bool>> color;

void coloring(ll sx, ll sy, string s){
    rep(i, s.size()-1){
        if(s[i] == 'U') sy++;
        else if(s[i] == 'D') sy--;
        else if(s[i] == 'R') sx++;
        else if(s[i] == 'L') sx--;
        color[sx][sy] = true;
    }
}

string bfs(ll sx, ll sy, ll tx, ll ty){
    // マスターをコピー
    vector<vector<bool>> tcolor(color.size(), vector<bool>(color[0].size(), false));
    rep(i, color.size()){ rep(j, color[i].size()) tcolor[i][j] = color[i][j]; }

    // キュー
    queue<pair<pair<ll, ll>, string>> que;
    que.push(make_pair(make_pair(sx, sy), ""));
    tcolor[sx][sy] = true;

    while(!que.empty()){
        auto front = que.front(); que.pop();
        ll x = front.first.first;   
        ll y = front.first.second;   
        string s = front.second;
        // 目的位置にたどり着いた場合
        if(x == tx && y == ty) return s;
        
        // それ以外の場合は移動できそうな場所をキューに積む（上下左右）
        if(y<tcolor[0].size()-1 && tcolor[x][y+1] == false) que.push(make_pair(make_pair(x, y+1), s+"U"));
        if(y>0 && tcolor[x][y-1] == false) que.push(make_pair(make_pair(x, y-1), s+"D"));
        if(x>0 && tcolor[x-1][y] == false) que.push(make_pair(make_pair(x-1, y), s+"L"));
        if(x<tcolor.size()-1 && tcolor[x+1][y] == false) que.push(make_pair(make_pair(x+1, y), s+"R"));
    }
}

int main(){
    Init();
    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string ans = "";

    // 差分
    ll dx = tx-sx;
    ll dy = ty-sy;

    // 内側時計回りで[s -> t -> s]を移動
    ans += string(dy, 'U') + string(dx, 'R');
    ans += string(dy, 'D') + string(dx, 'L');

    // 外側時計回りで[s -> t -> s]を移動
    ans += "L" + string(dy+1, 'U') + string(dx+1, 'R') + "D";
    ans += "R" + string(dy+1, 'D') + string(dx+1, 'L') + "U";

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

bool A[110][110];

int main (){
	int n,a,b,c;
	cin>>n;
	for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				A[i][j]=false;
		}
	}
	for(int i=1;i<=n;i++){
		cin>>a>>b;
		for(int j=1;j<=b;j++){
			cin>>c;
			A[a][c]=true;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(j==n) cout<<A[i][j]<<"\n";
			else cout<<A[i][j]<<" ";
		}
	}
	return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
 
    int N,A,B,test,sum,ans=0;

    cin >> N >> A >> B ;

    for(int i=1;i<=N;i++){
        test = i ;
        sum = 0;
        while(test>0){
            sum  = sum + test % 10;
            test = test / 10 ;
        }
        if(sum >= A && sum <=B){
            ans = ans + i;
        }
    }

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

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

int main() {

  priority_queue<int> que;

  while (1) {
    string command;
    cin >> command;
    if (command == "insert") {
      int x;
      cin >> x;
      que.push(x);
    } else if (command == "extract") {
      cout << que.top() << endl;
      que.pop();
    } else if (command == "end") {
      return 0;
    }
  }

  return 0;

}


Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N, T; cin >> N >> T;
  int cost = 10000;
  int time;
  for (int i = 0; i < N; i++) {
    int c,t; cin >> c >> t;
    if (cost > c && T >= t) {
      cost = c;
    }
  }
  if (cost == 10000) {cout << "TLE" << endl;}
  else {cout << cost << endl;}
}

Measured memory_bytes: 256
// C.

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(int argc, char *argv[]) {
	int n, a, b, c, ans = 1 << 30;
	cin >> n >> a >> b >> c;
	vector<int> l(n);
	for (int i = 0; i < n; ++i) {
		cin >> l[i];
	}
	int bm = 1 << n;
	for (int i = 1; i < bm; ++i) {
		int acost = 0, alen = 0;
		for (int x = 0; x < n; ++x) {
			if (i & (1 << x)) {
				if (alen > 0) {
					acost += 10;
				}
				alen += l[x];
			}
		}
		acost += abs(a - alen);
		for (int j = 1; j < bm; ++j) {
			if (i & j) continue;
			int blen = 0, bcost = acost;
			for (int x = 0; x < n; ++x) {
				if (j & (1 << x)) {
					if (blen > 0) {
						bcost += 10;
					}
					blen += l[x];
				}
			}
			bcost += abs(b - blen);
			for (int k = 1; k < bm; ++k) {
				if ((i & k) != 0 || (j & k) != 0) continue;
				int clen = 0, ccost = bcost;
				for (int x = 0; x < n; ++x) {
					if (k & (1 << x)) {
						if (clen > 0) {
							ccost += 10;
						}
						clen += l[x];
					}
				}
				ccost += abs(c - clen);
				ans = min(ans, ccost);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#　三井住友C
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
x = ni()
dp = [False for i in range(100002)]

# dp[99]=True
dp[0]=True
dp[100]=True
dp[101]=True
dp[102]=True
dp[103]=True
dp[104]=True
dp[105]=True
for i in range(100,100001):
    if dp[i-100] or dp[i-101] or dp[i-102] or dp[i-103] or dp[i-104] or dp[i-105]:
        dp[i]=True
    else:
        dp[i]=False

if dp[x]:
    print(1)
else:
    print(0)


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

typedef long long ll;
const ll MAXN = 3e6 + 5;
const long long MOD = 1e9 + 9;
const long double eps = 1e-6;

#define mp make_pair
#define pb push_back
#define all(temp) temp.begin(), temp.end()
#define REP(i,n) for(int i = 0; i < n; ++i)

int main()
{
	//freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

	ll a,b,c; cin >> a >> b >> c;
	ll x,y; cin >> x >> y;

	ll ans = x * a + y * b;

	for(ll i = 0; i <= 2 * max(x,y); i += 2){
        ll needA = max(0ll, x - i / 2);
		ll needB = max(0ll, y - i / 2);
		ll cur = i * c + needA * a + needB * b;
		ans = min(ans, cur);
	}
	cout << ans;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int64_t ans = 0;
  vector<int> member(n*3);
  for (int i = 0; i < n*3; i++) cin >> member.at(i);
  sort(member.begin(), member.end());
  for(int i = n; i < 3*n; i+=2) ans += member.at(i);
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
// #define sd(t) scanf("%d",&t)
// #define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define pdd pair<double , double>
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N    200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
#define s3   1.73205080757          // square root 3
const  int inf = (int)1e18+10 ;
const int MAX= 100;

 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ordered_set S;

int powmod(int x , int y){
	int res = 1;
	while(y > 0){
		if(y%2==1)
			res = (res*x)%mod;
		x = (x*x)%mod;
		y/=2;
	}
	return res;
}
int mul(int x , int y){
	return (x*y)%mod;
}

signed main(){
  fast;
 
  string a , b;
  int n ; cin >> n;

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


 }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;

const int maxn = 100010;

ll a[maxn];

int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	
	//sum[1] : positive
	int sgn = 1;
	ll cursum = 0;
	ll ans1 = 0;
	for (int i=1;i<=n;i++,sgn=1-sgn)
	{
		cursum += a[i];
		if (sgn == 1)
		{
			if (cursum > 0) continue;
			else ans1 += (1LL-cursum), cursum = 1;
		}
		else
		{
			if (cursum < 0) continue;
			else ans1 += (cursum + 1LL), cursum = -1;
		}
	}
	
	sgn = 0;
	cursum = 0;
	ll ans2 = 0;
	for (int i=1;i<=n;i++,sgn=1-sgn)
	{
		cursum += a[i];
		if (sgn == 1)
		{
			if (cursum > 0) continue;
			else ans2 += (1LL-cursum), cursum = 1;
		}
		else
		{
			if (cursum < 0) continue;
			else ans2 += (cursum + 1LL), cursum = -1;
		}
	}
	cout<<min(ans1,ans2)<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;
int main()
{
  string S;
  cin >> S;
  
  int price = 700;
  
  if (S[0] == 'o') price+=100;
  if (S[1] == 'o') price+=100;
  if (S[2] == 'o') price+=100;
  cout << price << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
string a,b,c;
int cnt;
int main() {
	cin>>n>>a>>b>>c;
	cnt=2*n;
	for (int i=0;i<n;i++) {
		int k=0;
		if (a[i]==b[i]) k++;
		if (b[i]==c[i]) k++;
		if (a[i]==c[i]) k++;
		if (k==3) cnt-=2;
		if (k==1) cnt-=1;
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	buf := make([]byte, 50000)
	scanner.Buffer(buf, 100000)

	s := getString()
	s = reverse(s)

	ans := "YES"
L:
	for i := 0; i < len(s); {
		switch {
		case len(s)-i >= 5 && (s[i:i+5] == "maerd" || s[i:i+5] == "esare"):
			i += 5
		case len(s)-i >= 6 && s[i:i+6] == "resare":
			i += 6
		case len(s)-i >= 7 && s[i:i+7] == "remaerd":
			i += 7
		default:
			ans = "NO"
			break L
		}
	}

	fmt.Println(ans)
}

func reverse(s string) string {
	rs := []rune(s)
	n := len(rs)

	for i := 0; i < n/2; i++ {
		rs[i], rs[n-i-1] = rs[n-i-1], rs[i]
	}

	return string(rs)
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <math.h>

int main() {
  int i, j;
  int n, flag, prime = 0;
  int a[10000];

  scanf("%d", &n);

  for(i = 0; i < n; i++)
    scanf("%d", &a[i]);

  for(i = 0; i < n; i++) {
    flag = 0;
    if(a[i] == 2) flag = 0;
    else if ((a[i] != 2) && ((a[i] % 2) != 0)) {
      for(j = 3; j <= sqrt(a[i]); j+=2) {
	if((a[i] % j) == 0) {
	  flag = 1;
	  break;
	}
      }
    }
    else flag = 1;
    
    if (flag == 0) prime++;
  }

  printf("%d\n", prime);

  return 0;
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace io {

#define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a), putchar('\n')

#define I_int ll
inline I_int read() {
    I_int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
char F[200];
inline void write(I_int x) {
    if (x == 0) return (void) (putchar('0'));
    I_int tmp = x > 0 ? x : -x;
    if (x < 0) putchar('-');
    int cnt = 0;
    while (tmp > 0) {
        F[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int

}
using namespace io;

using namespace std;

#define N 100010

int n = read(), q = read();
int sum[N];
char s[N];

int main() {
	 scanf("%s",s+1);
	 for(int i = 1; i <= n; ++i) {
	 	sum[i] = sum[i - 1];
	 	if(s[i]=='C'&&s[i-1]=='A') {
	 		++sum[i];
		 }
	 }
	 while(q--){
	 	int l = read(), r = read();
	 	outn(sum[r]-sum[l]);
	 }
}

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

int main() {
	int n, q;
	cin >> n >> q;
	int *r = new int[n + 1]();
	int ma = 1, mv = 0;

	int a, v;
	while (cin >> a >> v) {
		r[a] += v;
		if (a == ma) {
			if (v >= 0) {
				mv = r[a];
			}
			else {
				mv = -101;
				for (int i = 1; i <= n; ++i) {
					if (r[i] > mv) {
						ma = i, mv = r[i];
					}
				}
			}
		}
		else {
			if (mv < r[a]) {
				ma = a, mv = r[a];
			}
			else if (mv == r[a] && a < ma) {
				ma = a;
			}
		}
		cout << ma << " " << mv << endl;
	}
	delete[] r;

	return 0;
}

Measured memory_bytes: 6712
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, m, ans=0;
	int p, x;
	cin >> n >> m;
	int a[m+1];
	for(int i=1;i<=m;i++)a[i]=0;
	for(int i=1;i<=n;i++)
	{
		cin >> p;
		for(int j=1;j<=p;j++)
		{
			cin>>x;
			a[x]++;
		}
	}
	for(int i=1;i<=m;i++)
		if(a[i]==n)ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
typedef long long ll;
typedef pair<ll, ll> P;
map<long long, long long> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
signed main() {
    int n;
    cin >> n;
    vector<ll> as(n);
    map<ll, ll> cnt;
    ll sum = 0;
    REP(i, n) {
        cin >> as[i];
        cnt[as[i]]++;
        sum += as[i];
    }
    ll q;
    cin >> q;
    REP(i, q) {
        ll b, c;
        cin >> b >> c;
        sum += (c - b) * cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 10020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ( A + B > C + D ) { cout << "Left" << endl; }
  else if ( A + B < C + D ) { cout << "Right" << endl; }
  else if ( A + B == C + D ) { cout << "Balanced" << endl; }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define INFTY 1000000000

int num=0;
void merge(int *s,int left,int mid,int right){
  int n1 = mid - left;
  int n2 = right - mid;
  int i,j,k;
  
int L[n1],R[n2];
for(i = 0;i < n1;i++){
  L[i] = s[left + i];
 }
for(i = 0;i < n2; i++){
  R[i] = s[mid + i];
 }
 L[n1] = INFTY;
 R[n2] = INFTY;
 i = 0;
 j = 0;
 for(k = left;k< right; k++){
   num++;
    if(L[i] <= R[j]){
      s[k] = L[i];
      i = i + 1;
    }
    else {
      s[k] = R[j];
      j = j + 1;
    }
  }
}
void mergeSort(int *s,int left,int right){
  int mid;
  if(left+1 < right){
       mid = (left + right)/2;
       mergeSort(s, left, mid);
       mergeSort(s, mid, right);
       merge(s, left, mid, right);
  }
}


//int left,right,mid,num=0;

int main(){
  int i,n,A[1000000];
  scanf("%d", &n);
  for(i = 0;i < n; i++){
    scanf("%d", &A[i]);
  }
  mergeSort(A,0,n);
  for(i = 0;i<n;i++){
    printf("%d", A[i]);
    if(i < n-1)printf(" ");
  }
  printf("\n%d\n", num);
  return 0;
}

Measured memory_bytes: 5792
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

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

int N;
ll W;
ll w[110], v[110];
ll dp[110][100100] = {0};

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

    cin >> N >> W;

    for(int i = 0; i < N; i++){
        cin >> w[i] >> v[i];
    }

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

        for(long long j = 0; j <= W; j++){

            // i番目の品物を選ぶ
            if(j-w[i] >= 0){
                chmax(dp[i+1][j], dp[i][j-w[i]]+v[i]);
            }

            // 選ばない
            chmax(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[N][W] << endl;

    return 0;
}


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

using namespace std;

#define FOR(v, b, e)   for (int v = (b); v < (e); ++v)
#define REP(v, n)      FOR(v, 0, n)

#define ALL(c)         (c).begin(), (c).end()

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

	vector<string> Sn(n);
	for (auto& s : Sn) cin >> s;

	REP (i, n) sort(ALL(Sn[i]));

	string result = Sn[0];
	string tmp;
	FOR (i, 1, n) {
		tmp.clear();
		set_intersection(ALL(result), ALL(Sn[i]), inserter(tmp, tmp.end()));
		swap(tmp, result);
	}
	cout << result << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>

#define NIL -1
#define zizyou(a,b) pow(((a)-(b)),2.0)

int main()
{
    int target, length;
    int ini_array[100];
    int answer_num = 0;
    int answer_abs = 20000;
    int answer_array[101];

    scanf("%d %d", &target, &length);

    for (int i = 0; i<=101; i++)
    {
        answer_array[i] = i;
    }

    for (int i = 0; i<length; i++)
    {
        scanf("%d", &ini_array[i]);
        answer_array[ini_array[i]] = NIL;
    }

    for (int i = 0; i<=101; i++)
    {
        if (answer_array[i] == NIL)
        {
            continue;
        }

        if (zizyou(target, answer_array[i]) < answer_abs)
        {
            answer_abs = zizyou(target, answer_array[i]);
            answer_num = answer_array[i];
        }
    }

    printf("%d", answer_num);


    return 0;
}

Measured memory_bytes: 1728
#include <stdio.h>
#include <memory.h>
int main(void){
  int n,i,j,k,ans=-100001;
  int a[5000],t[5000];
  while(1){  
    scanf("%d",&n);
    if(!n)
      break;
    ans=-100001;
    memset(a,0,sizeof(a));
    memset(t,0,sizeof(t));
    for(i=0;i<n;i++){
      scanf("%d",&a[i]);
      t[i]=a[i];
      if(ans<a[i])
	ans=a[i];
    }
    for(i=1;i<n;i++){
      for(j=0;j<n-i;j++){
	t[j]=t[j]+a[i+j];
	if(ans<t[j])
	  ans=t[j];
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc,char** argv){
  string s;
  cin >> s;
  if(s.length() == 2){
    cout << s << endl;
  }else{
    for(int i = 0; i < 3; i++){
      cout << s[2-i];
    }
    cout << endl;
  }
  return 0;
}



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

using namespace std;

vector<vector<int>> dp(100005, vector<int>(2, -1));
vector<int> v;
int n;

//dp[k][p] = player who wins when there are k stones and player p plays first
int solve(int k, int p)
{
    int val = (p == 0) ? 2 : -1;
    if(k == 0)
        return(1-p);
    if(k < 0)
        return(p);
    if(dp[k][p] != -1)
        return(dp[k][p]);
    for(int i=0;i<n;i++)
    {
        if(p == 0)
            val = min(val, solve(k-v[i], 1-p));
        else
            val = max(val, solve(k-v[i], 1-p));
    }
    return(dp[k][p] = val);
}

int main()
{
    int k, ele, ans;
    cin >> n >> k;
    for(int i=0;i<n;i++)
    {
        cin >> ele;
        v.push_back(ele);
    }
    ans = solve(k, 0);
    cout << ((ans == 0) ? "First" : "Second") << endl;
    return(0);
}

Measured memory_bytes: 13568
s = input()

a = int(s[:2])
b = int(s[2:])

a_flag = False
b_flag = False

if a > 0 and a <= 12:
    a_flag = True

if b > 0 and b <= 12:
    b_flag = True


if a_flag and b_flag:
    print('AMBIGUOUS')
elif a_flag:
    print('MMYY')
elif b_flag:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3064
S=input()
N=len(S)
a = 0
b = 0
ans=0
for x in range(0,N-1):
    if S[x] == '<':
        a += 1
    else:
        b += 1
    if S[x] == '>' and S[x+1] == '<':
        if a > b:
            b -= 1
        else:
            a -= 1
        if a < 0:
            a = 0
        if b < 0:
            b = 0
        for y in range (0,a+1):
            ans += y
        for z in range (0,b+1):
            ans += z
        a = 0
        b = 0
if S[N-1] == '<':
        a += 1
else:
        b += 1
if a > b:
    b -= 1
else:
     a -= 1
for y in range (0,a+1):
    ans += y
for z in range (0,b+1):
    ans += z
print(ans)

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#include <iomanip>
#define M (1<<20)-1
#define MAX 100000000
#define MIN -100000000
#define mod 998244353 
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

int main(){
	ll n,m;
	cin>>n>>m;
	ll ans = 0;
	ans += (n*(n-1))/2;
	ans += (m*(m-1))/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256