akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

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

int main() {
    string s;
    string t[5];
    cin>>s;
   // cout<<s<<endl;
    for(int i=0;i<=1;i++){
        int sum=s[0]-'0';
        if(i==0){
                    sum+=s[1]-'0';
                    t[0]='+';
                }
                else {
                    sum-=s[1]-'0';
                    t[0]='-';
                }
        for(int j=0;j<=1;j++){ 
            int sum1=sum;
            if(j==0){
                    sum1+=s[2]-'0';
                    t[1]='+';
                }
                else {
                    sum1-=s[2]-'0';
                    t[1]='-';
                }
            for(int k=0;k<=1;k++){
               int sum2=sum1;
                if(k==0){
                    sum2+=s[3]-'0';
                    t[2]='+';
                    if(sum2==7){
                cout<<s[0]<<t[0]<<s[1]<<t[1]<<s[2]<<t[2]<<s[3]<<"="<<7<<endl;
                return 0;
            }
                 }
                else{
                    sum2-=s[3]-'0';
                    t[2]='-';
                    if(sum2==7){
                cout<<s[0]<<t[0]<<s[1]<<t[1]<<s[2]<<t[2]<<s[3]<<"="<<7<<endl;
                return 0;
            }
                }
                
        }       //cout<<sum<<endl;
                
                
                }
        
    
    }
    
    return 0;
}

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

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    s = set(li())
    print('No') if len(s) == 1 else print('Yes')

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
#define LL long long
#define MX 100010

int n;
int total;
vector<int> G[MX];
int colr[MX];

void DFS(int x,int pre,int c)
{
    if (colr[x]==-c) return;
    total++;
    for (int i=0;i<G[x].size();i++)
        if (G[x][i]!=pre)
            DFS(G[x][i],x,c);
}


void dfs(int u,int pre,int s,int &ok)
{
    if (u==n)
    {
        ok=s;
        return;
    }
    for (int i=0;i<G[u].size();i++)
    {
        if (ok)
        {
            if (u!=1&&s<=ok/2)
                colr[u]=1;
            if (u!=n&&s>ok/2)
                colr[u]=-1;
            return;
        }
        if (G[u][i]!=pre)
            dfs(G[u][i],u,s+1,ok);
    }
    if (ok)
    {
        if (u!=1&&s<=ok/2)
                colr[u]=1;
        if (u!=n&&s>ok/2)
                colr[u]=-1;
    }
    return;
}

int main()
{
    scanf("%d",&n);
    for (int i=1;i<n;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    colr[1]=1; //hei
    colr[n]=-1;//bai

    int ok=0;
    dfs(1,-10,0,ok);
/*
    for (int i=1;i<=n;i++)
        printf("%d ",colr[i]);
    printf("\n");
*/

    total=0;
    DFS(1,-10,1);
    int xxx = total;
    total=0;
    DFS(n,-10,-1);
    if (xxx-total>=1)
        printf("Fennec\n");
    else
        printf("Snuke\n");
    return 0;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
const ll INF=1e9+1;
using namespace std;
#define NOT_EXIST -1

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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> c(m);
	for(int i=0;i<m;i++){
		cin >>c[i];
	}
	sort(All(c));
	//dp[i]: i円のときのコスト
	vector<int> dp(n+1,INF);
	dp[0] = 0;

	for(int i=0;i<=n;i++){
		for(int j=0;j<m;j++){
			int key = c[j];
			if(i-key>=0) dp[i] = min(dp[i], dp[i-key]+1);
			//cout << "dp[" << i+c[j] << "] = " << dp[ i+c[j] ] << endl;
		}
	}

	cout << dp[n] << endl;
}


Measured memory_bytes: 3172
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <set>
#include <limits.h>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define rip(i,n,s) for (int i=(s);i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> da(n);
    int x;
    rip(i,n,0){
        cin >> x;
        da[x-1]=i;
    }
    set<int> se;
    se.insert(-1);
    se.insert(n);
    long long ans=0;
    rip(i,n,0){
        auto itr=se.upper_bound(da[i]);
        ans+=(ll)(*itr-da[i])*(da[i]-*--itr)*(ll)(i+1);
        se.insert(da[i]);
    }
    printf("%lld\n",ans);
}

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


