akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
	cin >> n;
	vector<int> a(n), b;
	rep(i, n)cin >> a[i];
	sort(all(a));
	rep(i, n-1)if(a[i] == a[i+1])b.push_back(a[i+1]);
	int ans = a.size()-b.size();
	int cnt = 0, s = b.size();
	while(s >= 3)s -= 2;
	if(s == 0)cnt = 0;
	if(s == 1)cnt = 1;
	if(s == 2)cnt = 0;
	cout << ans - cnt << endl;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int n=s.size();
	int ok=0;
	for(int i=0;i<n;i++){
		int j=n-i-1;
		if(s[i]=='q'&&s[j]=='p'){}
		else {
		    if(s[i]=='b'&&s[j]=='d'){}
		    else {
			if(s[i]=='d'&&s[j]=='b'){}
		          else {if(s[i]=='p'&&s[j]=='q'){}
		          else ok=1;
	              }
            }
        }
    }
	if(ok==0){
		cout<<"Yes"<<endl;return 0;
	}
	ok=0;
	for(int i=0;i<n;i++){
		if(s[i]=='p')s[i]=='q';
		if(s[i]=='q')s[i]=='p';
		if(s[i]=='b')s[i]=='d';
		if(s[i]=='d')s[i]=='b';
	}
	for(int i=0;i<n;i++){
		int j=n-i-1;
		if(s[i]=='q'&&s[j]=='p'){}
		else {
		    if(s[i]=='b'&&s[j]=='d'){}
		    else {
			if(s[i]=='d'&&s[j]=='b'){}
		          else {if(s[i]=='p'&&s[j]=='q'){}
		          else ok=1;
	              }
            }
        }
    }
    if(ok==0)cout<<"Yes"<<endl;
    else cout<<"No";
	return 0;
} 

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(100100)

N=int(input())
G=[[] for i in range(N)]
for i in range(N-1):
    u,v,w=map(int,input().split())
    u,v=u-1,v-1
    G[u].append((v,w))
    G[v].append((u,w))
res=[-1]*N
def dfs(v,p,c):
    res[v]=c
    for nv,w in G[v]:
        if res[nv]>=0:
            continue
        dfs(nv,v,(c+w)%2)
        """
        if w&1:
            dfs(nv,v,1-c)
        else:
            dfs(nv,v,c)
        """
dfs(0,-1,0)
for i in res:
    print(i)


Measured memory_bytes: 172320
#include <bits/stdc++.h>
using namespace std;
main()
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if ( a == b + c || b == c + a || c == a + b ){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    if(!( (N-1)/A + 1 <= B && B <= N - A + 1 )){
        cout << -1 << endl;
        return 0;
    }
    vector<int> vec;
    int x = N - A;
    int b = B - 1;
    while(x != 0){
        if(x - A >= b - 1){
            vec.push_back(A);
            x -= A;
            b--;
        }else{
            int a = x - b + 1;
            vec.push_back(a);
            b--;
            for(int i=0; i<b; i++)
                vec.push_back(1);
            break;
        }
    }
    vector<int> ans;
    for(int i=N-A+1; i<=N; i++) ans.push_back(i);
    int mx = N - A;
    for(int i=0; i<vec.size(); i++){
        int mn = mx - vec[i] + 1;
        for(int j=mn; j<=mx; j++) ans.push_back(j);
        mx = mn - 1;
    }
    for(auto a : ans)
        cout << a << " ";
    cout << endl;
    return 0;
}

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

vector <int> dx = {-1,1,0,0};
vector <int> dy = {0,0,-1,1};
ll gcd(ll a, ll b){
	if(b==0){return a;}
	return gcd(b,a%b);
}
int main(){
	int n;cin>>n;
	vector<int> a(n);
	int i;
	for(i = 0; i < n ;++i){
		cin >> a[i];
	}
	ll g = (ll) a[n-1];
	unordered_map<int,int> mp;
	mp[a[n-1]]++;
	for(i=n-2;i>=0;i--){
		g = gcd(a[i],g);
		mp[a[i]]++;
	}
	if(g > 1){
			cout<< "not coprime" <<"\n";
			return 0;
	}
	int max_elem = *max_element(a.begin(),a.end());
	for(i = 2;i <=max_elem ; ++i){
		int t = 0;
		for(int j = i; j <= max_elem; j += i){
			t += mp[j];
		}
		if(t > 1){
			cout << "setwise coprime\n";
			return 0;
		}
	}
	cout << "pairwise coprime\n";

	return 0;
}

