akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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 Graph = vector<vector<int>>;
int fg(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
signed main(){
  int N,M;
  cin>>N>>M;
  int a=N*(N-1)/2;
  int b=M*(M-1)/2;
  cout<<a+b;
 }


Measured memory_bytes: 256
#include<iostream>
#include<string>

int main(){
	std::string str;
	int n,max=0;
	std::cin>>str;
	n=str.size();
	for(int i=0;i<n;i++){
		end:;
		if(str[i]=='J'){
			int count_j=1,count_o=0,count_i=0;
			for(i+=1;i<n;i++){
				if(str[i]=='J')count_j++;
				else if(str[i]=='O'){
					count_o++;
					for(i+=1;i<n;i++){
						if(str[i]=='O')count_o++;
						else if(str[i]=='I'){
							count_i++;
							bool flg=false;
							if(i==n-1){
								int max2=0;
								if(count_o==std::min(count_i,std::min(count_j,count_o)))max2=std::min(count_i,std::min(count_j,count_o));
								max=std::max(max,max2);
								goto end;
							}
							for(i+=1;i<n;i++){
								if(str[i]=='I'){
									count_i++;
									if(i==n-1){
										int max2=0;
										if(count_o==std::min(count_i,std::min(count_j,count_o)))max2=std::min(count_i,std::min(count_j,count_o));
										max=std::max(max,max2);
										goto end;
									}
								}else{
									int max2=0;
									if(count_o==std::min(count_i,std::min(count_j,count_o)))max2=std::min(count_i,std::min(count_j,count_o));
									max=std::max(max,max2);
									goto end;
								}
							}
						}
						else goto end;
					}
				}
				else goto end;
			}
		}
	}
	std::cout<<max<<std::endl;
	return 0;
}

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

bool cmp(pair<int, int> a, pair<int, int> b)
{
	return a.first > b.first;
}

vector<int> parent;

int find_set(int v)
{
	if(v == parent[v]) {
		return v;
	} else {
		return parent[v] = find_set(parent[v]);
	}
}

void union_set(int u, int v)
{
	int p = find_set(u);
	parent[v] = p;
}

void make_set(int n)
{
	parent = vector<int>(n+1);
	for(int i = 0; i <= n; i++) parent[i] = i;
}

int main()
{
	int T;
	scanf("%d", &T);
	while(T--) {
		int n;
		scanf("%d", &n);
		long long happiness = 0;
		vector<pair<int,int>> st;
		vector<pair<int, int>> ed;
		for(int i = 0; i < n; i++) {
			int x, y, z;
			scanf("%d%d%d", &x, &y, &z);
			if(x == n) {
				happiness += y;
				continue;
			}
			if(y > z) {
				happiness += z;
				y -= z;
				st.push_back({y, x});
			} else if(z > y) {
				happiness += y;
				z -= y;
				ed.push_back({z, n-x});
			} else {
				happiness += y;
			}
		}
		sort(st.begin(), st.end(), cmp);
		sort(ed.begin(), ed.end(), cmp);
		make_set(n);
		for(int i = 0; i < st.size(); i++) {
			int p = find_set(st[i].second);
			if(p == 0) continue;
			happiness += st[i].first;
			union_set(p-1, p);
		}
		make_set(n);
		for(int i = 0; i < ed.size(); i++) {
			int p = find_set(ed[i].second);
			if(p == 0) continue;
			happiness += ed[i].first;
			union_set(p-1, p);
		}
		printf("%lld\n", happiness);
	}
}

Measured memory_bytes: 6428
#include<bits/stdc++.h>
//#include<iostream>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false)
#define FIX(a) cout << fixed << setprecision(a)
#define mp make_pair
//manip
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power_mod(T a, T b) {return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
template<class T> T power(T a, T b) {return b ? power(a * a, b / 2) * (b % 2 ? a : 1) : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
#define outa(a, n) rep(i_, n) cout << a[i_] << " "; cout << endl
#define out(a) cout << a << endl
#define outv(v) rep(i, SZ(v)) cout << v[i] << " "; cout << endl
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always



int main() {
    
    
    
    
    int n;
    string t = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    while (cin >> n && n) {
        int k[n]; rep(i, n) cin >> k[i];
        string s; cin >> s;
        
        rep(i, SZ(s)) {
            for (int j = 26 * 4 - 1; j >= 0; --j) {
                if (t[j] == s[i]) {
                    cout << (char)(t[j - k[i % n]]);
                    break;
                }
            }
            
        }
        cout << endl;
    }
    
    
    
    
}




Measured memory_bytes: 3152
#include <cstdio>
#include <vector>
typedef long long ll;

int n,A,B;
std::vector<int> a[300005];

int main()
{
    scanf("%d%d%d",&n,&A,&B);
    if(A+B-1<=n&&n<=(ll)A*B)
    {
        for(int i=B;i>=1;--i)a[1].push_back(i);
        // n-B -> A-1
        int Rem=n-B,Nv=B+1;
        for(int i=2;i<=A;++i)
        {
            int Cnt=Rem/(A-1)+(i-2<Rem%(A-1));
            for(int j=Nv+Cnt-1;j>=Nv;--j)a[i].push_back(j);
            Nv+=Cnt;
        }
        for(int i=1,j=0;i<=A;++i)
            for(auto k:a[i])
                printf("%d%c",k," \n"[++j==n]);
    }
    else puts("-1");
    return 0;
}

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

int main() {
  int n,k;
  cin >> n>>k;
  vector<int>d(k);
  vector<bool>b(10,true);
  rep(i,k){
    cin>>d.at(i);
    b.at(d.at(i))=false;
  }

  bool ex=true;
  int c=n;
  while(ex){
    string e=to_string(c);
    bool ch=true;
    rep(i,e.size()){
      if(!b.at(e.at(i)-'0')){
        ch=false;
        break;
      }
    }
    if(ch){
      cout<<c<<endl;
      ex=false;
    }
    else{
      c++;
    }
  }
}

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

int main(){
    
    long long n,x;
    cin>>n>>x;
    long long a=x;
    long long b=n-x;
    if(a<b)
    swap(a,b);
    while(b !=0){
        long long x=a;
        a=b;
        b=x%b;
        if(a<b)
        swap(a,b);
        
    }
    
    cout<<3*(n-a);
    return 0;
    
}


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

int main(){
    int n;
    cin >> n;
    
    int ans = 0;
    int div = 0;
    for(int i = 1; i <= n; i++){
        if(i % 2 == 1){
            div = 0;
            for(int j = 1; j <= i; j++){
                if(i % j == 0) div++;
            }
            if(div == 8) ans++;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
int main()
{
  int a,b;
  cin>>a>>b;
  cout<<max(0,a-2*b);
}

Measured memory_bytes: 3580
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    print(n*(n-1)//2)


if __name__=="__main__":
    main()


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n, l;
    cin >> n >> l;

    int diff = inf, ans = 0;

    REP(i, n){
        int d = abs(l + i);
        if(chmin(diff, d)){
            ans = l*(n-1) + n*(n - 1)/2 - i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 100005
#define ll long long
using namespace std;
map<ll,int> ma, vis;
vector<ll> v1, v2;
ll pre[maxn];
int n;

int main()
{
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>pre[i];
    ma[pre[i]] ++;
    if(ma[pre[i]] == 2){
      v1.push_back(pre[i]);
      ma[pre[i]] -= 2;
    }
  }
  sort(v1.begin(), v1.end());
  if(v1.size() < 2){
    cout<<"0"<<endl;
  }
  else{
    cout<<v1[v1.size() - 1] * v1[v1.size() - 2]<<endl;
  }
  return 0;
}


Measured memory_bytes: 7296
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProblemD
{
    class Program
    {
        static void Main(string[] args)
        {
            var wall = '#';
            var dot = '.';
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var H = read[0];
            var W = read[1];

            var strs = new List<char[]>();
            for (int i = 0; i < H; i++)
            {
                strs.Add(Console.ReadLine().ToCharArray());
            }
            var L = new int[H, W];
            var R = new int[H, W];
            var U = new int[H, W];
            var D = new int[H, W];
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    L[i, j] = strs[i][j] == wall ? 0 :
                        j == 0 ? 1 : L[i, j - 1] + 1;
                    R[i, W - j - 1] = strs[i][W - j - 1] == wall ? 0 :
                        j == 0 ? 1 : R[i, W - j - 1 + 1] + 1;
                    U[i, j] = strs[i][j] == wall ? 0 :
                        i == 0 ? 1 : U[i - 1, j] + 1;
                    D[H - i - 1, j] = strs[H - i - 1][j] == wall ? 0 :
                        i == 0 ? 1 : D[H - i - 1 + 1, j] + 1;
                }
            }
            var ret = 0;
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    ret = Math.Max(ret, L[i, j] + R[i, j] + U[i, j] + D[i, j] - 3);
                }
            }
            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 92608
#include<iostream>
using namespace std;
const int INF = 1000000000;
int main()
{
	while(true){
		int n, m;
		cin >> n >> m;

		if(n==0 && m==0)
			break;

		int C[100][100];
		int T[100][100];
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++){
				if(i==j){
					C[i][j] = T[i][j] = 0;
				}
				else{
					C[i][j] = T[i][j] = INF;
				}
			}
		}
		for(int i=0; i<n; i++){
			int a, b, c, t;
			cin >> a >> b >> c >> t;

			C[a-1][b-1] = C[b-1][a-1] = c;
			T[a-1][b-1] = T[b-1][a-1] = t;
		}

        int Cd[100][100]; // 最短距離
        int Td[100][100]; // 最短距離
        for(int i=0; i<m; i++){ // 重み配列で初期化
            for(int j=0; j<m; j++){
                Cd[i][j]=C[i][j];
                Td[i][j]=T[i][j];
            }
        }
        for(int k=0; k<m; k++){
            for(int i=0; i<m; i++){
                for(int j=0; j<m; j++){
                    if(Cd[i][j]>(Cd[i][k]+Cd[k][j])){
                        Cd[i][j] = (Cd[i][k]+Cd[k][j]);
                    }
                    if(Td[i][j]>(Td[i][k]+Td[k][j])){
                        Td[i][j] = (Td[i][k]+Td[k][j]);
                    }
                }
            }
        }
        int K;
        cin >> K;
        for(int i=0;i<K;i++){
            int p, q;
            cin >> p >> q;
            int r;
            cin >> r;
            if(r==1){
                cout<<Td[p-1][q-1]<<endl;
            }else{
                cout<<Cd[p-1][q-1]<<endl;
            }
        }
	}
	return 0;
}


Measured memory_bytes: 3236
#include	<stdio.h>
int	main(void)
{
	int a,b,d,r;
	double f;
//	scanf("%d,%d",&a,&b);
	scanf("%d",&a);
	scanf("%d",&b);
	d=(int)a/b;
	r=(int)a%b;
	f=(double)a/b;
	printf("%d %d %lf\n",d,r,f);
	return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int main(){

	ll N;
	scanf("%lld",&N);

	vector<ll> V;
	ll tmp;

	for(ll i = 0; i < N; i++){

		scanf("%lld",&tmp);
		V.push_back(tmp);
	}

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

	ll ans = V[0];
	ll rest = N-2;

	for(ll i = 1; i < V.size() && rest > 0; i++){

		ans += V[i];
		rest--;
		if(rest == 0)break;

		ans += V[i];
		rest--;
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 5348
'use strict'
const main = arg => {
	const input = arg.trim().split("\n");
	const N = Number(input[0])
	const Ts = input[1].split(' ').map(el => Number(el))
	const M = Number(input[2])
	const Ds = input.slice(3, input.length).map(e => { return { q: Number(e.split(' ')[0]), sec: Number(e.split(' ')[1])} })

	let drinkEffects = []
	for(let i = 1 ; i <= M ; i++) {
		drinkEffects.push(Ts[Ds[i - 1].q - 1] - Ds[i - 1].sec)
	}
	for(let i = 0 ; i < drinkEffects.length; i++) {
		console.log(Ts.reduce((prev, curr) => prev + curr, 0) - drinkEffects[i])
	}
	
}   
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 8300
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		sc.close();
		long ans = 0;
		if (n % 2 != 0) {
			ans = 0;
		} else {
			for (int i = 1; i <= 26; i++) {
				ans += (n / 2l) / (long) Math.pow(5, i);
			}
		}
		System.out.println(ans);
	}

	public static int arrayMax(int[] array) {
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < array.length; i++) {
			if (array[i] > ans)
				ans = array[i];
		}
		return ans;
	}

	public static long arrayMax(long[] array) {
		long ans = Long.MIN_VALUE;
		for (int i = 0; i < array.length; i++) {
			if (array[i] > ans)
				ans = array[i];
		}
		return ans;
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}

	public static String[] arrayString(Scanner sc, int n) {
		String[] array = new String[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.next();
		}
		return array;
	}

	static String nextPermutation(String s) {

		ArrayList<Character> list = new ArrayList<>();
		for (int i = 0; i < s.length(); i++)
			list.add(s.charAt(i));

		int pivotPos = -1;
		char pivot = 0;
		for (int i = list.size() - 2; i >= 0; i--) {
			if (list.get(i) < list.get(i + 1)) {
				pivotPos = i;
				pivot = list.get(i);
				break;
			}
		}

		if (pivotPos == -1 && pivot == 0)
			return "Final";

		int L = pivotPos + 1, R = list.size() - 1;
		int minPos = -1;
		char min = Character.MAX_VALUE;
		for (int i = R; i >= L; i--) {
			if (pivot < list.get(i)) {
				if (list.get(i) < min) {
					min = list.get(i);
					minPos = i;
				}
			}
		}

		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R + 1));

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < list.size(); i++)
			sb.append(list.get(i));

		return sb.toString();
	}
}


Measured memory_bytes: 21844
import math
n=input()
a=map(int, raw_input().split())
a=[a[i]-a[i-1] for i in range(1, len(a))]
a=[value/abs(value) for value in a if value]
cur=0
result=0
for value in a:
	if cur and cur!=value:
		cur=0
		result+=1
	else:
		cur=value
print result+1

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

int N, T;

int main() {
    scanf("%d %d", &N, &T);
    int s = 0, e = 0, ans = 0;
    for(int i = 0; i < N; i++) {
        int t; scanf("%d", &t);
        if(t > e) {
            ans += e - s;
            s = t, e = t + T;
        }
        else e = t + T;
    }
    ans += e - s;
    printf("%d", ans);
}


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

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

int main() {
	int pmin = INF, jmin = INF;
	rep(i, 3) {
		int p;
		scanf("%d", &p);
		pmin = min(pmin, p);
	}
	rep(i, 2) {
		int j;
		scanf("%d", &j);
		jmin = min(jmin, j);
	}
	printf("%d\n", pmin + jmin - 50);
	return 0;
}

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

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint euler(llint x){
	if(x==0)return 0;
	llint ret=x;
	for(llint i=2;i*i<=x;i++){
		if(x%i==0){
			ret-=ret/i;
			while(x%i==0)x/=i;
		}
	}
	if(x>1)ret-=ret/x;
	return ret;
}

void solve(){
	llint n;
	cin >> n;
	cout << euler(n) << endl;
}

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



Measured memory_bytes: 3124
#include<stdio.h>
int main(){
	int m[120];
	int n,j,i;
	
	m[0]=100000;
	for(i=1;i<100;i++){
		m[i]=m[i-1]*0.05+m[i-1];
		if(m[i]%1000!=0){
			j=m[i]%1000;
			m[i]-=j;
			m[i]+=1000;
		}
	}
	scanf("%d",&n);
	printf("%d\n",m[n]);
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#define INF 1000000000

const int N = 200000;

int main() {
  int n, r[N + 1];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &r[i]);
  r[n] = -INF;

  int min = r[0], max = r[0], ans = -INF;
  for (int i = 1; i <= n; i++) {
    if (r[i] <= min) {
      if (max == min) {
        if (r[i] - min > ans) ans = r[i] - min; 
      } else {
        if (max - min > ans) ans = max - min;
      }
      min = r[i];
      max = r[i];
    } else if (r[i] > max) {
      max = r[i];
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 3408
from collections import Counter
H, W = map(int, input().split())
s = ''
for i in range(H):
  s += str(input())
  
c = Counter(s)
m = c.most_common()
cnt = 0
l = []
for n in m:
  cnt += n[1] // 4
  l.append(n[1]%4)
if cnt < (H//2)*(W//2):
  print('No')
else:
  cnt = 0
  for i in l:
    if i % 2 == 1:
      cnt += 1
  if cnt <= 1:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 9288
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
using namespace std;
#define N 2005

char map[N][N];
int s[N][N],s1[N][N],s2[N][N],n,m,Q;

int get(int a,int b,int x,int y)
{
	return  (s[x][y]-s[a-1][y]-s[x][b-1]+s[a-1][b-1])
			-(s1[x][y]-s1[a][y]-s1[x][b-1]+s1[a][b-1])
			-(s2[x][y]-s2[a-1][y]-s2[x][b]+s2[a-1][b]);
}

int main()
{
	scanf("%d%d%d",&n,&m,&Q);
	for(int i=1;i<=n;i++)scanf("%s",map[i]+1);
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+(map[i][j]=='1');
	for(int i=2;i<=n;i++)
		for(int j=1;j<=m;j++)
			s1[i][j]=s1[i-1][j]+s1[i][j-1]-s1[i-1][j-1]+(map[i][j]=='1'&&map[i-1][j]=='1');
	for(int i=1;i<=n;i++)
		for(int j=2;j<=m;j++)
			s2[i][j]=s2[i-1][j]+s2[i][j-1]-s2[i-1][j-1]+(map[i][j]=='1'&&map[i][j-1]=='1');
	while(Q--)
	{
		int a,b,x,y;scanf("%d%d%d%d",&a,&b,&x,&y);
		printf("%d\n",get(a,b,x,y));
	}
}

Measured memory_bytes: 52864
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)

using namespace std;

int main(){
    while(true){
    int n;
    scanf("%d", &n);
    if(n==0) return 0;
    vector<int> a(n), b(n);
    REP(i, n)  scanf("%d %d", &a[i],&b[i]);
    int as=0, bs=0;
    REP(i,n){
        if(a[i]>b[i])as+=a[i]+b[i];
        else if(a[i]<b[i])bs+=a[i]+b[i];
        else {as+=a[i];bs+=b[i];}
    }
    printf("%d %d\n", as,bs);
    }
}

Measured memory_bytes: 3276
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define ll long long
#define mo 1000000007

using namespace std;

long long n,i,k,ans;

struct lgy{
	long long x,y,z;
}o[105];

double ans2;

ll read(){
	ll xx=0; char ch=getchar();
	for(; !isdigit(ch); ch = getchar());
	for(; isdigit(ch); ch = getchar()) xx = xx * 10 + (ch - '0');
	return xx;
}

ll pus(ll xx,int flagg){
	if(xx>=10) pus(xx/10,0);
	putchar(xx%10+'0');
	if(flagg==1)
		putchar(' ');
	if(flagg==2)
		putchar('\n');
}
int ss(ll j,ll u,ll v){
	if(j>n){
		ans=max(ans,u*u+v*v);
		return 0;
	}
	if(j<=10||u*u+v*v<=(u+o[j].x)*(u+o[j].x)+(v+o[j].y)*(v+o[j].y))
		ss(j+1,u+o[j].x,v+o[j].y);
	if(j<=10||u*u+v*v>(u+o[j].x)*(u+o[j].x)+(v+o[j].y)*(v+o[j].y))
		ss(j+1,u,v);
	return 0;
}

bool cmp(lgy u,lgy v){
	return u.z<v.z;
}

int main(){
	n=read();
	for(i=1;i<=n;i++)
		scanf("%lld%lld",&o[i].x,&o[i].y);
	for(i=1;i<=1000;i++){
		srand(i*i*123+i*456);
		for(k=1;k<=n;k++)
			o[k].z=rand();
		sort(o+1,o+n+1,cmp);
		ss(1,0,0);
	}
	ans2=sqrt(ans);
	printf("%.13lf\n",ans2);
	return 0;
}


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


int main(){
  char c;
  cin >> c;
if(c == 'a'||c == 'e' ||c == 'i'||c == 'o'||c == 'u'){
cout << "vowel" << endl;
}else{
cout << "consonant" << endl;
}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main(){
  string str;
  int K;
  cin >> str;
  cin >> K;

  int N = str.length();
  int i,j;
  set<string> sub_str;

  for(i = 0; i < N; i++){
    for(j = 1; j < N-i+1; j++){
      if(j > K) break;
      sub_str.insert(str.substr(i, j));
    }
  }

  auto itr = sub_str.begin();
  for(i = 0; i < K-1; i++) itr++;

  cout << *itr << endl;

  return 0;
}


Measured memory_bytes: 1664
n = int(input())
x = list(map(int,input().split()))
s_x = sorted(x)
med_1 = s_x[n//2-1]
med_2 = s_x[n//2]

for i in x:
    if i<med_2:
        print(med_2)
    else:
        print(med_1)


Measured memory_bytes: 25220
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e16)

ll N;

int main() {
    cin >> N;
    ll mn = INF, a;
    for (int i = 0; i < 5; i++) {
        cin >> a;
        mn = min(mn, a);
    }

    cout << 4 + (ll)((N+mn-1) / mn) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < (n); i++)
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;


template< int mod >
struct ModInt
{
  int x;
 
  ModInt() : x(0) {}
 
  ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
 
  ModInt &operator+=(const ModInt &p)
  {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
 
  ModInt &operator-=(const ModInt &p)
  {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
 
  ModInt &operator*=(const ModInt &p)
  {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }
 
  ModInt &operator/=(const ModInt &p)
  {
    *this *= p.inverse();
    return *this;
  }
 
  ModInt operator-() const { return ModInt(-x); }
 
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
 
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
 
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
 
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
 
  bool operator==(const ModInt &p) const { return x == p.x; }
 
  bool operator!=(const ModInt &p) const { return x != p.x; }
 
  ModInt inverse() const
  {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    return ModInt(u);
  }
 
  friend ostream &operator<<(ostream &os, const ModInt< mod > &p)
  {
    return os << p.x;
  }
 
  friend istream &operator>>(istream &is, ModInt< mod > &a)
  {
    long long x;
    is >> x;
    a = ModInt< mod >(x);
    return (is);
  }
 
};

const int mod = 1e9 + 7;
using modint = ModInt< mod >;

modint dp[202][101010];
int main(){
    int n, x;
    cin >> n >> x;
    vector<int> s(n);
    rep(i, n) cin >> s[i];
    sort(all(s));
    reverse(all(s));
    dp[0][x] = 1;
    rep(i, n){
        rep(j, 100001) dp[i+1][j] = dp[i][j]*(n-1-i);
        rep(j, 100001) dp[i+1][j%s[i]] += dp[i][j];
    }
    modint ans = 0;
    rep(i, 100001) ans += dp[n][i]*(i%s[0]);
    cout << ans << endl;

}


Measured memory_bytes: 80000
#include <bits/stdc++.h>
#define eb emplace_back
#define INF (0x3f3f3f3f)
using namespace std;
void fuk() { puts("-1"); exit(0); }

const int MAXN = 755;

bitset<MAXN> dp;

vector<int> G[MAXN];
bitset<MAXN> T[MAXN], chk, col;

int N, M, Ans = INF;

void f(int i, int &a, int &b) {
	chk[i] = true; a++;
	for(int v : G[i]) {
		if(chk[v]) {
			if(col[i] == col[v]) fuk();
			continue;
		}
		col[v] = !col[i];
		f(v, b, a);
	}
}

int main() {
	ios::sync_with_stdio(false);

	cin >> N >> M;
	for(int i = 0, a, b; i < M; i++) {
		cin >> a >> b;
		T[a][b] = T[b][a] = true;
	}
	for(int i = 1; i <= N; i++) {
		T[i][i] = true;
		for(int j = 1; j <= N; j++)
			if(!T[i][j]) G[i].eb(j);
	}

	dp[0] = true;
	for(int i = 1; i <= N; i++) if(!chk[i]) {
		int a = 0, b = 0;
		f(i, a, b);
		dp = (dp << a) | (dp << b);
	}

	for(int i = 0; i <= N; i++) if(dp[i]) {
		int t = i*(i-1) + (N-i)*(N-i-1);
		t >>= 1;
		if(t < Ans) Ans = t;
	}

	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 3200
#include "bits/stdc++.h"
using namespace std;
using namespace literals;
constexpr int Mod = 1000000007;
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> table(N+2, 0);
  table[0] = 3;
  int64_t ans = 1;
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    ans = ans * table[A] % Mod;
    --table[A];
    ++table[A + 1];
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
//Jai Shree Ram
//#include <iostream>
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define loopi(stop) for(int i=0; i<stop; i++)
#define loopj(stop2) for(int j=0; j<stop2; j++)
#define loopk(stop3) for(int k=0; k<stop3; k++)
#define loopi1(stop) for(int i=1; i<=stop; i++)
#define loopj1(stop2) for(int j=1; j<=stop2; j++)
#define loopk1(stop3) for(int k=1; k<=stop3; k++)
#define loopse(kt,sstart, eend) for(int kt = sstart; kt<eend; kt++)
#define faster_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define file_io_cf freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define p_b push_back
#define pii pair<int,int>
#define fi first
#define se second
#define prec_10 << fixed << setprecision(10)
#define DEB cout<<"DEBUG"<<'\n';
#define SRAND srand(time(0));

using namespace std;

int mod = 1000000007;

template <typename T>
void O(T x) {
    cout << x << '\n';
}

///////////////////////////////////CODE STARTS HERE///////////////////////////////////////////



int gcd(int a, int b, int c) {
    return (__gcd(a, __gcd(b, c)));
}

int32_t main() {

    faster_io
    // file_io_cf

    int n; cin >> n;
    int ans = 0;
    loopi1(n) {
        loopj1(n) {
            loopk1(n) {
                ans += gcd(i, j, k);
                // cout<<i<<' '<<j<<' '<<k<<'\n';
            }
        }
    }
    O(ans);

    return 0;
}

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

int main() {

  int N ;
  cin>>N;

  for (int i = 0; i < N; i++) {
    string S;
    cin>>S;
    if(S=="Y"){
      cout<<"Four"<<endl;
      break;}
    else if(i+1==N)
      cout<<"Three"<<endl;
    
     
  
    
  }

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };


ll a[2001];
int main() {
	int N;
	ll Z, W;
	cin >> N >> Z >> W;
	REP(i, N)cin >> a[i];
	if (N == 1) {
		cout << abs(W - a[0]) << endl;
		return 0;
	}
	ll A = abs(W - a[N - 1]);
	ll B = abs(a[N - 1] - a[N - 2]);
	cout << max(A, B) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans,cnt;

int main()
{
ll n , m ;
cin >> n >> m ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
sort(a.rbegin(),a.rend());
vector<ll> csum;
csum.push_back(0);
rep(i, n)
{
  csum.push_back(a[i] + csum[i]);
}
auto judge = [&](ll val) {
  ll ind=n-1;
  cnt=0;ans=0;
  rep(i,n){
    while(ind>=0&&a[i]+a[ind]<val){
      ind--;
    }
    cnt+=ind+1;
    ans+=a[i]*(ind+1)+csum[ind+1];
    if(cnt>=m)return 0;
  }
  return 1;
};
auto binarysearch = [&](ll lowerbound, ll upperbound) {
  if (!judge(lowerbound)) return -1LL;
  ll lower = lowerbound, upper = upperbound;
  while (1){
    if (judge((lower + upper) / 2)) lower = (lower + upper) / 2;
    else upper = (lower + upper) / 2;
    if (abs(upper - lower) <= 1){
      if (judge(upper)) return upper;
      else return lower;
    }
  }
};
ll s=binarysearch(INF,0);
judge(s);
ans+=(m-cnt)*(s-1);
cout << ans << endl;
return 0;
}

Measured memory_bytes: 2168
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	H := readInt()
	N := readInt()

	dp := make([]int, H+1)
	fill(dp, math.MaxInt64)

	dp[0] = 0
	for i := 0; i < N; i++ {
		a := readInt()
		b := readInt()
		for j := 0; j < H; j++ {
			if dp[j] == math.MaxInt64 {
				continue
			}
			t := j + a
			if t > H {
				t = H
			}
			if dp[j]+b < dp[t] {
				dp[t] = dp[j] + b
			}
		}
	}

	fmt.Println(dp[H])
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func fill(a []int, x int) {
	for i := 0; i < len(a); i++ {
		a[i] = x
	}
}


Measured memory_bytes: 768
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			if(n==0)
				return;
			int a[]=new int[n];//パイプ
			int b[]=new int[n-1];//ジョイント
			int j[]=new int[n-1];
			long ans=0;
			long sum=0;
			for(int i=0;i<n;i++)
			{
				a[i]=in.nextInt();
				sum+=a[i];
			}
			for(int i=0;i<n-1;i++)
				b[i]=in.nextInt();
			Arrays.sort(b);
			for(int i=0;i<n-1;i++)//ジョイントを降順にソート
				j[i]=b[n-2-i];
			
			//給料=max(パイプの本数*パイプの長さの総和)
			 ans=n*sum;
			for(int i=n-2;i>=0;i--)//i+1がジョイントを使う数 kはパイプ数
			{
				sum+=b[i];
				ans=Math.max(ans,(i+1)*sum);
			}
			System.out.println(ans);
		}
	}
	public static void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 161476
#include <bits/stdc++.h>
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
 
using namespace std;
 

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

	int n; cin >> n; 
	vector<int>v(n);
	for(int& i : v)cin >> i;
	int ans = 0;
	for(int i = 0 ; i < n; ++i){
		for(int j = i + 1 ; j < n; ++j){
			for(int k = j + 1 ; k < n; ++k){
				if(v[i] + v[j] > v[k] && v[k] + v[j] > v[i] && v[i] + v[k] > v[j] && v[i] != v[j] && v[j] != v[k] && v[i] != v[k]){
					cerr << v[i] <<" "<< v[j] << " " << v[k]<< endl;
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5280
#include <iostream>
#include <climits>

using namespace std;


class Card
{
  public:
    Card() { }
    Card(char picture, int n)
    { Picture = picture; Num = n; }

    char Picture;
    int Num; 

};

Card *Cards1, *Cards2;
int N;
bool Stable;

void BubbleSort()
{
  bool flag = true;
  int i = 0;
  Stable = true;

  do
  {

    flag = false;
    for(int j = N - 1; j >= i + 1; --j)
    {
      if(Cards1[j].Num < Cards1[j-1].Num)
      {
	Card tmp = Cards1[j];
	Cards1[j] = Cards1[j-1];
	Cards1[j-1] = tmp;

	flag = true;
      }

    }

    ++i;


  }while(flag);

  return;
}

void SelectionSort()
{

  Stable = true;

  for(int i = 0; i < N; ++i)
  {
    int mini = i;
    bool flag = false;

    for(int j = i; j < N; ++j)
    {
      if(Cards2[j].Num < Cards2[mini].Num)
      {
	mini = j; 
	flag = true;	
      }
    }

    //if(flag)
    {
      Card tmp = Cards2[i];
      Cards2[i] = Cards2[mini];
      Cards2[mini] = tmp;
    }
  }

  return;

}

int main()
{
  cin >> N;

  Cards1 = new Card[N];
  Cards2 = new Card[N];

  for(int i = 0; i < N; ++i)
  {
    string s; cin >> s;
    Cards1[i] = Card(s[0], s[1] - '0');
    Cards2[i] = Cards1[i]; 
  }

  BubbleSort();

  cout << Cards1[0].Picture << Cards1[0].Num;
  for(int i = 1; i < N; ++i)
    cout << " " << Cards1[i].Picture << Cards1[i].Num;
  cout << endl;
  cout << "Stable" << endl;

  SelectionSort();

  cout << Cards2[0].Picture << Cards2[0].Num;
  for(int i = 1; i < N; ++i)
    cout << " " << Cards2[i].Picture << Cards2[i].Num;
  cout << endl;

  Stable = true;
  for(int i = 0; i < N; ++i)
    if(Cards1[i].Picture != Cards2[i].Picture || Cards1[i].Num != Cards2[i].Num)
      Stable = false;

  cout << (Stable ? "Stable" : "Not stable") << endl;

  delete [] Cards1;
  delete [] Cards2;

  return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(int i = (int)(b); i < (int)(e); ++i)
#define RFOR(i, b, e) for(int i = (int)(e-1); i >= 0; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<int,int>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;

using namespace std;

ll conb(ll n, ll r) {
	if (n - r < r) { return conb(n, n - r); }
	ll tmp = 1;
	FOR(i, n - r + 1, n + 1) {
		tmp *= i;
	}
	FOR(i, 1, r + 1) {
		tmp /= i;
	}
	return tmp;
}

ll mod(ll n, ll r) {
	ll q = n % r;
	return (q < 0) ? q + r : q;
}

int main() {
	ll n;
	cin >> n;
	VL x(n), y(n), h(n);
	int tmp;
	REP(i, n) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] != 0) { tmp = i; }
	}

	vector<VL> mat = vector<VL>(101, VL(101, -1));
	list<PAIR> pl;

	REP(ty, 101) {
		REP(tx, 101) {
			mat[ty][tx] = abs(ty - y[tmp]) + abs(tx - x[tmp]) + h[tmp];
			pl.emplace_back(ty, tx);
		}
	}

	REPC(p, pl) {
		int tx = p.first;
		int ty = p.second;
		bool flg = true;
		flg = true;
		REP(i, n) {
			ll dis = abs(ty - y[i]) + abs(tx - x[i]);
			if (dis + h[i] != mat[ty][tx] ) { flg = false; }
			if (h[i] == 0) {
				if (dis >= mat[ty][tx]) {
					flg = true;
				}
			}
			if (!flg)break;
		}

		if (flg) {
			cout << tx << " " << ty << " " << mat[ty][tx] << endl;
			return 0;
		}

	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using VVI = vector<vector<int>>;
using VI = vector<int>;
const static string el = "\n";

int main()
{
  int n;
  cin >> n;
  vector<int> s(4);
  
  for (int i = 0;i < n;i++) {
    string tmp;cin >> tmp;
    if (tmp == "AC") {
        s[0]++;
    }else if(tmp == "WA") {
    	s[1]++;
    }else if (tmp == "TLE") {
    	s[2]++;
    }else {
    	s[3]++;
    }
  }

  for (int i = 0;i < 4;i++) {
  	switch (i) {
      case 0:
        cout << "AC x " + to_string(s[0]) << endl;
        break;
      case 1:
        cout << "WA x " + to_string(s[1]) << endl;
        break;
      case 2:
        cout << "TLE x " + to_string(s[2]) << endl;
        break;
      case 3:
        cout << "RE x " + to_string(s[3]) << endl;
        break;
    }
  }
  return 0;
}

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

void testcase()
{
	string digits;
	cin >> digits;
	long long res = 0;
	for(char c: digits) {
		res += (c - '0');
	}
	cout << ((res%9 == 0) ? "Yes" : "No");
}

int main()
{
	int t = 1;
	//scanf("%d", &t);
	while(t--) {
		testcase();
		puts("");
	}
}


Measured memory_bytes: 3752
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    ll H;
    int N;
    vector<int> A(100010);
    cin >> H >> N;
    for (int i=0;i<N;i++) cin >> A[i];
    ll res = accumulate(A.begin(), A.end(), 0LL);
    if (H<=res) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
	long long n, m, ans = 0;
	
	scanf("%lld %lld", &n, &m);
	
	if (n >= m/2){
		ans = m/2;
	}
	else {
		ans = n;
		ans += (m-n*2)/4;
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
import java.io.PrintWriter;
import java.util.Scanner;

class Main{
    private static final Scanner sc = new Scanner(System.in);
    private static final PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] Args){
        while(true){
            final int n = Integer.parseInt(sc.next());
            final int x = Integer.parseInt(sc.next());
            if(n==0&&x==0) break;
            int ans = 0;
            for(int i = 1; i<=n-2; i++){
                for(int j = i+1; j<=n-1; j++){
                    final int k = x-i-j;
                    if(j<k&&k<=n) ans++;
                }
            }
            out.println(ans);
        }
        out.flush();
    }
}

Measured memory_bytes: 26388
#include <iostream>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

string s;
int N;
int pos[15], id[105], lv[15], lvnum[105];
int perm[15];

int parseNumber(int &p)
{
  int ret = 0;
  while(s[p] >= '0' && s[p] <= '9'){
    ret *= 10, ret += s[p]-'0';
    p++;
  }
  return ret;
}

bool error;
int parse(int &p, int depth)
{
  //cout << p << " " << depth << endl;
  if(depth == -1){
    if(s[p] == '('){
      p++;
      int ret = parse(p, N-1);
      p++;
      return ret;
    }
    if(s[p] >= '0' && s[p] <= '9'){
      return parseNumber(p);
    }
  }
  int ret = parse(p, depth-1);
  if(perm[id[p]] == depth){
    if(s[p] == '+'){
      p++;
      ret += parse(p, depth-1);
    }
    else if(s[p] == '-'){
      p++;
      ret -= parse(p, depth-1);
    }
    else if(s[p] == '*'){
      p++;
      ret *= parse(p, depth-1);
    }
    else if(s[p] == '/'){
      p++;
      int res = parse(p, depth-1);
      if(res == 0){
        error = true;
        return -1;
      }
      ret /= res;
    }
  }
  return ret;
}

int main(void)
{
  while(1){
    cin >> s;
    if(s == "#") break;
    s += "=";
    int nest = 1, cnt = 0;
    for(int i = 0; i < s.size(); i++){
      if(s[i] == '(') nest++;
      if(s[i] == ')') nest--;
      if(s[i] == '+' || s[i] == '-' || s[i] == '*' || s[i] == '/'){
        pos[cnt] = i;
        id[i] = cnt;
        lv[cnt] = nest;
        cnt++;
      }
    }
    N = cnt;
    for(int i = 0; i < 105; i++) lvnum[i] = 0;
    for(int i = 0; i < N; i++) lvnum[lv[i]]++;
    for(int i = 1; i < 105; i++) lvnum[i] += lvnum[i-1];

    //for(int i = 0; i < 5; i++) cout << lvnum[i] << " "; cout<< endl;
    //for(int i = 0; i < cnt; i++) cout << lv[i] << " "; cout << endl;

    set<int> S;
    for(int i = 0; i < N; i++) perm[i] = i;
    do{
      bool flag = true;
      for(int i = 0; i < N; i++){
        if(perm[i] < lvnum[lv[i]-1] || perm[i] >= lvnum[lv[i]]) flag = false;
      }
      if(!flag) continue;

      error = false;
      int p = 0;
      int res = parse(p, N-1);
      if(!error) S.insert(res);
    }while(next_permutation(perm, perm+cnt));

    cout << (int)S.size() << endl;
    //for(auto it = S.begin(); it != S.end(); it++) cout << *it << " "; cout << endl;
  }

  return 0;
}



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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N; cin >>N;
    vector<int> F(N, 0);
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 10; j++){
            int c; cin >> c;
            F[i] += (c<<(9-j));
        }
    }

    vector<vector<int>> P(N, vector<int>(11,0));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 11; j++)cin >> P[i][j];
    }

    int ans = -1e9;
    for(int i = 1; i < (1<<10); i++){
        int sum = 0;
        for(int j = 0; j < N; j++){
            int cnt = 0;
            for(int k = 0; k < 10; k++) if((i>>k)&1 && (F[j]>>k)&1) cnt++;
            sum+=P[j][cnt];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;


    return 0;
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	int i = 1;
	while ( i * 1000 < N) {
		i++;
	}
	cout << i * 1000 - N << endl;
	return 0;
}

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

int main(){

    int n;
    cin>>n;

    vector<ll> a(n);
    ll su=0;
    rep(i,n){
        cin >> a[i];
        su+=a[i];
    }
    ll ts=0;
    ll ans=1e+15;
    for(int i=0;i<n-1;i++){
        ts+=a[i];
        ans=min(ans,abs(ts-(su-ts)));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

double df(double x)
{    
    return 3*x*x;
    
}
double f(double x,double q){    
    return x*x*x-q;
    
}
double newton(double x,double q){
    if(fabs(f(x,q)) < 0.00001*q)        
    return x;    
    return newton(x-(f(x,q)/df(x)),q);
    
}

int main(void){
    double q;
    while(scanf("%lf",&q) && q !=-1){
        double x;    x = q/2;
        printf("%lf\n",newton(x,q));    }
    
}    




Measured memory_bytes: 2040
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0276
{
    class Program
    {
        static void Main(string[] args)
        {
	    List<int> t = new List<int>();
		
            for (int i = 0; i < 7; i++)
            {
                int[] vs = RArInt();
                Console.WriteLine(vs[0] - vs[1]);
            }
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 17952