int main() {    
    int a, b, c;
    cin >> a >> b >> c;
    if( a%2 == 0 && a == b && b == c) cout << -1 << ln;
    else{
        int cnt = 0;
        while(1){
            if(a%2==1 || b%2==1 || c%2==1) break;
            int a_ = a/2, b_ = b/2, c_ = c/2;
            a = b_+c_;
            b = a_+c_;
            c = a_+b_;
            cnt++;
        }
        cout << cnt << ln;
    }
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.Maybe (fromJust)
import Data.List
import Data.Array.Unboxed
import Data.Array.ST
import qualified Data.Set as S

ary :: [Int] -> UArray Int Int
ary xs = runSTUArray $ do
    let gs = group xs
        zs = zip (map head gs) (map length gs)
    a <- newArray (head xs, last xs + 2) 0
    forM_ zs $ \(i,n) -> do
        x <- readArray a i
        writeArray a i (x+n)
    return a

solve :: UArray Int Int -> [Int] -> Int
solve a = foldr f 0
  where
    f x mx = let mx' = (a!x) + (a!(x+1)) + (a!(x+2))
              in max mx mx'

fastnub :: [Int] -> [Int]
fastnub = S.toList . S.fromList

main :: IO ()
main = do
    _ <- getLine
    a <- sort . map (fst . fromJust . BS.readInt)
        . BS.words <$> BS.getLine :: IO [Int]
    print $ solve (ary a) (fastnub a)


Measured memory_bytes: 23932
#!/usr/bin/env python
# coding: utf-8

# In[1]:


N = int(input())
Ws = list(map(int, input().split()))
"""
4
1 3 1 1
"""


# In[3]:


s1 = 0
s2 = sum(Ws)
diff_min = float('inf')
for i in range(N):
    s1 += Ws[i]
    s2 -= Ws[i]
    diff_min = min(abs(s2-s1), diff_min)
    
print(diff_min)


# In[ ]:






Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

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

    vector<int> numR, numG, numB;
    int totalR(0), totalG(0), totalB(0);

    int r(0), g(0), b(0);
    for(int i=0;i<N;++i){
        switch(S[i]){
        case 'R':
            ++r;
            break;
        case 'G':
            ++g;
            break;
        case 'B':
            ++b;
            break;
        }
        numR.push_back(r);
        numG.push_back(g);
        numB.push_back(b);       
    }
    totalR = r;
    totalG = g;
    totalB = b;
    
    long long ans(0);

    for(int i=0;i<N;++i){
        for(int j=i+1;j<N;++j){
            if(S[i] == S[j]) continue;
            if( (S[i] == 'R' and  S[j] == 'G') or (S[i] == 'G' and  S[j] == 'R') ){
                ans += (totalB - numB[j]);
                if( 2*j-i < N ){
                    if( S[2*j-i] == 'B') --ans;
                }
            }else if( (S[i] == 'G' and  S[j] == 'B') or (S[i] == 'B' and  S[j] == 'G') ){
                ans += (totalR - numR[j]);
                if( 2*j-i < N ){
                    if( S[2*j-i] == 'R') --ans;
                }
            }else if( (S[i] == 'B' and  S[j] == 'R') or (S[i] == 'R' and  S[j] == 'B') ){
                ans += (totalG - numG[j]);
                if( 2*j-i < N ){
                    if( S[2*j-i] == 'G') --ans;
                }
            }
        }
    }
        
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3704
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	s := sc.NextLine()

	cntA := 0
	cntB := 0
	for i, c := range s {
		if i%2 == 0 {
			if string([]rune{c}) == "0" {
				cntA++
			}
		}
		if i%2 == 1 {
			if string([]rune{c}) == "1" {
				cntA++
			}
		}
		if i%2 == 0 {
			if string([]rune{c}) == "1" {
				cntB++
			}
		}
		if i%2 == 1 {
			if string([]rune{c}) == "0" {
				cntB++
			}
		}
	}
	if cntA < cntB {
		fmt.Printf("%+v\n", cntA) // output for debug
	} else {
		fmt.Printf("%+v\n", cntB) // output for debug
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1280
line = $stdin.gets.split.map{|v| v.to_i }
r = line[0]
D = line[1]
x2k = line[2]

puts x2k1 = r * x2k - D
puts x2k2 = r * x2k1 - D
puts x2k3 = r * x2k2 - D
puts x2k4 = r * x2k3 - D
puts x2k5 = r * x2k4 - D
puts x2k6 = r * x2k5 - D
puts x2k7 = r * x2k6 - D
puts x2k8 = r * x2k7 - D
puts x2k9 = r * x2k8 - D
puts r * x2k9 - D


Measured memory_bytes: 1788
#include <iostream>

int main()
{
    int x;
    scanf("%d", &x);

    if (1800 <= x)
        printf("1");
    else if (1600 <= x)
        printf("2");
    else if (1400 <= x)
        printf("3");
    else if (1200 <= x)
        printf("4");
    else if (1000 <= x)
        printf("5");
    else if (800 <= x)
        printf("6");
    else if (600 <= x)
        printf("7");
    else if (400 <= x)
        printf("8");
}

Measured memory_bytes: 3756
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] light = new int[m][n];
		int k, s;
		for (int i = 0; i < m; i++) {
			k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				s = sc.nextInt() - 1;
				light[i][s]++;
			}
		}
		int[] p = new int[m];
		for (int i = 0; i < m; i++) {
			p[i] = sc.nextInt();
		}
		int t, d, idx, cnt, ans = 0;
		int[] sw;
		boolean ok;
		for (int i = 0; i < Math.pow(2, n); i++) {
			t = i;
			d = 512;
			idx = 9;
			sw = new int[n];
			while (t != 0) {
				if (t >= d) {
					t = t - d;
					sw[idx]++;
				}
				d = d / 2;
				idx--;
			}
			ok = true;
			for (int j = 0; j < m; j++) {
				cnt = 0;
				for (int l = 0; l < n; l++) {
					if (sw[l] == light[j][l] && sw[l] == 1) {
						cnt++;
					}
				}
				if (cnt % 2 == p[j]) {

				} else {
					ok = false;
					break;
				}
			}
			if (ok) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    ll n, x;
    cin >> n >> x;
    ll a;
    ll GCD=0;
    rep(i, n)
    {
        cin >> a;
        if(GCD == 0){
            GCD = abs(a - x);
            continue;
        }
        GCD = __gcd(GCD, abs(a - x));
    }
    cout << GCD << endl;
    return 0;
}

