akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final String s = sc.next();
			
			if(s.endsWith("s")) {
				System.out.println(s + "es");
			}else {
				System.out.println(s + "s");
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 36572
from heapq import heappush, heappop
import sys

INF = sys.maxsize

v_num, e_num, src = map(int, input().split())
graph = [[] for _ in range(v_num)]

for _ in range(e_num):
  s, t, dist = map(int, input().split())
  graph[s].append((t, dist))

heap = []
dst = [INF for _ in range(v_num)]

heappush(heap, (0, src))
dst[src] = 0

while heap:
  dist, node = heappop(heap)
  for to, cost in graph[node]:
    if dst[to] > cost + dist:
      dst[to] = cost + dist
      heappush(heap, (cost + dist, to))

for dist in dst:
  if dist == INF:
    print("INF")
  else:
    print(dist)




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

// 入力
int dx[4], dy[4];
// used[y][x] := (y,x) にカードをおいたかどうか
bool used[4][4];

int solve(int n){
	if(n == 0) return 1;
	
	int res = 0;
	
	// 1 枚目のカードを置く
	int x1, y1;
	for( y1 = 0 ; y1 < 4 ; y1++ ){
		for( x1 = 0 ; x1 < 4 ; x1++ ){
			if( !used[y1][x1] ) break;
		}
		if( x1 != 4 ) break;
	}
	used[y1][x1] = true;
	
	// 2 枚目のカードを置く
	for(int i=0 ; i < 4 ; i++ ){
		int mx = x1 + dx[i];
		int my = y1 + dy[i];
		if( mx < 0 || my < 0 || mx >= 4 || my >= 4 || used[my][mx] ) continue;
		used[my][mx] = true;
		res += solve(n-1);
		used[my][mx] = false;
	}
	
	used[y1][x1] = false;
	return res;
}

int main(){
	while( cin >> dx[0] ){
		if( dx[0] > 4 ) break;
		
		cin >> dy[0];
		for(int i=1 ; i < 4 ; i++ ){
			cin >> dx[i] >> dy[i];
		}
		
		// 初期化
		for(int y=0 ; y < 4 ; y++ ){
			for(int x=0 ; x < 4 ; x++ ){
				used[y][x] = false;
			}
		}
		int ans = solve(8);
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
from collections import deque

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n,m=input2()
g=[[] for _ in range(n+1)] #引数->要素で道しるべを保存
for i in range(m):
	a,b=input2()
	g[a].append(b)
	g[b].append(a)

q=deque() #bfs用
q.append(1) #始点

check=[0]*(n+1) #既に訪問している(1)か否(0)か
check[1]=1

ans=[0]*(n+1) #始点に近い側の，一つ前の要素(解答)
ans[1]=1
for _ in range(10**5+1):
	if len(q)==0:
		break
	v=q.popleft() #頂点を一つ取り出す
	for u in g[v]: #vとの通路を全て探索
		if check[u]==0: 
			check[u]=1 #探索済み==1
			ans[u]=v 
			q.append(u)
print("Yes")
for i in range(2,n+1):
	print(ans[i])

Measured memory_bytes: 34776
// https://atcoder.jp/contests/abc042/tasks/arc058_b
#include <bits/stdc++.h>
const int MOD = 1e9 + 7;

template <int N, typename T, T M> struct factorial_mod {
    T mod[N + 1];
    T inv_mod[N + 1];

    constexpr factorial_mod() : mod(), inv_mod() {
        mod[0] = 1;
        for (int i = 0; i < N; ++i) {
            mod[i + 1] = (mod[i] * (i + 1)) % M;
        }
        inv_mod[N] = power(mod[N], M - 2);
        for (int i = N - 1; i >= 0; --i) {
            inv_mod[i] = (inv_mod[i + 1] * (i + 1)) % M;
        }
    }

    constexpr T power(T a, T b) {
        T r = 1;
        while (b > 0) {
            if ((b & 1) != 0)
                r = (r * a) % M;
            a = (a * a) % M;
            b >>= 1;
        }
        return r;
    }

    constexpr T comb(T n, T r) {
        return (((mod[n] * inv_mod[r]) % M) * inv_mod[n - r]) % M;
    }
};
factorial_mod<200000, long long, MOD> facmod;

int main() {
    using namespace std;
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long H, W, A, B, ans = 0;
    cin >> H >> W >> A >> B;
    for (int i = 0; i < H - A; i++) {
        ans += facmod.comb(B - 1 + i, B - 1) *
               facmod.comb(H - i - 1 + W - B - 1, W - B - 1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,M,C = map(int,input().split())
B = input().split()
count = 0
sum = 0
for i in range(M):
  B[i] = int(B[i])
  
for i in range(N):
  A = input().split()
  for i in range(M):
    A[i] = int(A[i])
    sum += A[i]*B[i]
  sum += C
  if(sum > 0):
    count += 1
  sum = 0

print(count)
            


Measured memory_bytes: 3064
N = int(input())
L = list(map(int, input().split()))
m = 0		# 配列内の最大値
s = 0		# 配列の要素の総和
for i in range(N):
    s += L[i]
    if m < L[i]:
        m = L[i]

if s - m > m:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
X=io.read("n")
res=0
if X<4 then 
	res=1
else
	k=math.floor(math.sqrt(X))
	for i=2,k do
		local j=2
		while math.pow(i,j)<=X do
			j=j+1		
		end
		j=j-1
		res=math.floor(math.max(res,math.pow(i,j)))
	end
end
print(res)


Measured memory_bytes: 760
/**
*    Name: Ajay
*    Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loope(i,a,b) for(int i=a;i<=b;i++)
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

int main()
{      
   int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  if(n&1)
  {
    cout<<0;
    return 0;
  }
  sort(a,a+n);
  int med=(n/2);
  int left=med-1;
  int right=med;
  if(a[left]==a[right])
  {
    cout<<"0";
    return 0;
  }
  cout<<a[right]-a[left];
  return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
  
public class Main {
	
    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
    
    public void exec() throws IOException {
    	SimpleInputUtil in = new SimpleInputUtil();
        PrintWriter out = new PrintWriter(System.out);
    	int n = in.readInt();
    	
    	for(int i=0; i<n; i++) {
    		String[] cmd = in.br.readLine().split(" ");
    		if(cmd[0].equals("insert")){
    			DoublyLinkedList.insert(Integer.parseInt(cmd[1]));
    		} else if(cmd[0].equals("delete")){
    			DoublyLinkedList.delete(Integer.parseInt(cmd[1]));
    		} else if(cmd[0].equals("deleteFirst")){
    			DoublyLinkedList.deleteFirst();
    		} else {
    			DoublyLinkedList.deleteLast();
    		}
    	}
    	out.println(DoublyLinkedList.listToString());
    	out.flush();
    }
}

class DoublyLinkedList {
	public static DoublyLinkedList head = null;
	public static DoublyLinkedList tail = null;
	
	public static void insert(int x) {
		DoublyLinkedList newElem = new DoublyLinkedList(x);
		newElem.next = head;
		if(head != null) {
			head.prev = newElem;
		}
		head = newElem;
		if(tail == null) {
			tail = head;
		}
	}
	
	public static void deleteFirst() {
		if(head == null) throw new IllegalStateException();
		head = head.next;
		if(head == null)
			tail = null;
		else
			head.prev = null;
	}
	
	public static void deleteLast() {
		if(tail == null) throw new IllegalStateException();
		tail = tail.prev;
		if(tail == null)
			head = null;
		else
			tail.next = null;
	}
	
	public static void delete(int x) {
		for(DoublyLinkedList now = head; now != null; now = now.next) {
			if(now.value == x) {
				if(now == head) {
					deleteFirst();
				} else if(now == tail) {
					deleteLast();
				} else {
					now.prev.next = now.next;
					now.next.prev = now.prev;
				}
				return;
			}
		}
	}
	
	public static String listToString() {
		StringBuilder sb = new StringBuilder();
		for(DoublyLinkedList now = head; now != null; now = now.next) {
			if(now.prev != null) {
				sb.append(" ");
			}
			sb.append(now.value);
		}
		return sb.toString();
	}

	int value = -1;
	DoublyLinkedList next = null;
	DoublyLinkedList prev = null;
	
	public DoublyLinkedList(int x) {
		value = x;
	}
	

}

class SimpleInputUtil {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public String[] readStrArray(String delim) throws NumberFormatException, IOException{
    	return br.readLine().split(delim);
    }
    
    public int readInt() throws NumberFormatException, IOException{
    	return Integer.parseInt(br.readLine());
    }
    
    public int[] readIntArray(int[] a) throws NumberFormatException, IOException{
        int i=0;
        while(i<a.length) {
            for(String s: br.readLine().split(" ")){
            	if(i<a.length) {
                    a[i++] = Integer.parseInt(s);
            	}
            }
        }
        return a;
    }

    
}

Measured memory_bytes: 188628
saver_num = int(input())
mons_num = list(map(int, input().split()))
power_num = list(map(int, input().split()))
count = 0

for i in range(saver_num):
    if power_num[i] <= mons_num[i]:
        count += power_num[i]
    else:
        count += mons_num[i]
        power = power_num[i] - mons_num[i]
        if power <= mons_num[i+1]:
            count += power
            mons_num[i+1] = mons_num[i+1] - power
        else:
            count += mons_num[i+1]
            mons_num[i+1] = 0

print(count)

Measured memory_bytes: 18476
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>

using namespace std;

typedef long long ll;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
	cin >> n;
	vector<int> v(n+1);
	set<int> s;
	for(int i=1;i<=n;i++) cin >> v[i];
	int ans = 0,pos = 1;
	while(pos!=2){
		if(s.find(pos)!=s.end()){
			cout << "-1" << "\n";
			return 0;
		}
		s.insert(pos);
		pos = v[pos];
		ans++;
	}
	cout << ans << "\n";
    
	return 0;
}

Measured memory_bytes: 5376
using System;
using System.Collections.Generic;
using System.Globalization;

namespace AOJ0501DataConversion
{
    public class Program
    {
        static readonly IFormatProvider formatProvider = CultureInfo.InvariantCulture.NumberFormat;  
        private static void Main()
        {
            var outputs = new List<string>();

            while (true)
            {
                var numberOfTableRows = int.Parse(Console.ReadLine(), formatProvider);

                if (numberOfTableRows == 0 || outputs.Count >= 5)
                {
                    break;
                }

                var table = new Dictionary<char, char>();
                CreateTable(table, numberOfTableRows);

                var numberOfData = int.Parse(Console.ReadLine(), formatProvider);
                outputs.Add(CreateConvertedString(table, numberOfData));
            }

            foreach (var output in outputs)
            {
                Console.WriteLine(output);
            }
       }

        private static void CreateTable(Dictionary<char, char> table, int numberOfTableRows)
        {
            for (var i = 0; i < numberOfTableRows; ++i)
            {
                var readLine = Console.ReadLine();
                if (readLine != null)
                {
                    table.Add(readLine[0], readLine[2]);
                }
            }
        }

        private static string CreateConvertedString(Dictionary<char, char> table, int numberOfData)
        {
            var result = new List<char>();
            for (var i = 0; i < numberOfData; i++)
            {
                var readLine = Console.ReadLine();
                if (readLine == null)
                {
                    continue;
                }

                var data = readLine[0];
                char convertedCharacter;
                result.Add(table.TryGetValue(data, out convertedCharacter)
                               ? convertedCharacter
                               : data);
            }

            return new string(result.ToArray());
        }
    }
}



Measured memory_bytes: 20940
// https://atcoder.jp/contests/abc097/tasks/abc097_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int search(int x)
{
  REPR(i, x)
  {
    FOR(j, 2, ceil(sqrt(i)) + 1)
    {
      int k = 0, c = 1;
      while (c < i)
      {
        k++;
        c *= j;
        if (c == i)
          return i;
      }
    }
  }
  return 1;
}

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int x;

  cin >> x;

  cout << search(x) << '\n';

  return 0;
}


Measured memory_bytes: 256
function Main(input){
	if(input<=104){
		console.log(0)
	}else if(input<=134){
		console.log(1)
	}else if(input<=164){
		console.log(2)
	}else if(input<=188){
		console.log(3)
	}else if(input<=194){
		console.log(4)
	}else{
		console.log(5)
	}
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    //dp[heads]
    //if we had i tosses, then tails=i-heads
    vector<double> dp(n+1);
    // dp[i] - p-bility that there are i heads so far
    dp[0] = 1;
    for(int coin=0; coin <n; ++coin) {
        double p_head;
        cin >> p_head;
        for(int i=coin+1; i>=0; --i) {
            dp[i] = (i == 0 ? 0 :  dp[i-1]*p_head) + dp[i]*(1 - p_head);
        }
    }
    double ans = 0;
    for(int i=n/2+1; i<=n; ++i) {
        ans += dp[i];
    }
    cout << setprecision(10) << fixed <<  ans  << "\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		long []s = new long [n];
		
		for(int i = 0; i < n ;i++) {
		 if(i > 0) {
			s[i] += s[i-1];
		}
		   long x = sc.nextLong();
			s[i] += x;
			
		}
		
		long min = 200000000000000L;
		
		for(int i = 0 ; i < n-1 ; i++) {
			long a = s[i];
			long b = s[n-1] - s[i];
			
			long temp = Math.abs(a - b);
			min = Math.min(temp, min);
		}
		
		System.out.println(min);
		

	}

}


Measured memory_bytes: 85952
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define inf 10000000007
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);

using namespace std;

int n, k;
int v[51];
int pre[52][111], suf[52][111];

signed main()
{
	
 	FLASH

 	cin>>n>>k;

 	fr(i,1, n + 1) cin>>v[i];
 	if(k >= 2*n - 1){
 		int ans = 0;
 		fr(i, 1, n + 1) ans += max((int)0, v[i]);
 		cout<<ans;
 		return 0;
 	}

 	vector<int> in;
 	fr(i, 1, n + 1){
 		in.pb(v[i]);
 		sort(in.begin(), in.end());
 		reverse(in.begin(), in.end());

 		fr(j, 0, i + 1){
 			int sum = 0;
 			fr(l, 0, j) sum += in[l]; 

 			pre[i][2*i - j] = max(pre[i][2*i - j], pre[i - 1][2*i - j]);
 			pre[i][2*i - j] = max(pre[i][2*i - j], sum);
 		}
 	}

 	in.clear();
 	reverse(v + 1, v + n + 1);

 	fr(i, 1, n + 1){
 		in.pb(v[i]);
 		sort(in.begin(), in.end());
 		reverse(in.begin(), in.end());

 		fr(j, 0, i + 1){
 			int sum = 0;
 			fr(l, 0, j) sum += in[l];
 			suf[n - i + 1][2*i - j] = max(suf[n - i + 1][2*i - j], suf[n - i][2*i - j]);
 			suf[n - i + 1][2*i - j] = max(suf[n - i + 1][2*i - j], sum);
 		}
 	}
 	
 	int ans = 0;
 	fr(i, 1, n + 1){
 		fr(j, 1, k + 1){
 			pre[i][j] = max(pre[i][j], max(pre[i - 1][j], pre[i][j - 1]));
 			suf[i][j] = max(suf[i][j], max(suf[i + 1][j], suf[i][j - 1]));
 		}
 	}

 	fr(i, 1, n + 1){
 		fr(j, 1, k + 1){
 			ans = max(ans, pre[i][j] + suf[i + 1][k - j]);
 		}
 	}

 	cout<<ans;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;

int main()
{
    ll n,m,i,a=0,b=0,k,j;
    string s,t;
    cin>>s>>t;
    for(i=0;i<s.size();i++) if(s[i]!=t[i]) a++;
    cout<<a;
}

Measured memory_bytes: 3852
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define N 403
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
using namespace std;
const int mod=1000000007;
inline int read(){
	int x=0,w=0;char ch=getchar();
	while (!isdigit(ch))w|=ch=='-',ch=getchar();
	while (isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	return w?-x:x;
}
int n,m,f[N][N][N],ans;
vector<pii>v[N];
inline void add(int &a,int b){a+=b;if (a>=mod)a-=mod;}
inline bool check(int i,int j,int k,int m1,int m2,int m3,int M2){
	return (k<m1&&(m2==i||(j<m2&&k>=M2))&&(m3==-1||(j>=m3&&k>=m3)));
}
signed main(){
	n=read(),m=read();
	for (int i=1;i<=m;++i){
		int l=read(),r=read(),x=read();
		v[r].pb(mp(l,x));
	}
	f[0][0][0]=1;
	for (int i=0;i<n;++i){
		int m1=i+2,m2=i+2,M2=-1,m3=-1;
		for (int j=0;j<v[i+1].size();++j){
			if (v[i+1][j].se==1)m1=min(m1,v[i+1][j].fi);
			if (v[i+1][j].se==2)M2=max(M2,v[i+1][j].fi),m2=min(m2,v[i+1][j].fi);
			if (v[i+1][j].se==3)m3=max(m3,v[i+1][j].fi);
		}
		for (int j=0;j<=i;++j)
			for (int k=j?j+1:0;k<=i;++k){
				if (check(i+2,j,k,m1,m2,m3,M2))add(f[i+1][j][k],f[i][j][k]);
				if (check(i+2,j,i,m1,m2,m3,M2))add(f[i+1][j][i],f[i][j][k]);
				if (check(i+2,k,i,m1,m2,m3,M2))add(f[i+1][k][i],f[i][j][k]);
			}
	}
	for (int j=0;j<n;++j)
		for (int k=j?j+1:0;k<n;++k)
			add(ans,f[n][j][k]);
	printf("%d\n",ans%mod);
    return 0;
}

Measured memory_bytes: 190848
'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', function(inputStdin) {
    inputString += inputStdin;
});

process.stdin.on('end', function() {
    inputString = inputString.split('\n');
    main();
});

function readline() {
    return inputString[currentLine++];
}

// main funtion .. code start ..... ///
function main() {

//var input = readline()
var t = Number(readline())
    if(t == 25) console.log('Christmas')
    else if(t == 24) console.log('Christmas Eve')
    else if(t == 23) console.log('Christmas Eve Eve')
    else console.log('Christmas Eve Eve Eve') 
}

Measured memory_bytes: 21320
"use strict";
const s = require('fs').readFileSync('/dev/stdin', 'utf8');
let n = s.split("\n")[0].split(" ")[0]*1;
let x = s.split("\n")[0].split(" ")[1]*1;
let a = s.split("\n")[1].split(" ").sort((a, b) => a - b);
let cnt = 0;
for(let i = 0; i < n; i++){
  if(x >= a[i]) {
    x -= a[i]
    cnt++;
  } else {
    break;
  }
}
if (x > 0 && cnt >= n) {
  cnt--;
}
console.log(cnt);

Measured memory_bytes: 21192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)



int main(){

  ll n;
  cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  ll ans=INT_MAX;
  for(ll i=-100;i<=100;i++){
    ll sum=0;
    rep(j,n){
      sum+=(a[j]-i)*(a[j]-i);
    }
    ans = min(ans,sum);
  }
  cout << ans << endl;
  
  return 0;

}


Measured memory_bytes: 256
import math

N = int(input())
mod = int(1E9+7)

def prime(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    if n != 1:
        factor.append(n)
    return factor

def main():
    P = [0 for _ in range(N+1)]
    for n in range(2, N+1):
        A = prime(n)
        for a in A:
            P[a] += 1

    ans = 1
    for p in P:
        ans =  ans * (p+1) % mod

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
using namespace std;

int main(){
    int m,n;
    for(;;){
        scanf("%d%d",&m,&n);
        if(m==0 && n==0) break;
        vector<int> page(n);
        int mapa=0;
        for(int i=0;i<n;i++){
            scanf("%d",&page[i]);
            mapa=max(mapa,page[i]);
        }
        vector<int> sum(n);
        sum[0]=page[0];
        for(int i=1;i<n;i++){
            sum[i]=page[i]+sum[i-1];
        }
        vector<int> wis;
        int miwi=0;
        for(int i=0;i<n;i++){
            for(int j=i;j<n;j++){
                int w=sum[j]-sum[i]+page[i];
                if(mapa<=w && w<=1500000){
                    wis.push_back(w);
                    miwi=max(miwi,w);
                }
            }
        }
        for(int i=0;i<wis.size();i++){
            int wi=wis[i];
            int at=1,now=0;
            for(int j=0;j<page.size();j++){
                if(now+page[j]<=wi){
                    now+=page[j];
                }else{
                    at++;
                    now=page[j];
                }
            }
            if(at<=m) miwi=min(miwi,wi);
        }
        printf("%d\n",miwi);
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int G[9][9], wrong[9][9];
int cnt[9];

int main() {
    int t;
    cin >> t;
    int a = 0;
    while(t--){
        if(a++) puts("");
        for (int i = 0; i < 9; ++i) {
            for (int j = 0; j < 9; ++j) {
                cin >> G[i][j];
                G[i][j]--;
                wrong[i][j] = 0;
            }
        }
        fill(cnt, cnt+9, 0);
        for (int i = 0; i < 9; ++i) {
            fill(cnt, cnt+9, 0);
            for (int j = 0; j < 9; ++j) cnt[G[i][j]]++;
            for (int j = 0; j < 9; ++j) if(cnt[G[i][j]] >= 2) wrong[i][j] = 1;
        }
        for (int i = 0; i < 9; ++i) {
            fill(cnt, cnt+9, 0);
            for (int j = 0; j < 9; ++j) cnt[G[j][i]]++;
            for (int j = 0; j < 9; ++j) if(cnt[G[j][i]] >= 2) wrong[j][i] = 1;
        }
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                fill(cnt, cnt+9, 0);
                for (int k = 0; k < 3; ++k) {
                    for (int l = 0; l < 3; ++l) {
                        cnt[G[i*3+k][j*3+l]]++;
                    }
                }
                for (int k = 0; k < 3; ++k) {
                    for (int l = 0; l < 3; ++l) {
                        if(cnt[G[i*3+k][j*3+l]] >= 2) wrong[i*3+k][j*3+l] = 1;
                    }
                }
            }
        }
        for (int i = 0; i < 9; ++i) {
            for (int j = 0; j < 9; ++j) {
                putchar(wrong[i][j] ? '*' : ' ');
                printf("%d", G[i][j]+1);
            }
            puts("");
        }
    }
    return 0;
}


Measured memory_bytes: 3044
n=int(input())
pre=0
ans=1
t=0
for i in input().split():
    a=int(i)
    if pre==0:
        pre=a
    else:
        if pre>a:
            if -t<0 and t**2==1:
                ans+=1
                t=-2
            else:
                t=-1
        elif pre<a:
            if t<0 and t**2==1:
                ans+=1
                t=2
            else:
                t=1
        else:
            continue
        pre=a
print(ans)

Measured memory_bytes: 62960
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll dp[100001]; //dp[i]::=価値がiとなるよう選んだ時の重さの最小値
ll w[100], v[100];
int main() {
	int N, W;
	cin >> N >> W;
	for (int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
	}
	fill(dp, dp + 100001, 1LL << 60);
	dp[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 100000; j >= 0; j--) {
			if (j >= v[i]) {
				dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
			}
		}
	}
	for (int i = 100000; i >= 0; i--) {
		if (dp[i] <= W) {
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            String S = sc.next();

            StringBuilder result = new StringBuilder(S.length());
            for(int i = 0; i < S.length(); i++) {
                result.append("x");
            }

            System.out.println(result);
        }
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;
const ll INF = 0x3f3f3f3f3f3f3f3f;
#define DEBUG(x) cout << x << '\n'

char s[MAXN];
int main(){
    #ifdef Irene
    freopen("in.txt", "r", stdin);
    #endif // Irene
    ios::sync_with_stdio(false);

    cin >> s;
    int n = strlen(s), cnt = 0, l = -1, r = -1;
    s[n] = 'P';
    for(int i = 0; i < n; i++){
        if(s[i] == '?'){
            if(l == -1) l = i;
            r = i, cnt++;
        }
        else{
            for(int i = l; i < r; i++){
                if(i == 0 || s[i-1] == 'D') s[i] = 'P';
                else s[i] = 'D';
            }
            if(r > 0 && s[r-1] == 'P') s[r] = 'D';
            else if(s[r+1] == 'D') s[r] = 'P';
            else s[r] = 'D';
            cnt = 0;
            l = r = -1;
        }
    }
    if(cnt){
        for(int i = l; i < r; i++){
            if(i == 0 || s[i-1] == 'D') s[i] = 'P';
            else s[i] = 'D';
        }
        if(r > 0 && s[r-1] == 'P') s[r] = 'D';
        else if(s[r+1] == 'D') s[r] = 'P';
        else s[r] = 'D';
    }
    s[n] = '\0';
    cout << s;
}


Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IFOR(v,it) for(VI::iterator it=(v).begin();it!=(v).end();++it)
#define INF = 1000000000


int main() {
  LL N, H;
  cin >> N >> H;

  vector<LL> A, B;
  REP(i, N) {
    LL a, b;
    cin >> a >> b;
    A.PB(a); B.PB(b);
  }
  LL max_a = *max_element(ALL(A));
  SORT(B);

  // max(a_i)でn回斬る -> max(a_i) 以上のbを投げつける

  LL count = 0;
  for (auto it = B.end() - 1, end = lower_bound(ALL(B), max_a); it != end - 1; --it) {
    H -= *it;
    ++count;
    if (H <= 0)
      break;
  }
  if (H <= 0)
    cout << count << endl;
  else
    cout << count + ((H + max_a - 1) / max_a) << endl;

  return 0;
}


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

typedef pair< pair< int,int > ,int >T;
vector<T>q;
int tot;
void add(int x,int y,int z){
  q.push_back(make_pair(make_pair(x,y),z));
}
void work(int st,int pre,int rest){
  //printf("work %d %d %d\n",st,pre,rest);
  if(rest==0)return;
  int m=1;
  for(;1<<m<=rest;m++);m--;
  add(m+1,tot,pre);
  work(st,pre+(1<<m),rest-(1<<m));
}
int main(){
  //freopen("aa.in","r",stdin);
  int L;scanf("%d",&L);
  int M=1;
  for(;(1<<M)<=L;M++);M--;
  for(int i=1;i<=M;i++){
    add(i,i==M?i+1:i+1,0);
    add(i,i==M?i+1:i+1,1<<i-1);
  }
  tot=M+1;
  work(1,1<<M,L-(1<<M));
  printf("%d %d\n",tot,q.size());
  for(int i=0;i<q.size();i++){
    int x=q[i].first.first;
    int y=q[i].first.second;
    int z=q[i].second;
    printf("%d %d %d\n",x,y,z);
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

string S;
int D[4002], P[4002], n[4002], press[4002];
pair<int, int> E[4002];
int H[4002];

void dfs(int A, int from, int head) {
	if (D[head]) return;
	int ret1 = 0;
	int ret2 = 0;
	int ret3 = 0;
	int saidai = 0;
	for (int i = H[A]; i; i = E[i].second) {
		if (E[i].first != from) {
			dfs(E[i].first, A, i);
			ret1 += P[i] + n[i];
			ret2 += n[i];
			saidai = max(saidai, 2 * (P[i] + n[i]) - 2 * press[i]);
		}
	}
	if (saidai - ret1 < 0) ret3 = ret1 / 2;
	else ret3 = ret1 - saidai / 2;
	if (S[A - 1] == '1') ret2++;

	D[head] = 1;
	P[head] = ret1;
	n[head] = ret2;
	press[head] = ret3;
}

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


	int N;
	cin >> N;
	cin >> S;

	for (int i = 1; i < 2 * N - 2; i += 2) {
		int a, b;
		cin >> a >> b;
		E[i] = mp(a, H[b]);
		H[b] = i;
		E[i + 1] = mp(b, H[a]);
		H[a] = i + 1;
	}

	bool OK = 0;
	int saishou = 1e9;
	rep1(j, N) {
		int p = 0;
		int Press = 0;
		int saidai = 0;
		for (int i = H[j]; i; i = E[i].second) {
			dfs(E[i].first, j, i);
			p += P[i] + n[i];
			saidai = max(saidai, 2 * (P[i] + n[i]) - 2 * press[i]);
		}
		if (saidai - p < 0) Press = p / 2;
		else Press = p - saidai / 2;

		if (p == Press * 2) {
			OK = 1;
			saishou = min(saishou, Press);
		}
	}

	if (OK) co(saishou);
	else co(-1);

	Would you please return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

#define INF 1000000001

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

long long count = 0;

int main(int argc, char const *argv[]) {

  int i;
  int num;
  scanf("%d",&num);
  int S[num];

  for( i = 0 ; i < num ; i++ ){
    scanf("%d",&S[i]);
  }

  mergeSort(S,0,num);

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

  return 0;
}

void merge(int *A, int left, int mid, int right){

  int n1,n2;
  int i,j,k;

  n1 = mid - left;
  n2 = right - mid;
  int L[n1+1],R[n2+1];

  for( i = 0 ; i < n1 ; i++ ){
    L[i] = A[left+i];
  }

  for( i = 0 ; i < n2 ; i++ ){

    R[i] = A[mid+i];
  }

  L[n1] = INF;
  R[n2] = INF;

  i = 0;
  j = 0;

  for( k = left ; k < right ; k++ ){

    if( L[i] <= R[j] ){
      A[k] = L[i];
      i++;
    }else{

      //printf("%d",n1-i);
      count += (n1-i);
      A[k] = R[j];
      j++;
    }
  }

}

void mergeSort(int *A, int left, int right){

  int mid;

  if( left+1 < right ){
    mid = (left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);

  }

}

Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  cin >> n >> k;
  int s=0;
  
  for (int i=0; i<n ;i++){
    int x;
    cin >> x;
    s+=min(x,k-x);
  }
  cout << s*2 << endl;
  
}
      
        


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  ll cntM = 0, cntA = 0, cntR = 0, cntC = 0, cntH = 0;
  rep(i,n) {
    string s;
    cin >> s;
    if (s[0] == 'M') cntM++;
    else if (s[0] == 'A') cntA++;
    else if (s[0] == 'R') cntR++;
    else if (s[0] == 'C') cntC++;
    else if (s[0] == 'H') cntH++;
  }
  auto f = [&](int idx) {
    if (idx == 0) return cntM;
    else if (idx == 1) return cntA;
    else if (idx == 2) return cntR;
    else if (idx == 3) return cntC;
    else return cntH;
  };
  ll ans = 0;
  for (int bit = 0; bit < (1<<5); ++bit) {
    if (__builtin_popcount(bit) != 3) continue;
    bool ok = true;
    ll res = 1;
    rep(i,5) {
      if (bit & (1<<i)) {
        if (f(i) > 0) res *= f(i); //人を選ぶ
        else {
          ok = false; break; //0人だったら不成立
        }
      }
    }
    if (ok) ans += res;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
int inf=1000000000;
ll INF=10000000000000000;

struct edge { ll from, to, cost;};
edge es [1000020];
ll d[400000];
int v,e;

void shortest_path(int s){
    for (int i=0;i<e;i++) d[i]=INF;
    d[s]=0;
    int o=0;
    while(true){
        o++;
        bool update=false;
        for (int i=0;i<e;i++){
            edge e=es[i];
            if (d[e.from]!=INF && d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
                update=true;
            }
        }
        if (!update) break;
        if (o>e+10) {
            for (int j=0;j<v+10;j++){
            for (int i=0;i<e;i++){
            edge e=es[i];
            if (d[e.from]!=INF && d[e.to]>d[e.from]+e.cost){
                d[e.to]=-INF;
                update=true;
            }
        }
            }
            break;
        }
    }
}

int main(){
    ll p;
    cin >> v >> e >> p;
    rep(i,e){
        cin >> es[i].from >> es[i].to >> es[i].cost;
        es[i].cost=p-es[i].cost;
    }
    shortest_path(1);
    if (d[v]==-INF) cout << -1 << endl;
    else if (d[v]<0) cout << d[v]*(-1) << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 2304
#include<iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
  int x,y;
  char op;

  while(true){
    cin >>x >>op >> y;
    if(op == '?') break;

    switch(op){
      case '+':
        cout << (x+y) << endl;
        break;
      case '-':
        cout << (x-y) << endl;
        break;
      case '*':
        cout << (x*y) << endl;
        break;
      case '/':
        cout << (x/y) << endl;
        break;
      default:
        break;
    }
  }

}



Measured memory_bytes: 3088
n, m = map(int, input().split())
lr = [tuple(map(int, input().split())) for _ in range(m)]
maxl = max(_[0] for _ in lr)
minr = min(_[1] for _ in lr)
if minr - maxl >= 0:
    answer = minr - maxl + 1
else:
    answer = 0
print(answer)

Measured memory_bytes: 16668
n = int(input())
h = list(map(int, input().split()))

dp = [0] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, n):

    h1 = dp[i - 1] + abs(h[i] - h[i - 1])
    dp[i] = h1

    h2 = dp[i - 2] + abs(h[i] - h[i - 2])
    dp[i] = h2 if h2 < dp[i] else dp[i]

print(dp[-1])

Measured memory_bytes: 13980
/*-------------------------------*
| Name: Ayush Kumar              |
| Site: atcoder                  |
| Email: ayushkr667@gmail.com    |
*-------------------------------*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define INF (ll) 1e18
const double PI = 3.141592653589793238460;
int n, m, t;
ll sum = 0;
vector<int>arr[100001];
int dp[100001][3];
int max(int a, int b, int c)
{
    return max(a, max(b, c));
}

ll solve()
{
    dp[1][0] = arr[1][0]; dp[1][1] = arr[1][1]; dp[1][2] = arr[1][2];
    for(int i=2; i <= n; i++)
    {
        dp[i][0] = max( dp[i][0], arr[i][0]+ max( dp[i-1][1] , dp[i-1][2] ));
        dp[i][1] = max( dp[i][1], arr[i][1]+ max( dp[i-1][0] , dp[i-1][2] ));
        dp[i][2] = max( dp[i][2], arr[i][2]+ max( dp[i-1][0] , dp[i-1][1] ));
    }
    return max(dp[n][0], dp[n][1], dp[n][2]);
}



int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for (int i = 1; i <= n; i++)
    {
        int a, b, c;
        cin>> a >> b >> c;
        arr[i].pb(a); arr[i].pb(b); arr[i].pb(c);
    }
    cout<<solve();
    return 0;
}


Measured memory_bytes: 10296
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pil pair<int,ll>
#define pii pair<int,int>
#define ull unsigned long long
#define base 1000000000000000000
#define fio ios::sync_with_stdio(false);cin.tie(0)

using namespace std;

const double g=10.0,eps=1e-12;
const int N=200000+10,maxn=200000+10,inf=0x3f3f3f3f;


int main()
{
    fio;
    string s;
    cin>>s;
    s[3]='8';
    cout<<s<<"\n";
    return 0;
}
/********************

********************/


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1; 
    for(int T = 0; T < t ; T++){
        ll n;
        cin >> n;
        std::cout << n*n*n + n*n + n << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
#define all(v) v.begin(),v.end()
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define what(x) cout<<#x<<" is "<<x<<endl;
using namespace std;


template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

ll powmod(ll a,ll b,ll mod) {
    ll res=1;a%=mod;
    //assert(b>=0);
    for(;b;b>>=1){
        if(b&1)res=res*a%mod;a=a*a%mod;
    }
    return res;
}

void solve(){
	ll n;
	cin>>n;
	debug(n);
	cout<<(1000-((n%1000==0)?1000:n%1000))<<endl;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tc=1;
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	#endif
	// cin>>tc;
    while(tc--)solve();
}


Measured memory_bytes: 3620
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入
		String s = sc.next();
		String year =s.substring(0,4);
		String month =s.substring(5,7);
		String day =s.substring(8,10);

		int iYear = new Integer(year).intValue();
		int iMonth = new Integer(month).intValue();
		int iDay = new Integer(day).intValue();
		    // System.out.println(iYear);
		    // System.out.println(iMonth);
		    // System.out.println(iDay);
 
		if(iYear>2020){
		    System.out.println("TBD");
		}else if (iYear<2018){
		    System.out.println("Heisei");
		}else{
			if(iMonth>=5){
			    System.out.println("TBD");
			}else if (iMonth<=3){
			    System.out.println("Heisei");
			}else{
				if(iDay>=31){
				    System.out.println("TBD");
				}else if (iMonth<=29){
				    System.out.println("Heisei");
				}else{
				    System.out.println("Heisei");
				}
			}
		}
	}
}


Measured memory_bytes: 23892
#include <algorithm>
#include <iostream>
#include <memory>
#include <vector>

int main()
{
    int a, b, c, d, e;
    int m, n;
    int i, j, k;

    std::cin >> a >> b;

    printf("%d\n", (b%a==0)? a+b : b-a);

    return 0;
}

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

int main() {
  string S;//define
  cin >> S;//insert
  
  if(S[0] == S[1])//if all same
    if(S[1] == S[2])
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  else
    cout << "Yes" << endl;
}
  
  
  

Measured memory_bytes: 256
#include<cstdio>
int a[110];
int main()
{
	int n,m,s=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),s+=a[i];
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		int p,x;
		scanf("%d%d",&p,&x);
		printf("%d\n",s-a[p]+x);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <climits>
#include <set>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ve vector
#define umap unordered_map
#define iter iterator

int a,b,c,d,e,f;
pair<int,int> dp[3001][3001];
bool vis[3001][3001];
pair<int,int> func(int w, int s) {
    if (w > f) return { 1,-1000 };
	if (vis[w][s]) return dp[w][s];
	vis[w][s] = 1;
 
	pair<int,int> temp{w,s};
	dp[w][s] = temp;
	double score = (double)(s) / w;
	if (w == 0) score = -1;
	temp = func(w + 100 * a, s);
	if (score < (double)(temp.second) / temp.first) {
		score = (double)(temp.second) / temp.first;
		dp[w][s] = temp;
	}
	temp = func(w + 100 * b, s);
	if (score < (double)(temp.second) / temp.first) {
		score = (double)(temp.second) / temp.first;
		dp[w][s] = temp;
	}
	if (s + c <= (w - s)*e/100)	{
		temp = func(w + c, s + c);
		if (score < (double)(temp.second) / temp.first) {
			score = (double)(temp.second) / temp.first;
			dp[w][s] = temp;
		}
	}
	if (s + d <= (w - s)*e / 100) {
		temp = func(w + d, s + d);
		if (score < (double)(temp.second) / temp.first) {
			score = (double)(temp.second) / temp.first;
			dp[w][s] = temp;
		}
	}
	return dp[w][s];
}

void solve() {
    cin>>a>>b>>c>>d>>e>>f;
    pair<int,int> res = func(0,0);
    cout<<res.first<<" "<<res.second<<endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 68096
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram{
    public class Program
    {	
        public static void Main(string[] args)
    	{
            int[] kaisuu = new int[26];
            string s = Console.ReadLine();
            
            for(int i = 0 ; i < s.Length ; i++)
            {
                int a = s[i] - 'a';
                kaisuu[a]++;
            }
            
            bool isGood = true;
            for(int i = 0 ; i < kaisuu.Length; i++)
            {
                if(kaisuu[i] % 2 == 1) isGood = false;
            }
            
            if(isGood) Console.WriteLine("Yes");
            else Console.WriteLine("No");
    	}
    }
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n, m; cin >> n >> m;

    //約数列挙
    vector<ll> divisor;
    //片方は必ず√以下になる
    for (ll i = 1; i * i <= m; ++i) {
        if (m % i == 0) {
            divisor.push_back(i);

            ll j = m / i;

            if (i != j) {
                divisor.push_back(j);
            }
        }
    }

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

    for (auto d : divisor) {
        if (d >= n) {
            cout << m / d << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

long long GCD(long long a, long long b){
  long long M = max(a, b);
  long long m = min(a, b);

  while (M % m != 0){
    long long deg = M % m;
    M = m;
    m = deg;
  }
  return m;
}

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

int main(){

  long long N, M; cin >> N >> M;
  string S, T; cin >> S >> T;

  long long L = LCM(N, M);
  map <long long, int> word;

  for (long long i = 0; i < N; i++){
    int a = S[i] - 'a' + 1;
    word[L / N * i] = a;
  }
  
  bool flag = true;
  for (long long i = 0; i < M; i++){
    int a = T[i] - 'a' + 1;
    if (word[L / M * i] != 0 && word[L / M * i] != a){
      flag = false;
      break;
    }
  }
  
  if (flag == true) cout << L << endl;
  else cout << -1 << endl;
  

  return 0;
}

Measured memory_bytes: 10880
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  long int K,i,j,k;
  long int r=0;
  long int g=0;
  long int b=0;
  long int ans=0;
  char S[4001];

  scanf("%ld",&K);
  scanf("%s",S);

  for(i=0;i<K;i++)
  {
    if(S[i]=='R')
    {
      r++;
    }
    if(S[i]=='G')
    {
      g++;
    }
    if(S[i]=='B')
    {
      b++;
    }
  }

  ans = r*g*b;

  for(i=0;i<K;i++)
  {
    for(j=i+1;j<K;j++)
    {
      k=2*j-i;
      if(k<K && S[i]!=S[j] && S[j]!=S[k] && S[k]!=S[i])
      {
        ans--;
      }
    }
  }

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

  return 0;
}


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

using namespace std;

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

	long long int res = 0;
  	int n;
  
	cin >> n;

	for(int i=1;i<=n;i++)
	{
		if(i%3!=0 && i%5!=0)
		{
			res += i;
		}
	}

	cout << res << '\n';
	
	return 0;
}


Measured memory_bytes: 3608