Measured memory_bytes: 46588
import heapq
import operator
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n, k = ril()
ls = rils(n)
ls.sort(key=operator.itemgetter(1), reverse=True)
selected0 = set()
selected1 = set()
ls0 = []
ls1 = []
base = 0
for i, (t, d) in enumerate(ls):
    if i < k:
        if t in selected0:
            heapq.heappush(ls0, (d, t))
        selected0.add(t)
        base += d
    else:
        if t not in selected0 and t not in selected1:
            heapq.heappush(ls1, (-d, t))
            selected1.add(t)

m = len(selected0)
res = base + m**2

for _ in range(k):
    if len(ls0) == 0 or len(ls1) == 0:
        break
    d, _ = heapq.heappop(ls0)
    base -= d
    d, _ = heapq.heappop(ls1)
    base += -d
    m += 1
    res = max(res, base + m**2)
print(res)

Measured memory_bytes: 37132
import Control.Applicative
import Control.Monad
import Control.Arrow ((&&&))
import Data.List
import Data.Char (digitToInt)

main :: IO ()
main = do
  n <- readLn
  map solve <$> replicateM n getLine >>= mapM_ putStrLn
  where

solve :: String -> String
solve = reverse . snd . foldl' f (Nothing, []) . map (digitToInt . head &&& length) . group
  where
    ops = ["", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"]
    f (sc, ss) (d, l)
      | d == 0 = case sc of
                  Nothing -> (sc, ss)
                  Just c -> (Nothing, c : ss)
      | otherwise = (Just ((cycle (ops !! d)) !! (l - 1)), ss)



Measured memory_bytes: 6836
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n<3200) cout<<"red";
    else cout<<s;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int n, a[2000];

int make(int i, int m){
  int res;
  if (m==0)
    return 1;
  if (i>=n)
     return 0;
  res = make(i+1, m) || make(i+1, m-a[i]);

  return res;
}

int main(){
  int q, m, i;

  scanf("%d", &n);
  for (i=0; i<n; i++)
    scanf("%d", &a[i]);

  scanf("%d", &q);
  for (i=0; i<q; i++) {
    scanf("%d", &m);
    if (make(0, m)==1) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1796
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int N = 2e5+5;
const int maxn = 1e9+5;
const dd eps = 1e-6;
const ll mod = 1e9+7;


int n,a[N],minl=INT_MAX,ans;

int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>n;
  for(int i = 1;i <= n;i++) cin>>a[i];
  for(int i = 1;i <= n;i++){
    minl = min(a[i],minl);
    if(minl >= a[i]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <atcoder/dsu>

using namespace std;
using namespace atcoder;

int main() {
    int N,Q;
    cin >> N >> Q;
    dsu d(N);
    for(int i=0;i<Q;i++) {
        int t, u, v;
        cin >> t >> u >> v;
        if(t==0) {
            d.merge(u,v);
        }else{
            cout << (d.same(u, v) ? 1:0) << endl;
        }
    }
}

Measured memory_bytes: 3528
H, M = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]
ans = 0
def warshall_floyd(n):
    for i in range(n): #経由する点
        for j in range(n): #始点
            for k in range(n):  #終点
                c[j][k] = min(c[j][k], c[j][i] + c[i][k])

warshall_floyd(10)

for a in A:
    for ai in a:
        if ai == -1: pass
        else:
            ans += c[ai][1]
        
print(ans)

Measured memory_bytes: 40796
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;


public class Main {
	 static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreTokens()) 
	            { 
	                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; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    } 
	public static boolean solve(long r, long g, long b, long w) {
		 if((r%2+g%2+b%2+w%2)>1)return false;
		 else return true;
	}
	public static void main(String[] args)throws IOException  {
		FastReader s=new FastReader();		
		int n = s.nextInt(); 
		long sum=0;
        long[] ar = new long[n];
        for (int i=0; i<n; i++) {
        	ar[i]=s.nextLong();
        	
        }
        for (int i=1; i<n; i++) {
        	if(ar[i-1]>=ar[i]) {
        		sum+=Math.max(ar[i-1]-ar[i],0);
        		ar[i]=ar[i-1];
        		
        	}
        }
        System.out.println(sum);
        
      
	}
	
}


Measured memory_bytes: 55640
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0) {if(a<b) swap(a,b); a = a%b;} return max(a,b);
}