Measured memory_bytes: 3660
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    val (t, a) = listOfDouble()
    val hh = listOfDouble()

    var num = 1
    var min = Double.MAX_VALUE

    hh.forEachIndexed { index, fl ->
        val diff = Math.abs((t - fl * 0.006) - a)
        if (diff < min) {
            num = index + 1
            min = diff
        }
    }

    println(num)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfDouble() = listOfString().map { it.toDouble() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 35976
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
int main(){
    ll N; cin >> N;
    if (N == 1){
        cout << 0 << endl;
        return 0;
    }
    cout << N*(N-1)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main(){
  ll n, t, s, prev, ans = 0;
  cin >> n >> t;
  cin >> prev;
  ans = t;
  for(int i = 1; i < n; i++){
    cin >> s;
    ans += min(t, s - prev);
    prev = s;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,x=map(int,input().split())
a=[int(i) for i in input().split()]
ans=0
if a[0] > x:
    ans += a[0]-x
    a[0] = x
for i in range(n-1):
    if a[i] + a[i+1] > x:
        temp = a[i] + a[i+1] - x
        ans += temp
        a[i+1] -= temp
print(ans)

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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int solve(vvi a)
{
	int n=a.size();
	rep(i,n){
		repi(j,i,n) if(a[j][i]==1){
			swap(a[i],a[j]);
			break;
		}
		if(a[i][i]==0) continue;
		rep(j,n) if(j!=i && a[j][i]==1)
			repi(k,i,n+1) a[j][k]^=a[i][k];
	}
	rep(i,n) if(a[i][i]==0 && a[i][n]==1) return 0;
	return 1;
}

int main()
{
	for(int n,m,d;cin>>n>>m>>d && n|m|d;){
		vvi a(m*n,vi(m*n+1));
		rep(i,m) rep(j,n){
			a[i*n+j][i*n+j]=1;
			rep(k,m) rep(l,n)
				if(abs(k-i)+abs(l-j)==d)
					a[k*n+l][i*n+j]=1;
			cin>>a[i*n+j][m*n];
		}
		cout<<solve(a)<<endl;
	}
}

Measured memory_bytes: 4240
import sys
import numpy as np

a = np.array(sys.stdin.read().split(), dtype=np.int64)[1:].reshape(2, -1)

def main():
    np.cumsum(a[0], out=a[0])
    np.cumsum(a[1, ::-1], out=a[1, ::-1])
    print(np.amax(a.sum(axis=0)))

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 12480
import java.util.Scanner;

public class Main{
		
	public static void main(String args[]){
		  
	    Scanner sc = new Scanner(System.in);
	    
	    String a = sc.next();
	    String b = sc.next();
	    String c = sc.next();
	    
	    System.out.println("A" + b.charAt(0) + "C");
	    
	}
}

Measured memory_bytes: 22612
#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;

int main() {
    int n, k;
    long long a[200000];
    int start = 0;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (a[i] < 0)
            start = i;
    }
    start++;
    long long min = LONG_LONG_MAX;
    for (int i = 1; i <= n; i++) {
        long long p;
        if (i < start) {
            if ((start - i < k )&& ((n - i + 1) >= k)) {
                p = 2 * abs(a[i]) + abs(a[k + i - 1]);
                if (min > p)
                min = p;
            }
            else if (start - i == k) {
                p = abs(a[i]);
                if (min > p)
                    min = p;
            }
        }
        else {
            if (i - start + 1 < k && i >= k) {
                p = 2 * abs(a[i]) + abs(a[i - k + 1]);
                if (min > p)
                min = p;
            }
            else if (i - start + 1 == k){
                p = abs(a[i]);
                if (min > p)
                    min = p;
            }
        }


    }
    cout << min;
    return 0;
}


Measured memory_bytes: 1024
N,A,B = map(int,input().split())
cnt = 0

for i in range(1,N+1):
  d_num = i
  s_sum = 0
  while d_num > 0:
    s_sum += (d_num % 10)
    d_num //= 10
  
  if A <= s_sum <=  B:
    cnt += i

print(cnt)


Measured memory_bytes: 9064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h,w,n,a[10005],map[105][105];
	cin>>h>>w;
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	int ans=0;
	for(int i=0;i<h;i++)
	if(i%2)
	{
		for(int j=0;j<w;j++)
		{
			if(a[ans])
			{
				a[ans]--;
				map[i][j]=ans+1;
			}
			else
			{
				ans++;
				map[i][j]=ans+1;
				a[ans]--;
			}
		}
	}
	else
	{
		for(int j=w-1;j>=0;j--)
		{
			if(a[ans])
			{
				a[ans]--;
				map[i][j]=ans+1;
			}
			else
			{
				ans++;
				map[i][j]=ans+1;
				a[ans]--;
			}
		}
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(j==w-1) cout<<map[i][j]<<endl;
			else cout<<map[i][j]<<' ';
		}
	}
	return 0;
}

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if (a==b && a!=c) cout<<"Yes";
    else if (a==c && a!=b) cout<<"Yes";
    else if (b==c && b!=a) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <ctype.h>
using namespace std;

typedef long long ll;

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

int m[1010];

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int left, right;
  left = a + b;
  right = c + d;
  if (left == right) cout << "Balanced" << endl;
  else if (left > right) cout << "Left" << endl;
  else cout << "Right" << endl;
  return 0;
}


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

