akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define INF 1010001000
#define MAX_V 100000
#define min(a, b) a<b?a:b

typedef struct vertex {
    int edge_count;
    struct edge *head;
}vertex;

typedef struct edge {
    int to;
    struct edge *next;
}edge;

void add(int f, int t);
void dfs(int st, int prev);
void cc(void);

vertex graph[MAX_V]; 
int used[MAX_V], prenum[MAX_V], lowest[MAX_V], parent[MAX_V], ans[MAX_V];
int e, v, j;
int pre, ac;

int main(void)
{
    int i, t, f;
    scanf("%d%d", &v, &e);
    for (i = 0; i < e; i++) {
        scanf("%d %d", &f, &t);
        add(f, t);
        graph[f].edge_count++;
        add(t, f);
        graph[t].edge_count++;
    }
    cc();
    for (i = 0; i < v; i++) {
        if (ans[i]) {
            printf("%d\n", i);
        }
    }
    return 0;
}

void cc(void)
{
    int i;
    for (i = 0; i < v; i++) {
        lowest[i] = INF;
        prenum[i] = INF;
        used[i] = 0;
        if (graph[j].edge_count < graph[i].edge_count) {
            j = i;
        }
    }

    pre = 1;
    dfs(j, -1);
    for (i = 0; i < v; i++) {
        if (i == j || parent[i] == j) {
            continue;
        }
        if (prenum[parent[i]] <= lowest[i]) {
            ans[parent[i]] = 1;
        }
    }
}

void dfs(int st, int prev)
{
    int cnt = 0;
    edge *tmp = graph[st].head;

    prenum[st] = pre;
    lowest[st] = pre++;
    used[st] = 1;

    while (tmp) {
        if (!used[tmp->to]) {
            cnt++;
            parent[tmp->to] = st;
            dfs(tmp->to, st);
            lowest[st] = min(lowest[st], lowest[tmp->to]);
        } else if (tmp->to != prev) {
            lowest[st] = min(lowest[st], prenum[tmp->to]);
        }
        tmp = tmp->next;
    }
    if (st == j && cnt > 1) {
        ans[st] = 1;
    }
}

void add(int f, int t)
{
    edge *tmp, *new_ = (edge *)malloc(sizeof(edge));
    new_->to = t;
    new_->next = NULL;
    if (graph[f].head) {
        tmp = graph[f].head;
        while (tmp->next) {
            tmp = tmp->next;
        }
        tmp->next = new_;
    } else {
        graph[f].head = new_;
    }
}

Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
int digit(long long n)
{
        int  f1,d1;
   d1=((int)(log10(n)));
   f1=(int) (n/(int)(pow(10,d1)));
   return f1;
}
int main()
{
    long long n,i,j,k=0,p;
    cin>>n;
    int a[10][10]={0};
    for(i=1;i<=n;i++)
    {
         if(i%10==0)continue;
         else
         {
             j=digit(i);
             a[j][i%10]++;
         }
    }
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
            k+=a[i][j]*a[j][i];
        }
    }
    cout<<k<<endl;
    return 0;

}


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

