akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

    vector<int> table(26, 50);
    for(int i = 0; i < n; ++i){
        string tmp = S[i];
        vector<int> tmpTable(26);
        for(int j = 0; j < tmp.size(); ++j){
            tmpTable[tmp[j]-'a']++;
        }
        for(int j = 0; j < 26; ++j){
            table[j] = min(table[j], tmpTable[j]);
        }
    }
    string charTable = "abcdefghijklmnopqrstuvwxyz";
    for(int i = 0; i < 26; ++i){
        for(int j = 0; j < table[i]; ++j){
            cout << charTable[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
# ABC138D - Ki
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def dfs(v, p, tree, cnt):
    for u in tree[v]:
        if u != p:
            cnt[u] += cnt[v]
            dfs(u, v, tree, cnt)


def main():
    # ai may be not a parent of bi. -> set a skip condition (p) in dfs
    N, Q = tuple(map(int, input().split()))
    A = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    P = tuple(tuple(map(int, input().split())) for _ in range(Q))
    T = [[] for _ in range(N + 1)]
    cnt = [0] * (N + 1)
    for a, b in A:  # set tree relations
        T[a] += [b]
        T[b] += [a]
    for p, x in P:  # increment on roots
        cnt[p] += x
    dfs(1, -1, T, cnt)
    print(*cnt[1:])


if __name__ == "__main__":
    main()

Measured memory_bytes: 265748
import collections


class UnionFind:
    def __init__(self, max_size):
        self.parent = [i for i in range(max_size+1)]
        self.depth = [0 for _ in range(max_size+1)]
        self.cnt = [1 for i in range(max_size+1)]
    # 菲再起にしたい　Whileでスタックに突っこみながら見てスタックの中身全部に代入
    '''
    # 実はこっちのほうが速かったなんで？
    def find(self, x):
        t = x
        while t!=self.parent[t]:
            t = self.parent[t]
        self.parent[x]=t
        return t
    '''

    def find(self, x):
        de = collections.deque()
        t = x
        while t != self.parent[t]:
            de.append(t)
            t = self.parent[t]
        while de:
            tmp = de.pop()
            self.parent[tmp] = t
        return t

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.depth[x] < self.depth[y]:
            self.parent[x] = y
            self.cnt[y] += self.cnt[x]
        else:
            self.parent[y] = x
            self.cnt[x] += self.cnt[y]
            if self.depth[x] == self.depth[y]:
                self.depth[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return self.cnt[self.find(x)]


n, m = map(int, input().split())
utree = UnionFind(n+10)
for _ in range(m):
    x, y, z = map(int, input().split())
    utree.unite(x, y)
s = {utree.find(i) for i in range(1, n+1)}
print(len(s))


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

int main(){
    int n,k;
    cin >> n >> k;
    
    int p[n];
    
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    
    sort(p, p+n);
    
    int sum=0;
    
    for(int i=0;i<k;i++){
        sum+=p[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a,b,c;
  cin >> a>>b>>c;
  int p=max(a,max(b,c));
  int q=max(a,max(b,c))+1;
  if((3*p-(a+b+c))%2==0){
    cout <<(3*p-(a+b+c))/2;
  }else{
    cout << (3*q-a-b-c)/2;
  }
}


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

int main()
{
	string s;
	cin >> s;
	string t;
	cin >> t;
	string ans;
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	if (s < t) {
		ans = "Yes";
	}
	else {
		ans = "No";
	}
	cout << ans << endl;
}

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

mi = int( input( ) )
profit = 0 - 1000000000
n -= 1
i = 0
while i < n:
	num = int( input( ) )
	
	diff = num - mi
	if profit < diff:
		profit = diff

	if num < mi:
		mi = num
	i += 1

print( profit )

Measured memory_bytes: 6724
export class Main {
  static main(input): string {
    const tmp: string[] = input.split("\n");
    const n: number = Number(tmp[0]);
    let count: number = 0;
    let startB: number = 0;
    let endA: number = 0;
    let both: number = 0;
    for (let i: number = 1; i <= n; ++i) {
      const t: string = tmp[i];
      const f: string = t[0];
      const e: string = t[t.length - 1];
      if (f == "B" && e == "A") {
        ++both;
      } else if (f == "B") {
        ++startB;
      } else if (e == "A") {
        ++endA;
      }
      const m = t.match(/AB/g);
      if (m != null) {
        count += m.length;
      }
    }
    if (startB > 0 && endA > 0 && both) {
      count += both + 1;
      both = 0;
      --startB;
      --endA;
    }
    const [small, large]: number[] = [Math.min(startB, endA), Math.max(startB, endA)];
    const [s, l]: number[] = [Math.min(small, both), Math.max(small, both)];
    count += s * 2;
    count += small - s;
    const bothRemain: number = both - s;
    const remain: number = large - small;
    count += bothRemain > 0 ? bothRemain - 1 : 0;
    count += Math.min(remain, bothRemain > 0 ? 1 : 0);
    return `${count}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

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

int main(){
  int n,size;
  string s;cin>>n>>s;
  size=s.size();
  REP(i,size){
    s.at(i)+=n;
    if(s.at(i)>'Z') s.at(i)-=26;
  }
  cout<<s;
}

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

using namespace std;

int a[100005];
int go[100005];

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    int ans = 0;
    go[n] = n;
    for (int i = n - 1; i >= 1; --i) {
        if (a[i] >= a[i + 1]) go[i] = go[i + 1];
        else go[i] = i;
        ans = max(ans, go[i] - i);
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

const int inf=1e9+7;

using P = pair<int,int>;

int main(){
    int n,d;
    cin>>n>>d;
    int a[n][d];
    rep(i,n)rep(j,d)cin>>a[i][d-j-1];
    vector<vector<P>> dp(d+1,vector<P>(n+1,{inf,inf}));
    dp[0][n]={0,0};
    rep(i,d)rep(j,n){
        rep(k,n+1){
            if(j==k)dp[i+1][j]=min(dp[i+1][j],{dp[i][k].first+a[j][i],dp[i][k].second});
            else dp[i+1][j]=min(dp[i+1][j],{dp[i][k].first+a[j][i],dp[i][k].second+1});
        }
    }
    P ans={inf,inf};
    rep(i,n)ans=min(dp[d][i],ans);
    cout<<ans.first<<" "<<ans.second-1<<endl;
    int idx=-1;
    rep(i,d){
        if(idx==-1)rep(j,n){
            if(dp[d-i][j]==ans){
                idx=j;
                break;
            }
        }
        cout<<idx+1<<endl;
        ans.first-=a[idx][d-i-1];
        rep(k,n){
            if(k==idx){
                if(dp[d-i-1][k]==ans){
                    break;
                }
            }
            else {
                ans.second-=1;
                if(dp[d-i-1][k]==ans){
                    idx=k;
                    break;
                }
                else {
                    ++ans.second;
                }
            }
        }
    }

}


Measured memory_bytes: 3148
// ABC136C3.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int N;
	cin >> N;
	vector<int> H(N + 1);
	for (int i = 1; i <= N; i++)
	{
		cin >> H.at(i);
	}
	//
	int count = 0;
	int min = 1;
	for (int  j = 1; j <= N; j++)
	{
		if (H.at(j)>1&&H.at(j)>H.at(j-1))
		{
			H.at(j)--;
		}
		if (H.at(j)>=min)
		{
			count++;
			min = H.at(j);
		}
	}
	if (count==N)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ0567().doIt();
	}
	
	class AOJ0567{
		void doIt(){
			int n = in.nextInt();
			int a = in.nextInt(),b = in.nextInt();
			int kin = a,kizi_cal = in.nextInt();
			int[] topping = new int[n];
			for(int i=0;i<n;i++)topping[i] = in.nextInt();
			Arrays.sort(topping);
			double before = 0,col = kizi_cal;
			for(int i=n-1;i>=0;i--){
				col+=topping[i];
				kin+=b;
				double now = (double)col/kin;
//				System.out.println(col+" "+kin);
//				System.out.println(now+" "+before);
				if(now<before){
					kin-=b;
					col-=topping[i];
					break;
				}
				before = now;
			}
			System.out.println((int)(col/kin));
		}
	}
}

Measured memory_bytes: 18248
// Problem : B - Mix Juice
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//Mmmmmm......
#include<bits/stdc++.h>
using namespace std;

#define w cout
#define e '\n'
#define int long long
#define sz(x) (int)x.size()
#define re return 
#define vi vector<int>
#define vii vector<pair<int ,int > >
#define F first
#define S second
#define pussy push_back
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

const int N = 1e6 , mod = 1e9 + 7;


signed main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	int n , k; cin >> n >> k;
	vi a(n); cin >> a;
	sort(begin(a) ,end(a));
	int ans = 0;
	for(int i =0; i <k; i ++ )ans += a[i];
	w << ans;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i <= (n); i++)
#define MOD 1000000007
using ll = long long;
typedef pair<int, int> P;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b>=c){
        cout<<"delicious"<<endl;
        return 0;
    }
    if(c-b<=a){
        cout<<"safe"<<endl;
        return 0;
    }
    cout<<"dangerous"<<endl;
    return 0;
}

Measured memory_bytes: 3596
def CountingSort(A, B, k):
    C = [0] * (k+1)
    
    for j in range(n):
        C[A[j]] += 1
    
    for i in range(1, k+1):
        C[i] = C[i] + C[i-1]
#     print(C)
    
    for j in range(n-1, -1, -1):
        B[ (C[A[j]]-1) ] = A[j]
        C[A[j]] -= 1

n = int(input())
A = [int(num) for num in input().split()] 
B = [0] * n
k = max(A)
CountingSort(A,B,k)
print(" ".join(map(str,B)))


Measured memory_bytes: 240624
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
#define debug(a) cout<<#a<<" --> "<<(a)<<endl;
#define fastInput ios_base::sync_with_stdio(false);cin.tie(0)
#define INPUT freopen("input.txt","r",stdin)
#define OUTPUT freopen("output.txt","w",stdout)
#define Error  1e-9
#define pi (2*acos(0))
const ll mod =1e9 +7;
const int N = 1e5 +5;

void Solve(int cas)
{
    int n,base;
    scanf("%d %d",&n,&base);
    int dig = (int)(floor( log(n) /
                           log(base)) + 1);

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



}



int main()
{
    //fastInput;
    //cout.tie(0);
    //INPUT;
    //OUTPUT;
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        Solve(++cas);
    }
    return 0;
}
/*

*/


//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


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

int main(void)
{
	ll x,a=100,i;
	cin>>x;
	for(i=0;a<x;i++)
	{
		a+=a*0.01;
	//	cout<<a<<" ";
	}
//	cout<<endl;
	cout<<i;
	return 0;
}

Measured memory_bytes: 3544
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int X, Y;
    cin >> X >> Y;

    int ans = 0;
    if (X == 1) ans += 300'000;
    else if (X == 2) ans += 200'000;
    else if (X == 3) ans += 100'000;
    if (Y == 1) ans += 300'000;
    else if (Y == 2) ans += 200'000;
    else if (Y == 3) ans += 100'000;
    if (X == 1 && Y == 1) ans += 400'000;

    write(ans);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    char s[21];
    int i;
    scanf("%s", s);
    int len = strlen(s);
    for(i = len - 1; i >= 0; i--)
        putchar(s[i]);
    putchar('\n');
    
    return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<stdio.h>
using namespace std;

int a[25];

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

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String S = in.nextLine();
         if ((S.charAt(2) == S.charAt(3))&&((S.charAt(4) == S.charAt(5)))){
          System.out.println("Yes");
         }
         else {System.out.println("No");
                }
        }
    }

Measured memory_bytes: 22740
#include <iostream>
#include <cmath>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

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

    std::vector<long long> D(N, 0), T(N, 0);
    int max_depth = 0;

    for (int i = 0; i < N; i++) {
        cin >> D.at(i);
        if (i == 0 && D.at(0) != 0) {
            cout << 0 << endl;
            return 0;
        }

        if (i != 0 && D.at(i) == 0) {
            cout << 0 << endl;
            return 0;
        }

        if (D.at(i) > max_depth) {
            max_depth = static_cast<int>(D.at(i));
        }

        T.at(D.at(i))++;
    }

    long long count = 1;
    for (int i = 1; i < N; i++) {
        count *= T.at(D.at(i) - 1);
        while (count>998244353){
            count-=998244353;
        }
    }
    cout << count % 998244353 << endl;
    return 0;
}



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

int main(){
    //N,K,X,Yの入力
    int N,K,X,Y;
    cin >> N;
    cin >> K;
    cin >> X;
    cin >> Y;
    

    //金額の計算
    if(N<K){
        cout << X*N << endl;
    }else{
        cout << X*K+Y*(N-K) << endl;
    }

}

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

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

int main(){
	int N;
	cin >> N;
	int ans = 0;
	vector<int> P(N);
	REP(i,N){
	    cin >> P[i];
	}

	REP(i,N-2){
	    int M,m;
	    M = max({P[i],P[i+1],P[i+2]});
	    m = min({P[i],P[i+1],P[i+2]});
	    if ((M != P[i+1]) and (m != P[i+1])) ans++;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> a(N); rep(i, 0, N) { cin >> a[i]; }
	vector<int>lis; lis.push_back(a[0]);
	rep(i, 1, N) {
		if (lis.back() < a[i])lis.push_back(a[i]);
		else *lower_bound(all(lis), a[i]) = a[i];
	}
	cout << lis.size() << endl;
	return 0;
}

Measured memory_bytes: 3880
import collections
import math

A, B = map(int, input().split())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
     # divisors.sort()
    return divisors



def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

A_div = set(make_divisors(A))
B_div = set(make_divisors(B))
common_div = (A_div & B_div)

cnt = 1
for c in common_div:
    if is_prime(c):
        cnt += 1

print(cnt)

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


int main() {
  int N;
  cin >> N;
  set<string> S;
  for(int i = 0; i < N; i++){
    string s;
    cin >> s;
    S.insert(s);
  }
  
 cout << S.size();
  
  return 0;
}

Measured memory_bytes: 19132
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
int solve() {
    int n;
    cin >> n;
    map<int, int> odd, even;
    for (int i {}, t {}; i < n / 2; i++) {
        cin >> t;
        odd[t] = (odd.find(t) == odd.end() ? 1 : odd[t] + 1);
        cin >> t;
        even[t] = (even.find(t) == even.end() ? 1 : even[t] + 1);
    }
    auto findMax = [](const auto& m) {
        return *max_element(m.begin(), m.end(), [](const auto& p, const auto& q) {
            return p.second < q.second;
        });
    };
    const auto e1 = findMax(even), o1 = findMax(odd);
    even[e1.first] = 0;
    odd[o1.first] = 0;
    const auto e2 = findMax(even), o2 = findMax(odd);
    if (e1.first != o1.first) return n - e1.second - o1.second;
    return min(n - e1.second - o2.second, n - e2.second - o1.second);
}
int main() {
    cout << solve() << endl;
}

Measured memory_bytes: 4992
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
//分布を集計する用
const int M = 100005;

int main() {
    vector<ll>cnt(M);
    int n,q;
    ll S = 0;
    cin >> n;
    vector<int>a(n);
    rep(i, n) {
        cin >> a[i];
        cnt[a[i]]++;//入力の分布を集計
    }
    rep(i, M)S += cnt[i] * i;//初期の和
    cin >> q;
    vector<ll>b(q), c(q);
    rep(i, q) {
        cin >> b[i];
        cin >> c[i];
        cnt[c[i]] += cnt[b[i]];
        S += (c[i] - b[i]) * cnt[b[i]];
        cnt[b[i]] = 0;
        cout << S << endl;
    }


    return 0;
}

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

int main() {
  int a,b,j=0,c;
  cin >> a >> b ;
  for(int i=0 ; i <= a ; i++){
    c = i * 2 +(a - i) * 4 ;
    if(c == b) j = 1 ; 
  }
  if(j==0) cout << "No";
  else cout << "Yes";

}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define vb __int128
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define stoink stack<ll>
#define vec vector <ll>
#define vg vector<vector<ll> >
#define vgw vector<vector<pair<ll,ll> >
#define pa pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pre 0.00000000000000000001
#define inf 1000000000000
#define mod 998244353
vector<ld> arr;
vector<vector<ld>> dp;
ll n;
ld func(ll ind,ll numh) {
	if(numh < 0)
		return 0;
	if(numh > ind)
		return 0;
	if(ind == 1) {
		if(numh == 1){
			return arr[1];
		}
		else
			return 1 - arr[1];
	}
	if(dp[ind][numh] > -0.5)
		return dp[ind][numh];
	ld res;
	res = func(ind-1,numh) * (1 - arr[ind]) + func(ind-1,numh-1) * arr[ind];
	return dp[ind][numh] = res;
}
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	ll i,j;
	arr.resize(n + 1);
	for(i = 1 ; i <= n ; i++)
		cin >> arr[i];
	dp.resize(n+1,vector<ld>(n+1,-1));
	ld ans = 0;
	for(i = n/2 + 1; i <= n; i++)
		ans += func(n,i);
	cout << fixed << setprecision(12) << ans << endl;
	return 0;
}

Measured memory_bytes: 141312
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
  int A,B;
  cin >> A >> B;
  if(A == 1 && A == B){
    cout << 1000000 << endl;
    return 0;
  }
  int ans=0;
  if(A == 1){
    ans += 300000;
  }else if(A == 2){
    ans += 200000;
  }else if(A == 3){
    ans += 100000;
  }
  if(B == 1){
    ans += 300000;
  }else if(B == 2){
    ans += 200000;
  }else if(B == 3){
    ans += 100000;
  }
cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int isPrime(int x){
  int i;
  if(x<2)return 0;
  else if(x==2)return 1;
  if(x%2==0)return 0;
  for(i=3;i*i<=x;i+=2){
   if(x%i==0)return 0;
  }
  return 1;
}

int main(){
  int n,x,i;
  int cnt = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&x);
    if(isPrime(x))cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}

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

struct Restaurant
{
    int id;
    string city;
    int point;

    Restaurant(int i, string c, int p)
    {
        id = i;
        city = c;
        point = p;
    }

    bool operator<(const Restaurant &another) const
    {
        if (city == another.city)
        {
            return point > another.point;
        }
        else
        {
            if (city.compare(another.city) > 0)
            {
                return 0;
            }
            else
            {
                return 1;
            }
        }
    }
};

int main()
{
    vector<Restaurant> res;
    int n;
    cin >> n;
    for (auto i = 0; i < n; i++)
    {
        string c;
        int p;
        cin >> c >> p;
        Restaurant r(i + 1, c, p);
        res.push_back(r);
    }
    sort(res.begin(), res.end());

    for (auto i = 0; i < n; i++)
    {
        cout << res[i].id << endl;
    }
}

Measured memory_bytes: 256
def d_decrease(SIZE=50):
    K = int(input())

    # q 回数列全体を +1 し，r 回のシミュレーションを行う．
    # ans[r] を +SIZE し，その他の要素を -1 する．まとめて書くと以下の通り
    q, r = divmod(K, SIZE)
    ans = list(map(lambda x: x + q - r, range(SIZE)))
    for i in range(r):
        ans[i] += SIZE + 1
    return '{}\n{}'.format(SIZE, ' '.join(map(str, ans)))

print(d_decrease())

Measured memory_bytes: 3060
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

int main(){	
	ll N, K;
	cin >> N >> K;
	ll c = 0;
	rep(i, N) {
		ll h;
		cin >> h;
		if (h >= K) c++;
	}
	cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  if(n == 1){
    cout << "Hello World" << endl;
  }else{
    int a, b;
    cin >> a >> b;
    cout << a+b << endl;
  }
  return 0;
}

Measured memory_bytes: 3576
from sys import stdin


input = stdin.readline


N, M = map(int, input().split())
friends = [tuple(map(int, inp.strip().split())) for inp in stdin.read().splitlines()]
father = [-1] * N


def getfather(x):
    if father[x] < 0: return x
    father[x] = getfather(father[x])
    return father[x]


def union(x, y):
    x = getfather(x)
    y = getfather(y)
    if x != y:
        if father[x] > father[y]:
            x,y = y,x
        father[x] += father[y]
        father[y] = x;


for a, b in friends:
    union(a - 1, b - 1)
# print(max(Counter([getfather(i) for i in range(N)]).values()))
print(max([-father[getfather(i)] for i in range(N)] or [0]) )

Measured memory_bytes: 138772
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(998244353);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

template<typename T>
T power(T x, long long n, const T &m){
    if(n == 0) return 1;
    if(n == 1) return x;
    T tmp = power(x, n/2, m);
    if(n%2 == 0) return tmp * tmp % m;
    else return tmp * tmp % m * x % m;
}

template<typename T>
T inverse(T x, const T &m){
    return power(x, m-2, m);
}

struct Combination{
private:
    int N;
    long long M;
    vector<long long> f, i;
public:
    void init(int n, long long m){
        N = n; M = m;
        f.resize(N+1); f[0] = 1;
        i.resize(N+1); i[0] = 1;
        for(long long j=1; j<=N; j++){
            f[j] = f[j-1]*j%M;
            i[j] = inverse(f[j], M);
        }
    }
    long long fact(int n){
        return f[n];
    }
    long long C(int n, int r){
        return f[n] * i[r] % M * i[n-r] % M;
    }
};

ll N, M, K;
Combination comb;

signed main(){
    cin >> N >> M >> K;
    comb.init(N, MOD);
    ll ans = 0;
    rep(i, K+1){
        ans += comb.C(N-1, i) * M % MOD * power(M-1, N-i-1, MOD);
        ans %= MOD;
    }
    cout << ans << endl;
}

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

long long combination(int n, int r)
{
  if (n == r || r == 0)
    return 1;
  else
    return combination(n, r - 1) * (n - r + 1) / r;
}
 
int main() {
    int N, M;
    cin >> N >> M;
    cout << combination(N, 2) + combination(M, 2) << endl;
}

Measured memory_bytes: 256
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int dy[8] = { 1, 1, 1, 0, 0, -1, -1, -1 };
const int lr[4] = { 0, 1, 0, -1 };
const int ud[4] = { 1, 0, -1, 0 };



//LOVE Ayane Sakura



using namespace std;

int main() {
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		cout << "x";
	}
	cout << endl;
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
	char s[11],t[11];
	int pos = 0;
	scanf("%s",s);
	for(int i=0;s[i]!='\0';i++){
		if(s[i]=='B'){
			if(pos>0){
				pos--;
				t[pos] = '\0';
			}
		}else{
			t[pos] = s[i];
			pos++;
			t[pos] = '\0';
		}
	}
	printf("%s\n",t);
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#pragma warning(disable : 4996)


struct Node {
	int value;
	Node *parent;
	Node *left;
	Node *right;
	Node() : parent(NULL), left(NULL), right(NULL) {}
};

Node *Root = NULL;

void Preorder(Node *node) {
	printf(" %d", node->value);
	if(node->left != NULL) Preorder(node->left);
	if(node->right != NULL) Preorder(node->right);
}
void Inorder(Node *node) {
	if (node->left != NULL) Inorder(node->left);
	printf(" %d", node->value);
	if (node->right != NULL) Inorder(node->right);
}
void Postorder(Node *node) {
	if (node->left != NULL) Postorder(node->left);
	if (node->right != NULL) Postorder(node->right);
	printf(" %d", node->value);
}
void Insert(Node *z) {
	Node *y = NULL;
	Node *x = Root;
	while (x != NULL) {
		y = x;
		if (z->value < x->value) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NULL) {
		Root = z;
	}
	else if(z->value < y->value) {
		y->left = z;
	}
	else {
		y->right = z;
	}
}
Node *Find(int v) {
	Node *x = Root;
	while (x != NULL) {
		if(x->value == v) { 
			return x;
		}
		else if (v < x->value) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	return NULL;
}
Node *GetMinNode(Node *root) {
	Node *x = root;
	Node *y = NULL;
	while (x != NULL) {
		y = x;
		x = x->left;
	}
	return y;
}
void Delete(Node *z) {
	if ((z->left != NULL) && (z->right != NULL)) {
		Node *next = GetMinNode(z->right);
		z->value = next->value;
		Delete(next);
		return;
	}
	if ((z->left == NULL) && (z->right == NULL)) {
		if (z->parent != NULL) {
			if (z->parent->left == z) {
				z->parent->left = NULL;
			}
			else {
				z->parent->right = NULL;
			}
		}
		else {
			Root = NULL;
		}
		return;
	}
	if ((z->left == NULL) && (z->right != NULL)) {
		z->right->parent = z->parent;
		if (z->parent != NULL) {
			if (z->parent->left == z) {
				z->parent->left = z->right;
			}
			else {
				z->parent->right = z->right;
			}
		}
		else {
			Root = z->right;
		}
		return;
	}
	if ((z->left != NULL) && (z->right == NULL)) {
		z->left->parent = z->parent;
		if (z->parent != NULL) {
			if (z->parent->left == z) {
				z->parent->left = z->left;
			}
			else {
				z->parent->right = z->left;
			}
		}
		else {
			Root = z->left;
		}
		return;
	}
}
int main(void) {
	int n;
	scanf("%d", &n);
	char line[1024];
	for (int i = 0; i < n; ++i) {
		scanf("%s", &line[0]);
		if (strcmp(line, "print") == 0) {
			Inorder(Root);
			printf("\n");
			Preorder(Root);
			printf("\n");
		}
		else {
			int k;
			scanf("%d", &k);
			if (strcmp(line, "insert") == 0) {
				Node *z = new Node();
				z->value = k;
				Insert(z);
			}
			else if (strcmp(line, "find") == 0) {
				if (Find(k) == NULL) {
					printf("no\n");
				}
				else {
					printf("yes\n");
				}
			}
			else {
				Delete(Find(k));
			}
		}
	}
	return 0;
}



Measured memory_bytes: 21320
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    bool reversed = false;
    vector<char> front, back;
    for (int i = 0; i < Q; i++)
    {
        int T;
        cin >> T;
        if (T == 1)
        {
            reversed = !reversed;
        }
        else if (T == 2)
        {
            int F;
            char C;
            cin >> F >> C;
            if ((F == 1 && !reversed) || (F == 2 && reversed))
            {
                front.push_back(C);
            }
            else if ((F == 1 && reversed) || (F == 2 && !reversed))
            {
                back.push_back(C);
            }
        }
    }
    if (reversed)
    {
        for (int i = 0; i < back.size(); i++)
        {
            cout << back[back.size() - i - 1];
        }
        for (int i = 0; i < S.size(); i++)
        {
            cout << S[S.size() - i - 1];
        }
        for (int i = 0; i < front.size(); i++)
        {
            cout << front[i];
        }
        cout << endl;
    }
    else
    {

        for (int i = 0; i < front.size(); i++)
        {
            cout << front[front.size() - i - 1];
        }
        for (int i = 0; i < S.size(); i++)
        {
            cout << S[i];
        }
        for (int i = 0; i < back.size(); i++)
        {
            cout << back[i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
  
#define tate 3
#define yoko 3
#define total 9
#define TryCnt 45
 
extern inline void down_0(void);    
extern inline void up_0(void);      
extern inline void right_0(void);   
extern inline void left_0(void);    
 
extern int  serch(int x, int y, int MaxCnt, int pre);
 
int num = 0;        
int val[total] ={}; 
 
 
int main( void )
{
  int i = 0;
  int x,y = 0;
     
    
  for(i=0; i<total; i++)
    {
      scanf("%d",&val[i]);
         
      if(val[i] == 0)
        {
	  num = i;
        }
    }
     
   
  x = tate - (num/yoko) -1;
  y = yoko - (num%yoko) -1;
     
  for(i=0; i<TryCnt; i++)
    {
      if( serch(x,y,i,4) == 1 )
        {
	  printf("%d\n",i);
	  break;
        }
    }     
     
  return 0;
}
 
int serch(int x, int y, int MaxCnt, int pre)
{
  int result;
  int i=0;
     
  if(MaxCnt < (x + y) )
    {
      return 0;
    }
     
   
  if(MaxCnt==0)
    {
      for(i=0; i<total-1; i++)
        {
	  if(val[i] != (i+1))
            {      
	      return 0;
            }
        }
      return 1;
    }
     
     
  
  for(i=0; i<4; i++)
    {
      result = 0;
         
      switch(i)
        {
	case 0:
	  if( (x > 0) && (pre != 3) )
	    {
	      down_0();
                     
	      result = serch(x-1, y, MaxCnt-1, 0);
                     
	      up_0();
	    }
	  break;
                 
	case 1:
	  if( (y > 0) && (pre != 2) )
	    {
	      right_0();
                     
	      result = serch(x, y-1, MaxCnt-1, 1);
                     
	      left_0();
	    }
	  break;
                 
	case 2:
	  if( (y < yoko -1 ) && (pre != 1) )
	    {
	      left_0();
                     
	      result = serch(x, y+1, MaxCnt-1, 2);
                     
	      right_0();
	    }
	  break;
                 
	case 3:
	  if( (x < tate -1 ) && (pre != 0) )
	    {
	      up_0();
                     
	      result = serch(x+1, y, MaxCnt-1, 3);
                     
	      down_0();
	    }
	  break;
                 
	default:
	  break;
        }
         
      if(result)
        {
	  return 1;
        }
    }
     
  return 0;
}
 
 
inline void down_0()
{
  val[num] = val[num + yoko];
  num = num + yoko;
}
  
inline void up_0()
{
  val[num] = val[num - yoko];
  num = num - yoko;
}
  
inline void right_0()
{
  val[num] = val[num +1];
  num = num + 1;
}
  
inline void left_0()
{
  val[num] = val[num -1];
  num = num - 1;
}



Measured memory_bytes: 2740
l = list(map(int, input().split()))
l.sort()

i = 0
while l[1] != l[2]:
  l[0], l[1] = l[0]+1, l[1]+1
  i += 1

if l[0] == l[1]:
  print(i)
  exit()
elif l[0]%2 == l[1]%2:
  i += (l[1] - l[0])//2
  print(i)
  exit()
else:
  i += (l[1]+1-l[0])//2+1
  print(i)
  exit()

Measured memory_bytes: 38640
import sys
from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
from collections import deque 

input = sys.stdin.readline

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
def _dbg(o):
    print(o, file=sys.stderr)

# ---------------------------------------

N = inp()
mod = 10**9 + 7
_dbg(mod)

a = 1
b = 1
c = 1
for _ in range(N):
    a = (a * 10) % mod
    b = (b * 9) % mod
    c = (c * 8) % mod
print((a - 2 * b + c) % mod)


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  deque<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  // cout << "prev sort" << endl;
  sort(a.begin(), a.end());
  // cout << "after sort" << endl;
  for (int i = 0; i < m; i++) {
    a[n - 1] /= 2;
    if (n > 1 && a[n - 1] < a[n - 2]) {
      int tmp = a[n - 1];
      a.pop_back();
      auto p = lower_bound(a.begin(), a.end(), tmp);
      a.insert(p, tmp);
    }
  }
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n); ++i)
#define maxn 100005
struct edge{
    int x, y, c;
    edge(int _x, int _y, int _c):x(_x), y(_y), c(_c){}
};
int d[10][10], b[10][10];
int a[100][100];
int hit_i[100][100][10];
int hit_j[100][100][10];
int hit[100][100];
bool need[100][100];
void solve(){
    int n,m;
    cin >> n >> m;
    rep(i,n)rep(j,m){
        cin >> d[i][j];
    }
    rep(s,100)rep(t,100){
        rep(i,n)rep(j,m){
            a[s][t] = max(d[i][j] - (i + 1) * s - (j + 1) * t, a[s][t]);
        }
    }
    // rep(s, 100){
    //     rep(t, 100) cout << a[s][t] << ' ';
    //     cout << endl;
    // }
    rep(i,n)rep(j,m){
        b[i][j] = 1000000;
        rep(s,100)rep(t,100){
            b[i][j] = min(b[i][j], (i + 1) * s + (j + 1) * t + a[s][t]);
            if((i + 1) * s + (j + 1) * t + a[s][t] == d[i][j]){
                hit_i[s][t][i]  = 1;
                hit_j[s][t][j]  = 1;
                hit[s][t] += 1;
            }
        }
        if(b[i][j] > d[i][j]){
            cout << "Impossible" << endl;
            return;
        }
    }


    if (n == 1 && m == 1){
        need[0][0] = 1;
    }

    if (n == 1 && m > 1){
        rep(s, 100)rep(t, 100){
            if (hit[s][t] < 2) continue;
            if (s > 0) continue;
            need[s][t] = 1;
        }
    }

    if (n > 1 && m == 1){
        rep(s, 100)rep(t, 100){
            if (hit[s][t] < 2) continue;
            if (t > 0) continue;
            need[s][t] = 1;
        }
    }

    if (n > 1 && m > 1){
        rep(s, 100)rep(t, 100){
            if (hit[s][t] < 3) continue;
            int cnt = 0;
            rep(i, n) cnt += hit_i[s][t][i];
            if (cnt < 2) continue;
            cnt = 0;
            rep(j, m) cnt += hit_j[s][t][j];
            if (cnt < 2) continue;
            need[s][t] = 1;
        }        
    }

    int S, T, node;
    S = 1;
    T = 2;
    node = 3;
    vector<edge> e; e.clear();
    rep(s,100)rep(t,100) if(need[s][t]){
        // s X + t Y + a[s][t]
        vector<int> v;
        v.clear();
        rep(_, s) v.push_back(-2);
        rep(_, t) v.push_back(-1);
        rep(_, a[s][t] / 100) v.push_back(100);
        if(a[s][t] % 100 > 0) v.push_back(a[s][t] % 100);
        int last = S;
        rep(i, v.size()){
            if (i == v.size() - 1) e.push_back(edge(last, T, v[i]));
            else{
                e.push_back(edge(last, node, v[i]));
                last = node;
                node ++;
            }
        }
    }
    cout << "Possible" << endl;
    cout << node - 1 << ' ' << e.size() << endl;
    for(auto p: e){
        cout << p.x << ' ' << p.y << ' ';
        if(p.c == -2) cout << 'X'; else
        if(p.c == -1) cout << 'Y'; else
        cout << p.c;
        cout << endl;
    }
    cout << "1 2" <<endl;
}

int main(int argc, char const *argv[]) {
    solve();
    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
long int n,m,i,j,k,min,x,temp,sw;
  temp=0;
  sw=0;
  min=20000000;
  cin >> n >> m >> x; 
long int c[n],a[n][m],sum[m];
  
  for(i=0;i<n;++i)
  {
  cin >> c[i];
   for(j=0;j<m;j++)
   {
   cin >> a[i][j];
   }
  }
  
  for(j=0;j<m;j++)
  {sum[j]=0;
   }
  
  
  for(i=0;i<(1<<12);++i)
  {
  bitset<12> s(i);
    for(j=0;j<n;++j)
    {
    if(s.test(j)) {temp=temp+c[j];
      for(k=0;k<m;++k)
      {
      sum[k]=sum[k]+a[j][k];
      }
     }
    }
    for(k=0;k<m;++k)
      {
      if(sum[k]>=x) sw++;
      sum[k]=0;
      }
    if(sw==m && temp < min) min=temp;
    sw=0;
    temp=0;
  }
  if(min==20000000) cout << "-1";
  else cout << min;

return 0;}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n) for(i64 i=(s); i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

signed main()
{
  char c; cin >> c;
  if (c == 'A') c = 'T';
  else if (c == 'T') c = 'A';
  else if (c == 'G') c = 'C';
  else if (c == 'C') c = 'G';

  cout << c<< endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n,k, u, v;

  cin >> n;
  int g[n][n];
  for(int i=0;i< n ; i++){
    for(int j=0; j<n ; j++){
      g[i][j] = 0;
    }
  }
 for(int i=0 ; i< n ; i++){
   cin >> u >> k;
   u--;

   for(int j=0;j< k ; j++){
    cin >> v;
    v--;
    g[u][v]=1;
   }
 }

 for(int i=0; i<n;i++){
   for(int j=0;j< n ; j++){
     cout << g[i][j];
      if(j!= n-1){
       cout<<" ";
     }
   }
   cout << endl;
 }

 return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string a,b;
  cin>>a>>b;
  int x=1;
  for(int i=0;i<(a.length());i++)
  {
    if(a[i]!=b[i])
    {
      x=0;
      break;
    }
  }
  if(x==0)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
}

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

using namespace std;

int main() {
  int N;
  
  cin >> N;
  
  int sum = 0;
  vector<int> sums;
  
  for (int i = 0; i < N; i++) {
    int in;
    
    cin >> in;
    
    sum += in;
    sums.push_back(sum);
  }
  
  int ans = 0x7FFFFFFF;
  
  for (int i = 0; i < N - 1; i++) {
    ans = min(ans, abs(sums[N - 1] - 2 * sums[i]));
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

 
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
	    String str1=reader.readLine();
	    String s1[]=str1.split(" ");

	    int a=Integer.parseInt(s1[0]);
	    int b=Integer.parseInt(s1[1]);
	    int c=Integer.parseInt(s1[2]);

	    if(b-a==c-b){
		System.out.println("YES");
	    }else{
		System.out.println("NO");
	    }
		
	    reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    static int gcd (int a, int b){
	return b>0?gcd(b,a%b):a;
    }
    static int lcm (int a, int b) {
	return a*b/gcd(a,b);
    }
}


Measured memory_bytes: 23124
/**********************************************************/
/**            Bismillahir-rahmanir-rahim                **/
/**  In the name of Allah, the Beneficent, the Merciful. **/
/**********************************************************/
/****@author: Sayed Sohan, CSE 13th batch(2016), MBSTU*****/
/**********************************************************/

#include <bits/stdc++.h>
using namespace std;
//              Typedefs
typedef long long               ll;
typedef unsigned long long      ull;

//              Templates
template<class T>               using min_heap = \
                                priority_queue<T, \
                                std::vector<T>, std::greater<T>>;

//              Basic-Defs
#define PB                      push_back
#define MP                      make_pair
#define SP                      " "
#define NL                      "\n"
#define all(v)                  v.begin(), v.end()

//              DEBUG--SECTION
#define DE                      cout<<"HERE\n";
#define DE1(x)                  cout<<x<<"###\n";
#define DE2(x,y)                cout<<x<<"--->"<<y<<"\n";
#define Pause                   system("pause");

//              Functions
#define clr(arr,value)          memset(arr,value,sizeof(arr))
#define __FAST_IO               ios_base::sync_with_stdio(0);\
                                cin.tie(0);cout.tie(0);
#define NUM1(x)                 __builtin_popcount(x)
#define LCM(x,y)                (x*y)/__gcd(x,y)

//              Sizes--Math     0123456789
#define MOD                     1000000007   //1e9+7 
#define MAX                     100050      
#define INF                     1e18
#define PI                      acos(-1)
#define eps                     1e-6

//** your code goes from here

class Solve
{
public:
    void solve(){
        ll i,j,k,n,m,T; //basic variables
        ll l,r,d;
        cin>>n;
        ll arr[n+1];
        clr(arr,0);
        for(i=1;i*i<=n;i++){
            ll x = i*i;
            for(j=1;j*j<=n;j++){
                ll y = j*j;
                if(x+y>n) break;
                for(k=1;k*k<=n;k++){
                    ll z = k*k;
                    ll p = x+y+z+(i*j)+(j*k)+(i*k);
                    if(p>n) break;
                    arr[p]++;
                }
            }
        }
        for(i=1;i<=n;i++){
            cout<<arr[i]<<NL;
        }

    }
};

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    __FAST_IO;
    Solve A;
    ll T=1;
    // cin>>T;

    while(T--){
        A.solve();
    } 
    


    /// Don't forget to set array size....
    return 0;
}




Measured memory_bytes: 3728