akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
    int a,b,d;
	char c;
	while(1){
		scanf("%d %c %d",&a,&c,&b);
		if(c=='?')break;
		if(c=='+'){
			d=a+b;
		}
		if(c=='-'){
			d=a-b;
		}
		if(c=='*'){
			d=a*b;
		}
		if(c=='/'){
			d=a/b;
		}
		printf("%d\n",d);
	}

	return 0;
}

Measured memory_bytes: 2708
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+1;
const int mod = 1e9+7;
struct data{
	int nd,d,col;
};
vi adj[upperlimit];
int colour[upperlimit];
int mxdst[upperlimit];
data queries[upperlimit];
queue <data> vert;
void bfs(){
	while(! vert.empty()){
		data x=vert.front();
		int node=x.nd;
		int k=x.d;
		if(k<=mxdst[node]){
			vert.pop();
			continue;
		}
		mxdst[node]=k;
		if(! colour[node]) colour[node]=x.col;
		if(! k){
			vert.pop();
			continue;
		}
		for(int i = 0; i < adj[node].size(); i++){
			data temp;
			temp.nd=adj[node][i];temp.d=k-1;temp.col=x.col;
			vert.push(temp);
		}
		vert.pop();
	}
}
int main() {
	int n,m,a,b,q;
	sd(n);sd(m);
	for(int i = 1; i <= m; i++){
		sd(a);sd(b);
		adj[a].pb(b);adj[b].pb(a);
	}
	for(int i = 1; i <= n; i++) mxdst[i]=-1;
	sd(q);
	for(int i = q; i >= 1; i--){
		sd(queries[i].nd);sd(queries[i].d);sd(queries[i].col);
	}
	for(int i = 1; i <= q; i++){
		vert.push(queries[i]);
		bfs();
	}
	for(int i = 1; i <= n; i++) pdn(colour[i]);
	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    int sum=0;
    for(auto t:s)
        sum+=t-'0';
    if(sum%9==0) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3724
n,q = map(int,input().split())

Edges = [list(map(int,input().split())) for i in range(n-1)]

Graph = [[] for i in range(n)]
for edge in Edges:
    Graph[edge[0]-1].append(edge[1]-1)
    Graph[edge[1]-1].append(edge[0]-1)

Points = [list(map(int,input().split())) for i in range(q)]

Counter = [0 for i in range(n)]
for point in Points:
  Counter[point[0]-1] += point[1]

Parents = [-1 for i in range(n)]
Parents[0] = 0

stack = [0]
while stack:
    node = stack.pop()
    for adj in Graph[node]:
        if Parents[adj] == -1:
            Parents[adj] = node
            Counter[adj] += Counter[node]
            stack.append(adj)

print(*Counter)

Measured memory_bytes: 128784
import numpy as np
N,M=map(int, input().split())
H=list(map(int, input().split()))
TF=np.zeros(N)+1
for i in range(M):
    A,B=map(int, input().split())
    if H[A-1] > H[B-1]:
        TF[B-1] =-1
    elif H[A-1] < H[B-1]:
        TF[A-1] =-1
    else:
        TF[A-1] =-1
        TF[B-1] =-1
        
L = [i for i in TF if i > 0]
print(len(L))


Measured memory_bytes: 38544
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;

public class Main {

    public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int max=0;
        for(int i=1;i<N;i++){
            int cnt =0;
            String X= S.substring(0,i);
            HashSet Xset = new HashSet();
            String Y =S.substring(i);
            HashSet Yset = new HashSet();
            for(int j=0;j<X.length();j++){
                Xset.add(X.charAt(j));
            }
            for(int k=0;k<Y.length();k++){
                Yset.add(Y.charAt(k));
            }
            Iterator iterater = Xset.iterator();
            while(iterater.hasNext()){
                if(Yset.contains(iterater.next())){
                    cnt++;
                }
            }
            if(cnt>=max){
                max =cnt;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if (a==b && a!= c && b!=c ){
    cout<<"2"<<endl;
    
  }
    else if (a==c && a!= b && c!=b ){
    cout<<"2"<<endl;
    
  }   
 else if (b==c && b!= a && c!=a ){
    cout<<"2"<<endl;
    
  }
     else if (a!=b && b!= c && a!=c ){
    cout<<"3"<<endl;
    
  }
     else if (a == b && b == c ){
    cout<<"1"<<endl;
    
  }
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 10001
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define int long long
const double PI = acos(-1);
typedef pair<int, int> P;

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 mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}
vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i - 1);
            if (i * i != n)
            {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

signed main()
{
    string S;
    cin >> S;
    if (S[1] == 'B')
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3732
use proconio::input;

#[proconio::fastout]
pub fn main() {
    input! {
    n:isize,
    k:isize,
    }
    let a = n / k;
    let ans = std::cmp::min(n - a * k, (n - (a + 1) * k).abs());
    println!("{}", ans);
}


Measured memory_bytes: 2116
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int N = nextInt();
		int A = nextInt();



		System.out.println(N*N-A);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 23252
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

constexpr int MOD = 1e9 + 7;

using T = ll; // データ型
int n; // 頂点
vector<vector<pair<int, ll>>> tree;
vector<T> dist; // 根付き木中の i の子孫の数( i も含む )
vector<T> ans;
constexpr int INF = 1e9 + 6;

void dfs1(int v, int p = -1) {
    T res = 0;
    for (auto &u : tree[v]) {
        if (u.first == p) continue;
        dfs1(u.first, v);
        res = max(res, dist[u.first] + u.second);
    }
    dist[v] = res;
}

void dfs2(int v, T d_par, int p = -1) {
    // v における答えの計算
    ans[v] = max(d_par, dist[v]);

    // 左右からの累積演算を用いて子に送る d_par の計算
    // lf[i] : [:i-1]の演算結果
    // ri[i] : [i+1:]の演算結果
    auto f = [](T a, T b) { return max(a, b); }; // 演算
    int e = -INF; // 演算の単位元 ( maxの場合 -INF )
    vector<T> lf(tree[v].size(), e), ri(tree[v].size(), e);
    for (int i = 1; i < tree[v].size(); i++) {
        if (tree[v][i - 1].first == p) lf[i] = f(d_par, lf[i - 1]);
        else lf[i] = f(dist[tree[v][i - 1].first] + tree[v][i - 1].second, lf[i - 1]);
    }
    for (int i = tree[v].size() - 2; i >= 0; i--) {
        if (tree[v][i + 1].first == p) ri[i] = f(d_par, ri[i + 1]);
        else ri[i] = f(dist[tree[v][i + 1].first] + tree[v][i + 1].second, ri[i + 1]);
    }
    for (int i = 0; i < tree[v].size(); i++) {
        if (tree[v][i].first == p) continue;
        //dfs2(tree[v][i].first, f(f(lf[i], ri[i]), (p >= 0 ? d_par : -1)) + tree[v][i].second, v);
        dfs2(tree[v][i].first, f(lf[i], ri[i]) + tree[v][i].second, v);
    }
}

int main() {
    cin >> n;
    tree.resize(n);
    dist.resize(n);
    ans.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v; ll w; cin >> u >> v >> w;
        tree[u].push_back({v,w});
        tree[v].push_back({u,w});
    }
    dfs1(0);
    dfs2(0, 0);
    ll res = 0;
    for (int i = 0; i < n; i++) {
        res = max(res, ans[i]);
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 25452
def main():
    N, K = map(int, input().split())
    *x, = map(int, input().split())

    ans = 3 * 10 ** 8
    for left, right in zip(x, x[K - 1:]):
        if left * right < 0:
            ans = min(ans, right - left + min(-left, right))
        else:
            ans = min(ans, -left if left < 0 else right)
    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 14384
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    ll n,m;
    cin>>n>>m;
    ll a[n];
    rep(i,n)cin>>a[i];
    sort(a,a+n,greater<ll>());
    ll s[n+1]={};
    for(int i=0;i<n;++i){
        s[i+1]=s[i]+a[i];
    }
    int lb=0,ub=200001;
    while(ub-lb>1){
        ll cnt=0;
        int v=(ub+lb)/2;
        rep(i,n){
            cnt+=upper_bound(a,a+n,v-a[i],greater<ll>())-a;
        }
        if(cnt>m)lb=v;
        else ub=v;
    }
    ll cnt=0;
    ll ans=0;
    rep(i,n){
        int it=upper_bound(a,a+n,ub-a[i],greater<ll>())-a;
        cnt+=it;
        ans+=s[it]+it*a[i];
    }
    ans+=(m-cnt)*lb;
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main() {
	LL A, B;
	cin >> A >> B;
	cout << A + (int)(B / 2) << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		int N = Integer.parseInt(W.split(" ")[0]);
		int M = Integer.parseInt(W.split(" ")[1]);

		int ac = 0;
		int wa = 0;

		HashMap<Integer,ArrayList<String>> map = new HashMap<Integer,ArrayList<String>>();


		for(int i=0;i<M;i++){
			W = in.readLine();
			String[] Ws = W.split(" ");
			int p0 = Integer.parseInt(Ws[0]);
			if(map.containsKey(p0)){
				ArrayList<String> list = map.get(p0);
				list.add(Ws[1]);
			}else{
				ArrayList<String> list = new ArrayList<String>();
				list.add(Ws[1]);
				map.put(p0, list);
			}
		}

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

			if(map.containsKey(i)){
				ArrayList<String> list = map.get(i);
				boolean flg = false;
				for(int k=0;k<list.size();k++){
					if("WA".equals(list.get(k))){
						tmpWa++;
					}else{
						tmpAc++;
						flg=true;
						break;
					}
				}
				if(flg){
					ac+=tmpAc;
					wa+=tmpWa;
				}
			}
		}

		System.out.println(ac + " "+wa);
	}


}


Measured memory_bytes: 58808
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;


namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       
       
        public static long gcd(long x,long y)
        {
            if (x < y) gcd(y, x);
            
            while (y > 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }

        public static long lcm(long x,long y)
        {
            return x * y / gcd(x, y);
        }



        static void Main(string[] args)
        {
            var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);


            var n = Read();
            var m = 1;
            var memo = n;
            
            var ans = new List<char>();
            while (n-(long)Math.Pow(26, m) > 0)
            {
                n -= (long)Math.Pow(26,m);
                m++;
            }
            
            n--;
            for (int i = 0; i < m; i++)
            {
                ans.Add((char)('a' + n  % 26));
                n /= 26;
            } 
            

            
         
              
            
            var str = "";      
            for (int i = 0; i < ans.Count; i++)
            {
                str = ans[i].ToString() + str;
            }
            WriteLine(str);
          
            Out.Flush();
        }
    }
}




Measured memory_bytes: 18140
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>; 
int main() {
	int N; cin >> N;
	long long int ans = 0;
	vector<ll> A(N);
	vector<ll>An(N);
	rep(i, N) {
		cin >> A[i];
	}
	rep(i, N) {

		ans += An[A[i]];
		An[A[i]]++;
	}
	rep(i, N) {
		if (An[A[i]] != 1) {
			cout << ans - An[A[i]]+1 << endl;
		}
		else {
			cout << ans << endl;

		}
	}
}

Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <tuple>

std::vector<int> graph[100005];
std::vector<int> edge_n(100005, 0);
std::vector<int> parent(100005, 0);

std::queue<std::tuple<int, int> > que;
std::vector<int> sorted;

int n, m;

void tsort(void);

int main()
{
	int a, b;

	std::cin >> n >> m;
	for (int i = 0; i < n + m - 1; i++) {
		std::cin >> a >> b;

		graph[a].push_back(b);
		edge_n[b]++;
	}

	//???
	//std::cout << "main" << std::endl;

	tsort();

	//????
	for (int i = 1; i <= n; i++) {
		std::cout << parent[i] << std::endl;
	}

	return 0;
}

void tsort(void)
{
	int i = 1;
	while (edge_n[i] > 0) {
		i++;
	}

	que.push(std::tuple<int, int>(i, 0));
	while (!que.empty()) {
		int pos = std::get<0>(que.front()); 
		int old = std::get<1>(que.front());
		que.pop();

		edge_n[pos]--;

		if (edge_n[pos] <= 0) {
			parent[pos] = old;
			sorted.push_back(pos);
		}
		else {
			continue;
		}

		for (int i = 0; i < graph[pos].size(); i++) {
			que.push(std::tuple<int, int>(graph[pos][i], pos));
		}
	}

	return;
}


Measured memory_bytes: 7544
from collections import Counter

N = int(input())
S = [Counter(input()) for _ in range(N)]
aplhabet = 'abcdefghijklmnopqrstuvwxyz'

ans = ''
for a in aplhabet:
  a_min = float('inf')
  for s in S:
    a_min = min(a_min, s[a])
  ans += a * a_min

print(ans)

Measured memory_bytes: 3316
// https://atcoder.jp/contests/abc156/tasks/abc156_c

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

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#if DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 100;
const int X_I_MIN = 1;
const int X_I_MAX = 100;
const int INF = 1e9;

int N;
vector<int> X;

int xi, xx;

int main() {
  cin >> N;
  X = vector<int>(N);
  REP(i, N) cin >> X[i];

  xi = X_I_MIN;
  xx = X_I_MAX;
  REP(i, N) {
    xi = min(xi, X[i]);
    xx = max(xx, X[i]);
  }

  int ans = INF;
  FOR(p, xi, xx) {
    int hp = 0;
    REP(i, N) hp += (X[i] - p) * (X[i] - p);
    ans = min(ans, hp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*
 *  JUST KEEP GOING
 */
#define endl			'\n'
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define allr(v)			((v).rbegin()), ((v).rend())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define For(i,s)        for(auto i:s)
#define Forr(i,s)        for(auto &i:s)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <int,int>
#define vii				vector <ii>
#define vll				vector <pair<ll,ll>>
#define PI				double PPPPPP = 3.14159265358979323846;
#define bit(mask,i) ((mask>>i)&1)

void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 2e5+5,mod=1e9+7;
void solve(){
    int n;
    cin>>n;
    vector<int> v;
    map<int,ll> freq;
    for (int i = 0; i < n; ++i) {
        int a;
        cin>>a;
        if(freq[a]++)continue;
        v.push_back(a);
    }
    sort(all(v));
    ll ans=0;
    for (int j = 0; j < sz(v); ++j) {
        ll cnt=0;
        for (int i = j+1; i < sz(v); ++i) {
            for (int k = i+1; k < sz(v); ++k) {
                if(v[k]<v[i]+v[j])ans+=freq[v[i]]*freq[v[j]]*freq[v[k]];
            }
        }
    }
    cout<<ans;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    run();
    int t=1;
   // cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
const int MOD = 1e9+7;
const int MOOD = 998244353;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

int a[82][82];
int b[82][82];
bool bias[82][82][13000];

int main(){
	int h, w;
	cin >> h >> w;

	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			cin >> a[i][j];
		}
	}

	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			cin >> b[i][j];
		}
	}

	bias[1][1][abs(a[1][1] - b[1][1])] = true;

	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			for (int k = 0; k <= 80*(i+j-1); k++){
				if (i == h && j == w){
					for (int l = 0; l < 13000; l++){
						if (bias[h][w][l]){
							cout << l << endl;
							break;
						}
					}
					return 0;
				}
				if (bias[i][j][k] == true){
					bias[i+1][j][k+abs(a[i+1][j]-b[i+1][j])] = true;
					bias[i][j+1][k+abs(a[i][j+1]-b[i][j+1])] = true;
					bias[i+1][j][abs(k-abs(a[i+1][j]-b[i+1][j]))] = true;
					bias[i][j+1][abs(k-abs(a[i][j+1]-b[i][j+1]))] = true;
				}
			}
		}
	}
}