int main(){
    int n;
    while(cin >> n && n){
        printf("3C%02d\n", (n % 39!=0) ? n % 39 : 39);
    }
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

struct Data {
  int start,end,onAir,recorded;
  bool operator < ( const Data &data ) const {
    if( end != data.end ) return end < data.end;
    if( start != data.start ) return start < data.start;
    return ( onAir != data.onAir ) ? onAir < data.onAir : recorded < data.recorded;
  }
};

const int MAX_N = 1100;
const int IINF = INT_MAX;
int N,s[MAX_N],t[MAX_N],score[MAX_N][2],dp[2000][2000];
vector<int> buf;

int toTime(string s){
  rep(i,(int)s.size()) if( s[i] == ':' ) s[i] = ' ';
  stringstream ss;
  ss << s;
  int h,m;
  ss >> h >> m;
  return h * 60 + m;
}

int main(){
  while( cin >> N, N ){
    vector<Data> vec;
    rep(i,N) {
      string a,b,c;
      cin >> a >> b >> c >> score[i][0] >> score[i][1];
      assert( b != c );
      s[i] = toTime(b), t[i] = toTime(c);
      vec.push_back((Data){s[i],t[i],score[i][0],score[i][1]});
    }
    vec.push_back((Data){0,0,0,0});
    vec.push_back((Data){IINF,IINF,0,0});
    rep(i,N+2) rep(j,N+2) dp[i][j] = 0; 
    sort(vec.begin(),vec.end());
    buf.clear();
    int maxi = 0;
    rep(i,vec.size()) buf.push_back(vec[i].end);
    rep(i,vec.size()){
      rep(j,vec.size()){
        if( i == j ) {
          dp[i][j] = max((i?dp[i-1][j]:0),(j?dp[i][j-1]:0));
        } else if( i < j ) {
          dp[i][j] = dp[i][j-1];
          int prev = upper_bound(buf.begin(),buf.begin()+j,vec[j].start) - buf.begin() - 1;
          dp[i][j] = max(dp[i][j],((prev!=-1)?dp[i][prev]:0)+vec[j].recorded);
        } else {
          dp[i][j] = dp[i-1][j];
          int prev = upper_bound(buf.begin(),buf.begin()+i,vec[i].start) - buf.begin() - 1;
          dp[i][j] = max(dp[i][j],((prev!=-1)?dp[prev][j]:0)+vec[i].onAir);
        }
        maxi = max(maxi,dp[i][j]);
      }
    }
    cout << maxi << endl;
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<string> W(N);
  for (int i = 0; i < N; i++) {
    cin >> W[i];
  }

  string ans = "Yes";

  // new word check
  for (int i = 0; i < N; i++)
  {
    if (ans == "No") break;
    for (int j = 0; j < i - 1; j++)
    {
      if (W[i] == W[j]) {
        ans = "No";
        break;
      }
    }
  }

  // next word check
  for (int i = 1; i < N; i++)
  {
    if (ans == "No") break;

    if(W[i-1][W[i-1].size()-1] != W[i][0]) {
      ans = "No";
    }
  }
  
  
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535;

int main()
{
    int n;
    int h[100000];
    cin >> n;
    rep(i, n) cin >> h[i];

    for (int i = n - 1; i > 1; i--) {
        if (h[i - 1] <= h[i]) {
            continue;
        }
        else if (h[i - 1] == h[i] + 1) {
            h[i - 1]--;
        }
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MAX5 100010
#define MAX6 1000010
#define pb push_back
#define mp make_pair
typedef long long int ll;
int main()
{
    ll n,arr[MAX5];
    cin>>n;
    for(ll i=1;i<=n;i++)
        cin>>arr[i];
    ll dp[MAX5];
    arr[0]=INT_MAX;
    dp[0]=INT_MAX;dp[1]=0;
    for(ll i=2;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n]<<'\n';
return 0;
}

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

using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;


int32_t main() {
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    
    
    ins(n);
    int one = 0;
    FOR(i,0,3){
        if(n[i]-'0' == 7)
            one = 1;
    }
    if(one)out("Yes");
    else out("No");
    
  
    
    
    
    
    
    
    
    return 0;
}


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

#define SPEED cin.tie(0);ios::sync_with_stdio(false);
template <class T> void chmax(T& a, const T b){a=max(a,b);}

int main() {
    SPEED
    int N; cin >> N;
    vector<int> V(N+1),W(N+1);
    for(int i = 1; i <= N; ++i) cin >> V[i] >> W[i];

    //O(Q)
    constexpr int nl = 1<<10,nr=1<<8,L_max=100001;
    array<int,nl> msb;
    for(int i = 1; i < nl; ++i) msb[i]=31-__builtin_clz(i);

    array<int,nl> bit_w_dp;
    array<int,nl> bit_v_dp;
    vector<vector<int>> dp(nl,vector<int>(L_max,0));
    //前計算
    int m = min(nl,N+1);
    for(int n = 1; n < m; ++n) {
        int k = 2*n;
        vector<int> l;
        while(k/=2) l.push_back(k);
        int sz=l.size();
        //bit全探索
        for(int i = 1; i < (1<<sz); ++i) {
            bit_w_dp[i]=bit_w_dp[i^(1<<msb[i])]+W[l[msb[i]]];
            bit_v_dp[i]=bit_v_dp[i^(1<<msb[i])]+V[l[msb[i]]];
            if(bit_w_dp[i]<=L_max) chmax(dp[n][bit_w_dp[i]],bit_v_dp[i]);
        }
        //累積max
        for(int i = 1; i < L_max; ++i) {
            chmax(dp[n][i],dp[n][i-1]);
        }
    }

    int Q; cin >> Q;
    string ans_str="";

    //クエリ
    while(Q--) {
        int p,L,l_idx=0;; cin >> p >> L;
        vector<int> r;
        p *= 2;
        while(p/=2) {
            if(p<nl) chmax(l_idx,p);
            else r.push_back(p);
        }
        int sz = r.size(),ans=dp[l_idx][L];
        //bit全探索
        for(int i = 1; i < (1<<sz); ++i) {
            bit_w_dp[i]=bit_w_dp[i^(1<<msb[i])]+W[r[msb[i]]];
            bit_v_dp[i]=bit_v_dp[i^(1<<msb[i])]+V[r[msb[i]]];
            if(bit_w_dp[i]<=L) chmax(ans,dp[l_idx][L - bit_w_dp[i]]+bit_v_dp[i]);
        }
        ans_str += to_string(ans)+"\n";
    }
    cout << ans_str;

    return 0;
}


Measured memory_bytes: 408256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){
  long double x1,x2,y1,y2;
  
  cin >> x1 >> y1 >> x2 >> y2;
  cout << fixed << setprecision(5) << sqrt( (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1) ) << endl;
  return 0;
}

Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n,k;cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    ll dp[n];dp[0]=0;
    for(int i=1;i<n;i++){
        dp[i]=INF;
        for(int j=max(0ll,i-k);j<i;j++)
        dp[i]=min(dp[j]+abs(arr[i]-arr[j]),dp[i]);
    }
    cout<<dp[n-1]<<"\n";
}


Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,h,m,tan,tyo,sa,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)	{
		scanf("%d:%d",&h,&m);
		tan=h*300+m*5;
		tyo=m*60;
		sa=tan-tyo;
		if(sa<0)	sa=-sa;
		if(sa>1800)	sa=3600-sa;
		if(sa<300)	printf("alert\n");
		else if(sa>=900)	printf("safe\n");
		else printf("warning\n");
	}
	return 0;
}


Measured memory_bytes: 1008
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//????????¢??°????????????MAX???
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]>N[H[b]]?1:0;
}
//?????\??¢??°
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//??????????????¢??°
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,a[1010],b[1010],r[1010],s=0,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&a[i],&b[i]);
    for(j=i;j&&b[r[j-1]]>b[i];j--)r[j]=r[j-1];
    r[j]=i;
  }
  for(i=0;i<n;i++){
    s+=a[r[i]];
    hin(a[r[i]]);
    while(s>b[r[i]])s-=N[hout()];
  }
  printf("%d\n",C-1);
  return 0;
}

