akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};



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

    ll n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> ans(n);
    rep(i,n){
        if(i%2 == 0) ans[0] += a[i];
        else ans[0] -= a[i];
    }
    ans[0] /= 2;
    rep(i,n-1){
        ans[i+1] = a[i] - ans[i];
    }
    rep(i,n) cout << 2*ans[i] << " ";
    cout << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)

const int N = 5e5+5;

int col[N], cnt[N], res[N];
int ans = 0, BLK;

class Query{
    public:
    int L, R, id;

    Query(int L, int R, int id) : L(L), R(R), id(id) {

    }

    bool operator < (const Query& other) const {
        if(L / BLK == other.L / BLK)
            return (L / BLK % 2) ? R < other.R : R > other.R;
        return L / BLK < other.L / BLK;
    }
};

void add(int cur){
    cnt[col[cur]]++;
    if(cnt[col[cur]] == 1)
        ans++;
}

void rem(int cur){
    cnt[col[cur]]--;
    if(cnt[col[cur]] == 0)
        ans--;
}

void solve(){
    
    int n, q; cin >> n >> q;
    for(int i = 1; i <= n; i++){ cin >> col[i]; }
    vector< Query > query;
    for(int i = 0; i < q; i++){
        int L, R; cin >> L >> R;
        query.eb(L, R, i);
    }
  	BLK = (int)sqrt(n) + 3;
    sort(all(query));
    memset(cnt, 0, sizeof(cnt));
    int curL = 1, curR = 0;
    for(Query q : query){
        int L = q.L, R = q.R;
        while(curR < R){
            curR++;
            add(curR);
        }
        while(curR > R){
            rem(curR);
            curR--;
        }
        while(curL < L){
            rem(curL);
            curL++;
        }
        while(curL > L){
            curL--;
            add(curL);
        }
        res[q.id] = ans;
    }
    for(int i = 0; i < q; i++){ cout << res[i] << '\n'; }
    
}


int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    boost;

    int t = 1;
    // cin >> t;


    for(int i = 1; i <= t; i++){
        // cout << "Case #" << i << ": ";

        solve();

    }
    return 0;
}

Measured memory_bytes: 15624
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	long long int n,d;
	scanf("%lld %lld",&n,&d);
	long long int m=2*d+1,cnt=1,a=m;
	while(1)
        {
		if(m>=n){
			break;
		}
		m+=a;
		cnt++;
	}
	printf("%lld\n",cnt);
	return 0;
}


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

using namespace std;

typedef long long ll;
const int MAX = 100005;
const int MOD = 1000000007;

#define F first
#define S second