public class Main implements Runnable {
	public static void main (String[] args) {new Thread(null, new Main(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int N = fs.nextInt();
		int[] a = fs.nextIntArray(N);
		int max = 0;
		int[] freq = new int[100100];
		for(int i = 0; i < N; i += 2) {
			freq[a[i]]++;
			max = Math.max(max, freq[a[i]]);
		}
		int[] freq2 = new int[100100];
		for(int i = 1; i < N; i += 2) {
			freq2[a[i]]++;
		}
		int big1 = -1, big2 = -1;
		for(int i = 0; i < 100100; i++) {
			if(freq2[i] == 0) continue;
			if(big1 == -1) big1 = i;
			else {
				if(freq2[i] > freq2[big1]) {
					big2 = big1;
					big1 = i;
				}
				else if(big2 == -1) big2 = i;
				else if(freq2[i] > freq2[big2]) {
					big2 = i;
				}
			}
		}
		
		int res = Integer.MAX_VALUE;
		for(int who = 0; who < N; who += 2) {
			int add = N/2 - freq[a[who]];
			if(a[who] == big1) {
				if(big2 == -1) add += N/2;
				else add += N/2 - freq2[big2];
			}
			else {
				add += N/2 - freq2[big1];
			}
			res = Math.min(res, add);
		}
		
		out.println(res);
		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}

Measured memory_bytes: 27732
import collections

N=int(input())
arr=[]
for i in range(N):    
    arr.append(input())  

lastchar=list(arr[0])[len(arr[0])-1]
count=1
for i in range(1,N):
    firstchar=list(arr[i])[0]
    if(lastchar==firstchar):
        lastchar=list(arr[i])[len(arr[i])-1]
        count+=1
    else:        
        break

flag=True

tocheck=list(collections.Counter(arr).values())

for item in tocheck:
    if(item>1):        
        flag=False        
        break

if(N==count and flag==True):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3316
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

ll a[200010];
signed main(void)
{
	ll n, t;
	cin >> n >> t;
	REP(i, n) cin >> a[i];

	ll ret = 0;
	REP(i, n-1) {
		if(a[i+1] - a[i] >= t) {
			ret += t;
		} else {
			ret += a[i+1] - a[i];
		}
	}
	ret += t;
	cout << ret << endl;

	return 0;
}


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

#define REP(i,n) for(int i=0,_n=(int)(n);i<_n; i++)
template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }

typedef long long ll;

int nextInt() {
  int x; scanf("%d", &x); return x;
}

const ll INF = 1LL << 58;
const int MAX_N = 100000 + 10;
ll dp[MAX_N];
int X[MAX_N];

int main2() {
  int N = nextInt();
  ll A = nextInt();
  ll B = nextInt();
  REP(i, N) X[i] = nextInt();
  REP(i, N+1) dp[i] = INF;
  dp[0] = 0;
  for (int i = 1; i < N; i++) {
    chmin(dp[i], dp[i-1] + (X[i] - X[i-1]) * A );
    chmin(dp[i], dp[i-1] + B);
  }
  ll ans = dp[N-1];
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}


Measured memory_bytes: 1408
from math import ceil
import heapq

N, M = map(int, input().split())
heap = [-x for x in list(map(int, input().split()))]
heapq.heapify(heap)

for i in range(M):
    h = heapq.heappop(heap)
    h = ceil(h/2)
    heapq.heappush(heap, h)

ans = 0
for _ in range(N):
    h = heapq.heappop(heap)
    ans += -h

print(ans)

Measured memory_bytes: 14380
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n, a, b; cin >> n >> a >> b;
    ll res = 0;
    if((b-a)%2){
        ll num = min(min(n-a, n-b), min(a-1, b-1));
        res = num+1 + (b-a-1)/2;
    }else{
        res = (b-a)/2;
    }
    cout << res << ln;
}

    

Measured memory_bytes: 256
/*input

*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main()
{
	IOS;
	int a,b;
	cin>>a>>b;
	if(b%a==0) cout<<a+b<<'\n';
	else cout<<b-a<<'\n';
	return 0;
}


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

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

    for (int i = 1; i <= n; i++) {
        x = i;
    	if (x % 3 == 0) {
    		cout << " " << i;
    	}
    	else {
            while (true) {
            	if (x % 10 == 3) {
            		cout << " " << i;
            		break;
            	}
        		x /= 10;
            	if (x)
            	    continue;
         	    else
         	        break;
            }
    	}
    }

	cout << endl;
}



Measured memory_bytes: 3092
from functools import reduce
from collections import Counter


def calc(N,M,A):
    LR = [0]
    pa = 0
    for a in A:
        pa += a
        LR.append(pa)
    LR = list(map(lambda x:x%M,LR))

    LRCount = Counter(LR)
    LRNum = [int(LRCount[k]*(LRCount[k]-1)/2) for k in LRCount]
    LRNum = sum(LRNum)
    print(LRNum)

N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
calc(N,M,A)

Measured memory_bytes: 17160
(* O(n log n) *)
Scanf.scanf "%d" @@ fun n ->
  let a_s = Array.init (3 * n) @@ fun _ -> Scanf.scanf " %d" @@ (+) 0 in
  Array.sort (fun x y -> y - x) a_s;
  let ans = ref 0 in
  for i = 1 to n do
    ans := !ans + a_s.(i * 2 - 1)
  done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b[100],c=0,d=0,i;
    cin>>a;
    for(i=0;i<a;i++) cin>>b[i];
    sort(b,b+a,greater<int>());
    for(i=0;i<a;i++){
        if(i%2==0) c=c+b[i];
        if(i%2!=0) d=d+b[i];
    }
    cout<<c-d<<endl;
}


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

int main(){
    vector<int> array = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << array.at(K - 1) << endl;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<cctype>
typedef long long ll;
using namespace std;
typedef string::const_iterator State;

string s, pass;
ll a, b, c, d;

ll solve(State &begin) {
  ll ans = 0;
  if (*begin == 'a') ans = a, begin++;
  else if (*begin == 'b') ans = b, begin++;
  else if (*begin == 'c') ans = c, begin++;
  else if (*begin == 'd') ans = d, begin++;
  else if (*begin == '[') {
    begin++;
    if (*begin == '+') begin++, ans = solve(begin) | solve(begin);
    else if (*begin == '*') begin++, ans = solve(begin) & solve(begin);
    else if (*begin == '^') begin++, ans = solve(begin) ^ solve(begin);
    begin++;
  }
  return ans;
}

int main() {
  while (cin >> s, s != ".") {
    cin >> pass;
    a = pass[0] - '0';
    b = pass[1] - '0';
    c = pass[2] - '0';
    d = pass[3] - '0';
    State state = s.begin();
    ll result = solve(state), ans = 0;
    for (a = 0; a < 10; a++) for (b = 0; b < 10; b++) {
      for (c = 0; c < 10; c++) for (d = 0; d < 10; d++) {
        state = s.begin();
        if (result == solve(state)) ans++;
      }
    }
    cout << result << " " << ans << endl;
  }
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pi(n,m) n.insert(n.begin(),m);
#define ee(n) n.erase(n.end()-1)
#define eb(n) n.erase(n.begin())
#define check(n) reverse(all(n));rep(z,0,n.size())cout<<n[z];co("");reverse(all(n));
using namespace std;
using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){//幅優先探索
  int n;
  string s;
  cin>>n>>s;
  if(s.size()<=n) co(s);
  else{
    rep(i,0,n) cout<<s[i];
    co("...");
  }
  return 0;
}

Measured memory_bytes: 3624
#!/usr/bin/env python3


def solve(A, B, C, X, Y):

  def cost(cnt):
    a, b, c = cnt
    return a * A + b * B + c * C

  def useAB(cnt):
    return [max(0, cnt[0] - 1),
            max(0, cnt[1] - 1),
            cnt[2] + 2]

  cnt = [X, Y, 0]
  while cost(cnt) > cost(useAB(cnt)):
    cnt = useAB(cnt)

  return cost(cnt)


if __name__ == '__main__':
  A, B, C, X, Y = map(int, input().split())
  print(solve(A, B, C, X, Y))

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace AtCoder_Grand_Contest_034 {
	class Program {
		static void Main(string[] args) {
			var input = Helper<int>.ReadLine();
			var p = input[0];
			var q = input[1];
			var r = input[2];

			var results = new List<int> {
				p + q,
				p + r,
				q + r
			};

			Console.WriteLine(results.Min());
		}
	}

	public static class Helper<T> {
		public static T[] Read(int count) {
			var result = new T[count];
			for (int index = 0; index < count; index++) {
				result[index] = (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromString(Console.ReadLine());
			}
			return result;
		}

		public static T[] ReadLine() {
			var input = Console.ReadLine();
			var inputs = input.Split(' ');
			var result = new T[inputs.Count()];
			for (int index = 0; index < inputs.Count(); index++) {
				result[index] = (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromString(inputs[index]);
			}
			return result;
		}
	}
}


Measured memory_bytes: 14432
MOD = 10**9+7
n, m = map(int, input().split())
broken = [False for _ in range(n+1)]
dp = [0 for _ in range(n+1)]
dp[0] = 1
for _ in range(m):
	b = int(input())
	broken[b] = True
for i in range(1, n+1):
	if broken[i]:
		continue
	if i == 1:
		dp[i] = dp[i-1]
	else:
		dp[i] = dp[i-1] + dp[i-2]
		dp[i] %= MOD
print(dp[n])

Measured memory_bytes: 7832
#include <stdio.h>
int main(void)
{
 
int S;
int h;
int m;
int s;
 
scanf("%d",&S);
 
h = S / 3600;
m = ( S - 3600 * h ) / 60;
s = S % 60;
 
printf("%d:%d:%d\n",h,m,s);
 
return 0;
 
}

Measured memory_bytes: 592
i = list(map(int,input().split()))
w = i[0]
h = i[1]
x = i[2]
y = i[3]

m = (w*h)/2

if (2*x == w) and (2*y == h):
  s = 1
else:
  s = 0
  

print("{:.9}".format(m));print(s)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(){
	int N;
	int x;
	char S[255];
	scanf("%d", &N);
	int ctr[8] = {0};
	for(int i = 0 ; i < N ; i++){
		scanf("%s", &S);
		if(x = strcmp (S, "AC") == 0){
			++ctr[1];
		}
		if(x = strcmp (S, "WA") == 0){
			++ctr[2];
		}
		if(x = strcmp (S, "TLE") == 0){
			++ctr[3];
		}
		if(x = strcmp (S, "RE") == 0){
			++ctr[4];
		}
	}
	printf("AC x %d\n", ctr[1]);
	printf("WA x %d\n", ctr[2]);
	printf("TLE x %d\n", ctr[3]);
	printf("RE x %d\n", ctr[4]);
	return 0;
}

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

int main() {

  long long int a, b;
  cin >> a >> b;

  if ( a + b == 15 ) {
    cout << "+" << endl;
  } else if ( a * b == 15 ) {
    cout << "*" << endl;
  } else {
    cout << "x" << endl;
  }

  return 0;

}


Measured memory_bytes: 256
s=input()
t=input()
import sys
from collections import defaultdict
dic1=defaultdict(lambda:'A')
dic2=defaultdict(lambda:'B')
ans=1
for i in range(len(s)):
  if s[i] in dic1 or t[i] in dic2:
    if dic1[s[i]]==t[i] and  dic2[t[i]]==s[i]:
      pass
    else:
      print('No')
      quit()
  else:
    dic1[s[i]]=t[i]
    dic2[t[i]]=s[i]
print('Yes')


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

int main()
{
  string s;
  cin >> s;
  int ans = 10000;
  for(int i=0; i<s.size()-2; i++)
  {
    string subs = s.substr(i, 3);
    int a = atoi(subs.c_str());
    ans = min(ans, abs(753 - a));
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000
using ll = long long;
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n != 0) {
		sum += n % 10; n /= 10;
	}
	return sum;//Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
ld mysqrtl(ld x)
{
	ld a = sqrtl((double)x); // 近似値
	do {
		a = (a + x / a) / 2.0L;
	} while (fabsl(x - a * a) > eps);
	return a;
}
 ll gcd(ll a, ll b) {
	 if (b == 0) return a;
	 return gcd(b, a % b);
	
}

 ll lcm(ll a, ll b) {
	 ll g = gcd(a, b);
	 return a / g * b; 
 }

//平方根を求める。sqrtより精度が高い。
//epsを変えて誤差を調整する。
int main(void) {
	Rapid_pleaseAC_fast;
	llint ans = 0, n = 0, m = 0, count = 0, sum = 0, ch = 0, a[200000] = {0};
	bool check = false;
	string s;
	vector<llint> array;
	char c;
	cin >> n;
	rep(i, n-1) {
		cin >> count;
		a[count-1]++;
	}
	rep(i, n) {
		cout << a[i] << endl;
	}
	
	please AC;
}


Measured memory_bytes: 5240
'use strict'

function Main(input) {
  input = input.trim().split('\n')
  const array = input[0].split(' ').map(s => parseInt(s))
  const rest = input.slice(1)
  const H = array[0]
  const N = array[1]

  const magic = []
  for(let i = 0; i < rest.length; ++i) {
    const a = rest[i].split(' ').map(s => parseInt(s))
    magic.push([a[0], a[1]])
  }
  magic.sort((a, b) => a[0] - b[0])

  let dp = Array(H+1).fill(Infinity)

  dp[0] = 0
  for(let i = 0; i < N; ++i) {
    const w = magic[i][0]
    const v = magic[i][1]
    for(let j = 0; j <= H; ++j) {
      
      const min = Math.min(j + w, H)

      dp[min] = Math.min(dp[min], dp[j] + v) 
    }

    // console.log(`${i}までの魔法を利用`)
    // console.log(dp)
    // console.log('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^')
  }
  
  console.log(dp[H])
  
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 10540
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int m, d;
	cin >> m >> d;
	int sum = 0;
	for(int i = 1; i <= d; i++){
		if(i%10*(i/10) <= m && i%10*(i/10) > 0 && i % 10 >= 2 && i / 10 >= 2){
			sum++;
		}	
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> v(n);
    for(int &x:v)cin>>x;
    int count=0;
    for(int i=0;i<n-2;i++)
    {
		for(int j=i+1;j<n-1;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				if(v[i]!=v[j] and v[j]!=v[k] and v[k]!=v[i] and (v[i]<v[j]+v[k] and v[j]<v[i]+v[k]  and v[k]<v[i]+v[j]))
				{
					//cout<<v[i]<<" "<<v[j]<<" "<<v[k]<<endl;
					count++;
				}
			}
		}
	}
	cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define FAST std::ios::sync_with_stdio(false);
#define endl '\n'
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MAX_N 200005
#define Mem(a,b) memset(a,b,sizeof(a))
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
using namespace std;
const ll mod=1e9+7;
int main() {
    int n;
    cin>>n;
    for(ll i=1; i<=3500; i++)
        for(ll j=1; j<=3500; j++) {
            if((3*i*j>n*(i+j))&&(i*j*n)%(4*i*j-n*(i+j))==0) {
                cout<<i<<" "<<j<<" "<<(i*j*n)/(4*i*j-n*(i+j))<<endl;
                return 0;
            }
        }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include<vector>
#include <queue>
using namespace std;
int h[200005] = { 0 };
int main()
{
	priority_queue<int>pque;
	int n,a;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		pque.push(a);
		h[i] = a;
	}
	for (int i = 1; i <= n / 2 - 1; i++){
		pque.pop();
	}
	int c2 = pque.top();
	pque.pop();
	int c1 = pque.top();
	//cout << c2 << " " << c1 << endl;
	for (int i = 1; i <= n; i++) {
		if(h[i]<=c1) cout<<c2<<endl;
		else cout << c1 << endl;
	}
}


Measured memory_bytes: 3828
#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>

#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



#include <array>
#include <iterator>



using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl;
typedef pair < int, int> P;


string S, T;
int main() {
	cin >> S >> T;
	int ans = 0;
	rep(i, 3) {
		if (S[i] == T[i]) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;

class Prog{
    static void Main(){
        int[] di = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int[] ls = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int n = di[0];
        int x = di[1];
        int l = 0;
        int k = 1;
        for(int i = 0;i<n;i++){
            l += ls[i];
            k++;
            if(l > x){
                k -= 1;
                break;
            }
        }
        Console.WriteLine(k);
    }
}

Measured memory_bytes: 27424
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

bool is_int(double x) {
    return abs(x - int(x)) < pow(0.1, 8);
}
int main(void) {
    ll n;
    cin >> n;
    const int LIM = 3500;
    for (int i = 1; i <= LIM; ++i) {
        for (int j = 1; j <= LIM; ++j) {
            const ll d = n * i * j;
            const ll m = 4LL * i * j - i * n - j * n;
            if (m <= 0) {
                continue;
            }

            if (d % m != 0) {
                continue;
            }

            ll u = d/m;

            if (0 < u && u <= LIM) {
                printf("%d %d %lld\n", i, j, u);
                return 0;
            }
            // double a = double(d)/m;
            // if (a > 0 && is_int(a)) { 
            //     cout << i << " " << j << " " << int(a) << endl;
            //     return 0;
            // }
            // if (m != 0 && (n * i * j) % m == 0) {
                // int u = (n * i * j) / m;
                // if (u > 0 && u <= LIM) {
                    // cout << i << " " << j << " " << u << endl;
                    // return 0;
                // }
        }
    }

    return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

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

Measured memory_bytes: 3588
from collections import defaultdict
from collections import deque
from collections import OrderedDict
import itertools
from sys import stdin
input = stdin.readline


def main():
  N, M, K = list(map(int, input().split()))

  friends = [[] for _ in range(N)]
  for _ in range(M):
    a, b = map(int, input().split())
    friends[a-1].append(b-1)
    friends[b-1].append(a-1)

  block = [[] for _ in range(N)]
  for _ in range(K):
    a, b = map(int, input().split())
    block[a-1].append(b-1)
    block[b-1].append(a-1)

  num_cand = [-1]*(N)
  member = {}
  group = {}

  for i in range(N):
    if i in group:
      continue
    start = i
    # print(f'start:{start}')
    q = deque([start])
    member[start] = set([start])
    group[start] = start
    is_visited = set([start])
    while len(q):
      now = q.popleft()
      for next_ in friends[now]:
        num_cand[now] -= 1
        # print(f'group:{start}, now:{now}->next_:{next_}', now, '-1')
        if next_ not in is_visited:
          member[start].add(next_)
          group[next_] = start
          # num_cand[next_] -= 1
          # print(f'group:{start}, now:{now}->next_:{next_}', next_, '-1')
          # num_cand[now] -= 1
          # print(f'group:{start}, now:{now}->next_:{next_}', now, '-1')
          q.append(next_)
          is_visited.add(next_)

  # print(member)
  # print(num_cand)
  for i in range(N):
    num_cand[i] += len(member[group[i]])
    for enemy in block[i]:
      if enemy in member[group[i]]:
        num_cand[i] -= 1

  print(*num_cand, sep=' ')


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 142304
mod reader {
    use std;

    macro_rules! read_line((  ) => {
                           {
                           let mut input = String :: new (  ) ; std :: io ::
                           stdin (  ) . read_line ( & mut input ) . unwrap (
                           ) ; input } } ;);

    pub fn read_str() -> String { read_line!().trim().to_owned() }
}
use reader::*;

fn is_acgt(s: char) -> bool {
    match s { 'A' | 'T' | 'G' | 'C' => true, _ => false, }
}

fn main() {
    let s = read_str();
    let cs = s.chars();

    let mut count: usize = 0;
    let mut tmp_count: usize = 0;
    let mut flag = false;
    for c in cs {
        if is_acgt(c) {
            if !flag { tmp_count = 0; }
            flag = true;
            tmp_count += 1;
        } else { flag = false; }

        if count < tmp_count { count = tmp_count; }
    }

    println!("{}" , count);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

ll t[100];

ll gcd(ll a,ll b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
int main()
{
	int n;
	ll ans=0;
	
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>t[i];
	
	if(n==1)
	{
		ans=t[0];
	}else{
		ll g=gcd(t[0],t[1]);
		ans = t[0]*(t[1]/g);
		for(int i=2;i<n;i++)
		{
			ll g=gcd(ans,t[i]);
			ans = ans*(t[i]/g);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

    if(b < 0){
        if((b - a) % 2 == 0)
            cout << "Negative" << endl;
        else
            cout << "Positive" << endl;
    }
    else if(0 < a){
        cout << "Positive" << endl;
    }
    else{
        cout << "Zero" << endl;
    }

    return 0;
}

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

int main(){
	int a,b,c,d,e,f;
	cin>>a;
	b=a/60;//????????\?????????
	c=a%60;//?§?
	d=b/60;//??????
	e=b%60;//???
	cout<<d<<":"<<e<<":"<<c<<endl;
	return 0;

}

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

using namespace std;


char board[200][200];
char temp[200][200];

int main(){
    int h,w; cin >> h >> w;
    
    for(int i = 0 ; i < h ; i++){
        for(int j = 0 ; j < w ; j++){
            cin >> temp[i][j];
        }
    }
    
    for(int i = 0 ; i < h ;i++){
        for(int j = 0 ; j < w ; j++){
            board[i * 2][j] = temp[i][j];
            board[i * 2 + 1][j] = temp[i][j];
        }
    }
    
    for(int i = 0 ; i < h * 2 ; i++){
        for(int j = 0 ; j < w ; j++){
            cout << board[i][j];
        }
        cout << endl;
    }
}


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

int debug = 0;

int main()
{
    int n,m;
    int a[n];
    int sum,tmp;
    cin >> n >> m;
    sum = 0;
    rep(i,m){
        cin >> tmp;
        sum += tmp;
    }

    int ans;
    ans = n - sum;
    if(ans <0){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
import math
a,b=map(int,input().split())
if b < 10:
  a *= 10
elif b <100:
  a *= 100
else:
  a *=1000
a_b =a + b
if math.sqrt(a_b) - int(math.sqrt(a_b)) == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 61756
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int R, C;
int f(int x, int y) {
	if (x == 0) return y;
	if (y == C) return C + x;
	if (x == R) return R + 2 * C - y;
	if (y == 0) return 2 * R + 2 * C - x;
	return -1;
}

int main() {
	int N;
	cin >> R >> C >> N;
	vii v;
	for (int i = 0; i < N; ++i) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		int a = f(x1, y1), b = f(x2, y2);
		if (a > b) swap(a, b);
		if (a != -1 && b != -1) {
			v.emplace_back(a, i);
			v.emplace_back(b, i);
		}
	}
	sort(v.begin(), v.end());
	bool ans = 1;
	stack<int> S;
	bitset<100001> vis;
	for (int i = 0; i < v.size(); ++i) {
		if (!vis[v[i].s]) {
			S.emplace(v[i].s);
			vis[v[i].s] = 1;
		}
		else {
			while (!S.empty() && S.top() != v[i].s) S.pop();
			if (S.empty()) {
				cout << "NO" << '\n';
				return 0;
			}
			S.pop();
		}
	}
	cout << "YES" << '\n';
	return 0;
}

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

int main()
{
    int n,m;
    cin >> n >> m;
    int ans[3];
    int flag = -1;
    for( int j = 0; j < n; j++ )
    {
        ans[j] = -1;
    }

    for( int i = 0; i < m; i++ )
    {
        int s, c;
        cin >> s >> c;
        if( ans[s-1] != -1 && ans[s-1] != c )
        {
            flag = 1;
        }
        ans[s-1] = c;
    }

    if( flag != 1 ){
        for( int z = 0; z < n; z++ )
        {
            if( z == 0 && n != 1 )
            {
                if( ans[z] == 0 )
                {
                    cout << -1;
                    break;
                }
                else if( ans[z] == -1 )
                {
                    cout << 1;
                }
                else
                {
                    cout << ans[z];
                }
            }
            else if( z == 0 && n == 1 && m == 0 )
            {
                cout << 0;
                break;
            }
            else
            {
                if(ans[z] != -1)
                {
                    cout << ans[z];
                }
                else if(ans[z] == -1)
                {
                    cout << 0;
                }
            }
        }
    }
    else
    {
        cout << -1;
    }    
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main() {
  int N = 3;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(all(A));
  int sum = 0;
  for (int i = 0; i < N - 1; i++) {
    sum += A[i + 1] - A[i];
  }
  cout << sum << endl;
  return 0;
}




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

int main(){
  int n,x=1,y=1; cin>>n;
  for(int i=0;i<n;i++){
    int a; cin>>a;
    x*=3;
    if(a%2==0){
      y*=2;
    }else{
      y*=1;
    }
  }
  cout<<x-y<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
int dp[405][405];
int main(){
	int n,m1,m2,c1,c2,cost,ans=INF;
	scanf("%d%d%d",&n,&m1,&m2);
	rep(i,401)rep(j,401)dp[i][j]=INF;
	dp[0][0]=0;
	rep1(k,n){
		scanf("%d%d%d",&c1,&c2,&cost);
		for(int j=10*n;j>=c1;j--)
		for(int k=10*n;k>=c2;k--)
		dp[j][k]=min(dp[j][k],dp[j-c1][k-c2]+cost);
	}
	rep1(k,min(400/m1,400/m2))
	ans=min(ans,dp[k*m1][k*m2]);
	if(ans==INF)printf("-1");
	else printf("%d",ans);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

long long int gcd(long long int a, long long int b) {
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a%b);
	}
}

int main() {
	long long int a, b, c, d;
	cin >> a >> b >> c >> d;
	long long int x, y;
	x = abs(a - c);
	y = abs(b - d);
	cout << (x / gcd(x, y) + y / gcd(x, y) - 1)*gcd(x, y) << endl;
	return 0;
}

Measured memory_bytes: 256
A,B,H,M=map(int,input().split())
from math import cos
p=3.14159265358979323846264338328
ho=H*p/6+M*p/360
mi=M*p/30
t=ho-mi
x=(A*A+B*B-2*A*B*cos(t))**0.5
print(x)

Measured memory_bytes: 62332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[100010],b[100010];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<=n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	ll ans=0,zan=0;
	for(int i=0;i<=n;i++){
		if(zan!=0){
			ans+=min(a[i],zan);
			a[i]-=min(a[i],zan);
			zan=0;
		}
		ll now=min(a[i],b[i]);
		ans+=now;
		a[i]-=now;
		b[i]-=now;
		if(a[i]<b[i]){
			zan=b[i]-a[i];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/3/ALDS1_3_A


def solve():
    stack = []
    equations = list(map(str, input().split()))

    for equ in equations:
        try:
            num = int(equ)
            stack.append(num)
        except Exception:
            a = stack.pop()
            b = stack.pop()
            stack.append(int(eval('{} {} {}'.format(b, equ, a))))
    print(stack.pop())


if __name__ == '__main__':
    solve()



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

int main()
{
   int n,x,t;scanf("%d %d %d",&n,&x,&t);
   if(n%x==0)
   printf("%d\n",(((n/x)*t)));
   else
    printf("%d\n",(((n/x)*t))+t);
    return 0;
}


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

using namespace std;

int dist(int& x, int& y) {
	return abs(x - y);
}
const int INT_MAX = 1e9;
int minCost(int n, int k, vector <int>& h) {
	vector <int> dp(n + 1, 0);
	for (int i = 2; i <= n; ++i) {
		dp[i] = INT_MAX;
		// cout << i << " I\n";
		for (int j = k; j >= 1; --j) {
		  
			if (i - j > 0) {
				dp[i] = min(dp[i], dp[i - j] + dist(h[i - 1], h[i - j - 1]));
			
			}
		}
	}
	return dp[n];
}


int main() {
	int n, x, k;
  	cin >> n >> k;
  	vector <int> v;
  	for(int i = 0; i < n; ++i) 
      cin >> x, v.push_back(x);
  	cout << minCost(n, k, v) << endl;
}



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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back



int main(){
    int n; cin>>n;long long int a[n];long long int sum=0;long long int temp=0;long long int min = 10e20;long long int d = 0;
    for(int i = 0; i < n; i++){
        cin>>a[i];
        sum += a[i];
    }
    for (int i = 0; i < n-1; i++){
        temp += a[i];
        d = abs((sum-temp) - temp);
        if(d<min){
            min = d;
        }
    }
    cout<<min;
    
}

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

int main(){

   string s1,s2,s3;
   cin>>s1>>s2>>s3;

    char dif='a'-'A';
    cout<<(char)(s1[0]-dif)<<(char)(s2[0]-dif)<<(char)(s3[0]-dif)<<endl;





    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
char S[1000];
signed main(){
    scanf("%s",S);
    int i=0;int j=strlen(S)-1;
    while(i<j){
        if(S[i]!=S[j]){printf("No");return 0;}
        i++;j--;
    }
    i=0;j=(strlen(S)-1)/2 -1;
    while(i<j){
        if(S[i]!=S[j]){printf("No");return 0;}
        i++;j--;
    }
    i=(strlen(S)+3)/2 -1;j=strlen(S)-1;
    while(i<j){
        if(S[i]!=S[j]){printf("No");return 0;}
        i++;j--;
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    int ans=0;
    int tmp=0;
    
    cin >> n;
    
    vector<int> p(n+1, 0);
    
    for(int i=1; i<=n; i++){
        
        cin >> p.at(i);
        
        if(i==p.at(i)){
            
            if(tmp==0){
                
                ans += 1;
                tmp = 1;
                
            } else {
                
                tmp = 0;
                
            }
            
        } else {
            
            tmp = 0;
            
        }
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 640
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,m,cha[88][88];
bool dp[88][88][168*88*2];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>cha[i][j];
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			int x;
			cin>>x;
			cha[i][j]-=x;
			cha[i][j]=abs(cha[i][j]);
		}
	}
	for(int i=0;i<=n;i++)
	{
		dp[i][0][12825]=true;
	}
	for(int j=0;j<=m;j++)
	{
		dp[0][j][12825]=true;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			for(int k=0;k<12825*2+100;k++)
			{
				if((dp[i-1][j][k] && (i!=1 || (i==1 && j==1))) || (dp[i][j-1][k] && (j!=1 || (i==1 && j==1))))
				{
					dp[i][j][k+cha[i][j]]=true;
					dp[i][j][k-cha[i][j]]=true;
				}
			}
		}
	}
	int ans=1e9;
	for(int k=0;k<12825*2+100;k++)
	{
		if(dp[n][m][k])
		{
			ans=min(ans,abs(k-12825));
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

// TYPEDEFS
typedef long long int li;
typedef unsigned long long int uli;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;
typedef pair<int, int> ii;
typedef pair<li, li> ll;
typedef pair<int, char> ic;
typedef pair<char, int> ci;
typedef pair<li, char> lc;
typedef pair<char, li> cl;
typedef vector<ic> vic;
typedef vector<ci> vci;
typedef vector<lc> vlc;
typedef vector<cl> vcl;
typedef map<int, int> mii;
typedef map<li, li> mll;
typedef map<char, int> mci;
typedef map<int, char> mic;
typedef map<li, char> mlc;
typedef map<char, li> mcl;
typedef map<char, bool> mcb;
typedef map<int, bool> mib;
typedef map<li, bool> mlb;
typedef set<int> si;
typedef set<li> sl;
typedef set<char> sc;
typedef priority_queue<int> pqi;
typedef priority_queue<li> pql;

// DEFINITIONS
#define fi(i, a, b, jump) \
    for (int i = int(a); i <= int(b); i += jump)
#define fir(i, a, b, jump) \
    for (int i = int(b); i >= int(a); i -= jump)
#define fl(i, a, b, jump) \
    for (li i = li(a); i <= li(b); i += jump)
#define flr(i, a, b, jump) \
    for (li = li(b); i >= li(a); i -= jump)
#define fv(v) \
    for (int i = 0; i < v.size(); ++i)
#define fvr(v) \
    for (int i = v.size()-1; i >= 0; --i)
#define fm(mp) \
    for (it = mp.begin(); it != mp.end(); ++it)
#define mem(arr, val) \
    memset(arr, val, sizeof(arr))

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li n,m,in;
    cin >> n >> m;
    priority_queue<li> arr;
    li summ = 0;
    fi(i,0,n-1,1){
        cin >> in;
        summ += in;
        arr.push(in);
    }
    
    while(summ && m--){
        li old_val = arr.top();
        arr.pop();
        summ -= (old_val - (old_val>>1));
        old_val = (old_val>>1);
        arr.push(old_val);
    }
    cout << summ;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,k,sum=0;
	cin>>a>>b>>c>>k;
	if(a>=k){
		cout<<k<<endl;
		return 0;
	}
	k-=a;
	sum+=a;
	if(b>=k){
		cout<<sum<<endl;
		return 0;
	}
	k-=b;
	cout<<sum-min(k,c)<<endl;
	return 0;
}


Measured memory_bytes: 3632
# coding: euc-jp
X, Y = gets.split.map {|e| e.to_i}

# 初期値はXから、Xの倍数がYを超えるまでカウント
ans = 1
max = X

while (max <= Y)
  ans += 1
  max = max * 2
end

puts ans - 1 


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

typedef long long ll;

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,l,n) for(int i=(l);i<(n);i++)

int main(){
	int N;
	ll ans = 0;
	cin >> N;
	vector<int> A(N),B(N),C(N);
	rep(i,N) cin >> A[i];
	rep(i,N) cin >> B[i];
	rep(i,N) cin >> C[i];
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	sort(C.begin(),C.end());
	for(auto num : B){
		ll left = -1, right = N;
		ll up_count = 0, un_count = 0;
		while(right - left > 1){
			ll mid = (right + left)/2;
			if(A[mid] >= num) right = mid;
			else  left = mid;
		}
		up_count = left+1;
		left = -1; right = N;
		while(right - left > 1){
			ll mid = (right + left)/2;
			if(C[mid] <= num) left = mid;
			else  right = mid;
		}
		un_count = N-right;
		ans += up_count * un_count;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
/*
给一个长度n 编号 1-n 的数组， m个操作， 每次操作选定 [L,R] 搞一次， q个查询，
每次查询问[L,R] 严格子区间内，搞了几回 。
例如: 操作 [1,1] [2,2] [1,2] , [1,6] 查询[1 2] 得到3
*/

#include<bits/stdc++.h>

using namespace std;
#define int long long
#define N 666
int n,m,q;
int dp[N][N],mp[N][N]={0};
/*
dp(i,j): 区间 [i,j] 覆盖的子区间的数量
dp(l,r)+=dp(l,r-1)+dp(l+1,r)-dp(l-1,r-1) 
*/
signed main(){
	cin>>n>>m>>q;
	int l,r;
	for(int i=0;i<m;i++){
		cin>>l>>r;
		mp[l][r]++;
	}
	for(int l=n;l>=1;l--){
		for(int r=l;r<=n;r++){
			dp[l][r]=mp[l][r]+dp[l][r-1]+dp[l+1][r]-dp[l+1][r-1];
		}
	}
	while(q--){
		cin>>l>>r;
		cout<<dp[l][r]<<'\n';
	}
	return 0;
}

Measured memory_bytes: 8652