akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
typedef pair<int, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}


int main() {
	int n,q;
    cin>>n>>q;
    vector<ll>w(n);
    vector<vector<int>>path(n);
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        path[a].push_back(b);
    }
    //map<int,int>px;
    rep(i,q){
        ll p,x;
        cin>>p>>x;
        p--;
        w[p]+=x;
    }
    queue<int>que;
    que.push(0);
    while(que.size()){
        int tmp=que.front();
        que.pop();
        rep(i,path[tmp].size()){
            //cout<<path[tmp][i]<<" ";
            w[path[tmp][i]]+=w[tmp];
            que.push(path[tmp][i]);
        }
        //cout<<endl;
    }
    rep(i,n){
        cout<<w[i];
        if(i!=n-1){
            cout<<" ";
        }else{
            cout<<endl;
        }
    }
}



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

#define MAX 256

int main(void){
	int N[52];
	for (int i = 0; i < 52; i++){
		N[i] = 0;
	}

	int n, a;
	char b;

	scanf("%d", &n);
	
	for (int i = 0; i < 2*n; i++){
		scanf("%c%d", &b, &a);
		switch (b){
		case 'S': N[a - 1] = 1; break;
		case 'H': N[a + 12] = 1; break;
		case 'C': N[a + 25] = 1; break;
		case 'D': N[a + 38] = 1; break;
		}
	}
	for (int i = 0; i < 52; i++){
		if (N[i] == 0){
			switch (i / 13){
			case 0:printf("S %d\n", i % 13 + 1); break;
			case 1:printf("H %d\n", i % 13 + 1); break;
			case 2:printf("C %d\n", i % 13 + 1); break;
			case 3:printf("D %d\n", i % 13 + 1); break;
			}
		}
	}


	return 0;
}

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