int main(){
  int n;
  cin>>n;
  int x;
  rep(i,n+1){
    ll x = i*1.08;
    if(n<=x&&x<n+1) {
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<":("<<endl;


  return 0;
}


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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MAX_V 100000

#define MOD 1000000007L
#define INF 2147483647

signed main() {
	int h, w;
	cin >> h >> w;
	string a[h];
	for (size_t i = 0; i < h; i++) {
		cin >> a[i];
	}
	for (size_t i = 0; i < h * 2; i++) {
		for (size_t j = 0; j < w ; j++) {
			cout << a[(int)(i / 2)][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>
#pragma warning (disable:4996)
#include<string.h>
int main()
{
	char a[100], b[100] = { 0 }, c[100] = { 0 };
	
	scanf("%s", a);
	getchar();
	int len = strlen(a);
	for (int i = 0; i <len; i++)
	{
		c[i] = a[len-i-1];
	}
	scanf("%s", b);
    if (strcmp(c, b)==0)printf("YES\n");
	else printf("NO\n");
}

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

int main(void) {
    int N,L;cin>>N>>L;
    int mi = 10000;
    int mi_index;
    for (int i = 1; i <= N; i++) {
        if (mi > abs(L + i - 1)) {
            mi = abs(L + i - 1);
            mi_index = i;
        }
    }

    // りんごの味を算出
    int result = 0;
    for (int i = 1; i <= N; i++) {
        if (i != mi_index) result += L + i - 1;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 888
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [S] = [(input_raw[0])]
    abs_min = sys.maxint
    for i in range(len(S) - 2):
        abs_min = min(abs(753 - int(S[i] + S[i + 1] + S[i + 2])), abs_min)

    print abs_min


if __name__ == '__main__':
    main()

Measured memory_bytes: 3056
#include <stdio.h>

int main() {

	int n, i;

	while ( scanf( "%d", &n ) != EOF ) {

		i = 1;

		while ( n != 1 ) {

			if ( n & 1 == 1 ) {

				printf( "%d ", i );

			}

			n >>= 1;
			i *= 2;

		}

		printf( "%d\n", i );

	}

	return 0;

}

Measured memory_bytes: 596
n=int(input())
A=list(map(int,input().split()))
flag=1
counter=0
while flag:
    flag=0
    for j in range(1,n):
        if A[j] < A[j-1]:
            tmp=A[j]
            A[j]=A[j-1]
            A[j-1]=tmp
            flag=1
            counter+=1
for k in range(len(A)):
    if k != len(A)-1:
        print(A[k],end=' ')
    else:
        print(A[k])
print(counter)


Measured memory_bytes: 5600
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <random>

#include <ctime>
#include <cmath>
#include <cassert>

using namespace std;

mt19937 rng(735);

const long long INF = 4e18;
const long long inf = 1e9 + 7;

const long long P = 6666622222487;
const long long Q = 150001;

template <typename T>
T sqr(T x) {
    return x * x;
}

long long powmod(long long x, long long a, long long mod) {
    return (a <= 0) ? 1 : (((a % 2) ? (x * powmod(x, a - 1, mod)) : sqr(powmod(x, a / 2, mod))) % mod);
}

long long gcd(long long a, long long b) {
    return (b == 0) ? a : gcd(b, a % b);
}

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

    int N;
    cin >> N;
    long long sum = 0;
    long long max_el = INF;

    for (int i = 0; i < N; i++) {
        long long A, B;
        cin >> A >> B;
        sum += A;
        if (A > B) max_el = min(max_el, B);
    }

    if (max_el == INF) cout << 0 << endl;
    else cout << sum - max_el << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <queue>
#include <algorithm>
using namespace std;
int main() {
    int a,b;
    scanf("%d %d", &a,&b);
    if((a<1)||(a>9)||(b<1)||(b>9)){
        printf("%d",-1);
    }else{
        printf("%d",a*b);
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n;
	int m;
	int i;
	char c;
	char temp[2];
	int itemp;
	scanf("%d",&n);
	while(n){
		char convert[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
		for(i=0;i<n;i++){
			scanf("\n%c %c",&temp[0],&temp[1]);
			itemp = (int)temp[0];
			if(48<=itemp && itemp<=57){
				convert[itemp-48] = temp[1];
			}else if(65<=itemp && itemp<=90){
				convert[itemp-55] = temp[1];
			}else{
				convert[itemp-61] = temp[1];
			}
		}
		scanf("%d",&m);
		for(i=0;i<m;i++){
			scanf("\n%c",&c);
			itemp = (int)c;
			if(48<=itemp && itemp<=57){
				c = convert[itemp-48];
			}else if(65<=itemp && itemp<=90){
				c = convert[itemp-55];
			}else{
				c = convert[itemp-61];
			}
			printf("%c",c);
		}
		printf("\n");
		scanf("%d",&n);
	}
	return 0;
}

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

using namespace std;

void cldflm()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

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

int main()
{

	cldflm();

	int n;
	cin >> n;

	string AC = "AC";
	string WA = "WA";
	string TLE = "TLE";
	string RE = "RE";
	int ac1 = 0, wa1 = 0, tle1 = 0, re1 = 0;

	for (int i = 0; i < n; i++)
	{
		string str;
		cin >> str;
		if (str == AC)
			ac1++;
		else if (str == WA)
			wa1++;
		else if (str == TLE)
			tle1++;
		else
			re1++;
	}

	cout << "AC" << " x " << ac1 << endl;
	cout << "WA" << " x " << wa1 << endl;
	cout << "TLE" << " x " << tle1 << endl;
	cout << "RE" << " x " << re1 << endl;


	return 0;
}



Measured memory_bytes: 3640
def multipilation():
    N = int(input())
    A = list(map(int,input().split()))
    if 0 in A:
        print(0) 
        return
    
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return

    print(prod)
    
multipilation()
    
    


Measured memory_bytes: 21648
#include "bits/stdc++.h"
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/10/04  Problem: Nagoya_univ_contest_17_i  / Link:   ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N, M;

// BIT 簡易の方 1indexの方
template<typename type>struct BIT {int N;int nn;vector<type> data;
BIT(int n) {N = n + 1;data = vector<type>(n + 1, 0);nn = 1;while (nn * 2 <= N)nn *= 2;}
void add(int i, type w) {for (int x = i; x <= N; x += x & -x) {data[x] += w;}}
type sum(int i) {type ret = 0;for (int x = i; x > 0; x -= x & -x) {ret += data[x];}return ret;}};

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

	cin >> N >> M;
	VI width[100005];
	BIT<int> bit(100005);
	FOR(i, 0, N) {
		int l, r;
		cin >> l >> r;
		width[r-l+1].push_back(l);
	}
	int Size = N;
	FOR(i, 1, M + 1) {//幅iについて
		Size -= SZ(width[i - 1]);
		int ans = Size;
		FOR(j, 0, SZ(width[i - 1])) {
			bit.add(width[i - 1][j], 1);
			bit.add(width[i - 1][j]+i-1, -1);
		}
		for (int j = i; j <= M; j += i) {//ここにあるのは重複する可能性はない
			ans += bit.sum(j);
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 6784
#include <stdio.h>

int main(void) {
	int x[10000], i = 0, cnt;
	while(1){
		scanf("%d", &x[i]);
		if(x[i] == 0){
			break;
		}else{
			i++;
			cnt++;
		}
	}
	for(i = 1; i <= cnt; i++){
		printf("Case %d: %d\n",i, x[i - 1]);
	}
	return 0;
}

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

int main()
{
    int r, c;
    cin >> r >> c;
    int a[r][c];
    for (int i = 0; i < r; i++)
        for (int j = 0; j < c; j++) {
            int t;
            cin >> t;
            a[i][j] = t;
        }
    for (int i = 0; i < r; i++) {
        int sum = 0;
        for (int j = 0; j < c; j++) {
            sum += a[i][j];
            cout << a[i][j] << " ";
        }
        cout << sum << endl;
    }
    int sumsum = 0;
    for (int i = 0; i < c; i++) {
        int sum = 0;
        for (int j = 0; j < r; j++) {
            sum += a[j][i];
        }
        cout << sum << " ";
        sumsum += sum;
    }
    cout << sumsum << endl;
}



Measured memory_bytes: 3096
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

constexpr long long int MOD = 1000000007;
//const int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;

constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	priority_queue<pair<int, int>>PQ;
	for (int i = 0; i < N; i++) {
		cin >> L >> R;
		PQ.push({ R,L });
	}
	vector<int>v(M);
	for (auto &i : v)cin >> i;
	sort(v.begin(), v.end());
	long long int bef = MOD * MOD;
	while (1) {
		while (!PQ.empty() && PQ.top().second > v.back()) {
			PQ.pop();
		}
		if (PQ.empty())break;
		bef = PQ.top().first;
		PQ.pop();
		v.pop_back();
	}
	cout << M - v.size() << endl;
}


Measured memory_bytes: 4148
import java.io.*;

 public class Main{
	 public static void main(String args[]) throws IOException{
		 BufferedReader bf = new BufferedReader(
				 new InputStreamReader(System.in));
		 int deta[] = new int[1000];
		 int x,j = 0;
		 String str;
		 while((str = bf.readLine()) != null ){
			 x = Integer.parseInt(str);
			 for(int i = 0; i < (600/x) -1; i++){
				 deta[j] += x*(sqrt((1+i)*x));
			 }
			 j++;		
		 }
		 for(int i = 0; i < j ;i++){
			 System.out.println(deta[i]);
		 }
		 
	 }
	 
	 public static int sqrt(int x){
		 int y;
		 y = x*x;
		 return y;
	 }
}

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

int main()
{
ll n,m;
cin >> n >> m ;
ll res[n]={};
rep(i, m)
{
  ll a,b;
  cin >> a>>b;
  res[a-1]++;
  res[b-1]++;
}

rep(i,n){
  if(res[i]%2){
    cout << "NO" << endl;
return 0;
  }
}
cout << "YES" << endl;
return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long 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;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
int main() {
	int n;
	cin >> n;
	vector<int> x;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		x.push_back(a);
	}
	long long int ans = 10000000000000000;
	for (int i = 0; i <= 100; i++) {
		long long int sum = 0;
		for (int j = 0; j < x.size(); j++) {
			sum = sum + (i - x[j]) * (i - x[j]);
		}
		ans = min(sum, ans);
	}
	cout << ans;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int towerCount = sc.nextInt();
		int roadCount = sc.nextInt();

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

		boolean[] towerJudge = new boolean[towerCount];
		for (int i = 0; i < towerCount; i++) {
			towerJudge[i] = true;
		}

		int[] towerA = new int[roadCount];
		int[] towerB = new int[roadCount];
		for (int i = 0; i < roadCount; i++) {
				towerA[i] = sc.nextInt();
				towerB[i] = sc.nextInt();

				towerA[i]--;
				towerB[i]--;

				if(towerHeight[towerA[i]] <= towerHeight[towerB[i]]) {
					towerJudge[towerA[i]] = false;
				}

				if(towerHeight[towerB[i]] <= towerHeight[towerA[i]]) {
					towerJudge[towerB[i]] = false;
				}
		}

		int goodTowerCount = 0;


		for (int i = 0; i < towerCount; i++) {
			if (towerJudge[i]) {
				goodTowerCount++;
			}
		}

		System.out.print(goodTowerCount);

	return;

	}
}


Measured memory_bytes: 50992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		string S = GetString();
		int L = S.Length;
		int ans = 0;
		for(int i = 0; i < L; i++)
			if(S[i] != S[L - 1 - i])
				ans++;

		WriteLine(ans / 2);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
 
void solve() {
    int n, k;
    cin >> n >> k;
    ll h_list[n];
    rep(i,n) cin >> h_list[i];
    ll dp[n];
    dp[0] = 0;
    for (int i = 1; i < n; i++)
    {
        ll temp_min = INF;
        int curr;
        curr = 0;
        for (int j = 1; j <= min(i,k); j++)
        {
            curr = dp[i-j] + abs(h_list[i] - h_list[i-j]);
            if(curr < temp_min) temp_min = curr;
        }
        dp[i] = temp_min;
    }
    cout << dp[n-1] << endl;
}

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

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main(){
	int n,k;
	cin >> n >> k;
	
	int num = n % 2 ? n/2 + 1:n/2;
	
	if(num < k){
		cout << "NO" << endl;
	}else{
		cout << "YES" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T, typename U, typename V>
ostream &operator<<(ostream &os, const tuple<T, U, V> &t){
  os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef tuple<int, int, int> TT;
typedef pair<int, TT> PT;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

map<int, int> mp;
signed main(){
  int n, ans = 0;cin >> n;
  for(int i = 1;i*i <= n;i++){
    if(n%i == 0)mp[i]++, mp[n/i]++;
    // cout << n%i << " " << i << " " << n/i << endl;
  }
  for(auto it = mp.begin();it != mp.end();it++){
    int a = (*it).fi-1;
    if(a <= 1)continue;
    if(n/a == n%a)ans += a;
  }
  cout << ans << endl;
  return 0;
}






Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main() {
 
  int N; cin >> N;
  vector<int> P(N),Q(N);
  for(int i = 0; i < N; i++){
    cin >> P.at(i); 
  }
  for(int i = 0; i < N; i++){
    cin >> Q.at(i) ;
  }
  
  vector<int> v(N);
  for(int i = 0; i < N; i++){
    v.at(i) = i + 1;
  }
  
  int n = 1;
  for(int i = 0; i < N; i++){
    n *= i + 1;
  }
  
  vector<vector<int>> pmt(n);
  
  int num = 1;
  int num_P,num_Q;
  
  do{
    if(v == P) num_P = num;
    if(v == Q) num_Q = num;
    num++;
  }
  while(next_permutation(v.begin(), v.end() ));
    
    
    /*
    for(int i = 0; i < N; i++){
      cout << v.at(i) << " ";
      if(i == N - 1) cout << endl;
    }
    */
  
  cout << max(num_P - num_Q, num_Q - num_P) << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

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


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] ai = new int[N];
		for(int i =0; i < N; i++){
			ai[i]=0;
		}
		for(int i =0; i < N-1; i++){
			int up = sc.nextInt();
			ai[up-1]++;
		}
		for(int i =0; i < N; i++){
			System.out.println(ai[i]);
		}
        return;
	}
}


Measured memory_bytes: 60160
// https://atcoder.jp/contests/abc126/tasks/abc126_c

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

struct WeightedUnionFind {
    vector<int> par; // 親の番号
    vector<int> ws;  // 親との重みの差
    WeightedUnionFind(int size) : par(size, -1), ws(size) {}

    // x が入っている集合と y が入っている集合を併合する．
    bool unite(int x, int y, int w) { // x <-(w)- y (x + w = y)
        w += weight(x);
        w -= weight(y);
        x = root(x);
        y = root(y);

        if (x != y) {
            if (par[y] < par[x]) { // 多い方が根になるようにスワップする.
                swap(x, y);
                w = -w;
            }
            par[x] += par[y];
            par[y] = x;
            ws[y] = w;
            return true;
        } else {
            return false;
        }
    }
    // x と y が同じ集合に入っているかどうかを判定する．
    bool same(int x, int y) { return root(x) == root(y); }

    // 根を返す
    int root(int x) {
        if (par[x] < 0) {
            return x;
        } else {
            int parent = root(par[x]);
            ws[x] += ws[par[x]];
            return par[x] = parent;
        }
    }

    int weight(int x) {
        root(x);
        return ws[x];
    }

    int diff(int x, int y) { // x - y を求める. 比較不能ならnull.
        if (!same(x, y)) {
            return -1;
        }
        return abs(weight(x) - weight(y));
    }
    // size()はUnionrootと同じなので省略.
};

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

    WeightedUnionFind tree(n);

    for (int i = 0; i < n - 1; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        tree.unite(--x, --y, z);
    }
    for (int i = 0; i < n; i++) {
        // 0 か 1 を出力
        cout << (1 & tree.weight(i)) << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val s= (1..n).map { readLine()!! }
    val m= readLine()!!.toInt()
    val t= (1..m).map { readLine()!! }

    val z=s.distinct().map { str -> s.count{it==str} - t.count{it==str} } + 0
    println(z.max())

}

Measured memory_bytes: 33656
#include <iostream>
#include <string>
#include <stack>

using namespace std;

int main(void) {
	string word;
	stack<int> S;
	int x, y;
	while(cin >> word) {
		if (word == "+") {
			x = S.top();
			S.pop();
			y = S.top();
			S.pop();
			S.push(x + y);
		}
		else if (word == "-") {
			x = S.top();
			S.pop();
			y = S.top();
			S.pop();
			S.push(y - x);
		}
		else if (word == "*") {
			x = S.top();
			S.pop();
			y = S.top();
			S.pop();
			S.push(x * y);
		} else {
			S.push(stoi(word));
		}
	}
	cout << S.top() << endl;
}



Measured memory_bytes: 3176
n, k = list(map(int, input().split()))

if k % 2 == 0:
    # 全部nの倍数
    x1 = int(n // k)
    # 全部nの倍数と半分
    x2 = int((n + k/2) // k)

    print(x1 ** 3 + x2 ** 3)

else:
    # 全部nの倍数
    x1 = int(n // k)
    print(x1 ** 3)



Measured memory_bytes: 2940
#include <cstdio>

int main()
{
  int n, l;
  scanf("%d %d", &n, &l);
  if (l + n - 1 < 0)
  {
    printf("%d\n", (n - 1) * l + (n - 2) * (n - 1) / 2);
  }
  else if (l <= 0)
  {
    printf("%d\n", n * l + n * (n - 1) / 2);
  }
  else
  {
    printf("%d\n", (n - 1) * l + n * (n - 1) / 2);
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        while (n != 0) {
            char text[] = sc.nextLine().toCharArray();
            int alpha = 0;
            int beta = 0;
            for (int a = 0; a <= 100; a++) {
                for (int b = 0; b <= 100; b++) {
                    Set<Character> set = new HashSet<Character>();
                    Map<Character, Character> map = new HashMap<Character, Character>();
                    for (int i = 0; i < 26; i++) {
                        set.add((char) ('a' + ((a * i + b) % 26)));
                        map.put((char) ('a' + i),
                                (char) ('a' + ((a * i + b) % 26)));
                    }
                    if (set.size() == 26) {
                        StringBuilder sb = new StringBuilder();
                        for (int j = 0; j < text.length; j++) {
                            if (text[j] != ' ')
                                sb.append(map.get(text[j]));
                            else
                                sb.append(' ');
                        }
                        String str = sb.toString();
                        if (str.matches(".*" + "this" + ".*")
                                || str.matches(".*" + "that" + ".*")) {
                            System.out.println(str);
                            a = 101;
                            break;
                        }
                    }
                }
            }
            n--;
        }
    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
}

Measured memory_bytes: 12000
#include <iostream>
#include <cstring>
using namespace std;
int a[110000];
int main()
{
    int n,q,i,j=0;
    cin>>n>>q;
    string s;
    cin>>s;
    a[0]=0;
    for(i=1; i<n; i++)
    {
        if(s[i-1]=='A'&&s[i]=='C')
            j++;
        a[i]=j;
    }
    while(q--)
    {
        int st,e;
        cin>>st>>e;
        cout<<a[e-1]-a[st-1]<<endl;
    }
    return 0;
}

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

int findGCD(int a, int b)
{
    if (a == b) {
        return a;
    } else if (a > b) {
        return findGCD(a - b, b);
    } else if (a < b) {
        return findGCD(a, b - a);
    }
}

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

    int gcd = findGCD(x, y);
    cout << gcd << endl;

    return 0;
}

Measured memory_bytes: 3080
#include<stdio.h>

int main(){
 int i,n,x;
 long long int sum,min,max;
 scanf("%d",&n);
 scanf("%d",&x);
 min = x;
 max = x;
 sum = x;
 for(i=1;i<n;i++){
  scanf("%d",&x);
  sum = sum + x;
  if(x < min) min = x;
  if(max < x) max = x;}
 printf("%lld %lld %lld\n",min,max,sum);
 return 0;}
  
/*int???9????????§??????????¨????????????????????????????????????§????????¨?????????*/
/*????????????????????????long long int?????????????????????????????????%lld*/
/**/
/**/
/**/

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s;
int N = 0;
vector<int> v(N);
int a, b;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  cin >> s;
  if (s[0] == s[2])
    Yes();
  else
    No();

  return 0;
}

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



int main(){
    int l,r;
    cin >> l >> r;
    int ll = l % 2019, rr = r % 2019;
    if(r-l>=2019||ll>rr){
        cout << 0;
    }else{
        int mini=1000000;
        for(int i=ll;i<=rr;i++){
            for(int j=i+1;j<=rr;j++){
                mini=min((i*j)%2019,mini);
            }
        }
        cout << mini;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll n;
ll a[MAX];
ll sum;
int main(){FAST;
cin>>n;
for(ll i=1;i<=n;i++)cin>>a[i];
for(ll i=1;i<=n;i++)sum+=a[i]-1;
cout<<sum;
return 0;
}

Measured memory_bytes: 256
def resolve():
	n = int(input())
	s = input()
	west_sum = [0]*(n+1)
	east_sum = [0]*(n+1)

	for i in range(n):
		if s[i] == 'E':
			east_sum[i+1] = east_sum[i] + 1
			west_sum[i+1] = west_sum[i]
		else:
			west_sum[i+1] = west_sum[i] + 1
			east_sum[i+1] = east_sum[i]
	ans = float('inf')
	for i in range(1, n):
		if i == 1:
			ans = min(ans, east_sum[-1] - east_sum[1])
		elif i == (n - 1):
			ans = min(ans, west_sum[-2])
		else:
			v = west_sum[i-1] + (east_sum[-1] - east_sum[i])
			ans = min(ans, v)
	print(ans)
resolve()

Measured memory_bytes: 45552
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int k;
    cin >> k;

    queue<ll> q;
    rep(i, 1, 10) q.push(i);

    ll ans;
    rep(i, 0, k)
    {
        ans = q.front();
        q.pop();

        ll val = ans * 10 + ans % 10;
        if (ans % 10 != 0) q.push(val - 1);
        q.push(val);
        if (ans % 10 != 9) q.push(val + 1);
    }

    cout << ans << endl;
}


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

#define move ______move

vector<int> move[2];
string s;
bool dpx[17000], dpy[17000];
int x, y;

int solve(bool *dp, vector<int> x){
	int sum = 0;
	for(int i = 0;i < x.size();i++)sum += x[i];
	dp[0] = true;
	for(int i = 0;i < x.size();i++){
		for(int j = 16999;j - x[i] >= 0;j--){
			dp[j] |= dp[j-x[i]];
		}
	}
	return sum;
}

bool ok(int sum, int x, bool *dp){
	if((sum - x) % 2)return false;
	if((sum - x) / 2 >= 0 && (sum - x) / 2 < 17000 && dp[(sum - x)/2])return true;
	if((sum + x) / 2 >= 0 && (sum + x) / 2 < 17000 && dp[(sum + x)/2])return true;
	return false;
}

int main(){
	cin >> s;
	cin >> x >> y;
	s += 'T';
	int sx = 0;
	int sy = 0;
	while(sx < s.size() && s[sx] != 'T')sx++;
	int turn = 0;
	int cnt = 0;
	for(int i = sx;i < s.size();i++){
		if(s[i] == 'T'){
			move[turn].push_back(cnt);
			turn ^= 1;
			cnt = 0;
		}
		else{
			cnt++;
		}
	}

	int sumx = solve(dpx, move[0]);
	int sumy = solve(dpy, move[1]);
	
	if(ok(sumx, abs(sx-x), dpx) && ok(sumy, abs(sy-y), dpy))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int counter = 0;
    char start = s[0];
    for(size_t i = 1; i < s.size(); i++)
    {
        if(start != s[i]){
            start = s[i];
            continue;
        }
        else if(s[i] == '0'){
            counter ++;
            start = '1';
        }
        else if(s[i] == '1'){
            counter ++;
            start = '0';
        }
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
#define ll               long long
int main(){
  ll a,b,f=0;cin>>a;
  a=a%10;
  if(a==3)cout<<"bon";
  else if(a==0||a==1||a==6||a==8)cout<<"pon";
  else cout<<"hon";
  }


Measured memory_bytes: 3636