void solve()
{
	ll n;
	cin>>n;
	string str;
	cin>>str;
	set<ll> st[26];
	for(int i=0;i<26;i++)
	{
		st[i].clear();
		st[i].insert(n);
	}
	for(int i=0;i<n;i++)
	{
		st[str[i]-'a'].insert(i);
	}
	ll q;
	cin>>q;
	for(int i=0;i<q;i++)
	{
		ll x;
		cin>>x;
		if(x==1)
		{
			ll idx;
			char c;
			cin>>idx>>c;
			idx--;
			st[str[idx]-'a'].erase(idx);
			str[idx]=c;
			st[str[idx]-'a'].insert(idx);
			
		}
		else
		{
			ll l,r;
			cin>>l>>r;
			l--,r--;
			ll ans=0;
			//set<ll>::iterator low;
			for(int i=0;i<26;i++)
			{
				//auto low;
				auto low=st[i].lower_bound(l);
				if(*low<=r)
					ans+=1;
			}
			cout<<ans<<endl;
		}
	}
	return;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 26268
package main

import "fmt"

func main() {
	var W, H, x, y, r int
	fmt.Scan(&W)
	fmt.Scan(&H)
	fmt.Scan(&x)
	fmt.Scan(&y)
	fmt.Scan(&r)

	if 0 <= (x-r) && (x+r) <= W && 0 <= (y-r) && (y+r) <= H {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}



Measured memory_bytes: 1148
import itertools
import functools
import operator
pi = functools.partial(functools.reduce, operator.mul)


def solve():
    N = int(input())
    d = [int(x) for x in input().split()]
    ans = 0
    for c in itertools.combinations(d, 2):
        # print(c)
        ans += pi(c)
    print(ans)


if __name__ == "__main__":
    solve()

Measured memory_bytes: 68112
#include<bits/stdc++.h>  
using namespace std;  
int father[100500];  
int dis[100500];  
int find_father(int x) {  
    if(father[x]==x)return x;  
    int a1=father[x];  
    int a2=find_father(father[x]);  
    father[x]=a2;  
    dis[x]=dis[x]+dis[a1];  
    return a2;  
}  
int find_dis(int x) {  
    if(father[x]==x)return 0;  
    return find_dis(father[x])+dis[x];  
}  
int main(void) {  
    int num,cas,L,R,D;  
    cin>>num>>cas;  
    for(int i=0; i<=num; i++) {  
        father[i]=i;  
        dis[i]=0;  
    }  
    while(cas--) {  
        cin>>L>>R>>D;  
        int fl=find_father(L);  
        int fr=find_father(R);  
        if(fl==fr) {  
            if(dis[L]+D!=dis[R]) {  
                cout<<"No"<<endl;  
                return 0;  
            }  
        } else {  
            father[fr]=fl;  
            dis[fr]=find_dis(L)-find_dis(R)+D;  
        }  
    }  
    cout<<"Yes"<<endl;  
    return 0;  
}  

Measured memory_bytes: 1024
/*---------------Go Code GO---------------*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using Order_Set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
//(order) Set.order_of_key(); (pointer) Set.find_by_order();

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff


long long Frq[200005], Arr[200005];

int main()
{
    long long i,j,k,l,tst=0,ans=0, csno=0, N,M;
    cin>>N;
    for(i=0; i<N; i++)
    {
        cin>>Arr[i];
        Frq[Arr[i]]++;
    }
    for(i=1; i<=N; i++)
    {
        ans+=(Frq[i]*(Frq[i]-1))/2;
    }
    for(i=0; i<N; i++)
    {
        k = ans-Frq[Arr[i]]+1;
        cout<<k<<endl;

    }




    return 0;
}



Measured memory_bytes: 4736
N, K = map(int, input().split())
A = list(map(int, input().split()))

# 1の場所を探す
pos = A.index(1)

count = 0
num_forward = pos  # 前方の残り数
num_backward = N - pos - 1  # 後方の残り数

# 前方にX回試行したときに負の余りが生じる場合は後方に回す
rest = num_forward % -(K - 1)
num_backward += rest

while num_forward > 0:  # 先頭まで1にする
    num_forward -= K - 1
    count += 1
while num_backward > 0:  # 末尾まで1にする
    num_backward -= K - 1
    count += 1
print(count)


Measured memory_bytes: 13880
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int dansuu = 1;
  
  int N;
  cin >> N;
  
  
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    
    cin >> d.at(i);
    
  }
  
  sort(d.begin(), d.end());
  
 
  
  int a =  d.at(0);
  
  for (int i = 0; i < N; i++){
    
    if (a != d.at(i)) {
      
      dansuu++;
      
      a = d.at(i);
      
    } else if (a == d.at(i)) {
      
      continue;
      
    }
    
  }
  cout << dansuu << endl;
  
}

Measured memory_bytes: 3632
use std::io::*;
use std::str::*;

pub fn read_from<T: FromStr, R: Read>(s: &mut R) -> T {
    let s = s.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    if !s.is_empty() {
        if let Ok(s) = s.parse::<T>() {
            s
        } else {
            panic!("faild to parse {}", s);
        }
    } else {
        println!("reached to EOF");
        std::process::exit(0)
    }
}

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    read_from(&mut stdin)
}

pub fn readn<T: FromStr>(n: usize) -> Vec<T> {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    (0..n).map(|_| read_from(&mut stdin)).collect()
}
    
fn main() {
    let a: i32 = read();
    let b: i32 = read();
    println!("{}", (a-1)*(b-1));
}


Measured memory_bytes: 4352
import java.net.StandardSocketOptions;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;

import org.omg.Messaging.SyncScopeHelper;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new Test_300().doIt();
	}
	class Test_300{
		void doIt() {
			int N = sc.nextInt();
			long K = sc.nextLong();
			long A[] = new long[100002];
			for(int i = 0;i < N;i++) {
				int a = sc.nextInt();
				long b = sc.nextLong();
				A[a] = A[a] + b;
			}
			long cnt = 0;
			for(int i = 0;i < 100002;i++) {
				cnt = cnt + A[i];
				if(cnt >= K) {
					System.out.println(i);
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 84264
#include <iostream>

using namespace std;

int main() {
	int data[100];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> data[i];
	for (int i = 0; i < n; i++) {
		cout << data[i];
		if (i == (n - 1)) cout << endl;
		else cout << " ";
	}
	for (int i = 1; i < n; i++) {
		int key = data[i];
		int j = i - 1;
		for (; j >= 0; j--) {
			if (data[j] >= key) {
				data[j + 1] = data[j];
			}
			else break;
		}

		data[j + 1] = key;

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


	return 0;
}


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

struct Edge{
    int to; // 辺の行先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t),weight(w){}
};

using Graph = vector<vector<Edge>>;
vector<int> color;

void dfs(const Graph &G, int v,long long weight){
    color[v] = weight % 2;
    for( auto next_v : G[v]){
        if(color[next_v.to] == -1){
            dfs(G,next_v.to,weight + next_v.weight);
        }
    }
}

int main(){
    int N;
    cin >> N;
    Graph G(N+1);
    for(int i = 0; i < N - 1; i++){
        int from, to, weight;
        cin >> from >> to >> weight;
        G[from].push_back(Edge(to,weight));
        G[to].push_back(Edge(from,weight));
    }   

    color.assign(N + 1,-1);
    for(int v = 1; v <= N; v++){
        if(color[v] != -1) continue;
        dfs(G,v,0);
    }

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


}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define LL long long
LL A,B,C,D;
LL Calc(LL x) {
	LL s = x;
	s -= x/C;
	s -= x/D;
	s += x/(C/__gcd(C,D) * D);
	return s;
}
int main () {
	cin >> A >> B >> C >> D;
	cout<<Calc(B) - Calc(A-1);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define modp(x) ((x)%modn)
using namespace std;
const int maxn=100005;
int f[maxn],a[maxn];
int n;
int main()
{
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",a+i);
	rep(i,2,n) 
	{
		if(i==2) f[i]=abs(a[i]-a[i-1]);
		else f[i]=min(f[i-1]+abs(a[i]-a[i-1]),f[i-2]+abs(a[i-2]-a[i]));
	}
	printf("%d",f[n]);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main() {

	string s;

	cin >> s;

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

		if (s.at(i) == s.at(i + 1)) {

			cout << "Bad" << endl;
			break;
		}
	}

		if (s.at(0) != s.at(1) && s.at(1) != s.at(2) && s.at(2) != s.at(3)) {

			cout << "Good" << endl;
		}

	

	return 0;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;
ll n;
int dfs(int seven=0, int five=0, int three=0, ll cur=0) {
  if(cur > n) return 0;
  int res = 0;
  if(seven > 0 && five > 0 && three > 0) res++;
  res += dfs(seven + 1, five, three, cur * 10 + 7);
  res += dfs(seven, five + 1, three, cur * 10 + 5);
  res += dfs(seven, five, three + 1, cur * 10 + 3);
  return res;
}

int main() {
  cin >> n;
  int ans = dfs();
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int N, X, m[110], sum = 0, min = 10000000, A;

	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		cin >> m[i];
		sum += m[i];
		if (min > m[i]) {
			min = m[i];
		}
	}
	A = N + (X - sum) / min;
	cout << A << endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a=0,b=0,c;
  for(int i=0;i<4;i++)cin>>c,a+=c;
  for(int i=0;i<4;i++)cin>>c,b+=c;
  cout<<(a<b?b:a)<<endl;
  return 0;
}

Measured memory_bytes: 1164
import sys

inf = 1 << 32

def solve():
    N, W = map(int, input().split())
    ws = []
    vs = []

    for i in range(N):
        wi, vi = map(int, input().split())
        ws.append(wi)
        vs.append(vi)

    dp = [[[-inf]*(3*N + 1) for j in range(N + 1)]
                              for i in range(N + 1)]

    dp[0][0][0] = 0

    for i in range(N):
        for j in range(N + 1):
            for k in range(3*N + 1):
                dp[i + 1][j][k] = dp[i][j][k]

                if j - 1 >= 0 and k - (ws[i] - ws[0]) >= 0:
                    dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j - 1][k - (ws[i] - ws[0])] + vs[i])

    ans = 0

    for j in range(N + 1):
        for k in range(3*N + 1):
            if ws[0]*j + k <= W:
                ans = max(ans, dp[N][j][k])

    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 68060
#include <bits/stdc++.h>
using namespace std;
#define LEFTHAND  0;
#define RIGHTHAND 1;

string s;
string leftkey  = "qwertasdfgzxcvb";

int leftOrRight(int index){
  for(int i=0; i < leftkey.size(); i++){
    if(leftkey[i] == s[index]) return LEFTHAND;
  }
  return RIGHTHAND;
}

int main(void){
  while(cin >> s, s[0] != '#'){
    int change = 0;
    int previous = leftOrRight(0);
    for(int i=1; i < s.length(); i++){
      int now = leftOrRight(i);
      if(previous == now){
      }else{
	change++;
      }
      previous = now;
    }
    cout << change << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
typedef long long ll;

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5+1;


void solve()
{
  ll n,k;
  cin>>n>>k;
  ll a[n];
  for(int i=0;i<n;i++)
  {
        cin>>a[i];  
  }
  
  sort(a,a+n);
  ll sum = 0;
  for(int i=0;i<k;i++)
  {
          sum+=a[i];
  }
  cout<<sum;
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a5=0,a7=0,a,b,c;
	cin>>a>>b>>c;
	if(a==5)a5++;
	if(a==7)a7++;
	
	if(b==5)a5++;
	if(b==7)a7++;
	
	if(c==5)a5++;
	if(c==7)a7++;
	
	if(a5==2&&a7==1)printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
long long ans,dp[110][N],val,w,n,W;

int main(){
  scanf("%lld%lld",&n,&W);
  for(int i = 0; i < 110; ++i)for(int j = 0; j < N; ++j)dp[i][j] = LLONG_MAX/4LL;
  dp[0][0] = 0;
  for(int i = 1; i <= n; ++i){
  	scanf("%lld%lld",&w,&val);
    for(int j = 0; j <= N; ++j){
    	dp[i][j] = dp[i-1][j];
        if(j >= val)dp[i][j] = min(dp[i][j],dp[i-1][j-val]+w);
    }
  }
  for(int i = 0; i < N; ++i)if(dp[n][i] <= W)ans=i;
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 86144
import java.io.{BufferedReader, IOException, InputStream, InputStreamReader}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{min, max, abs}

object Main {
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    val S = sc.next

    sealed trait Part
    case class Left(v: Int) extends Part
    case class Right(v: Int) extends Part
    case class Pair(l: Int, r: Int)

    def step(cs: List[Char], pre: Char, cnt: Int, acc: List[Part]): List[Part] = {
      def mkPart = pre match {
        case '(' => Left(cnt)
        case ')' => Right(cnt)
      }

      cs match {
        case Nil => mkPart :: acc
        case c :: remain =>
          c match {
            case `pre` => step(remain, c, cnt + 1, acc)
            case _ => step(remain, c,1, mkPart :: acc)
          }
      }
    }

    val parts = step(S.drop(1).toCharArray.toList, S.charAt(0), 1, Nil).reverse

    def step1(ps: List[Part], left: Option[Left], acc: List[Pair]): List[Pair] = ps match {
      case Nil => left match {
        case None => acc
        case Some(Left(l)) => Pair(l, 0) :: acc
      }
      case Right(r) :: remain =>
        val l = left.map(_.v) getOrElse 0
        step1(remain, None, Pair(l, r) :: acc)

      case (l: Left) :: remain =>
        step1(remain, Some(l), acc)

    }

    val pairs = step1(parts, None, Nil).reverse

    var r = 0 // )の数
    var l = 0 // (の数
    pairs foreach { p =>
      if (p.l > p.r) {
        l += p.l - p.r
      } else if (p.r > p.l) {
        val r0 = p.r - p.l
        if (r0 > l) {
          r += r0 - l
          l = 0
        } else {
          l -= r0
        }
      }
    }
    println("(" * r + S + ")" * l)
  }

  def main(args: Array[String]): Unit = {
    solve()
  }



  class InputReader(val stream: InputStream) {
    val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}


Measured memory_bytes: 25540
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }



int main(){
  int a,b;
  char op;
  cin >> a >> op >> b;
  int ans;
  if(op == '+')ans = a + b;
  else ans = a -b;
  cout << ans << endl;
}


Measured memory_bytes: 256
import math
def g(a,b,c):
    ans=math.gcd(a,b)
    p=math.gcd(ans,c)
    return p
n=int(input())
sum=0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            sum=sum+g(i,j,k)
print(sum)


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

vector<ll> z_algorithm(const string &s) {
  vector<ll> prefix(s.size());
  for (ll i = 1, j = 0; i < s.size(); i++) {
    if (i + prefix[i - j] < j + prefix[j]) {
      prefix[i] = prefix[i - j];
    } else {
      ll k = max(0LL, j + prefix[j] - i);
      while (i + k < s.size() && s[k] == s[i + k]) ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (ll)s.size();
  return prefix;
}
int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll N;
  scanf("%lld", &N);

  string s;
  cin >> s;

  ll ans = 0;

  for (ll i = 0; i < s.size() - 1; i++) {
    // cout << "# " << i << endl;
    auto pre = z_algorithm(s.substr(i));
    // for (ll i = 0; i < pre.size(); i++) {
    //   cout << pre[i] << endl;
    // }

    for (ll i = 1; i < pre.size(); i++) {
      ll tmp = min(i, pre[i]);
      ans = max(ans, tmp);
    }
  }

  // cout << "----" << endl;
  cout << ans << endl;
}


Measured memory_bytes: 256
n,x=map(int,input().split())
a=list(map(int,input().split()))
cnt=0
for i in range(n-1):
    if a[i]+a[i+1]>x:
        cnt+=a[i+1]-max(x-a[i],0)
        a[i+1]=max(x-a[i],0)
        if a[i+1]==0 and a[i]>x:
            cnt+=a[i]-x
            a[i]=x
print(cnt)


Measured memory_bytes: 14052
// Problem : C - GCD on Blackboard
// Contest : AtCoder - AtCoder Beginner Contest 125
// URL : https://atcoder.jp/contests/abc125/tasks/abc125_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define XOX
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define int long long
#define re return
#define beg() begin()
#define cont continue
#define ldb long double
#define db double

#define br break
#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mkp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>

#define si set<int>
#define sdb set<db>
#define sldb set<ldb>

#define test int t; cin>>t; while(t--)
#define scan() int n; cin>>n; int a[n]; for(int i=0;i<n;i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k; int a[n]; for(int i=0;i<n;i++) cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define srt(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define cn(x) cout<<x<<"\n"
#define cs(x) cout<<x<<" "
#define c(x) cout<<x
#define all(v) v.begin(),v.end()

#define forr(i,a,b) for (int i = (a); i < (b); ++i)
#define rrof(i,a,b) for (int i = (b)-1; i >= (a); --i)


const int MOD = 1e9+7;
const ldb PI = 4*atan((ldb)1);
const int INF = 1e18;
const int NINF = -1e18;

int get_hash(string s){
	int N=1000001;
	int base[N],A=11,MD=1110111110111;
	base[0]=1;

	forr(i,1,N)
	base[i]=(base[i-1]*A)%MD;

	int hs=0;
	forr(i,0,s.size()){
		hs+=(s[i]*base[i]);
		hs%=MD;
	}

	re hs;
}

int power(int a,int n){
	int res=1;

	while(n){
		if(n%2)
		res*=a;
		a*=a;
		n/=2;
	}

	return res;
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
	vector<string> __attribute__ ((unused)) args,
	__attribute__ ((unused)) int idx,
	__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
	template <typename Head, typename... Tail>
	void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif


int32_t main(){
	fast;
	
	int n;
	cin>>n;
	
	int a[n];
	forr(i,0,n)
	cin>>a[i];
	
	int pref[n+2]={0},suff[n+2]={0};
	forr(i,0,n)
	pref[i+1]=__gcd(pref[i],a[i]);
	
	rrof(i,0,n)
	suff[i+1]=__gcd(suff[i+2],a[i]);
	
	int maxa=0;
	forr(i,1,n+1){
		int x=__gcd(pref[i-1],suff[i+1]);
		
		if(x>maxa)
		maxa=x;
	}
	
	cout<<maxa;
	re 0;
}

Measured memory_bytes: 2560
n = int(input())
a = list(map(int,input().split()))
cnt4 = cnt2 = 0
for i in a:
    if i % 4 == 0:
        cnt4 += 1
    elif i % 2 == 0:
        cnt2 += 1
if cnt4 >= n//2:
    print('Yes')
elif cnt2 >= n-cnt4*2:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	unordered_map<int,int> m;
	for(int i=0;i<k;i++)
	{
		int d;
		cin>>d;
		
		for(int i=0;i<d;i++)
		{
			int v;
			cin>>v;
			m[v]=1;
		}
		
	}
	
	int ans=n-m.size();
	cout<<ans;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <vector>

using namespace std;

int x[100000];
int a[100000];

vector <int> mul(vector <int> &v, vector <int> &w) {
    int i;
    vector <int> z(v.size());
    
    for (i = 0; i < v.size(); i++) z[i] = w[v[i]];
    
    return z;
}

vector <int> pow(vector <int> &v, long long k) {
    int i;
    vector <int> ans;
    
    for (i = 0; i < v.size(); i++) ans.push_back(i);
    
    while (k > 0) {
        if (k & 1) ans = mul(ans, v);
        
        v = mul(v, v);
        k >>= 1;
    }
    
    return ans;
}

int main() {
    int n, m, i;
    long long k, sum;
    vector <int> v;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%d", &x[i]);
    
    scanf("%d %lld", &m, &k);
    
    for (i = 0; i < m; i++) scanf("%d", &a[i]);
    
    for (i = 0; i < n - 1; i++) v.push_back(i);
    
    for (i = 0; i < m; i++) {
        a[i] -= 2;
        
        swap(v[a[i]], v[a[i] + 1]);
    }
    
    v = pow(v, k);
    
    sum = x[0];
    
    printf("%lld\n", sum);
    
    for (i = 0; i < n - 1; i++) {
        sum += x[v[i] + 1] - x[v[i]];
        
        printf("%lld\n", sum);
    }
    
    return 0;
}


Measured memory_bytes: 3168
#include<stdio.h>
int main()
{
int n,i,a[3];
scanf("%d",&n);
for(i=0;i<n;i++)
{
 scanf("%d%d%d",&a[0],&a[1],&a[2]);
 if(a[0]*a[0]+a[1]*a[1] == a[2]*a[2]|| a[0]*a[0]+a[2]*a[2] == a[1]*a[1] || a[2]*a[2]+a[1]*a[1] == a[0]*a[0])
 printf("YES\n");
 else
 printf("NO\n");
}
return 0;
 }


Measured memory_bytes: 1928
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

static const unsigned long long int MOD = 1000000007LL;

//ユークリッドの互除法
unsigned gcd(unsigned a, unsigned b)
{
    if (a < b)
    {
        gcd(b, a);
    }

    unsigned r;

    while ((r = a % b))
    {
        a = b;
        b = r;
    }

    return b;
}

int main()
{
    pair<int, int> p[200001];
    int n;
    long long int t = 0;

    cin >> n;

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

    sort(p, p + n);

    for (int i = 0; i < n; i++)
    {
        t += p[i].second;
        if (t > p[i].first)
        {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";

    return 0;
}


Measured memory_bytes: 1792
class AsciiCode

  def initialize
    @b2a = {"00000" => "A", "00001" => "B", "00010" => "C", "00011" => "D", "00100" => "E", "00101" => "F", "00110" => "G", "00111" => "H", "01000" => "I", "01001" => "J", "01010" => "K", "01011" => "L", "01100" => "M", "01101" => "N", "01110" => "O", "01111" => "P", "10000" => "Q", "10001" => "R", "10010" => "S", "10011" => "T", "10100" => "U", "10101" => "V", "10110" => "W", "10111" => "X", "11000" => "Y", "11001" => "Z", "11010" => " ", "11011" => ".", "11100" => ",", "11101" => "-", "11110" => "'", "11111" => "?"}
    @a2d = {" " => "101","'" => "000000","," => "000011","-" => "10010001","." => "010001","?" => "000001","A" => "100101","B" => "10011010","C" => "0101","D" => "0001","E" => "110","F" => "01001","G" => "10011011","H" => "010000","I" => "0111","J" => "10011000","K" => "0110","L" => "00100","M" => "10011001","N" => "10011110","O" => "00101","P" => "111","Q" => "10011111","R" => "1000","S" => "00110","T" => "00111","U" => "10011100","V" => "10011101","W" => "000010","X" => "10010010","Y" => "10010011","Z" => "10010000"}
    @a2b = Hash[*(@b2a.to_a.map{|k,v| [v,k]}.flatten)]
    @d2a = Hash[*(@a2d.to_a.map{|k,v| [v,k]}.flatten)]
  end

  def s2c(f)
    s=[]
    while f.length > 0 do
      x = f.shift
      s.push(@a2b[x])
    end
    return s
  end

  def decode(bin0)
    bin=bin0.dup
    t=[]
    while bin.length>0 do
      3.upto(8){|i|    # 9 is dummy
        if @d2a.has_key?(bin.slice(0, i)) then
          t.push(@d2a[bin.slice!(0, i)])
          break
        elsif i>=bin.length then
          bin.slice!(0, i)
          break
        end
      }
    end
    return t
  end

end

def main
  if true then
    fh = STDIN
  else
    fh = open("in1_0111.txt")
  end
  ac = AsciiCode.new
  while fh.gets do
    f=$_.chomp.split(//)
    bin = ac.s2c(f).inject(""){|acc,x| acc+x}
    s= ac.decode(bin)

    puts s.join
  end
end

if $0 == __FILE__ then
  main
end

Measured memory_bytes: 9632
# if true

# include <iostream>
# include <string>
# include <algorithm>

int main()
{

    std::string s;
    std::cin >> s;


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

    if (s[0] != s[3] && s[0] == s[1] && s[2] == s[3])
    {
        std::cout << "Yes";
    }
    else
    {
        std::cout << "No";
    }


    return 0;
}


# endif

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++) // for簡略表記
#define DUMP(ar) for(int loop=0; loop<(int)ar.size(); loop++) cout << "[" << loop << "]:" << ar[loop] << endl // 配列一覧表示
#define DUMPL(ar) for(int loop=0; loop<(int)ar.size(); loop++) { cout << ar[loop]; if(loop<(int)ar.size()-1) cout << ' '; } cout << endl; // 配列一行一覧表示
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl // ループ回数デバグ
using namespace std;
// cout << fixed << setprecision(4) で小数点以下4桁の桁そろえ
// cout << setw(5) << ... で表示形式を5桁に設定 5桁未満なら頭に空白がつく 5桁越なら先頭から5桁まで
// cout << setw(5) << setfill('0') << ... で空白部分の埋め文字に5を使う
// getline(cin, [変数]); で空白などを含む入力の受け取り(行ごとの受け取り)
// cin >> ws; でそこまでにストリームに残されたホワイトスペースを取り除く(=以降のgetlineの有効化)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,a,b;
  cin >> x;
  if(x==1){
     cout<<"Hello World"<<endl;
  }else{
  cin>>a>>b;
    cout<<a+b<<endl;
  }
    

    return 0;
}


Measured memory_bytes: 256
program B_solution

implicit none
integer :: n,a(200)=0,i
double precision :: b(200)=0

read(*,*) n
read(*,*) (a(i),i=1,n)

i = 1
do
b = mod(a, 2**i)
if( sum(b) > 0) exit
i = i + 1
end do

write(*,*) i-1

end program

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

using namespace std;
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for (int i = 0; i < (int)(n); ++i)
#define fore(i,a,b) for (int i = a; i < (int)(b); ++i)
#define forin(i, n) for (auto& i : (n))
#define make_unique(x) (x).erase(unique(all((x))), (x).end())
#define hbar ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<class T> T mgcd(T a, T b) {while(b) {a%=b; swap(a,b);} return a;}

const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  hbar;
  ll a, b;
  cin >> a >> b;
  ll n = mgcd(a,b), ans=1LL;
  for (ll i = 2; i*i <= n; i++){
    if(n%i==0){
      while(n%i==0) n/=i;
      ++ans;
    }
  }
  if(n>1) ++ans;

  cout << ans << '\n';
  
  return 0;
}


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

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(long long N){
    vector< vector< pair<string,int> > > s(N+1);
    s[0].pb(mp("",0)); 
    REP(i,1,N+1){
        for(auto x : s[i-1]){
            REP(j,0,x.second+1){
                string tmps=x.first;
                char tmpc='a'+j;
                tmps += tmpc;
                s[i].pb(mp(tmps,max(x.second,j+1)));
            }
        }
    }
    REP(j,0,s[N].size()){
        cout<<s[N][j].first<<endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 10736
// Last Change:    12/08/2018 21:17:33.
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <list>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}

int main() {
  int N, maxNum, p[10];
  maxNum = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    maxNum = max(p[i], maxNum);
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += p[i];
  }
  ans -= maxNum / 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 string h;
  cin>>h;
  int count=0;
  for(int i=0;i<h.length()-1;i++){
    if(h[i]!=h[i+1]){
      count+=1;
    }
  }
    cout<<count<<endl;
}

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


#define LINE cout << "Line : " << __LINE__  << endl
#define dump(X) cout << "Line : " << __LINE__  << ", " << #X << " : " << X
#define dumpln(X) dump(X) << endl

using State = string::iterator;
struct Node {
  int num = -1;
  int idx = 0;
  int l = -1;
  int r = -1;
};
vector<Node> nodes0;
vector<Node> nodes1;

vector<Node> nodes2;

int synNodes(int id0, int id1) {
  int id2 = nodes2.size();
  nodes2.push_back(Node());
  nodes2[id2].idx= id2;
  if(nodes0[id0].num == -1 || nodes1[id1].num == -1) return id2;
  nodes2[id2].num = nodes0[id0].num + nodes1[id1].num;
  if(nodes0[id0].l != -1 && nodes1[id1].l != -1) {
    auto tmp = synNodes(nodes0[id0].l, nodes1[id1].l);
    nodes2[id2].l = tmp;
  }
  if(nodes0[id0].r != -1 && nodes1[id1].r != -1) {
    auto tmp = synNodes(nodes0[id0].r, nodes1[id1].r);
    nodes2[id2].r = tmp;
  }
  return id2;
}

string output(int id) {
  if(nodes2[id].num == -1) return "()";
  string s = "(";
  if(nodes2[id].l != -1) {
    auto tmp = output(nodes2[id].l);
    s += tmp;
  }
  s += ")";
  s += '[';
  s += to_string(nodes2[id].num);
  s += ']';
  s += '(';
  if(nodes2[id].r != -1) {
    auto tmp = output(nodes2[id].r);
    s += tmp;
  }
  s += ')';
  return s;
}

int getNum(State& s) {
  int ret = 0;
  while(*s >= '0' && *s <= '9') {
    ret *= 10;
    ret += *s - '0';
    ++s;
  }
  return ret;
}
vector<Node> nodes;
int calc(State& s) {
  int id = nodes.size();
  nodes.push_back(Node());
  nodes[id].idx = id;
  assert(*s == '(');
  ++s;
  if(*s != ')') {
    int tmp = calc(s);
    nodes[id].l = tmp;
  }
  ++s;
  ++s;
  nodes[id].num = getNum(s);
  ++s;
  ++s;
  if(*s != ')') {
    int tmp = calc(s);
    nodes[id].r = tmp;
  }
  ++s;
  return id;
}

int main() {
  string s, t;
  cin >> s >> t;
  //  dumpln(s);
  //  dumpln(t);
  
  auto it0 = s.begin();
  auto it1 = t.begin();
  int par0 = calc(it0);
  nodes0 = nodes;
  nodes.clear();

  // dumpln(nodes0.size());
  // rep(i, nodes0.size()) {
  //   dumpln(nodes0[i].idx);
  //   dumpln(nodes0[i].num);
  //   dumpln(nodes0[i].l);
  //   dumpln(nodes0[i].r);
  // }

  //dumpln("------------");
  
  int par1 = calc(it1);
  nodes1 = nodes;
  nodes.clear();
  
  // dumpln(nodes1.size());
  // rep(i, nodes1.size()) {
  //   dumpln(nodes1[i].idx);
  //   dumpln(nodes1[i].num);
  //   dumpln(nodes1[i].l);
  //   dumpln(nodes1[i].r);
  // }

  
  int par2 = synNodes(par0, par1);
  cout << output(par2) << endl;
  return 0;
}



Measured memory_bytes: 3316
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val aList = readLine()?.split(" ")?.map { it.toInt() } ?: return

    val map = mutableMapOf<Int, Int>()

    for (a in aList) {
        val a1 = map.putIfAbsent2(a - 1, 0)
        val a2 = map.putIfAbsent2(a, 0)
        val a3 = map.putIfAbsent2(a + 1, 0)

        map[a - 1] = if (a1 != null) a1 + 1 else 1
        map[a] = if (a2 != null) a2 + 1 else 1
        map[a + 1] = if (a3 != null) a3 + 1 else 1
    }

    val max = map.maxBy { it.value }?.value ?: return

    println(max)
}

private fun <K, V> MutableMap<K, V>.putIfAbsent2(key: K, value: V): V? {
    return if (containsKey(key)) {
        get(key)
    } else {
        put(key, value)
    }
}

Measured memory_bytes: 59108
#include <stdio.h>
int main(void){
  long int n,i,t=0;
 scanf("%ld",&n);
 for(i=1;i<=n;i++){
   if(i%3!=0){
     if(i%5!=0){
       if(i%15!=0) t+=i;
     }
   }
 }
 printf("%ld",t);
return 0;
}

Measured memory_bytes: 1708
import java.util.Scanner;

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

    	String first = insert.substring(0,1);
    	String last = insert.substring((insert.length() - 1),insert.length());
    	String middle = insert.substring(1,(insert.length() - 1));
    	int middle_mojisu =  middle.length();

    	System.out.println(first + middle_mojisu + last);
    	}
    }

Measured memory_bytes: 21716
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-13
#define INF 1e9
#define LINF 1e18

int const MaxSize = 300 + 10;
int N, M, A[MaxSize][MaxSize], cnt[MaxSize], curI[MaxSize];

int main() {
	ios_base::sync_with_stdio(false);
	//freopen("/Users/george/A_1.in", "r", stdin);

	cin >> N >> M;

	LP(p, 0, N)
	{
		LP(s, 0, M)
			cin >> A[p][s];
	}

	set<int> bl;
	int ans = INF;

	LP(p, 0, N)
	{
		cnt[A[p][0]]++;
	}

	while (bl.size() < M) {

		int maxCnt = 0;
		vector<int> bads;
		LPE(sport, 1, M)
		{
			if (bl.count(sport))
				continue;

			int sc = cnt[sport];
			if (sc > maxCnt) {
				bads.clear();
				bads.push_back(sport);
				maxCnt = sc;
			} else if (sc == maxCnt) {
				bads.push_back(sport);
			}
		}

		//cout << maxCnt << " ";

		ans = min(ans, maxCnt);

		LP(bi, 0, bads.size())
		{
			//	cout << bads[bi] << " ";
			bl.insert(bads[bi]);
		}
		//cout << endl;

		LP(p, 0, N)
		{

			bool changed = false;
			while (bl.count(A[p][curI[p]])) {
				curI[p]++;
				changed = true;
			}

			if (changed) {
				cnt[A[p][curI[p]]]++;
			}

			//cout << " " << curI[p];
		}

	//	cout << endl;
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main()
{
    int n;
    cin >> n;
    cout << (((n / 1000 + 1) * 1000 - n )% 1000);
    return 0;
}

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

int main(){
  int n,ans=0;
  string s;
  cin>>n>>s;
  for(int i=0; i<n; i++){
    int count=0;
    for(char c='a'; c<='z'; c++){
      bool left=false,right=false;
      for(int j=0; j<i; j++) {
        if(s[j]==c) left=true;
      }
      for(int j=i; j<n; j++) {
        if(s[j]==c) right=true;
      }
      if(left && right) count++;
    }
    ans = max(ans,count);
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



string S, T;
//---------------------------------------------------------------------------------------------------
vector<int> f(string s) {
    map<char, int> m;
    fore(c, s) m[c]++;
    vector<int> res;
    fore(p, m) res.push_back(p.second);
    sort(all(res));
    return res;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S >> T;

    if (f(S) == f(T)) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 1112