Measured memory_bytes: 69568
#include<iostream>
#include<cmath>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=(int)b;i<(int)n;i++)
#define rep(i,n)   REP(i,0,n)
#define eps 1e-10
class rec{
public:
  double low,up,;
  rec(){};
  rec(double tl,double tu){low=tl;up=tu;}
  bool operator<(const rec&a)const {
    if ( !(abs(low-a.low)<eps))return low < a.low;
    else return up < a.up;
  }
};


double solve(vector<double> &kukan,vector<rec>  *data){
  double ret= 0;
  rep(i,kukan.size()){
    double nowup=-100000,width=kukan[i];
    double tmp=0;
    rep(j,data[i].size()){
      if ( data[i][j].up < nowup)continue;
      else if ( nowup < data[i][j].low)tmp+=(data[i][j].up-data[i][j].low)*width;
      else tmp+=(data[i][j].up-nowup)*width;
      nowup=data[i][j].up;
    }
    ret+=tmp;
  }
  return ret;
}

void construct(double x1,double x2,double y1,double y2,vector<rec> *data,vector<double> &inx){
  rep(i,inx.size()-1){
    if ( x1-eps< inx[i] && inx[i+1]<x2+eps){
      data[i].push_back(rec(y1,y2));
    }
  }
  return;
}