Measured memory_bytes: 2656
def main():
    N, T = map(int, input().split())
    min_c = float('inf')
    for i in range(N):
        c, t = map(int, input().split())
        if t <= T:
            min_c = min(min_c, c)

    if min_c == float('inf'):
        return "TLE"
    return min_c

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

Measured memory_bytes: 3060
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=998244353;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=1e6+5;
int fac[N],ifac[N],n,m,res;
inline int C(R int n,R int m){return m>n?0:1ll*fac[n]*ifac[m]%P*ifac[n-m]%P;}
inline int calc(R int n,R int m){return C(n+m,n);}
inline void init(int n=1e6){
	fac[0]=ifac[0]=1;fp(i,1,n)fac[i]=mul(fac[i-1],i);
	ifac[n]=ksm(fac[n],P-2);fd(i,n-1,1)ifac[i]=mul(ifac[i+1],i+1);
}
int main(){
	init();
	scanf("%d%d",&n,&m);
	fp(i,1,min(n,m))upd(res,mul(calc(i,i),calc(n-i,m-i)));
	res=mul(res,ksm(mul(calc(n,m),2),P-2));
	upd(res,max(n,m));
	printf("%d\n",res);
	return 0;
}

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

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();

        out.println((n + 1) / 2);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

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

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

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

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

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

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ll long long
#define pb push_back
#define PII pair<int,int>
#define X first
#define Y second
#define MP make_pair
#define PI acos(-1.0)
#define eps 1e-8
const int maxn=5e3+10;
const int mod=1e9+7;
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s[s.length()-1]=='s')
        s+="es";
    else
        s+="s";

    cout<<s<<endl;

    return 0;
}


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

