akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int n;
  cin >> n;

  map<string, ll> dict;
  string s;

  rep(i, 0, n) {
    cin >> s;
    sort(s.begin(), s.end());
    dict[s]++;
  }

  ll ans = 0;
  for (auto d : dict) {
    ans += d.second * (d.second - 1) / 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 11264
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int GCD(int a,int b)
{
  int r, tmp;
   /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int n,k,ans=0;
  cin>>n>>k;
  vector<pair<int,int>> v;
  rep(i,n){
    int a,b;
    cin>>a>>b;
    v.emplace_back(a,b);
  }
  sort(v.begin(),v.end());
  for(auto c:v){
    ans+=c.second;
    if(ans>=k){
      cout<<c.first<<endl;
      return 0;
    }
  }
  
  
  
}
///////////////////////////




Measured memory_bytes: 1400
#include <stdio.h>
int main(void){
    long long int N,i,ans=0,pre;
    long long int A[200001];

    scanf("%lld",&N);
    for(i=1;i<=N;i++){
        scanf("%lld",&A[i]);
    }

    pre=0;
    for(i=1;i<=N-1;i++){
        if((A[i]+pre)>A[i+1]){
            ans=ans+(A[i]+pre-A[i+1]);
            pre=A[i]+pre-A[i+1];
        }else{
            pre=0;
        }
    }

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

    return 0;


}

Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	int64_t A, B;
	cin >> A >> B;

	int64_t C = abs(A - B);

	if(C % 2 != 0)
	{
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	C /= 2;
	C += min(A, B);
	cout << C << endl;

	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
///////////////////////___combination___////////////////////
vector<ll> fac, finv, inv;
void COMinit(const int MAX = 5000000, const ll &MOD = MOD){
  fac.resize(MAX);finv.resize(MAX);inv.resize(MAX);
  fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
  repd(i,2,MAX){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
ll COM(int n, int k){
  if(n < k)return 0;
  if(n < 0 || k < 0)return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

///////////////////////////////////////////////////////////
int n,a[210000];
signed main(){
  cin>>n;bool b = true;
  rep(i,n)cin>>a[i];
  int ans = 0;
  rep(i,n){
    if(a[i] > i || a[i+1]-a[i] > 1)b = false;
    if(a[i]+1 != a[i+1])ans += a[i];
  }
  if(b)cout << ans << endl;
  else cout << -1 << endl;
}



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

using namespace std;

int main()
{
    string s;
    set<char> m;
    cin >> s;
    for(int i = 0; i < s.length(); ++i)
    m.insert(s[i]);
    if(m.size()==2)
        cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
const int INF = 0x3f3f3f3f;
int main()
{
    ll n,i;
    scanf("%lld",&n);
    vector<ll> ns(n);
    for(i=0;i<n;i++)
        scanf("%lld",&ns[i]);
    ll ma=-INF,mi=INF;
    ll maw,miw;
    ll zs=0,fs=0;
    for(i=0;i<n;i++)
    {
        if(ns[i] > 0)
            zs++;
        else if(ns[i] < 0)
            fs++;
        if(ma < ns[i])
        {
            ma = ns[i];
            maw = i;
        }
        if(mi > ns[i])
        {
            mi = ns[i];
            miw = i;
        }
    }
    vector<ii> xl;
    if(ma == mi)
    {
        printf("0\n");
        return 0;
    }
    else if(mi >= 0)
    {
    ex1:for(i=1;i<n;i++)
        {
            while(ns[i-1] > ns[i])
            {
                ii ne(maw,i);
                xl.push_back(ne);
                ns[i] += ns[maw];
                if(ns[i] > ma)
                {
                    ma = ns[i];
                    maw = i;
                }
            }
        }
    }
    else if(ma <= 0)
    {
    ex2:for(i=n-2;i>=0;i--)
        {
            while(ns[i] > ns[i+1])
            {
                ii ne(miw,i);
                xl.push_back(ne);
                ns[i] += ns[miw];
                if(ns[i] < mi)
                {
                    mi = ns[i];
                    miw = i;
                }
            }
        }
    }
    else
    {
        if(-mi < ma)
            goto ex1;
        else
            goto ex2;
    }
    printf("%d\n",xl.size());
    for(i=0;i<xl.size();i++)
        printf("%lld %lld\n",xl[i].first+1,xl[i].second+1);
    return 0;
}


Measured memory_bytes: 256
import numpy as np
import re, sys

A = np.zeros((3,3), dtype=int)
for i in range(3):
  row = input()
  nums = re.split(' ', row)
  for j in range(3):
  	A[i, j] = int(nums[j])
N = int(input())
b = []
for i in range(N):
  b.append(int(input()))
for i in range(3):
  if len(set(A[i]) & set(b)) == 3 or len(set(A[:,i]) & set(b)) == 3:
    print('Yes')
    sys.exit()
cross1 = [A[0,0] ,A[1,1], A[2,2]]
cross2 = [A[0,2] ,A[1,1], A[2,0]]
if len(set(cross1) & set(b)) == 3 or len(set(cross2) & set(b)) == 3:
  print('Yes')
  sys.exit()
else:
  print('No')

Measured memory_bytes: 14552
(defun solve (n xs &optional (ans 0))
  (cond
    ((= n 0) (float ans))
    ((= ans 0 ) (solve (1- n) (cdr xs) (car xs)))      
    (t  (solve (1- n) (cdr xs) (/ (+ ans (car xs)) 2)))))

(let* ((n (read))
       (a (read-from-string
           (concatenate 'string "(" (read-line) ")")))
       (b (sort (copy-list a) #'<=)))
      (princ
       (solve n b)))

Measured memory_bytes: 4068
n = int(input())
S = input()

flag = True
while flag is True:
    Snum = {"(": 0, ")": 0}
    flag = False
    for s in S:
        if s == ")":
            Snum["("] -= 1
        elif s == "(":
            Snum["("] += 1

        if Snum["("] < 0:
            S = "(" + S
            flag = True
            break
    else:
        S += ")" * (S.count("(") - S.count(")"))

print(S)


Measured memory_bytes: 3064
a = list(input())
b = list(input())
c = list(input())
t = a.pop(0)
while True:
    if t == "a":
        if len(a) == 0:
            print("A")
            exit()
        else:
            t = a.pop(0)
    elif t == "b":
        if len(b) == 0:
            print("B")
            exit()
        else:
            t = b.pop(0)
    elif t == "c":
        if len(c) == 0:
            print("C")
            exit()
        else:
            t = c.pop(0)


Measured memory_bytes: 3064
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    s="<"+input()
    
    dp=[[0]*(N+1)for _ in range(N+1)]
    #dp[i][j]はi番目まで見て，Piよりも大きいものがj個ある時の通り数
    dp[0][-1]=1#0からスタートしたとみなす    
    
    for i in range(N):
        if s[i]==">":
            S=0
            for j in range(N-i+1):
                S=(S+dp[i][j])%mod
                dp[i+1][j]=S
        else:
            S=0
            for j in range(N-i,0,-1):
                S=(S+dp[i][j])%mod
                dp[i+1][j-1]=S
    print(dp[-1][0])
                
                
                    
            

main()


Measured memory_bytes: 111836
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for i in range(len(L)-2):
    for j in range(i+1, len(L)-1):
        ans += bisect.bisect_left(L, L[i]+L[j])-j-1    
print(ans)

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

int main(){

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if(abs(c - a) <= d || (abs(b - a) <= d && abs(c - b) <= d)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;

void add_self(int &a,int b){
    a = a + b;
    if(a >= mod)
        a -= mod;
}


int getcount(int num){
    int ans = 0;
    while(num)
    {
        ans += (1 & num);
        num >>= 1;
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    int p[n][n];
    for(int i = 0; i <n;i++){
        for(int j = 0;j<n;j++){
            cin>> p[i][j];
        }
    }
    
    vector<int> dp(1 << n);//bitmask dp (2^n)
    //dp[i]
    
    dp[0] = 1;
    
    for(int masks = 0;masks < (1<<n)-1 ;++masks){
        int a = getcount(masks);
            for(int b = 0;b<n;b++)
            {
                if(p[a][b] && !(masks & (1 << b)))
                {
                    int m2 = masks ^ (1 << b);
                    add_self(dp[m2],dp[masks]);
                }
            }
        
    }

    
    cout << dp[(1<<n)-1] <<"\n";
    return 0;
}

Measured memory_bytes: 8448
#A
#UnionFind
class UF:
    def __init__(self,n):
        self.n = n
        self.root = [-1]*n #root[x]<0 ならxが根かつその値が木の要素数
        self.rank = [0]*n #木の深さ
    def __del__(self):
        pass
        
    def find(self,x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]
            
    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        
        if self.rank[x] < self.rank[y]:
            self.root[y] += self.root[x]
            self.root[x] = y
        else:
            self.root[x] += self.root[y]
            self.root[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x]+=1
                
    def same(self,x,y):
        return self.find(x) == self.find(y) #bool
    
    def count(self,x):
        return -self.root[self.find(x)]
    
N,Q = map(int,input().split())
uf = UF(N)

for _ in range(Q):
    c,x,y = map(int,input().split())
    if c == 0:
        uf.unite(x,y)
    else:
        if uf.same(x,y):
            print(1)
        else:
            print(0)
    




Measured memory_bytes: 5808
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
tree=[[] for i in range(n+1)]
for i in range(n-1):
    a,b,c=mp()
    tree[a].append([a,b,c])
    tree[b].append([b,a,c])
ans=[-1]*(n+1)
ans[1]=0
que=deque()
que.append(tree[1])
while len(que):
    q=que.popleft()
    for x,y,z in q:
        if ans[y]==-1:
            ans[y]=(ans[x]+z)%2
            que.append(tree[y])
print(*ans[1:],sep="\n")

Measured memory_bytes: 48640
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
const lli N=1e7+5;
bool prime[N];
lli rem[N], ans[N], cou;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli i,j,n,tot=0;
    cin>>n;
    
    memset(prime, true, sizeof(prime));
    prime[1]=false;
    for(i=1;i<N;i++) rem[i]=i, ans[i]=1;
    
    for(i=2;i*i<=N;i++)
    {
        if(prime[i])
        {
            for(j=i;j<N;j+=i)
            {
                cou=1;
                while(rem[j]%i==0)
                {
                    rem[j]/=i;
                    cou++;
                }
                ans[j]*=cou;
                
                prime[j]=false;
            }
        }
    }
    
    for(i=1;i<=n;i++)
    {
        if(rem[i]!=1) ans[i]*=2;
        tot+=(i*ans[i]);
    }
    cout<<tot;
    return 0;
}

Measured memory_bytes: 169620
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
int a, b;
int counto;
int aa[2000];
char bb[5];
int main() {
	int n = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> aa[i];
	}
	for (int i = 1; i < n - 1; i++) {
		
		if (aa[i - 1] < aa[i] && aa[i] < aa[i + 1]) {
			counto++;
			//cout << i << endl;
		}
		else if (aa[i - 1] > aa[i] && aa[i] > aa[i + 1]) {
			counto++;
			//cout << i << endl;
		}

	}
	cout << counto << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, X, T) = Read3Longs();

            return Math.Ceiling((double)N / X) * T;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28168
import java.util.Scanner;
public class Main{
public static void main(String[]args){
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int b=scan.nextInt();
int count[][]=new int[a+1][b+1];
for(int i=0;i!=a;i++) {
	int sum=0;
	for(int j=0;j!=b;j++) {
		count[i][j]=scan.nextInt();
		sum+=count[i][j];
	}
	count[i][b]=sum;
}
for(int i=0;i!=b+1;i++) {
	int sum=0;
	for(int j=0;j!=a;j++) {
		sum+=count[j][i];
	}
	count[a][i]=sum;
}
for(int i=0;i!=a+1;i++) {
	for(int j=0;j!=b+1;j++) {
	System.out.print(count[i][j]);
	if(j!=b) {
		System.out.print(" ");
	}
	}
	System.out.println();
	}

}
}


Measured memory_bytes: 42284
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(System.out);

        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(h[0] - h[1]);

        for (int i = 2; i < h.length; i++) {
            dp[i] = dp[i - 1] + Math.abs(h[i] - h[i - 1]);
            dp[i] = Math.min(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
        }
        out.println(dp[n - 1]);
        out.flush();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 32868
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    String s = a+b;
    int num = Integer.parseInt(s);
    for(int i = 1; i < 1000; i++){
      int result = (int) Math.pow(i,2);
      if(result == num){
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
int memo[87];
 
int luca(int n) {
    if(memo[n]!=0) return memo[n];
    if(n==0) return 2;
    if(n==1) return 1;
    return memo[n] = luca(n-1) + luca(n-2);
}
 
signed main() {
    int n;
    cin >> n;
    cout << luca(n) << endl;
    return 0;
}
 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
	string s1, s2;
	cin >> s1 >> s2;

	map <string, int> mp;
	int a, b;
	cin >> a >> b;
	mp[s1] = a;
	mp[s2] = b;

	string s;
	cin >> s;

	mp[s] --;

	cout << mp[s1] << " " << mp[s2] << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
program main
    implicit none
    integer i, j, k
    integer n_len, tg, pop
    integer :: mod_ = 10**9+7
    integer, allocatable :: dp(:),old_dp(:)
    character(10**5):: S

    read*, S
    n_len = len_trim(S)
    allocate(dp(0:12), old_dp(0:12))
    dp(0:12) = 0
    dp(0) = 1
    old_dp(0:12) = 0
    
    do i=1, n_len
        old_dp(0:12) = dp(0:12)
        dp(0:12) = 0

        if(S(i:i) == "?")then
            do j = 0,9
                do k=0,12
                    pop = mod(k*10+j,13)
                    dp(pop) = dp(pop) + old_dp(k)
                    dp(pop) = mod(dp(pop),mod_)
                enddo
            enddo

        else
            read(S(i:i),*) tg
            do k=0,12
                pop = mod(k*10+tg,13)
                dp(pop) = dp(pop) + old_dp(k)
                dp(pop) = mod(dp(pop),mod_)
            enddo
        endif

    enddo

print'(i0)', dp(5)

stop
end program main

Measured memory_bytes: 700
import Control.Applicative

main :: IO ()
main = loop

loop :: IO ()
loop = do
  [x, y] <- fmap ( read :: String -> Int).words <$> getLine
  -- putStrLn $ show x ++ " " ++ show y
  if x == 0 && y == 0 
    then return ()
    else do 
      let ans = swap x y
      putStrLn ans
      loop
      

swap :: Int -> Int -> String
swap x y | x < y = show x ++ " " ++ show y
         | otherwise = show y ++ " " ++ show x
  

Measured memory_bytes: 3948
#include <iostream>
#include <algorithm>
using namespace std;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
int main(){
	int high[10] = {};
	for(int i=0; i<10; i++){
		cin >> high[i];
	}

	sort(high, high + SIZE_OF_ARRAY(high), greater<int>());

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


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

int main() {
    int N;
    string S;
    cin >> N >> S;

    int ans = 0;
    for (int i = 0; i <= 999; i++) {
        string key = to_string(i);
        while (key.length() < 3) {
            key = "0" + key;
        }

        int pos = 0;
        for (int j = 0; j < N; j++) {
            if (S[j] == key[pos]) {
                pos++;
            }
            if (pos == 3)
                break;
        }
        if (pos == 3) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define RIDGE 4
#define FLOOR 3
#define ROOM 10

int main(void) {
int n;
int b, f, r, v;
int dorm[RIDGE][FLOOR][ROOM] = {0};
int x,y,z;

scanf("%d", &n);

for(x = 0; x < n; x++) {
scanf("%d %d %d %d", &b, &f, &r, &v);
dorm[b-1][f-1][r-1] += v;
}

for(x = 0; x < RIDGE; x++) {
for(y = 0; y < FLOOR; y++) {
for(z = 0; z < ROOM; z++) {
printf(" %d", dorm[x][y][z]);
}
printf("\n");
}
if (x != 3) {
printf("####################\n");
}
}

return (0);
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for (int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

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

    int N;
    cin >> N;

    REP(num, N)
    {
        string s1, s2, ans = "";
        cin >> s1 >> s2;

        int len1 = s1.size() - 1;
        int len2 = s2.size() - 1;
        int next = 0;

        int mlen = max(s1.size(), s2.size());

        REP(i, mlen)
        {
            int sum = 0;

            if (0 <= len1)
                sum += s1[len1--] - '0';

            if (0 <= len2)
                sum += s2[len2--] - '0';

            ans = (char)((sum + next) % 10 + '0') + ans;

            if (10 <= sum + next)
                next = 1;
            else
                next = 0;
        }

        if (ans.size() + next <= 80)
            cout << (next == 1 ? "1" : "") << ans << endl;
        else
            cout << "overflow" << endl;
    }

    return 0;
}


Measured memory_bytes: 3180
#include <iostream>
using namespace std;
int main(void){
    int n;
    int v[20];
    int c[20];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&v[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%d",&c[i]);
    }
    int sum=0;
    for(int i=0;i<n;i++){
        if(v[i]-c[i]>0)sum+=(v[i]-c[i]);
    }
    printf("%d\n",sum);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
template <typename T> using lim = numeric_limits<T>;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    set<string> valid = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"};
    bool yymm = valid.count(s.substr(2));
    bool mmyy = valid.count(s.substr(0, 2));
    if(not yymm and not mmyy) {
        cout << "NA" << endl;
    } else if(not yymm and mmyy) {
        cout << "MMYY" << endl;
    } else if(yymm and not mmyy) {
        cout << "YYMM" << endl;
    } else {
        cout << "AMBIGUOUS" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
using namespace std;

int vis[100000];

int main(){
	long long n,x,y,mi,ma,sum;
	cin >> n >> x >> y;
	mi = (n - 2) * x,ma = (n - 2) * y;
	sum = ma - mi + 1;
	if(sum < 0) sum = 0;
	cout << sum;
}

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

#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define f(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pc __builtin_popcount // counts number of 1's in bin(num)

const double pi = 2*acos(0.0);
//__gcd(n1, n2);
//cout << fixed;
//cout << setprecision(6); //fixes # of dp



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
    cout.tie(0);
	
    string r, b;
    cin >> r >> b;
    int rc, bc;
    cin >> rc >> bc;
    string rm;
    cin >> rm;
    if(rm == r){
        cout << rc-1 << " " << bc;
    } else{
        cout << rc << " " << bc-1;
    }
     
}   








Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
     Scanner scan = new Scanner(System.in);
     int a = scan.nextInt();
     int b = scan.nextInt();
     if( a < b ) {
    	 System.out.println("a < b");
     }else if( a > b ){
    	 System.out.println("a > b");
     }else{
    	 System.out.println("a == b");
     }
    }
}



Measured memory_bytes: 26188
import * as fs from 'fs'

const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n');
const line1 = input[0];
const line2 = input[1];
let h = parseInt(line1.split(' ')[0], 10);
const n = parseInt(line1.split(' ')[1], 10);

const tech = line2.split(' ').map(n => parseInt(n, 10));
for (let i = 0; i < tech.length; i++) {
    h -= tech[i];
}

if (h <= 0) {
    console.log('Yes');
} else {
    console.log('No');
}

// 210 5
// 31 41 59 26 53
// console.log(h);
// console.log(n);
// console.log(line2);
// console.log(tech);

Measured memory_bytes: 16716
#include<iostream>
#include<bitset>
#include<string>
#include<vector>
#include<functional>
using namespace std;

int main(int argc, char *argv[])
{
  for(;;) {
    int n; cin >> n;
    if(n==0) break;
    string s;
    getline(cin, s);
    vector<string> ss;
    for(int i = 0; i < n; i++) {
      getline(cin, s);
      ss.push_back(s);
    }
    vector<string> ts;
    for(int i = 0; i < n; i++) {
      bool ok = true;
      for(int j = 0; j < n; j++) {
        if(i == j) continue;
        if(ss[j].find(ss[i]) != string::npos) {
          ok = false;
          break;
        }
      }
      if(ok) ts.push_back(ss[i]);
    }
    int m = ts.size();
    auto overlap = [&ts](int c, int d) {
      int ret = 0;
      int cl = ts[c].length();
      for(int i = 0; i < cl; i++) {
        auto p = std::mismatch(ts[c].begin() + i, ts[c].end(), ts[d].begin(), ts[d].end());
        if(p.first == ts[c].end()) { // c[i:] is a prefix of d
          ret = max(ret, cl - i);
        }
      }
      //cout << "overlap of " << ts[c] << " and " << ts[d] << " is " << ret << endl;
      return ret;
    };
    vector<vector<int>> ov(m, vector<int>(m));
    for(int i = 0; i < m; i++) {
      for(int j = 0; j < m; j++) {
        ov[i][j] = overlap(i, j);
      }
    }
    vector<vector<int>> memo(m, vector<int>(1<<m, -1));
    function<int(int,int)> rec = [&memo,&ov,m,&rec](int c, int cs) {
      if(cs==0) return 0;
      if(memo[c][cs] >= 0) return memo[c][cs];
      int ans = 0;
      for(int i = 0; i < m; i++) {
        const int ii = 1<<i;
        if(ii & cs) {
          ans = max(ans, ov[c][i] + rec(i, cs-ii));
        }
      }
      memo[c][cs] = ans;
      return ans;
    };
    int maxov = 0;
    for(int i = 0; i < m; i++) {
      maxov = max(maxov, rec(i, ((1<<m)-1)-(1<<i)));
    }
    int ans = -maxov;
    for(auto t : ts) {
      ans += t.length();
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3816
#include <iostream>
  #include <vector>
  #include <algorithm>
  #include <math.h>
  #include <climits>
  #include <iomanip>
  
  
  using namespace std;
  
  
  int main() {
    int d[3];
    cin >> d[0] >> d[1] >> d[2];
      
    sort(d, d+3);
    
    cout << d[0] + d[1] << endl;
    return 0;
  }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

#define Yes(x) cout<<(x?"Yes":"No")<<endl;

int a[100010];

int main() {

    int N, K;
    cin >> N >> K;
    rep(i, N)cin >> a[i];

    int cou = 0;
    int rcou = 0;
    int minap = min_element(a, a + N) - a;

    if (a[0] == 1) {
        cou += ((N - 1) - minap) / (K - 1);
        if (((N - 1) - minap) % (K - 1) != 0)cou++;
        cout << cou << endl;
    }
    else if (a[N - 1] == 1) {
        cou += minap / (K - 1);
        if (minap % (K - 1) != 0)cou++;
        cout << cou << endl;
    }
    else {
        cou += (N - 1) / (K - 1);
        if (((N - 1)) % (K - 1) != 0)cou++;
        cout << cou << endl;
    }
        /*
        //小さい方
        cou += minap / (K - 1);
        if (minap % (K - 1) != 0) {
            cou++;
            rcou++;
        }
        //大きい方
        cou += ((N - 1) - minap) / (K - 1);
        if (((N - 1) - minap) % (K - 1) != 0) {
            cou++;
            rcou++;
        }
        if (rcou == 2) {
            cou--;
        }
        cout << cou << endl;

    }
    */
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
#define STDIN freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);
const int N = 2e5 + 10;

int a[N];
long long f(long long a)
{
    return a >=0 ? a : -a;
}
int main()
{
    //STDIN
    long long n, k;
    cin >> n >> k;
    cout << min(f((n%k) - k), f(n%k) )<< endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

/*
typedef struct{
  int id;
  int parent;
  int left;
  int right;
}Tree;
*/
int *A;
int n;

void maxHeapify(int i){
  int l, r;
  int largest;
  int tmp;

  l=i*2;
  r=i*2+1;

  if((l <= n) && (A[l] > A[i])){
    largest = l;
  }else{
    largest = i;
  }
  if ((r <= n) && (A[r] > A[largest])) {
    largest = r;
  }
  //printf("largest:%d\n",largest );
  //printf("A[largest]:%d\n",A[largest]);
  if(largest != i){
    //printf("A[%d]:%d\n",i,A[i] );
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}

void buildHeap(){
  int i;

  for(i = n/2; i >= 1; i--){
    maxHeapify(i);
  }
}

void printer(){
  int i;

  for (i = 1; i <= n; i++) {
    printf(" %d",A[i] );
  }
  printf("\n");
}

int main() {
  int i;

  scanf("%d",&n );
  A = (int *)malloc(sizeof(int) * (n+1));

  for(i=1; i<=n; i++){
    scanf("%d",&A[i]);
    //printf(" A[%d]:%d",i,A[i] );
  }
  //printf("\n");

  buildHeap();
  printer();

  free(A);
  return 0;
}



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



int main() {
       set<int> s;
for(int i =1 ; i <=9; i++){
       for(int j =1 ; j <=9; j++){
              s.insert(i*j);
       }
}

int n; cin >> n;
if(s.find(n) != s.end())
  cout << "Yes" << endl;
 else
 cout << "No" << endl;
 
 return 0;

}








  

Measured memory_bytes: 256
N = int(input().strip())

# 約数列挙
def divisor(n):
  result = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      result.append(i)
      if i != n // i:
        result.append(n//i)
  return result

count = 0
for j in range(1,N+1):
  if j % 2 == 0:
    continue
  if len(divisor(j)) == 8:
    count += 1
print(count)


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

using namespace std;
int n,dat[100005],id[100005];

bool cmp(int a,int b)
{return dat[a]<dat[b];}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&dat[i]),id[i]=i;
	sort(id+1,id+n+1,cmp);
	int res=0;
	for(int i=1;i<=n;i++)
		if((id[i]&1)&&!(i&1)) res++;
	printf("%d",res);
	return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	int p;
	for(int i = 1; i <= n; i++){
       p = i * 1.08;
       if(p == n){
            cout << i << "\n";
            return 0;
       }
	}

	cout << ":(" << "\n";

}


Measured memory_bytes: 256
N = int(input())
# 99分解して、マンハッタン距離を求める
# ただし、iとjが近い方が距離が短くなる

cand = 1
n = 1
while n * n <= N:
  if N % n == 0:
    cand = n
  n += 1

print(cand - 1 + N // cand - 1)

Measured memory_bytes: 63120
#include<bits/stdc++.h>
 
#define REP(i,s,N) for (int i=s;i<(N); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

bool judge(string str){
  string str1=str;
  reverse(str.begin(),str.end());
  return str == str1;
}

int main(){
	string S;
	cin >> S;
	int N = S.length();
	string S2 = S.substr(0,(N-1)/2);
	string S3 = S.substr((N+3)/2-1);
	
	if(judge(S)&&judge(S2)&&judge(S3)){
		cout << "Yes" << endl;
	}else{
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a + (b - 1)) / b; }
int positive_surplus(int &a) { return (a + MOD) % MOD; }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last) {
  if ((first == last) || (first == k) || (last == k))
    return false;
  Iterator itr1 = first;
  Iterator itr2 = last;
  ++itr1;
  if (last == itr1)
    return false;
  itr1 = last;
  --itr1;
  itr1 = k;
  --itr2;
  while (first != itr1) {
    if (*--itr1 < *itr2) {
      Iterator j = k;
      while (!(*itr1 < *j)) ++j;
      std::iter_swap(itr1, j);
      ++itr1;
      ++j;
      itr2 = k;
      std::rotate(itr1, j, last);
      while (last != j) {
        ++j;
        ++itr2;
      }
      std::rotate(k, itr2, last);
      return true;
    }
  }
  std::rotate(first, k, last);
  return false;
}

int a[50];
int b[50];
int c[50];
int d[50];
int maxi = 0;
signed main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  rep(i, Q) {
    cin >> a[i];
    cin >> b[i];
    cin >> c[i];
    cin >> d[i];
  }
  vector<int> A(M + N - 1);
  FOR(i, 1, M + N)
  A[i - 1] = i;
  do {
    int ret = 0;
    rep(i, Q) if ((A[b[i] - 1] - (b[i] - 1)) - (A[a[i] - 1] - (a[i] - 1)) == c[i]) ret += d[i];
    maxi = max(maxi, ret);
  } while (next_combination(A.begin(), A.begin() + N, A.end()));
  cout << maxi << endl;
}


Measured memory_bytes: 3688
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    string s,t;
    cin>>s;
    cin>>t;
    if(s[0]==t[2] && s[1]==t[1] && s[2]==t[0]){
        cout<<"YES"<<endl;

    }
    else{
        cout<<"NO"<<endl;
    }


    return 0;
}

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

int main(){
    string s[4] = {"Sunny","Cloudy","Rainy","Sunny"},t;
    cin >> t;
    for(int i = 0;i < 3;i++){
        if(s[i] == t){
            cout << s[i+1];
        }
    }
}

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

int main(){
    int r, c;
    cin >> r >> c;
    int table[r+1][c+1];
    for (int i=0; i<r; i++){
        for (int j=0; j<c; j++){
            cin >> table[i][j];
        }       
    }
    for (int i=0; i<r; i++) {
        int sum = 0;
        for  (int j=0; j<c; j++) {
            sum += table[i][j];
        }
        table[i][c] = sum;
    }
    for (int j=0; j<c; j++) {
        int sum = 0;
        for  (int i=0; i<r; i++) {
            sum += table[i][j];
        }
        table[r][j] = sum;
    }
    int sum = 0;
    for (int i=0; i<r; i++) {
        sum += table[i][c];
    }
    table[r][c] = sum;

    for (int i=0; i<r+1; i++){
        for (int j=0; j<c+1; j++){
            cout << table[i][j];
            if (j!=c) cout << " ";
        }
        cout << endl;       
    }

}


Measured memory_bytes: 3088
N=int(input())
S=input()

def condition(num):
    data=[]
    for i in range(0,N-num+1):
        data.append((S[i:i+num],i))

    data.sort()
    if len(data)==1:
        return False

    small=data[0][1]
    large=data[0][1]
    for i in range(0,len(data)-1):
        if data[i][0]==data[i+1][0]:
            large=data[i+1][1]
        else:
            if large-small>=num:
                return True
            else:
                small=data[i+1][1]
                large=data[i+1][1]

    if large-small>=num:
        return True

    return False

start=0
end=N
while end-start>1:
    test=(end+start)//2
    if condition(test):
        start=test
    else:
        end=test

if condition(end):
    print(end)
else:
    print(start)

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

int main() {
	int n;
	int a[101];
	string ans = "APPROVED";
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		if (a[i] % 2 == 0) {
			if (a[i] % 3 != 0 && a[i] % 5 != 0) {
				ans = "DENIED";
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
   int N;cin>>N;
   if(N%4==1){
       if(N==1) cout<<"No"<<endl;
       else{
           cout<<"Yes"<<endl;
           for(int i=1;i<=N-3;i++){
               cout<<i<<" "<<i+1<<endl;
           }
           cout<<N-2<<" "<<N+1<<endl;
           for(int i=1;i<=N-3;i++){
               cout<<N+i<<" "<<N+i+1<<endl;
           }
           cout<<N-1<<" "<<N<<endl;
           cout<<N<<" "<<1<<endl;
           cout<<1<<" "<<2*N-1<<endl;
           cout<<2*N-1<<" "<<2*N<<endl;
       }
   }else if(N%4==3){
       cout<<"Yes"<<endl;
       for(int i=1;i<=2*N-1;i++){
           cout<<i<<" "<<i+1<<endl;
       }
   }else if(N%4==2){
       if(N==2) cout<<"No"<<endl;
       else {
           cout<<"Yes"<<endl;
           for(int i=1;i<=N-4;i++){
               cout<<i<<" "<<i+1<<endl;
           }
           cout<<N-3<<" "<<N+1<<endl;
           for(int i=1;i<=N-4;i++){
               cout<<N+i<<" "<<N+i+1<<endl;
           }
           cout<<N-2<<" "<<N-1<<endl;
           cout<<N-1<<" "<<1<<endl;
           cout<<1<<" "<<2*N-2<<endl;
           cout<<2*N-2<<" "<<2*N-1<<endl;
           cout<<N<<" "<<N-1<<endl;
           cout<<2<<" "<<2*N<<endl;
       }
   }else{
      int i=1;
      bool flag=false;
      while(i<=N){
          i*=2;
          if(i==N) flag=true;
      }

      if(flag) cout<<"No"<<endl;
      else{
           cout<<"Yes"<<endl;
       for(int i=1;i<=N-2;i++){
           cout<<i<<" "<<i+1<<endl;
       }
       cout<<N-1<<" "<<N+1<<endl;
       for(int i=1;i<=N-2;i++){
           cout<<N+i<<" "<<N+i+1<<endl;
       }
       int k;
       for(int i=0;i<30;i++){
           if(N&(1<<i)){
               k=i;
               break;
           }
       }
       cout<<N-(1<<k)+1<<" "<<N<<endl;
       cout<<N+(1<<k)<<" "<<2*N<<endl;
      }
   }
    
}




Measured memory_bytes: 2816
# -*- Coding: utf-8 -*-

trial_num = int(input())
n_line = [0 for i in range(trial_num)]

alphabet = [chr(i) for i in range(ord('a'), ord('z')+1)]

for i in range(trial_num):
    n_line[i] = list(input())


result_list = [0 for i in range(26)]
tmp = 50

for i in range(26):
    for j in range(trial_num):
        tmp_min = n_line[j].count(alphabet[i])
        if(tmp_min < tmp):
            tmp = tmp_min

    result_list[i] = tmp
    tmp = 50

for i in range(26):
    print(result_list[i] * alphabet[i], end = "")

Measured memory_bytes: 3064
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a;
    for (int i=0; i<n; i++) {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    for(auto e : a) {
        if (e % 2 == 0) {
            if (e % 3 == 0 || e % 5 == 0) {
            } else {
                puts("DENIED");
                return 0;
            }
        }
    }
    puts("APPROVED");
    

}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 256
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
x = inl()
mn = 10**8
for p in range(1,101):
    sm = 0
    for j in range(n):
        sm += (x[j]-p)**2
    mn = min(mn,sm)
print(mn)


Measured memory_bytes: 39152
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef map<string, int> M;
int main(void) {
  int n;
  cin >> n;
  M m;
  string s;
  vector<int> t(n);
  rep(i, n) {
    cin >> s >> t[i];
    m[s] = i;
  }
  string x;
  cin >> x;
  int ans = 0;
  for(int i = m[x] + 1; i < n; i++) {
    ans += t[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;


int main()
{
	int N,M=0;
	cin >> N;
	vec a(N+1);
	vec b(N+1,0);

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


	for (int i = N; i >= 1; --i)
	{
		int total = 0;
		for (int k = 2; k*i <= N; ++k)
		{
			total += b[k*i];
			total %= 2;
		}
		b[i] = (total + a[i]) % 2;
		M += b[i];
	}
	cout << M << endl;
	for (int i = 1; i <= N; ++i)
		if (b[i] == 1)cout << i << endl;

	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define up(i, a, b) for (int i = a, _b = b; i <= _b; i++)
#define down(i, a, b) for (int i = a, _b = b; i >= _b; i--)
#define SZ(a) (int)a.size()
#define long long long
#define endl '\n'
#define X first
#define Y second
#define II pair<int, int>
#define debug(X) cerr << #X << " = " << X << endl
#define debug2(X, Y) cerr << #X << " = " << X << " , " << #Y << " = " << Y << endl
#define show(X, a, b) { cerr << #X << " = "; up(_, a, b) cerr << X[_] << " "; cerr << endl; }
#define gc getchar
#define pc putchar
using namespace std;
template <class T>
inline void read(T &x) {
        int c = gc();
        x = 0;
        int neg = 0;
        for (; ((c<48 || c>57) && c != '-'); c = gc());
        if(c=='-') {neg=1; c=gc();}
        for(; c>47 && c<58; c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
        if(neg) x=-x;
}
template <class T>
inline void writeln(T x) {

        char buffor[21];
        int i=0;
        int neg=0; if (x<0) {neg=1; x= -x;}
        do {
                buffor[i++]=(x%10)+'0';
                x/=10;
        } while(x);
        i--;
        if (neg) pc('-');
        while(i>=0) pc(buffor[i--]);
        pc('\n');
}
long a, b, c, x, y;
void input() {
      cin >> a >> b >> c >> x >> y;
}


void solve() {
      long res = 1e18;
      up(ab, 0, 2 * max(x, y)) {
          long cost = ab * c + max(0LL, x - ab / 2) * a + max(0LL, y   - ab / 2) * b;
          res = min(res, cost);
      }

      cout << res;
}
int main() {
  #ifdef I_Love_Pork
        clock_t sttime = clock ();
  #endif
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);

  #ifdef I_Love_Pork
  #define TASK "tmp"
        freopen(TASK ".inp","r",stdin);
        freopen(TASK ".out","w",stdout);
  #endif
        input();
        solve();



  #ifdef I_Love_Pork
        clock_t entime = clock ();
        cerr << "\nExecution time: " << double (entime - sttime) / CLOCKS_PER_SEC << "s";
  #endif

}


Measured memory_bytes: 256
N = input()
K = int(input())

len_N = len(N)

dp = [[[0 for _ in range(K + 2)] for _ in range(2)] for _ in range(len_N + 1)]
dp[0][0][0] = 1 # position, is_less, num_of_zeros
for i in range(len_N):
    for j in range(2):
        for k in range(K + 1):
            lim = 9 if j else int(N[i])
            for d in range(lim + 1):
                if d != 0:
                    dp[i + 1][j or d < lim][k + 1] += dp[i][j][k]
                else:
                    dp[i + 1][j or d < lim][k] += dp[i][j][k]
ans = 0
for i in range(2):
    ans += dp[len_N][i][K]
print(ans)
# for d in dp:
#     print(d)

Measured memory_bytes: 40944
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
using namespace std;

const int N = 5010;
int k, q, d[N];

int main() {
	cin >> k >> q;
	for (int i = 0; i < k; i++)
		cin >> d[i];

	while (q--) {
		long long n, x, m;
		long long res = 0;
		cin >> n >> x >> m;
		long long sum;
		sum = 0;
		for (int i = 0; i < k; i++) {
			sum += d[i] % m;
			if (d[i] % m == 0)
				res++;
		}

		x %= m;
		sum = x + sum * ((n - 1) / k);
		res *= (n - 1) / k;
		for (int i = 0; i < (n - 1) % k; i++) {
			sum += d[i] % m;
			if (d[i] % m == 0)
				res++;
		}
		cout << n - res - 1 - sum / m << endl;
	}

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
    IO
    ll n,m;
    cin>>n>>m;
    ll p,sum=0,ans=-1;
    for(ll i=1;i<=m;i++)
    {
        cin>>p;
        sum+=p;
    }
    if(sum<=n)
    ans=(n-sum);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3640