main(){
  int n,tc=1;
  while(cin>>n && n){
    double x[n],y[n],r[n];
    vector<double> inx,kukan;
    set<double> S;
    rep(i,n){
      cin>>x[i]>>y[i]>>r[i];
      if (S.find(x[i]-r[i]) ==S.end())S.insert(x[i]-r[i]),inx.push_back(x[i]-r[i]);
      if (S.find(x[i]+r[i]) ==S.end())S.insert(x[i]+r[i]),inx.push_back(x[i]+r[i]);
    }
    //inx.push_back(0);//deleted
    sort(inx.begin(),inx.end());
    rep(i,inx.size()-1)kukan.push_back(inx[i+1]-inx[i]);
    vector<rec> data[kukan.size()];

    
    rep(i,n)construct(x[i]-r[i],x[i]+r[i],y[i]-r[i],y[i]+r[i],data,inx);
    rep(i,kukan.size())sort(data[i].begin(),data[i].end());

    printf("%d %.2lf\n",tc++,solve(kukan,data));

  }
  return false;
}

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

int n, m, k;
void solve(){
	int i, j;
}

int main(){
	string s, t;
	cin >> s >> t;
	if(t.length() != s.length()+1){
		cout << "No";
		return 0;
	}
	for(int i=0;i<s.length(); i++){
		if(s[i]!=t[i]){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 3544
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


const int mod = 1000000007;

bool memo[100001] = { false };
int fmemo[100001] = { 0 };

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

	int N, M;
	cin >> N >> M;
	REP(i, M) {
		int a;
		cin >> a;
		memo[a] = true;
	}
	fmemo[N] = 1;
	fmemo[N - 1] = memo[N - 1] ? 0 : 1;
	for (int i = N - 2;i >= 0;i--) {
		if (memo[i]) fmemo[i] = 0;
		else fmemo[i] = (fmemo[i + 1] + fmemo[i + 2]) % mod;
	}
	cout << fmemo[0] << endl;

	return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<cstdio>

int main(){
    std::string str1;
    std::string str2;
    int diff=32;
    int i;
 
   std::getline(std::cin,str1);

    for(i=0;i<str1.size();i++){
        if((str1[i]>='a')&&(str1[i]<='z')){
            printf("%c",str1[i]-diff);
        }else if((str1[i]>='A')&&(str1[i]<='Z')){
            printf("%c",str1[i]+diff);
        }else{
            printf("%c",str1[i]);
        }
    }
    std::cout<<std::endl;

    return 0;
}



Measured memory_bytes: 3152
mod = 998244353
N, K = map(int, input().split())

S = []
for i in range(K):
    L, R = map(int, input().split())
    S.append((L, R))

dp = [0] * (N+1)
dpsum = [0] * (N+1)
dp[1] = 1
dpsum[1] = 1

for i in range(2, N+1):
    for s in S:
        l = i - s[1]
        r = i - s[0]
        if r < 1:continue
        l = max(1, l)

        dp[i] += dpsum[r] - dpsum[l-1]
        dp[i] %= mod

    dpsum[i] = (dpsum[i-1] + dp[i]) % mod

print(dp[-1])


Measured memory_bytes: 24356
#include<stdio.h>

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

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

#define endl '\n'

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int a;
	string s;
	cin >> a >> s;
	if (a < 3200) cout << "red" << endl;
	else cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n, h;
  cin >> n >> h;
  vector<pair<ll, ll>> attack;
  rep (i, n) {
    int a, b;
    cin >> a >> b;
    attack.push_back(make_pair(a, 1));
    attack.push_back(make_pair(b, 0));
  }

  sort(attack.rbegin(), attack.rend());

  int ans = 0;
  for (auto v : attack) {
    bool finish = v.second;
    int damage = v.first;

    if (finish) {
      if (h <= damage) ans++;
      else {
	int cnt = h / damage;
	h -= damage * cnt;
	if (h == 0) ans += cnt;
	else {
	  ans += cnt + 1;
	}
      }
      cout << ans << endl;
      return 0;
    } else {
      h -= damage;
      ans++;
      if (h <= 0) {
	cout << ans << endl;
	return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 7312
#include <iostream>
#include <vector>
int main(void){
    
    int n, m;
    std::cin >> n >> m;
    
    std::vector<std::vector<int>> check(m);
    std::vector<int> p(m);
    for (int i = 0; i < m; i++) {
        int k;
        std::cin >> k;
        for (int j = 0; j < k; j++) {
            int num;
            std::cin >> num;
            check[i].push_back(num);
        }
    }
    for (int i = 0; i < m; i++) {
        std::cin >> p[i];
    }
    int ans = 0;
    for (int bit = 0; bit < (1<<n); bit++) {
        std::vector<int> switches(n);
        for (int i = 0; i < n; i++) {
            if (bit & (1<<i)) switches[i] = 1;
            else switches[i] = 0;
        }
        bool flag = true;
        for (int i = 0; i < m; i++) {
            int check_sum = 0;
            for (int j = 0; j < check[i].size(); j++) {
                check_sum += switches[check[i][j] - 1];
            }
            if (check_sum % 2 != p[i]) flag = false;
        }
        if (flag) ans++;
    }
    
    std::cout << ans << std::endl;
    
    
}

Measured memory_bytes: 3616
/*　　　　　　　{:i:i:|:i:i:/l/--　 　 　 --l/li:i:i|i:i:i:i}
　　　　　　 　 {:rx|:i:iィi芥ミ 　 　 .ィi芥ミｉ:ｉ:|ﾍ:i:i:}
.　　　 　 　 　 ｛ﾏ|ｉ: {::’:} 　 　 　 {:‘::} :ｉ:i:|〉｝:/
　　 　 　 　 　 乂|:i:| ｀¨¨´ 　 　　　 ｀¨¨´:i:ｉ:|ｼ/
　 　 　 　 　 　 ﾉ:|:i|　　　　　　′　　　 　   |:i:i:|ﾂ
　　　　　　　　/:/|:i:| ､　　　 　_ _ 　　　　  |:i:i:|
　 　 　　 　 /:/ .|:i:|/ ＼　　　 　 　     ｨ〔|:i:/
　　 　 　  　 〈;/ く刈＿ 个 　   -   　＜}　./|/_〉
　　     　　 r-っ'~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ|___
　　 　     /／ニつ　　　　　　 ､　　　　　　　ノﾆﾆ　＼
.　　　     |　　ニ⊃ 　./　/　 ──   /　/　　..⊆ﾆﾆ　　:|
.　　　     |　　丁´　 /|￣|￣  ─‐ /|￣|￣ 　 .￣|丁 　|
.　　　     |　　ﾉ.  　 |￣|￣  ─‐  |￣|￣ 　 　.|八 　|
.　　　     |　　||. 　 |￣|￣ |￣| |￣|￣ 　   .|　|
.　 　 　   |  　||   　￣￣￣　￣ 　￣￣￣　　  .|　|  |
.　 　 　  　    ||＿＿＿＿＿＿＿＿＿＿＿＿______|__　　 ',
　 　      ,′　 | ７ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ}  ,′
.　　     {　　　|/　}ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ{/ 　 　
*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

#define rep(a) _rep(0,int(a))
#define _rep(a,b) for(int i=int(a);i<int(b);i++)
#define ll long long
#define fst first
#define snd second


//factorial
int fact(int n) {
	int a = 1;
	for (int i = 1;i <= n;i++) a *= i;
	return a;
}

int a, b;
int main() {
	cin >> a >> b;
	cout << (a + b / 2) << endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long a,b,c,k;
long long ans=0;
int main(void){
  cin>>a>>b>>c>>k;
  for(int i=0;i<k;i++){
    if(a>=b&&a>=c)a=a*2;
    else if(b>=a&&b>=c)b=b*2;
    else c=c*2;
  }
  ans=a+b+c;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int F(ll A, ll B) {
  ll f = max(A, B);
  int x = 0;
  for(int i = 0; f > 0; i++) {
    f /= 10;
    x++;
  }
  return x;
}

int main() {
  ll N; cin >> N;
  int x = 100000;
  for(ll i = 1; i <= sqrt(N); i++) {
    if(N % i == 0) {
      x = min(x, F(i, N / i));
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
int posa[2005],posb[2005];
int L_ab[2005][2005];
int L_b[2005];
int L_ba[2005][2005];
int L_a[2005];
int dp[2005][2005];
int main(){
    cin>>n;
    repn(i,2*n){
        string s; int a;
        cin>>s>>a;
        if(s == "W") posa[a] = i;
        else posb[a] = i;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<i;j++) if(posa[j] > posa[i]) L_a[i]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<i;j++) if(posb[j] > posb[i]) L_b[i]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            L_ab[j][i] = L_ab[j-1][i]+(posb[i] < posa[j]);
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            L_ba[j][i] = L_ba[j-1][i]+(posa[i] < posb[j]);
        }
    }
    rep(i,2005) rep(j,2005) dp[i][j] = INF;
    dp[0][0] = 0 ;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(i)dp[i][j] = min(dp[i][j],dp[i-1][j]+L_a[i]+L_ba[j][i]);
            if(j)dp[i][j] = min(dp[i][j],dp[i][j-1]+L_b[j]+L_ab[i][j]);
        }
    }
    cout<<dp[n][n]<<endl;
}

Measured memory_bytes: 47360
#include<bits/stdc++.h>
using namespace std;
int gcd(int m,int n){
  if((m==0)||(n==0)) return 0;
  while(m!=n){
    if(m>n) m=m-n;
    else n=n-m;
  }
  return m;
}
int lcm(int m,int n){
  if((m==0)||(n==0)) return 0;
  return ((m/gcd(m,n))*n);
}
int main(){
  int n,m;
  while(cin>>n>>m){
    cout<<gcd(n,m)<<" ";
    cout<<lcm(n,m)<<endl;
  }
return(0);
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,X,T,ans;
  cin>>N>>X>>T;
  if(N%X==0){
     ans=N/X*T;
  }
  else{
  ans=N/X*T+T;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
fun main(args: Array<String>) {
    val list = (1..5).map { readLine()!!.toInt() }
    val k = readLine()!!.toInt()

    for (i in 0..3) {
        for (j in (i + 1)..4) {
            val (hoge, fuga) = Pair<Int, Int>(list[i], list[j])
            if (list[j] - list[i] > k) {
                println(":(")
                return
            }
        }
    }

    println("Yay!")
}

Measured memory_bytes: 31772
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
t,a = i2()
h = intl()

ans = 0
min = 10000
for i in range(n):
	if abs(t - 0.006*h[i] - a) < min:
		min = abs(t - 0.006*h[i] - a)
		ans = i+1
print(ans)

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';
ll const mod = 998244353;

struct LazySegmentTree {
private:
    int n;
    vector<ll> node,lazy_b,lazy_c;
    vector<bool> upd;
public:
    LazySegmentTree(vector<ll> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1);
        lazy_b.resize(2*n-1,1);
        lazy_c.resize(2*n-1,0);
        upd.resize(2*n-1,false);
        for (int i = 0;i < sz;++i) node[i+n-1] = v[i];
        for (int i = n-2;i >= 0;--i) node[i] = (node[i*2+1]+node[i*2+2])%mod;
    }

    void eval(int k,int l,int r) {
        if (upd[k]) {
            (node[k] *= lazy_b[k]) %= mod;
            (node[k] += lazy_c[k]*(r-l)%mod) %= mod;
            if (r-l > 1) {
                (lazy_b[2*k+1] *= lazy_b[k]) %= mod;
                (lazy_b[2*k+2] *= lazy_b[k]) %= mod;
                (lazy_c[2*k+1] *= lazy_b[k]) %= mod;
                (lazy_c[2*k+2] *= lazy_b[k]) %= mod;
                (lazy_c[2*k+1] += lazy_c[k]) %= mod;
                (lazy_c[2*k+2] += lazy_c[k]) %= mod;
                upd[2*k+1] = upd[2*k+2] = true;
            }
            lazy_b[k] = 1;
            lazy_c[k] = 0;
            upd[k] = false;
        }
    }

    void update(int a,int b,ll x,ll y,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        eval(k,l,r);
        if (b <= l || r <= a) return;
        if (a <= l && r <= b) {
            lazy_b[k] = x;
            lazy_c[k] = y;
            upd[k] = true;
            eval(k,l,r);
        } else {
            update(a,b,x,y,2*k+1,l,(l+r)/2);
            update(a,b,x,y,2*k+2,(l+r)/2,r);
            node[k] = (node[2*k+1]+node[2*k+2])%mod;
        }
    }

    ll getsum(int a,int b,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        if (b <= l || r <= a) return 0;
        eval(k,l,r);
        if (a <= l && r <= b) return node[k];
        ll vl = getsum(a,b,k*2+1,l,(l+r)/2);
        ll vr = getsum(a,b,2*k+2,(l+r)/2,r);
        return (vl+vr)%mod;
    }
};

int main() {
    int n,q;
    cin >> n >> q;
    vector<ll> a(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    LazySegmentTree seg(a);
    for (int i = 0;i < q;++i) {
        int t,l,r;
        cin >> t >> l >> r;
        if (t) cout << seg.getsum(l,r) << newl;
        else {
            int b,c;
            cin >> b >> c;
            seg.update(l,r,b,c);
        }
    }
}

Measured memory_bytes: 35696
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

H, W, K = MAP()

# あみだくじとして妥当かの判定
def check(S):
    for i in range(W-1):
        # 1つでも隣り合う場所に横棒があればNG
        if S & 1<<i and S & 1<<(i+1):
            return False
    return True

# dp[i][S][j] := i段目まで見て、今の段の横棒の状態がSで、j本目の縦棒に行く通り数
dp = list3d(H+1, 1<<W, W+1, 0)
dp[0][0][1] = 1
for i in range(H):
    for S1 in range(1<<W):
        # 左端はただの番兵なので、立っていたらスキップ
        if S1 & 1:
            continue
        # あみだくじとして妥当でない集合は全てスキップ
        if not check(S1):
            continue
        for S2 in range(1<<W):
            if S2 & 1:
                continue
            if not check(S2):
                continue
            for j in range(1, W+1):
                # 左に棒があれば左に遷移
                if S2 & 1<<(j-1):
                    dp[i+1][S2][j-1] += dp[i][S1][j]
                    dp[i+1][S2][j-1] %= MOD
                # 右に棒があれば右に遷移
                elif S2 & 1<<j:
                    dp[i+1][S2][j+1] += dp[i][S1][j]
                    dp[i+1][S2][j+1] %= MOD
                # 棒がなければ真下に遷移
                else:
                    dp[i+1][S2][j] += dp[i][S1][j]
                    dp[i+1][S2][j] %= MOD
ans = 0
for S in range(1<<W):
    ans += dp[H][S][K]
    ans %= MOD
print(ans)


Measured memory_bytes: 50524
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    string n;
    cin >> n;
    if (n[0] == n[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

int main(){
    ll N , M , ans = 0;
    cin >> N >> M;

    vector<ll> ball(N, 0);
    vector<ll> ball_num(N, 1);
    ball[0] = 1;
    ll x , y;

    for(int i = 0; i < M; i++){
        cin >> x >> y;
        x--;
        y--;
        if(ball[x] == 1){
            ball[y] = 1;
            ball_num[y]++;
            ball_num[x]--;
            if(ball_num[x] == 0){
                ball[x] = 0;
            }
        }else{
            ball_num[y]++;
            ball_num[x]--;
        }
    }
    
    cout << accumulate(ball.begin(), ball.end(),0) << endl;

}

Measured memory_bytes: 1792
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define F first
#define S second


void bfs(int s,  vector<vector<int>> adj, int n, vector<vector<int>> &ans)
{
	vector<bool> vis(n + 1, false);
	vector<int> level(n + 1, 0);
	vector<int> count_in_level(n + 1, 0);
	vis[s] = true;
	queue<int> q;
	q.push(s);
	level[s] = 0;
	while (!q.empty())
	{
		int u = q.front();
		q.pop();
		for (int v : adj[u])
		{
			if (!vis[v])
			{
				level[v] = level[u] + 1;
				count_in_level[level[v]]++;
				vis[v] = true;
				q.push(v);
			}
		}
	}
	ans.pb(count_in_level);
	return;
}

int main()
{

// #ifndef ONLINE_JUDGE
// 	// for getting input from input.txt
// 	freopen("input1.txt", "r", stdin);
// 	// for writing output to output.txt
// 	freopen("output1.txt", "w", stdout);
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, x, y;
	cin >> n >> x >> y;
	vector<vector<int>> adj(n + 1);
	for (int i = 1; i < n; i++)
	{
		adj[i].pb(i + 1);
		adj[i + 1].pb(i);
	}
	adj[x].pb(y);
	adj[y].pb(x);
	vector<vector<int>> ans;
	for (int i = 1; i <= n; i++)
	{
		bfs(i, adj, n, ans);
	}
	for (int k = 1; k < n; k++)
	{
		ll out = 0;
		for (int i = 1; i <= n; i++)
		{
			out += ans[i - 1][k];
		}
		cout << out / 2 << "\n";
	}
	return 0;
}

Measured memory_bytes: 16256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, A, B;
    string s;
    cin >> n >> A >> B >> s;

    ll cnt1 = 0, cnt2 = 0; // cnt1 : 国内 , cnt2 : 海外
    vl ans(n);  // ans[i] : 1のとき予選通過
    rep(i, n) {
        if(s[i] == 'a') {
            if(cnt1 + cnt2 < A+B) {
                ans[i] = 1;
                cnt1++;
            }
        }
        else if(s[i] == 'b') {
            if(cnt1 + cnt2 < A+B && cnt2 < B) {
                ans[i] = 1;
                cnt2++;
            }
        }
    }

    rep(i, n) {
        if(ans[i]) {
            out("Yes");
        }
        else {
            out("No");
        }
    }
    
    re0;
}

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

int main() {
	int a[1000000+ 1], count = 1;
	scanf("%d", &a[count]);
	while (1) {
		++count;
		if (a[count - 1] % 2 == 0)a[count] = a[count - 1] / 2;
		else if (a[count - 1] % 2 != 0)  a[count] = 3 * a[count - 1] + 1;
		for (int i = 1;i < count;++i) {
			if (a[i] == a[count]) {
				printf("%d\n",count);
				return 0;
			}
		}
	}
	
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n, k;
    cin >> n >> k;

    vector<ll> v(n);

    ll ans = 0;

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

    for (int l = 0; l < n; l++)
    {
        for (int r = l; r <= n; r++)
        {
            int res = 0;
            vector<int> q;
            ll sum = 0;

            for (int i = 0; i < n; i++)
            {
                if (i < l || r <= i)
                {
                    q.push_back(v[i]);
                    sum += v[i];
                }
            }

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

            if (k < l + n - r)
            {
                continue;
            }

            for (int i = 0; i < k - (l + n - r) && i < q.size(); i++)
            {
                if (q[i] > 0)
                {
                    break;
                }

                sum -= q[i];
            }

            ans = max(ans, sum);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    lint n, k;
    cin >> n >> k;
    vector<lint> a(n), s(n + 1);
    repeat (i, n) cin >> a[i];
    s[0] = 0;
    repeat (i, n) s[i + 1] = s[i] + a[i];
    
    map<lint, lint> mp;
    repeat (i, n + 1) {
        mp[s[i] % k] += 1;
    }
    
    lint ans = 0;
    for (auto key: mp) {
        //dump(key.fst); dump(key.snd); el;
        lint c = key.snd;
        if (key.snd < 2) continue;
        ans += ((c-1)*c)/2;
    }
    cout << ans << endl;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

ll f(ll n) {
    PRINT(n);
    ll result = 0;
    int k = 0;
    ll pow2k = 1;
    while (n >= pow2k) {
        ll q = n / (pow2k * 2);
        ll r = n % (pow2k * 2);
        PRINT(q);
        PRINT(r);
        ll ones = q * pow2k + max(0ll, r - pow2k);

        PRINT(ones);
        if (ones % 2 == 1) {
            result ^= pow2k;
        }
        
        k++;
        pow2k <<= 1;
    }
    return result;
}

int main(void)
{
    ll A, B;
    cin >> A >> B;

    REP(i, 10) {
        PRINT(f(i));
    }
    ll result = f(B + 1) ^ f(A);
    cout << result << endl;


    return 0;
}



Measured memory_bytes: 256