int main()
{
  int n, k;
  scanf("%d%d", &n, &k);
  vector<int> a(n);
  for(int &i : a)
  {
    scanf("%d", &i);
  }
  vector<bool> dp(k + 1);
  for(int i = 1; i <= k; i++)
  {
    for(int j = 0; j < n; j++)
    {
      if(i - a[j] >= 0 and !dp[i - a[j]])
      {
        dp[i] = true;
      }
    }
  }
  printf("%s", dp[k] ? "First" : "Second");
  
  return 0;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

def choose2(n):
    return n*(n-1)//2

n = int(input())
A = list(map(int, input().split()))
A = [a-1 for a in A]
  
Cnt = [0]*n
for i in range(n):
  Cnt[A[i]] += 1
    
tot = 0
for i in range(n):
    tot += choose2(Cnt[i])

for i in range(n):
    ans = tot
    ans -= choose2(Cnt[A[i]])
    ans += choose2(Cnt[A[i]]-1)
    print(ans)

Measured memory_bytes: 26268
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long  ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define np(str) next_permutation(str.begin(),str.end())
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define rep(i,n) for(ll  i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll M = 1e9 + 7;
ll INF = 1e18;
ll n, m;

int main() {
	// your code goes here
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll  i, j, t, k, x, y, z,  N;
	cin >> n >> x >> t;
	cout << (ll)ceil(db(n) / db(x))*t;

	return 0;
}





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

int main() {
    for(;;) {
        int n, m;
        std::cin >> n >> m;
        if (n == 0 && m == 0) {
            break;
        }
        std::vector<int> cs(m);
        for(int i = 0; i < m; ++i) {
            std::cin >> cs[i];
        }
        std::vector<int> xs(n);
        for(int i = 0; i < n; ++i) {
            std::cin >> xs[i];
        }
        long inf = 1LL << 50;
        std::vector<long> dp(256, inf);
        dp[128] = 0;
        for(int i = 0; i < n; ++i) {
            std::vector<long> dp2(256, inf);
            for(int v = 0; v < 256; ++v) {
                for(int c : cs) {
                    int new_v = std::max(0, std::min(v + c, 255));
                    long diff = new_v - xs[i];
                    dp2[new_v] = std::min(dp2[new_v], dp[v] + diff * diff);
                }
            }
            dp = dp2;
        }
        long res = inf;
        for(int v = 0; v < 256; ++v) {
            res = std::min(res, dp[v]);
        }
        printf("%ld\n", res);
    }
}



Measured memory_bytes: 3144
from heapq import heappush, heappop
from math import floor
N, M = map(int, input().split())
A = []
for a in map(int, input().split()):
    heappush(A, -a)
    
for _ in range(M):
    l = heappop(A) / 2
    
    heappush(A, l)
    
print(sum([floor(-heappop(A)) for _ in range(N)]))

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

#define fastio std::ios::sync_with_stdio(false);
#define ll long long
#define scann(n) scanf("%d",&n)
#define scand(n) scanf("%lf",&n)
#define scans(s) scanf("%s",&s)
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define full v.begin(),v.end()
#define debug cout<<"Bug! Vag! Bagh!"<<endl;
#define pi acos(-1)
#define mx 10010
#define inf 10e10

bool cmp(pair<string,ll>x,pair<string,ll>y)
{
    if(x.second==y.second) return x.first<y.first;
    else return x.second>y.second;
}

int main()
{
    ll n;
    cin>>n;
    map<string,ll>m;
    string s;
    ll x;
    for(ll i=0;i<n;i++)
    {
        cin>>s;
        m[s]++;
    }

    vector< pair<string,ll> >v;

    copy(m.begin(),m.end(),back_inserter(v));

    sort(full,cmp);

    ll flag=0;

    for(ll i=0;i<v.size();i++)
    {
        if(v[i].second>v[i+1].second)
        {
            cout<<v[i].first<<endl;
            break;
        }
        else
        {
            cout<<v[i].first<<endl;
        }
    }

    return 0;
}
///arBishal_2017331022


Measured memory_bytes: 29296
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
#define REP(i, x, y) for(ll i = x; i < y; i++)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

ll b[100010];
plglg c[100010];
ll bsum[100010];
ll mark[100010];

ll bit[1000010], n;

ll sum(int i) {
    ll s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(int i, ll x) {
    while (i <= n) {
        bit[i] += x;
        i += i & -i;
    }
}

int main() {
    ll N;
    cin >> N;
    ll a[N];
    REP(i, 0, N) {
        cin >> a[i];
    }
    if (N == 1) {
        cout << a[0] << endl;
        return 0;
    }
    ll hi = 1e9 + 1;
    ll lo = 0;
    while (hi - lo > 1) {
        ll mid = (hi + lo) / 2;
        REP(i, 0, N) {
            if (a[i] >= mid) {
                b[i] = 1;
            } else {
                b[i] = -1;
            }
        }
        bsum[0] = b[0];
        REP(i, 1, N) {
            bsum[i] = bsum[i - 1] + b[i];
        }
        REP(i, 0, N) {
            c[i] = plglg(bsum[i], i);
        }
        sort(c, c + N);
        mark[c[0].second] = 1;
        ll tmp = 1;
        REP(i, 1, N) {
            if (c[i].first != c[i - 1].first) {
                tmp++;
            }
            mark[c[i].second] = tmp;
        }
        n = tmp + 1;
        fill(bit, bit + n, 0);
        ll inv = 0;
        REP(i, 0, N) {
            inv += i - sum(mark[i]);
            add(mark[i], 1);
        }

        ll num = N * (N - 1) / 2 - inv;
        //cout << mid << " " << num << endl;
        ll pl = lower_bound(c, c + N, plglg(0, 0)) - c;
        //cout << inv << " " << pl << endl;
        if (num + (N - pl) >= (N * (N + 1) / 2 + 1) / 2) {
            lo = mid;
        } else {
            hi = mid;
        }
    }
    cout << lo << endl;
}


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

int main()
{
	int x, y;
	while(1){
		cin >> x >> y;
		if(x == 0 && y == 0){
			break;
		}
		if(x < y){
			cout << x << " " << y << endl;
		}
		else{
			cout << y << " " << x << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Main {
	public final static double MAX_T = 1000000;
	public final static double MIN_T = 0;
	public static int s = 0;
 
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
 
	static class TaskC {
 
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			char[] s = in.next().toCharArray();
			out.println((char) s[0] + "" + (s.length - 2) + "" + (char) s[s.length - 1]);
		}
 
	}
 
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
 
		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
 
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
 
		public int nextInt() {
			return Integer.parseInt(next());
		}
 
		public long nextLong() {
			return Long.parseLong(next());
		}
 
		public double nextFloat() {
			return Double.parseDouble(next());
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 100000 + 5;

int n;
int a[N << 1], p[N << 1];

int check(int x) {
	for (int i = 1; i <= 2 * n - 1; i++) a[i] = (p[i] >= x ? 1 : 0);
	int last = 1;
	for (int i = 1, j; i <= 2 * n - 1; i = j + 1) {
		j = i;
		while (j + 1 <= 2 * n - 1 && a[j + 1] == a[i]) j++;
		if (i != j) {
			if (last <= i - 1 && last <= n && n <= i - 1) {
				int len = i - 1 - last + 1;
				if (len & 1) return !a[last];
				else {
					int pos = last + len / 2 - 1;
					return n <= pos ? !a[last] : !a[i - 1];
				}
			}
			if (i <= n && n <= j) return a[i];
			last = j + 1;
		}
	}
	return a[1];
}

int main() {
	read(n);
	for (int i = 1; i <= 2 * n - 1; i++) read(p[i]);
	int l = 1, r = 2 * n - 1, ans;
	while (l <= r) {
		int m = (l + r) >> 1;
		if (check(m) == 1) {
			ans = m;
			l = m + 1;
		} else r = m - 1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1920
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int A[201],B[201],C[201];
int N;
int D[201];
int main() {
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A[i]>>B[i]>>C[i];
	}
	int M;
	for(int i=0;i<N;i++){
		M=0;
		for(int j=0;j<N;j++){
			if(A[i]==A[j]){
				M+=1;
			}
		}
		if(M==1)D[i]+=A[i];
	}
	for(int i=0;i<N;i++){
		M=0;
		for(int j=0;j<N;j++){
			if(B[i]==B[j]){
				M+=1;
			}
		}
		if(M==1)D[i]+=B[i];
	}
	for(int i=0;i<N;i++){
		M=0;
		for(int j=0;j<N;j++){
			if(C[i]==C[j]){
				M+=1;
			}
		}
		if(M==1)D[i]+=C[i];
	}

	for(int i=0;i<N;i++){
		cout<<D[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 3044
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int a[3];
    rep(i,3){
        a[i] = s[i] - 'a';
    }
    sort(a,a+3);
    
    if(a[0]+1 == a[1] && a[1]+1 == a[2]) puts("Yes");
    else puts("No");
     
}

Measured memory_bytes: 256
S = input()
code = ["A", "T", "G", "C"]
w_count = 0
count = 0
for i in range(0,len(S)):
    if S[i] in code:
        w_count = w_count + 1
    else:
        if (count <= w_count): count = w_count
        w_count = 0

if (count <= w_count): count = w_count
print(count)

Measured memory_bytes: 8972
#include <bits/stdc++.h>
using namespace std;
int a,b,c,ar,i,s=0;
int main()
{
    cin>>a>>b>>c;
    for(i=1;i<=a;i++)
    {
        cin>>ar;
        if(ar<b||ar>=c)
        s++;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
s=raw_input()
n=len(s)
a=[0]*(n+1)
for i in range(n):
	if s[i]=='<':
		a[i+1]=a[i]+1
for i in range(n-1,-1,-1):
	if s[i]=='>':
		a[i]=max(a[i+1]+1,a[i])
print sum(a)

Measured memory_bytes: 37228
use std::io;

fn read_line<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn solve_c(a: &[i32]) -> i32 {
    let med: f64 = a.iter().fold(0, |acc, x| acc + x) as f64 / a.len() as f64;
    let med = med.round() as i32;
    a.iter().fold(0, |acc, x| acc + (x - med) * (x - med))
}

fn main() {
    let _ = read_line::<i32>();
    let input = read_line::<i32>();
    println!("{}", solve_c(&input));
}


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

int main() {
  
  int N; cin >> N;
  
  vector<pair<int64_t, int64_t>> vec(N);
  
  for (int i = 0; i < N; i++) {
    
    int64_t A, B; cin >> A >> B;
    
    vec[i].first = B; vec[i].second = A;
    
  }
  
  sort(vec.begin(), vec.end());
  
  int64_t total = 0;
  
  for (int i = 0; i < N; i++) {
    
    total += vec[i].second;
    
    if (vec[i].first < total) { cout << "No" << endl; return 0; }
    
  }
  
  cout << "Yes" << endl;
  
}

Measured memory_bytes: 6400
#4から50000までの素数を見つけ出す
MAX=50001
SQRT=233

num=[True for i in range(MAX)]
def prime(num):
    num[0]=num[1]=False
    for i in range(4,MAX,2):
        num[i]=False
    for i in range(2,SQRT+1):
        if num[i]==True:
            for j in range(i*i,MAX,i):
                num[j]=False

prime(num)

prime_num=[i for i in range(MAX) if num[i]==True]
#print(len(num))
def count(num,n):
    #数える処理
    total=0
    #足していく
    for i in prime_num:
        if i>(n/2):
            break
        if num[n-i]==True:
            #print(i)
            total+=1
    return total
    

while True:
    n=int(input())
    if n==0:
        break
    print(count(num,n))



Measured memory_bytes: 6168
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

    public static final int MOD = (int) (Math.pow(10, 9) + 7);

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        Deque<Long> q = new ArrayDeque<>();
        for (int i = 1; i < n + 1; i++) {
            long a = Long.parseLong(sc.next());
            if (i % 2 != 0) {
                q.addLast(a);
            } else {
                q.addFirst(a);
            }
        }
        StringBuilder sb = new StringBuilder();
        if (n % 2 == 0) {
            for (int i = 0; i < n; i++) {
                sb.append(q.pollFirst());
                sb.append(" ");
            }
        } else {
            for (int i = 0; i < n; i++) {
                sb.append(q.pollLast());
                sb.append(" ");
            }
        }
        sb.setLength(sb.length() - 1);
        sb.append("\n");
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 73488
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        final int R = (int) 2e5 + 1;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            List<Integer> ones = new ArrayList<>();
            boolean[] ens = new boolean[R];
            for (int i = 0; i < m; ++i) {
                int x = in.nextInt();
                int y = in.nextInt();
                if (x == 1) ones.add(y);
                if (y == n) ens[x] = true;
            }
            for (int x : ones) {
                if (ens[x]) {
                    out.println("POSSIBLE");
                    return;
                }
            }
            out.println("IMPOSSIBLE");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



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

int dp[301][301][301];
bool dont[301][301][301];
short cond[301][301];
ll mod = 1e9 + 7;

// #undef DEBUG
// #define DEBUG
/// {{{ DEBUG --- ///
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { if(&o == &cerr) { o << '{'; for(size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? ", " : ""); o << "}"; } else { for(size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? " " : ""); } return o; }
#ifdef DEBUG
#define dump(...) (cerr<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<make_tuple(__VA_ARGS__)<<"\n")
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream &o, tuple<T...> const &t){ o << "("; _ot<0>(o, t); o << ")"; return o; }
#else
#define dump(...) (0)
#endif
/// }}}--- ///

void calc(int r, int g, int b, int r2, int g2, int b2) {
  if(dont[r2][g2][b2]) return;
  dp[r2][g2][b2] = ((ll) dp[r2][g2][b2] + dp[r][g][b]) % mod;
}

void calc0(int k, int r, int g, int b) {
  if(r == g) {
    if(g == b) {
      calc(r, g, b, r, g, k);
    } else {
      calc(r, g, b, g, b, k);
      calc(r, g, b, r, g, k);
    }
  } else {
    calc(r, g, b, g, b, k);
    calc(r, g, b, r, b, k);
    calc(r, g, b, r, g, k);
  }
}

int solve() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, m; cin >> n >> m;
  for(int i = 0; i < m; i++) {
    int l, r, x; cin >> l >> r >> x;
    if(cond[l][r] != 0 && cond[l][r] != x) return 0;
    cond[l][r] = x;
    for(int G = 0; G < r; G++) for(int R = 0; R <= G; R++) {
      if(G == R && R != 0) continue;
      switch(x) {
        case 1: if(G >= l) dont[R][G][r] = 1; break;
        case 2: if(R >= l || l > G) dont[R][G][r] = 1; break;
        case 3: if(l > R) dont[R][G][r] = 1; break;
      }
    }
  }
  dp[0][0][0] = 1;
  for(int k = 1; k <= n; k++) {
    int B = k - 1;
    for(int G = 0; G <= B; G++) {
      if(B == G && G != 0) continue;
      for(int R = 0; R <= G; R++) {
        if(G == R && R != 0) continue;
        calc0(k, R, G, B);
      }
    }
  }
  ll res = 0;
  for(int i = 0; i < n; i++) {
    for(int j = i; j < n; j++) {
      int t = 6;
      if(j == 0) t = 3;
      res += (ll) dp[i][j][n] * t;
    }
  }
  res %= mod;
  return res;
}

int main() {
  cout << solve() << endl;
}



Measured memory_bytes: 133376
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,i,a[1000],b[1000],cnt=0;
    cin>>n;
    for(i=0;i<n;++i){
        cin>>a[i];
    }
    for(i=0;i<n;i++){
        b[i]=a[i];
    }
    sort(b,b+n);
    for(i=0;i<n;i++){
        if(a[i]!=b[i]) cnt++;
        }
        if(cnt>2) cout<<"NO"<<endl;
        else cout<<"YES"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;

int n, m, R;
bool visited[10];
int edge[210][210];
int r[10];
int ans = INT_MAX;

void dfs(int now, int cnt, int d){
  if(cnt == R){
    ans = min(ans, d);
    return;
  }
  rep(i, R)if(!visited[i]){
    visited[i] = true;
    if(now==-1) dfs(i, cnt+1, d);
    else dfs(i, cnt+1, d+edge[r[now]][r[i]]);
    visited[i] = false;
  }
  return;
} 

int main(){
  cin >> n >> m >> R;
  rep(i, R) visited[i] = false;
  rep(i, n){
    rep(j, n) edge[i][j] = 100000000;
    edge[i][i] = 0;
  }
  rep(i, R){
    int s; cin >> s;
    r[i] = s-1;
  }
  rep(i, m){
    int a, b, c; cin >> a >> b >> c;
    edge[a-1][b-1] = edge[b-1][a-1] = c;
  }
  rep(k, n)rep(i, n)rep(j, n) edge[i][j] = min(edge[i][j], edge[i][k]+edge[k][j]);
  dfs(-1, 0, 0);
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

int add_num(std::vector<long long int> &BIT, long long int N_MAX, long long int index, long long int d);
long long int cumulative_sum(std::vector<long long int> &BIT, long long int r);

int main(){

  long long int N, D, A, tmp1, tmp2;
  std::vector<std::pair<long long int, long long int> > XH;
  scanf("%lld%lld%lld", &N, &D, &A);

  for(long long int i = 0; i < N; i++){
    scanf("%lld%lld", &tmp1, &tmp2);
    XH.push_back(std::make_pair(tmp1, tmp2));
  }

  std::sort(XH.begin(), XH.end());

  /*std::cerr << "sorted XH:" << std::endl;
  for(long long int i = 0; i < N; i++){
    std::cerr << XH[i].first << " " << XH[i].second << std::endl;
  }*/

  // solve problem
  long long int ans = 0;
  long long int kill_max = -1;

  long long int l, r, mid;
  std::vector<long long int> attack_max(N);
  for(long long int i = 0; i < N; i++){
    if(XH[i].first +2*D >= XH[N-1].first){
      attack_max[i] = N-1;
      continue;
    }

    l = i;
    r = N-1;
    while(r-l > 1){
      mid = (l+r)/2;
      if(XH[mid].first <= XH[i].first+2*D){
        l = mid;
      }
      else{
        r = mid;
      }
    }
    attack_max[i] = l;
  }

  /*std::cerr << "attack_max:" << std::endl;
  for(long long int i = 0; i < N; i++){
    std::cerr << attack_max[i] << " ";
  }std::cerr << std::endl;*/

  // prepare BIT
  long long int N_MAX = 1<<20;

  std::vector<long long int> BIT;
  for(int i = 0; i < N_MAX; i++){
    BIT.push_back(0);
  }

  // solve problem
  long long int n_attack, leftH;
  for(long long int i = 0; i < N; i++){
    // calculate left HP
    leftH = XH[i].second - cumulative_sum(BIT, i);
    // if the Monster has already passed away
    if(leftH <= 0){
      continue;
    }
    // calculate atatch number
    if(leftH%A == 0){
      n_attack = leftH/A;
    }
    else{
      n_attack = leftH/A+1;
    }



    // update answer
    ans += n_attack;
    // update BIT
    add_num(BIT, N_MAX, i, n_attack*A);
    add_num(BIT, N_MAX, attack_max[i]+1, -n_attack*A);
  }

  std::cerr << "Answer: " << std::endl;
  std::cout << ans << std::endl;



  return 0;
}

int add_num(std::vector<long long int> &BIT, long long int N_MAX, long long int index, long long int d){
  index ++;
  while(index < N_MAX){
    BIT[index-1] += d;
    index += (index & -index);
  }
  
  return 0;
}

long long int cumulative_sum(std::vector<long long int> &BIT, long long int r){
  // sum of no elements
  if(r == -1){
    return 0;
  }
  
  r++;
  long long int sum = 0;
  while(r > 0){
    sum += BIT[r-1];
    r -= (r & -r);
  }
  
  return sum;
}


Measured memory_bytes: 16236
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
typedef tree<string,null_type,less<string>,rb_tree_tag,tree_order_statistics_node_update> indexed_set2;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

int main()
{   
    ll n;
    cin>>n;
    
    vector<ll> arr(n+1);
    REP(i,0,n+1) arr[i] = i;
    REP(i,2,n + 1){
        if(arr[i] == i){
            for(ll j=2;j<=n/i;j++){
                if(arr[i*j] == i*j) arr[i*j] = i;
            }
        }
    }

    vector<ll> factors(n+1,0);
    factors[1] = 1;

    REP(i,2,n+1){
        ll p = i;
        ll c = 0;
        while(p % arr[i] == 0){
            p /= arr[i];
            c++;
        }
        factors[i] = factors[p]*(c+1);
    }

    ll ans = 0;
    REP(c,1,n){
        ans += factors[c];
    }
    cout<<ans<<endl;
    return 0;
}   
    

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

int main()
{
  string str;
  cin >> str;
  
  int cnt = 0;
  rep(i,3)
  {
    if(str[i] == 'R') cnt++;
  }
  if(cnt == 2&& str[1] == 'S') cnt = 1;
  
  cout << cnt;
  return 0;
}

Measured memory_bytes: 3628
n, k = map(int, input().split())
next = list(map(int, input().split()))
next = list(map(lambda x: x - 1, next))
c = list(map(int, input().split()))

ans = -(10 ** 17)

for i in range(n):
    now = i
    cycle_sum = 0
    cycle_len = 0

    while True:
        cycle_sum += c[now]
        cycle_len += 1
        now = next[now]
        if now == i:
            break

    sum = 0
    cnt = 0

    while True:
        sum += c[now]
        cnt += 1

        if cnt > k:
            break

        laps = (k - cnt) // cycle_len
        score = sum + max(0, cycle_sum) * laps
        ans = max(ans, score)

        now = next[now]
        if now == i:
            break

print(ans)

Measured memory_bytes: 73668
N = io.read()
a = {}
for i=1,N do
  table.insert(a, tonumber(io.read("*n")))
end

result = 0

for i=1,N do
  while a[i]&0x01 == 0 do
    a[i] = a[i] / 2
    result = result + 1
  end
end

print(string.format("%d",result))


Measured memory_bytes: 1388
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n;
int a[100001];

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    int odd = 0;
    int b2 = 0;
    int b4 = 0;
    for(int i=0;i<n;i++){
        if(a[i] % 4 == 0) b4++;
        else if(a[i] % 2 == 0) b2++;
        else odd++;
    }
    if(b2 <= 0){
        if(b4 >= odd - 1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else{
        if(b4 >= odd) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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

void insertionSort(int A[], int N, int g, int *cnt)
{   
    for (int i = g; i < N; i++)
    {
        int v = A[i];
        int j = i - g;

        while (j >= 0 && A[j] > v)
        {
            A[j+g] = A[j];
            j -= g;
            (*cnt)++;
        }
        A[j+g] = v;
    }
}

void shellSort(int A[], int N)
{
    int cnt = 0;
    int m   = 1;

    int temp = 1;
    while(1)
    {
        temp = 3 * temp + 1;
        if (temp >= N) break;
        m++;
    }

    int *G = new int[m];
    G[m-1] = 1;
    for (int i = m-2; i >= 0; i--) G[i] = 3 * G[i+1] + 1;

    for (int i = 0; i < m; i++) insertionSort(A, N, G[i], &cnt);

    std::cout << m << std::endl;
    for (int i = 0; i < m; i++)
    {
        std::cout << G[i];

        if (i < m-1) std::cout << " ";
        else         std::cout << std::endl;
    }
    std::cout << cnt << std::endl;
    for (int i = 0; i < N; i++) std::cout << A[i] << std::endl;
}

int main()
{
    int num;
    std::cin >> num;

    int *element = new int[num];

    for (int i = 0; i < num; i++) std::cin >> element[i];

    shellSort(element, num);
}


Measured memory_bytes: 7000
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	int ans=(b-1)/(a-1);
	if((b-1)%(a-1)!=0)
		ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
output=[]
for i in range(1, N):
	L = list(S[0:i])
	R = list(S[i:N])
	temp=[]
	for j in L:
		if j in R and not j in temp:
			temp.append(j)
	output.append(len(temp))
print(max(output))


Measured memory_bytes: 3060
N = int(input())
H = list(map(int, input().split()))
 
next_num = 10**9
result = True
for i in reversed(H):
    if i > next_num:
        i -= 1
        if i > next_num:
            result = False
    next_num = i

if result:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 63856
n = int(input())
s = ""
ac=0
wa=0
tle=0
re=0

for i in range(n):
    s = input()

    if s == 'AC':
        ac = ac+1
    elif s == 'TLE':
        tle = tle+1
    elif s == 'WA':
        wa = wa+1
    elif s == 'RE':
        re = re+1

print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

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

int main(){
	string a,b;
	cin >> a >> b;
	for(int i = 0;i < a.length() + b.length();i++){
		if(i % 2) cout << b[i / 2];
		else cout << a[i / 2];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
abc = [[int(i) for i in input().split()] for j in range(N)]
dp = [abc[0]]  # On the first day, Taro chooses [A, B, C]
for i in range(1, N):
    ith_day = [
        max(dp[-1][1], dp[-1][2]) + abc[i][0],
        max(dp[-1][2], dp[-1][0]) + abc[i][1],
        max(dp[-1][0], dp[-1][1]) + abc[i][2],
    ]
    dp.append(ith_day)
print(max(dp[-1]))


Measured memory_bytes: 44148
n, m = map(int, input().split())

arr = [[] for _ in range(n)] 

p = [0] * m
y = [0] * m

for i in range(m):
    p[i], y[i] = map(int, input().split())
    arr[p[i]-1].append(y[i])    

for i in range(n):
    arr[i].sort()

import bisect
for i in range(m):
    num = bisect.bisect_left(arr[p[i]-1], y[i]) + 1
    a = str(p[i])
    b = str(num)
    print(a.zfill(6) + b.zfill(6))


Measured memory_bytes: 26992
# -*- coding: utf-8 -*-
# 整数の入力
from functools import reduce


def main():
    # a, b
    n = int(input())
    a = map(int, input().split())
    print(process(n, a))


def process(n, a):
    a = map((lambda x: 1 / x), a)
    asum = reduce((lambda x, y: x + y), a)
    return 1 / asum


if __name__ == "__main__":
    main()


Measured memory_bytes: 3700
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

const ll MOD = 1e9+7;
const int N = 2010;
vector<vector<ll>> C(N + 1, vector<ll>(N + 1, 0));
void pre(){
    C[0][0] = 1;
    for(int n = 1; n <= N; ++n){
        C[n][0] = C[n][n] = 1;
        for(int k = 1; k < n; ++k){
            C[n][k] = (C[n - 1][k - 1] + C[n - 1][k]) % MOD;
        }
    }
}
void solve(){
    pre();
    ll n;
    cin >> n;
    ll ans = 0;
    ll up = n/3;
    for(int k = 1; k <= up; ++k){
        ans = (ans + C[n - 2 * k - 1][n - 3 * k]) % MOD;
    }
    cout << ans << endl;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


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

int main() {
    int one_digit, two_digit, three_digit, four_digit;
    int N;

    cin >> N;

    four_digit = N / 1000;
    N %= 1000;
    three_digit = N / 100;
    N %= 100;
    two_digit = N / 10;
    N %= 10;
    one_digit = N;

    if( ( ( four_digit == three_digit ) && ( three_digit == two_digit ) ) ||
        ( ( three_digit == two_digit ) && ( two_digit == one_digit ) ) ){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <string> vs;

const int INF = (int) 1E9 + 5;
const ll LINF = (ll) 4E18 + 5;


#define F first
#define S second
#define si size()
#define le length()
#define be begin()
#define en end()
#define mp make_pair
#define mt make_tupple

#define forz(i,n) for(int i=(0);i<(n);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define rforz(i,n) for(int i=(n-1);i>=(0);i++)
#define rfore(i,a,b) for(int i=(a);i>=(b);i--)
	

#define pb push_back
#define pof pop_front
#define pf push_front
#define pob pop_back

#define Mod 1000000007

#define ALL(v) (v).begin(), (v).end()
#define SET(a, x) memset((a), (x), sizeof(a))

#define SORT(x) sort(ALL(x))
#define GSORT(x) sort(ALL(x), greater<typeof(*((x).begin()))>())

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

#define endl "\n"
#define o0(a) cout<<a<<" "
#define o1(a) cout<<a<<endl
#define o2(a,b) cout<<a<<" "<<b<<endl

#define test int t; cin>>t; while(t--)

#define mod(a) max(a,-a)

template<typename T> T gcd(T a, T b) { return (b == 0) ? abs(a) : gcd(b, a % b); }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }

/*calling template
cout<<gcd<int>(2,5);
cout<<gcd<ll>(234,5432);*/



int main(){
	FASTIO;
	
	int n;
	cin>>n;
	int  a= n%10;
	string s{};
	if(a==2||a==4||a==5||a==7||a==9){s+="hon";}
	else if(a==0||a==1||a==6||a==8){s+="pon";}
	else{s+="bon";}
	cout<<s<<'\n';
	return 0;
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.OptionalInt;
import java.util.regex.Pattern;
import java.util.stream.Stream;

public class Main {
  public static void main(String[] args) {

    new Main().run();
  }

  public void run() {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String line = br.readLine();
      final Pattern delim = Pattern.compile(" ");
      int[] arrayS = delim
        .splitAsStream(line)
        .mapToInt(Integer::parseInt)
        .toArray();

      OptionalInt max =
        Arrays.stream(arrayS).max();

      dispIntArray( countingSort(arrayS, max.getAsInt()) );
    }
    catch ( IOException e ) {
      System.out.println("IOException!");
    }

  }

  public int[] countingSort(int[] a, int k) {

    int   aLength = a.length;
    int[] result  = new int[aLength];
    int[] counter = new int[k+1];

    for (int var : a) {
      counter[var]++;
    }

    for (int i=1, max=k+1; i < max; i++) {
      counter[i] += counter[i-1];
    }

    for (int i=aLength-1, val=0; i>=0; i--) {
      val = a[i];
      result[counter[val]-1] = val;
      counter[val]--;
    }

    return result;
  }

  public void dispIntArray(int[] target) {
    StringBuilder s = new StringBuilder();

    for (int i : target) { s.append(i).append(" "); }
    s.setLength(s.length()-1);

    System.out.println(s);
  }
}


Measured memory_bytes: 182084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  // 変数aで入力を受け取る
  cin >> A;
  cin >> B;
  int sum = 1;
  int count =0;

  //cout << B;

  for(int i =0;true;i++){
      sum = sum + A-1;
      //cout << i;
      if(sum >= B){
          //cout << sum;
          count = i;
          break;
      }
  }
  if(B == 1){
      cout << 0 << endl;
  }else{
      cout << count+1 << endl;
  }
}

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

int S(int64_t N) {
	int ans = 0;
	for (int i = 9;i >= 0;--i) {
		ans += N / (int64_t)pow(10, i);
		N %= (int64_t)pow(10, i);
	}
	return ans;
}

int main(){
	int64_t N;
	cin >> N;
	cout << (N % S(N) == 0 ? "Yes" : "No") << endl;
	return 0;
}

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

// isDebug?
#ifndef ONLINE_JUDGE
#define _DEBUG
#endif

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// -* https://xn--kst.jp/blog/2019/08/29/cpp-comp/ *- Thx :)
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    cout << __FILE__ << ": " << __LINE__ << ": " << __func__ << " -> ";   \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

// namespace / type / class / struct - alias, def:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;
const int FACN = 510000;

// Global Variables:
// ll fac[FACN], finv[FACN], inv[FACN];

// Prototype Declarations:
int gcd(int, int);
int lcm(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    string n;
    cin >> n;
    int ans = 0;
    rep(i, n.size()) {
        ans += n[i] - '0';
        ans %= 9;
    }

    if(ans) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}
// ===========================================

// Functions:
// 最大公約数 O(log(min(a, b)))
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
// 最小公倍数 O(log(min(a, b)))
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

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


Measured memory_bytes: 3744
N=int(input())
a=[int(t.strip()) for t in input().split()]
cnt=0
p=[[0 for i in range(2)] for j in range(2*N)]

if min(a) >= 0:#正数のみ
	for i in range(N-1):
		if a[i] > a[i+1]:
			#print(i+1,i+2)
			p[cnt][0]=i+1
			p[cnt][1]=i+2
			
			a[i+1] += a[i]
			cnt+=1
elif max(a)<0:#非自然数のみ
	for i in reversed(range(1,N)):
		if a[i] < a[i-1]:
			a[i-1] += a[i]
			#print(i+1,i)
			p[cnt][0]=i+1
			p[cnt][1]=i
			cnt+=1
else:#負も正も混同
	if max(a) > min(a)*-1:
		tmp=max(a)
		ind = a.index(max(a))
		for i in range(N):
			a[i] +=tmp
			#print(ind+1,i+1)
			p[cnt][0]=ind+1
			p[cnt][1]=i+1
			cnt+=1
		for i in range(N-1):
			if a[i] > a[i+1]:
				#print(i+1,i+2)
				p[cnt][0]=i+1
				p[cnt][1]=i+2
				cnt+=1
				a[i+1] += a[i]
	else:
		tmp=min(a)
		ind = a.index(min(a))
		for i in range(N):
			a[i] +=tmp
			#print(ind+1,i+1)
			p[cnt][0]=ind+1
			p[cnt][1]=i+1
			cnt+=1
		for i in reversed(range(1,N)):
			if a[i] < a[i-1]:
				a[i-1] += a[i]
				#print(i+1,i)
				p[cnt][0]=i+1
				p[cnt][1]=i
				cnt+=1

print(cnt)
for i in range(cnt):
	print(p[i][0],p[i][1])
#print(a)

Measured memory_bytes: 3192
N,M = map(int,input().split())
A = [[] for i in range(N)]
for i in range(N):
    A[i] = list(map(int,input().split()))
B = [[0]*1 for i in range(M)] 
for i in range(M):
    B[i] = int(input()) 
for row in range(N):
    tmp = 0
    for col in range(M):
        tmp += A[row][col]*B[col]
    print("%d"%(tmp))


Measured memory_bytes: 6020
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
  static void Main()
  {
    List<int> input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).Distinct().ToList();
    var count = input.Where(x => x == 1 || x == 9 || x == 7 || x == 4).Count();
    if (count == 4) Console.WriteLine("YES");
    else Console.WriteLine("NO");
  }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define INF 10000000000000009
#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N;
    double Ave=0;
    int Ans=0;
    int A[104];
    cin >> N;
    REP(i,N){
        cin >> A[i];
        Ave+=A[i];
    }
    Ave/=N;
    REP(i,N){
        if(abs(A[i]-Ave)<abs(A[Ans]-Ave)){
            Ans=i;
        }
    }
    cout << Ans << endl;
    return 0;
}   


Measured memory_bytes: 764
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var X = Sarray()[0];
            var expo = new bool[X + 1];
            expo[1] = true;
            for (var b = 2; b <= X; b++)
            {
                var v = b * b;
                while(v<=X)
                {
                    expo[v] = true;
                    v *= b;
                }
            }
            for(var i=X;i>=1;i--)
            {
                if(expo[i])
                {
                    WriteLine(i);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 13268