const int maxn = 1e5 + 5;
string s[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    int ans = 0;
    int x = 0, y = 0, z = 0;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        for (int j = 0; j + 1 < (int)s[i].size(); ++j) {
            if (s[i][j] == 'A' && s[i][j + 1] == 'B')
                ++ans;
        }

        if (s[i].back() == 'A' && s[i][0] == 'B') x++;
        else if (s[i].back() == 'A') y++;
        else if (s[i][0] == 'B') z++;
    }

    int d = max(0, min(y - 1, z - 1));
    ans += d;
    y -= d;
    z -= d;

    int c = (y > 0) + (z > 0);
    if (c == 2)
        ans += x + 1;
    else if (c == 1)
        ans += x;
    else if (x > 0)
        ans += x - 1;


    cout << ans << endl;
}


Measured memory_bytes: 1536
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    int N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> ma;
    rep(i, N) {
        cin >> A[i];
        ma[i - A[i]]++;
    }

    ll ans = 0;
    rep(i, N) { ans += ma[A[i] + i]; }

    cout << ans << endl;
}

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

int main()
{
  int D;
  while(cin>>D)
  {
    if(D==25) cout<<"Christmas"<<endl;
    else if(D==24) cout<<"Christmas Eve"<<endl;
    else if(D==23) cout<<"Christmas Eve Eve"<<endl;
    else cout<<"Christmas Eve Eve Eve"<<endl;
  }
  
  return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  map<int,int> mp;
  int n,k;
  cin>>n>>k;
  rep(i,n) {
    int a;
    cin>>a;
    mp[a]++;
  }
  vector<int> As;
  for(auto& x : mp) {
    As.push_back(x.second);
  }
  sort(As.begin(),As.end());
  int ans=0;
  rep(i,(int)As.size()-k) {
    ans+=As[i];
  }
  cout << ans << endl;
  return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  map<ll,ll> m;
  rep(i,n){
    ll a; cin>>a;
    m[a]++;
  }
  ll ans=0;
  for(auto e: m){
    ans+=e.second-1;
  }
  if(ans%2==0) ans=n-ans;
  else ans=n-ans-1;
  cout<<ans<<endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
int main()
{
    int N,M,X;
    cin >> N >> M >> X;
    vector< vector<int> > A(N, vector<int>(M));
    vector<int> C(N);
    for (int i=0; i<N; i++) {
        cin >> C[i];
        for (int j=0; j<M; j++)
            cin >> A[i][j];
    }
    int ans = 100000 * N + 1;
    for (int bit = 0; bit < (1 << N); ++bit) {
        vector <int> sumA(M,0);
        vector <int> judge(M,0);
        int cost=0;
        for (int i=0; i<N; i++) {
            if (bit & (1<<i) ) {
                cost += C[i];
                for (int j=0; j<M; j++){ 
                    sumA[j] += A[i][j];
                    judge[j] = int (sumA[j] >= X);
                }
            }
        }
        if (accumulate(judge.begin(), judge.end(), 0) == M) 
            ans = min(cost,ans);
    }
    
    if (ans == 100000 * N + 1) ans = -1;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3632
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	LL sum = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	sum /= 2;
	for (int i = 1; i < n; i += 2)
	{
		sum -= a[i];
	}
	a[n] = sum;
	for (int i = n - 1; i > 0; i--)
	{
		a[i] -= a[i + 1];
	}
	for (int i = 1; i <= n; i++)
		printf("%d%c", a[i] * 2, " \n"[i == n]);
	return 0;
}

Measured memory_bytes: 1664
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    if(s.equals("SUN")) System.out.println(7);
    if(s.equals("MON")) System.out.println(6);
    if(s.equals("TUE")) System.out.println(5);
    if(s.equals("WED")) System.out.println(4);
    if(s.equals("THU")) System.out.println(3);
    if(s.equals("FRI")) System.out.println(2);
    if(s.equals("SAT")) System.out.println(1);
  }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll X;
  cin >> X;

  rep2(A, -200, 201){
    rep2(B, -200, 201){
      if((ll)pow(A, 5) - (ll)pow(B, 5) == X){
	cout << A << ' ' << B << endl;
	return 0;
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 4100
import math
x = int(input())
i = 1

def expo(x,i):
    while x % i == 0:
        x = x//i
    if x == 1:
        return True
    else:
        return False

if x > 4:
    while x >1:
        for j in range(2,int(math.sqrt(x))+1):
            if expo(x, j) == True:
                print(x)
                break
        if expo(x,j) == True:
            break
        else:
            x -= 1
else:
    print(1)
    

Measured memory_bytes: 9120
from collections import defaultdict

n = int(input())
A = list(map(int, input().split()))

D = defaultdict(lambda: 0)
for a in A:
    D[a] += 1

if n % 2 == 0:
    for a in range(1, n, 2):
        if D[a] != 2:
            print(0)
            exit()
else:
    if D[0] != 1:
        print(0)
        exit()
    for a in range(2, n, 2):
        if D[a] != 2:
            print(0)
            exit()

print(2 ** (n // 2) % (10 ** 9 + 7))


Measured memory_bytes: 14820
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
    string h;
    cin>>h;
    for(int i=0;i<h.size();i++){
    if(h[i]=='A'){
        h[i]='X';
    }
    else if(h[i]=='B'){
        h[i]='Y';
    }
    else if(h[i]=='C'){
        h[i]='Z';
    }
    else{
       h[i]=h[i]-3;
    }
    }
    for(int i=0;i<h.size();i++){
        cout<<h[i];
    }
    cout<<endl;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x, n;
    cin >> x >> n;
    vector<int> p(n), q;
    REP(i,n){
        cin >> p[i];
    }
    for (int i = -100; i <=110; i++)
    {
        bool ok = true;
        for (int j = 0; j < n; j++)
        {
            if(p[j]==i){
                ok = false;
                break;
            }
        }
        if(ok){
            q.push_back(i);
        }
    }
    int ans = INF;
    int num = INF;
    sort(ALL(q));
    for (int i = 0; i < q.size(); i++)
    {
        if(abs(q[i]-x) <ans){
            ans = abs(q[i] - x);
            num = q[i];
        }
    }
    cout << num << endl;
    


    return 0;
}

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

using namespace std;

int main()
{
    ios_base :: sync_with_stdio(false);
    int N, K;
    cin >> N >> K;

    int gc = 0;
    int maxim = 0;
    while (N --) {
        int val;
        cin >> val;
        gc = __gcd(val, gc);
        maxim = max(maxim, val);
    }

    if (K % gc == 0 && K <= maxim)
        cout << "POSSIBLE\n";
    else
        cout << "IMPOSSIBLE\n";
    return 0;
}


Measured memory_bytes: 256