akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void) {
    int s[3]={0};
    char ss[4];
    scanf("%s", ss);
    s[ss[0]-'a']++;
    s[ss[1]-'a']++;
    s[ss[2]-'a']++;
    
    if(s[0]==1 && s[1]==1 && s[2]==1) printf("Yes");
    else printf("No");
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
const int mxn = 2000;
ll binpow(ll a, ll b, ll mod = 2e18){
	ll ans = 1;
	while(b){
		if(b&1) ans*=a;
		a*=a;
		ans%=mod;
		a%=mod;
		b/=2;
	}
	return ans;
}
ll fact[mxn + 1];
void calcfac(ll n, ll mod = 2e18){
	fact[0]  = 1;
	for(int i = 1; i<=n;++i){
		fact[i] = fact[i-1]*i;
		fact[i] %= mod;
	}
}
 
ll nCr(ll p, ll q, ll mod = 2e18){
	ll val = fact[p];
	ll invfact = fact[q]*fact[p-q];
	val%=mod;
	invfact%=mod;
	val*=binpow(invfact, mod - 2, mod);
	val += mod;
	return val%mod;
}
 
 
ll nPr(ll p, ll q, ll mod = 2e18){
	ll val = nCr(p, q, mod);
	val*=fact[q];
	val%=mod;
	return val;
}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, b, r;cin>>n>>b;
	r = n - b;
	ll mod = 1e9 + 7;
	calcfac(mxn, mod);
	for(int i = 1; i <=b;++i){
		if(r + 1 < i){
			cout<<0<<endl;
			continue;
		}
		cout<<(nCr(r+1, i, mod)*nCr(b-1, i - 1, mod))%mod<<endl;
	}
	return 0;
}

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

int main(){
	int n,cnt=0;
	cin >> n;
	vector <int> s(n);
	for(int i=0; i < n; i++){
		cin >> s[i];
		if((i+1) % 2 == 1 && s[i] % 2 == 1)
			cnt++;
	} 
	cout << cnt <<endl;
}

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

ans = 9999999999

for i in range(2 ** N):
    ans_tmp = 1
    for b in format(i, "0%db" %N):
        if b == "0":
            ans_tmp *= 2
        else:
            ans_tmp += K
    ans = min(ans, ans_tmp)
    
print(ans)

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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    int c = 0;
    for(int i = 1;;i++){
        c += A;
        if(i % 7 == 0) c += B;
        if(c >= C){
            cout << i << endl;
            break;
        }
    }
    return 0;
}



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

int main() {
	int N;
	while (cin >> N) {
		if (N == 0) return 0;
		int A[5000] = {}, DP[5010][2] = {}, MAX = -1000000;
		for (int i = 0; i < N; i++) cin >> A[i], MAX = max(MAX, A[i]);
		for (int i = 0; i < N; i++) {
			DP[i + 1][1] = max(DP[i][1] + A[i], DP[i + 1][1]);
			DP[i + 1][1] = max(A[i], DP[i + 1][1]);
			DP[i + 1][0] = max(DP[i][0], DP[i + 1][1]);
		}
		if (DP[N][0] != 0) cout << DP[N][0] << endl;
		else cout << MAX << endl;
	}
}


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long n, a, b; cin >> n >> a >> b;
	if (a % 2 == b % 2) 
		cout << (b - a) / 2 << '\n';
	else
		cout << min(a - 1, n - b) + (b - a + 1) / 2 << '\n';
	return 0;
}

Measured memory_bytes: 256
Public Class Program
  Shared Sub Main()
    Dim s As String = Console.ReadLine()
    Dim ans As String = ""
    Select Case s
      Case "Sunny": ans = "Cloudy"
      Case "Cloudy": ans = "Rainy"
      Case "Rainy": ans = "Sunny"
    End Select
    Console.WriteLine(ans)
  End Sub
End Class

Measured memory_bytes: 19792
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int A,B;

int main(){
	scanf("%d%d" , &A , &B);
	if(A == 1) A += 13;
	if(B == 1) B += 13;
	if(A>B){
		printf("Alice\n");
	} else if(B>A){
		printf("Bob\n");
	} else {
		printf("Draw\n");
	}
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;

namespace AtCoder.Abcdef
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            //Input int array
            int[] inputArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int d = inputArray[0], t = inputArray[1], s = inputArray[2];

            if((double)d/s <= t) Console.WriteLine("Yes");
            else Console.WriteLine("No");

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28224
import heapq
N = int(input())
node = [[] for _ in range(N)]
for _ in range(N-1):
  a,b,c = map(int,input().split())
  node[a-1].append([c,b-1])
  node[b-1].append([c,a-1])
Q,K = map(int,input().split())

flag = [True]*N
ques = [[0,K-1]]
D = [0]*N
while ques:
  d1,l1 = heapq.heappop(ques)
  if flag[l1]:
    flag[l1]=False
    D[l1] = d1
    for d2,l2 in node[l1]:
      if flag[l2]:
        heapq.heappush(ques,[d1+d2,l2])
for _ in range(Q):
  x,y = map(int,input().split())
  print(D[x-1]+D[y-1])
        


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

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    int j[4] = {0};
    for(int i = 0; i < n; ++i){
        cin >> s[i];
        if("AC" == s[i]){
            ++j[0];
        }
        if("WA" == s[i]){
            ++j[1];
        }
        if("TLE" == s[i]){
            ++j[2];
        }
        if("RE" == s[i]){
            ++j[3];
        }
    }
    cout << "AC"  << " x " << j[0] << endl
         << "WA"  << " x " << j[1] << endl
         << "TLE" << " x " << j[2] << endl
         << "RE"  << " x " << j[3] << endl;
    return 0;
}

Measured memory_bytes: 6420
// AOJ 404 Shiba Inu
// 2019.9.29

#include <stdio.h>

int main()
{
	int i, x, ans;

	ans = 0; for (i = 0; i < 4; i++) scanf("%d", &x), ans += x;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2092
s=gets.chomp
if s[0]==s[1]&& s[1]==s[2] && s[1]=="R"
  puts 3
elsif s[0]==s[1] && s[0]=="R"
  puts 2
elsif s[1]==s[2] && s[2]=="R"
  puts 2
elsif s[0]=="R"||s[1]=="R"||s[2]=="R"
  puts 1
else
  puts 0
end


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

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

  int64_t N, M;
  cin >> N >> M;
  int64_t ans = 1;
  for(int i=1;i<=N;i++){
    ans *= i;
    ans %= INF;
  } 
  for(int i=1;i<=M;i++){
    ans *= i;
    ans %= INF;
  }
  if(abs(N-M) == 1) cout << ans << endl;
  else if(N == M) cout << ans * 2 % INF << endl;
  else cout << 0 << endl;
}

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

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a < b) {
		cout << "a < b" << endl;
	}
	else if (a > b) {
		cout << "a > b" << endl;
	}
	else {
		cout << "a == b" << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int main(){
  int n;
  cin>>n;
  vector<long> vec(3*n);
  rep(i,3*n) cin>>vec[i];
  sort(all(vec));

  long ans = 0;
  for(int i=3*n-2; i>=n; i-=2) ans += vec[i];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>

double f(double x,double y ,double x1,double y1,double x2,double y2){
return (y1-y2)*x-(x1-x2)*y-(y1-y2)*x2+(x1-x2)*y2;
}

int main(void){

double xa,ya,xb,yb,xc,yc,xd,yd;

while(1){

if(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)==EOF){break;}

double r1=f(xc,yc,xa,ya,xb,yb)*f(xd,yd,xa,ya,xb,yb);
double r2=f(xd,yd,xb,yb,xc,yc)*f(xa,ya,xb,yb,xc,yc);
double r3=f(xa,ya,xc,yc,xd,yd)*f(xb,yb,xc,yc,xd,yd);
double r4=f(xb,yb,xd,yd,xa,ya)*f(xc,yc,xd,yd,xa,ya);

if(r1>0 && r2>0 && r3>0 && r4>0){printf("YES\n");continue;}
printf("NO\n");
}

return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define rep( i, n ) for (long long i = 0; i < ( long long )(n); i++)

using namespace std;
typedef long long ll;
typedef pair< int , int > P;

int main(){
  string s;
  cin>>s;

  if((s[2]==s[3])&&(s[4]==s[5])&&(s[4]!=s[6])){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}

Measured memory_bytes: 256
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=[LI() for i in range(n)]
ans=0
for i in range(n):
    for j in range(n):
        ans+=sqrt((lis[i][0]-lis[j][0])**2+(lis[i][1]-lis[j][1])**2)
print(ans/n)

    
            
        
        
    

    
        
    
    
    

Measured memory_bytes: 65840
import sys
sys.setrecursionlimit(10**7)

N = int(input())
ad = [[] for _ in range(N)]
edge = []
# 0からn-1の値をとる木構造を管理する。
for _ in range(N-1):
    a, b = map(int,input().split())
    a -= 1; b -= 1
    ad[a].append(b)
    ad[b].append(a)
    edge.append((a, b))

K = max(len(S) for S in ad)
d = dict()

def dfs(v=0, pv=-1, memo=-1):
    color = 0
    for nv in ad[v]:
        if nv == pv:
            continue
        if color == memo:
            color += 1
        d[(v, nv)] = color
        d[(nv, v)] = color
        dfs(nv, v, color)
        color += 1

dfs()

print(K)
for e in edge:
    print(d[e]+1)

Measured memory_bytes: 94440
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};

int T, t[33];
int N, D[110], M[110];

int dp[110][33];

void solve() {
	vector< int > day(110, 23);
	for_(i,0,N)	day[ D[i] - 1 ] = min(day[ D[i] - 1 ], M[i]);
	
	for_(i,0,110) fill(dp[i], dp[i] + 33, iINF);
	dp[0][0] = 0;
	
	for_(i,0,100) {
		for_(j,0,T) {
			if (dp[i][j] == iINF) continue;
			
			dp[i + 1][1 % T] = min(dp[i + 1][1 % T], dp[i][j] + 1);
			
			if (t[j] <= day[i]) {
				int next_j = (j + 1) % T;
				dp[i + 1][next_j] = min(dp[i + 1][next_j], dp[i][j]);
			}
		}
	}
	
	int ans = iINF;
	for_(i,0,30) ans = min(ans, dp[100][i]);
	
	cout << ans << endl;
}

int main() {
	while (cin >> T, T) {
		for_(i,0,T) cin >> t[i];
		cin >> N;
		for_(i,0,N) cin >> D[i] >> M[i];
		solve();
	}
	return 0;
}

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

int main()
{
   /// BISMILLAHIR RAHMANIR RAHIM
	int n;
	cin >> n;
	ll ans = 1;
	ll a[n+1];
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		if (a[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i = 0;i < n;i++) {
		ans = ans * a[i];
	}
	if (ans <= 1000000000000000000 && ans > 0) {
		cout << ans << endl;
	}
	else cout << -1 << endl;
	return 0;

    /// ALHAMDULILLAH
}


Measured memory_bytes: 4412
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<char> a;
bool af[33];
int xma[33],xmi[33];
int yma[33],ymi[33];
int h,w;
char m[55][55];
bool used[33];

int dx[] = {0,1};
int dy[] = {1,0};
bool f[55][55];
int dfs(char c,int x,int y){
  if(f[x][y]) return 0;
  f[x][y] = true;
  int res = 1;
  for(int i = 0; i < 2; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(xma[c-'A'] < nx || yma[c-'A'] < ny || m[nx][ny] == '.' || !used[m[nx][ny]-'A'] ) continue;
    res += dfs(c,nx,ny);
  }
  return res;
}

bool solve(int bit){
  if(bit == (1<<(int)a.size())-1) return true;

  for(int i = 0; i < (int)a.size(); i++){
    memset(f,false,sizeof(f));
    if(bit & 1<<i) continue;
    int al = a[i] - 'A';
    used[al] = true;
    if(dfs(a[i],xmi[al],ymi[al]) != (xma[al]-xmi[al]+1) * (yma[al]-ymi[al]+1) ){
      used[al] = false;
      continue;
    }
    //cout << a[i] << " = " <<  dfs(a[i],xmi[al],ymi[al]) << endl;
    if(solve(bit | 1<<i)) return true;
    used[al] = false;
  }
  return false;
}

int main(void){
  int n;
  cin >> n;
  for(int k = 0; k < n; k++){
    a.clear();
    for(int i = 0; i < 33; i++){
      af[i] = used[i] = false;
      xma[i] = yma[i] = -1;
      xmi[i] = ymi[i] = 111;
    }

    cin >> h >> w;
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
	cin >> m[j][i];
	if(m[j][i] < 'A' || 'Z' < m[j][i]) continue;
	if(!af[m[j][i]-'A']){
	  af[m[j][i]-'A'] = true;
	  a.push_back(m[j][i]);
	}
	xma[m[j][i]-'A'] = max(xma[m[j][i]-'A'],j);
	xmi[m[j][i]-'A'] = min(xmi[m[j][i]-'A'],j);
	yma[m[j][i]-'A'] = max(yma[m[j][i]-'A'],i);
	ymi[m[j][i]-'A'] = min(ymi[m[j][i]-'A'],i);
      }
    }

    if(solve(0)) cout << "SAFE" << endl;
    else cout << "SUSPICIOUS" << endl;
  }
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <vector>
#include <algorithm>
#define lli long long int
#define pb push_back
using namespace std;

const int MAXN = (int)2e5 + 5;
const int INF = (int)1e9;

struct Line {
    lli a;
    lli b;

    Line() {}
    Line(lli a, lli b):a(a), b(b) {}

    lli query(lli x) {
        return a * x + b;
    }
};

struct ConvexEnvelope {
    vector<Line> envelope;
    int bestLineIdx;

    ConvexEnvelope() {
        bestLineIdx = 0;
    }

    void add(Line line) {
        while(isBetterThanPrevious(line)) {
            envelope.pop_back();
        }
        envelope.pb(line);
        return;
    }

    bool isBetterThanPrevious(Line& line) {
        int sz = (int)envelope.size();
        if (sz > 0) {
            lli a = envelope.back().a;
            lli b = envelope.back().b;

            if (a == line.a && b <= line.b) {
                return true;
            }
        }

        if (sz >= 2) {
            lli a1 = envelope[sz - 2].a;
            lli b1 = envelope[sz - 2].b;
            lli a2 = envelope.back().a;
            lli b2 = envelope.back().b;

            if (1.0 * (b2 - b1) * (a1 - line.a) >= 1.0 * (line.b - b1) * (a1 - a2)) {
                return true;
            }
        }
        return false;
    }

    lli query(int x) {
        while (bestLineIdx < (int)envelope.size() - 1) {
            if (envelope[bestLineIdx].query(x) >= envelope[bestLineIdx + 1].query(x)) {
                bestLineIdx++;
            } else {
                break;
            }
        }
        return envelope[bestLineIdx].query(x);
    }
};


int h[MAXN];
lli dp[MAXN];

int main(void) {
    int n;
    lli C;
    ConvexEnvelope envelope = ConvexEnvelope();

    scanf(" %d %lld", &n, &C);
    for (int i = 1; i <= n; i++) {
        scanf(" %d", &h[i]);
    }

    dp[1] = 0;
    envelope.add(Line(-2 * h[1], 1LL * h[1] * h[1]));
    for (int i = 2; i <= n; i++) {
        dp[i] = C + 1LL * h[i] * h[i] + envelope.query(h[i]);
        envelope.add(Line(-2 * h[i], dp[i] + 1LL * h[i] * h[i]));
    }
    printf("%lld\n", dp[n]);

    return 0;
}


Measured memory_bytes: 8560
#include<bits/stdc++.h>
using namespace std;
priority_queue<int>pq;
int main(){
    int N,K;
    cin>>N>>K;
    while(N--){
        int x;
        cin>>x;
        pq.push(x);
    }
    int ans=0;
    while(K--){
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

case class Input(cxs: List[Boolean]) {
  private def aux(cxs: List[Boolean], acc: Int): Int = cxs match {
    case Nil => acc
    case h :: Nil => acc
    case b1 :: b2 :: rst => if (b1 ^ b2) aux(rst, acc + 1)
                            else aux(b2::rst, acc)
  }
  def solved: Output = {
    Output(aux(this.cxs, 0))
  }
}

object Input {
  def fromString(s: String): Input =
    Input(s.toCharArray().map(_ == 'O').toList)
  def fromStdin(): Input = {
    val sc = new Scanner(System.in)
    sc.nextLine()
    Input.fromString(sc.nextLine())
  }
}

case class Output(v: Int) {
  override def toString(): String = {
    v.toString()
  }

  def print() = println(this.toString())
}

object Main extends App {
  Input.fromStdin().solved.print()
}



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

int main() {
    string s;
    cin >> s;
    int ans = s.size();
    int cntS = 0;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s.at(i) == 'S') cntS++;
        else if (0 < cntS) {
            ans -= 2;
            cntS--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr front()
#define tp top()
typedef long long int ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
#define iofast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define iofile freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
const ll LLINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1);
const int SIZE = 100005;

int N;
int A[SIZE];
map<int,int> Mp;	

int main (){
	
	scanf("%d", &N);
	for(int i=0;i<N;i++){
		scanf("%d", &A[i]);
		Mp[A[i]]++;
	}
	int ans=0;
	for(map<int,int>::iterator itm=Mp.begin();itm!=Mp.end();itm++){
		if(itm->se%2==1) ans++;
	}
	printf("%d\n", ans);
	
	return 0;
}

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

#define int long long

signed main(){
	int a, b;
	cin >> a >> b;

	for(int i = 0;i <= 10000;i++){
		int x = i * 1.08;
		int y = i * 1.10;

		if(x-i == a && y-i == b){
			cout << i << endl;
			return 0;
		}
	}
	
	cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
const int maxn = 1000000;
ll mod = INF;

int ans=0;
int a[3]={-1,-1,-1};
int n,m;
int M=0;

int main(){
    cin >> n>>m;
    rep(i,m){
        int s,c;
        cin >> s>>c;
        if(n<s){
            cout << -1<<endl;
            return 0;
        }
        
        if(a[n-s]==-1){
            a[n-s]=c;
        }else if(a[n-s]!=INF&&a[n-s]!=c){
            cout << -1<<endl;
            return 0;
        }
    }

    if(n==1){
        for(int i=0;i<=9;i++){
            bool key=true;
            int tmp=i;
            for(int j=0;j<n;j++){
                if(a[j]!=-1&&a[j]!=tmp%10){
                    key=false;
                    break;
                }
                tmp=tmp/10;
            }
            if(key){
                cout << i<<endl;
                return 0;
            }
        }
    }else if(n==2){
        if(a[n-1]==0){
            cout << -1<<endl;
            return 0;
        }
        for(int i=10;i<=99;i++){
            bool key=true;
            int tmp=i;
            for(int j=0;j<n;j++){
                if(a[j]!=-1&&a[j]!=tmp%10){
                    key=false;
                    break;
                }
                tmp=tmp/10;
            }
            if(key){
                cout << i<<endl;
                return 0;
            }
        }
    }else{
        if(a[n-1]==0){
            cout << -1<<endl;
            return 0;
        }
        for(int i=100;i<=999;i++){
            bool key=true;
            int tmp=i;
            for(int j=0;j<n;j++){
                if(a[j]!=-1&&a[j]!=tmp%10){
                    key=false;
                    break;
                }
                tmp=tmp/10;
            }
            if(key){
                cout << i<<endl;
                return 0;
            }
        }
    }

    //cout << -1<<endl;
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <map>
#include <vector>
using namespace std;



int main(void){
    
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    cout << s1[0] << s2[1] << s3[2];
    
    
    
    return 0;
    
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int w,h;

    scanf("%d %d", &h, &w);
    while (w!=0 || h!=0){
        for (int i=0; i<h; i++){
            for (int j=0; j<w; j++){
                if (i>0 && i<h-1 && j>0 && j<w-1) printf(".");
                else printf("#");
            }
            printf("\n");
        }
        printf("\n");
        scanf("%d %d", &h, &w);
    }
    return 0;
}

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

int main()
{
  int n;
  int a;
  int b;
  
  cin >> n >> a >> b;
  
  if (a * n <= b)
    cout << a * n << endl;
  else 
    cout << b << endl;
  
  return (0);
}

Measured memory_bytes: 256
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let mut it = line
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<u32>().ok().unwrap());
    let (a, b, c) = (it.next().unwrap(), it.next().unwrap(), it.next().unwrap());
    if ((a == b) & (b == c) & (c == a)) | ((a != b) & (b != c) & (c != a)) {
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 2084
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 2100;
int H, W;
string S[Max];
char G[Max][Max];
int h[Max][Max];
int w[Max][Max];


int main(int argc, const char * argv[]) {
    cin >> H >> W;
    inputArray(S, H);
    memset(G, 'x', Max*Max*sizeof(char));

    rep(i, H) {
        rep(j, W) {
            G[i+1][j+1] = S[i][j];
        }
    }

    repd(i, 1, H+1) {
        repd(j, 1, W+1) {
            if (G[i][j] != '.') {
                w[i][j] = 0;
                continue;
            }
            if (G[i][j-1] == '.') {
                w[i][j] = w[i][j-1];
                continue;
            }
            int jj = j + 1;
            while (G[i][jj] == '.') {
                jj++;
            }
            w[i][j] = jj - j;
        }
    }

    repd(i, 1, H+1) {
        repd(j, 1, W+1) {
            if (G[i][j] != '.') {
                h[i][j] = 0;
                continue;
            }
            if (G[i-1][j] == '.') {
                h[i][j] = h[i-1][j];
                continue;
            }
            int ii = i + 1;
            while (G[ii][j] == '.') {
                ii++;
            }
            h[i][j] = ii - i;
        }
    }

    // repd(i, 0, H+1) {
    //     repd(j, 0, W + 1){
    //         printf("%d ", w[i][j]);
    //     }
    //     printf("\n");
    // }

    
    int maxc = 0;
    repd(i, 1, H+1) {
        repd(j, 1, W + 1){
            chmax(maxc, h[i][j] + w[i][j] - 1);
        }
    }

    output(maxc);

    return 0;
}

Measured memory_bytes: 43136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> a(n);
  ll res = 0;
  res = 1;
  bool ok = true;
  bool zero = false;
  for(int i = 0;i < n;i++){
    cin >> a[i];
    string copy,now;
    copy = to_string(res);
    now = to_string(a[i]);
    //cout << (ll)pow(10,18) / a[i] << " " << res << endl;
    if(a[i] == 0){
      res = 0;
      zero = true;
      break;
    }
    if(res > ((ll)pow(10,18) / a[i]) + (ll)1){
      //cout << "!" << endl;
      ok = false;
    }
    if(ok)res *= a[i];
        if(res > (ll)pow(10,18))ok = false;
    //cout << res << endl;
    //cout << pow(10,18) << endl;
    if(a[i] == 0)zero = true;
  }
  if(ok)cout << res << endl;
  else{
    if(zero)cout << 0 << endl;
    else cout << -1 << endl;
  }
}




Measured memory_bytes: 4048
import sys
import copy
import math
import bisect
import pprint
import bisect

def dictCount(str):
    dict = {}

if __name__ == '__main__':
    n = int(input())
    s = []
    sum =0
    for i in range(n):
        a = [int(i) for i in input().split()]
        s.append(a)
    for i in range(n):
        for j in range(n):
            if j > i:
                x = s[i][0] -s[j][0]
                y = s[i][1] -s[j][1]
                sum = sum + math.sqrt(x*x + y*y)
    sum = sum*2

    print(sum/n)


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    if (N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9){
        cout << "hon" << endl;
    }
    else if (N % 10 == 3){
        cout << "bon" << endl;
    }
    else {
        cout << "pon" << endl;
    }
return 0;
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var M = input[1];
            var X = ReadArrayInt();
            if (N >= M) { Console.WriteLine(0); return; }
            Array.Sort(X);
            var length = new List<int>();
            for (int i = 0; i < M - 1; i++) length.Add(Math.Abs(X[i + 1] - X[i]));
            length.Sort((a, b) => b - a);
            var ans = length.Sum();
            for (int i = 0; i < N - 1; i++) ans -= length[i];

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 26208
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
    long long minu(long long a, long long b){
        return mod(mod(a)-mod(b));
    }
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
    
    vector<int>dirX={-1,0,1};
    vector<int>dirY={-1,0,1};
 
 
    void solve(){
        ll n;
        cin>>n;
        if(n==1){
            cout<<0;
            return;
        }
        if(n==2){
            cout<<2;
            return;
        }
        ll ans=minu(add(modPow(10LL,n),modPow(8LL,n)),mul(2LL,modPow(9LL,n)));
        cout<<ans;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
        //    cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>

using ui = uint64_t;
using li = int64_t;

li num[100100];
char op[100100];

const li INF = li(100100) * 1000000000;
li dp[100100];
//op[i]==-
li func(int i)
{
	//i以降（i含む)で最大
	if (op[i + 1] == '-') { return dp[i]  = -(num[i] - num[i + 1]) + num[i + 1]; }
	if (dp[i] != INF) { return dp[i]; }
	return dp[i] = -(num[i] - num[i+1])
		+ std::max(
			-(num[i + 1] - num[i + 2]) + num[i + 2],
			+(num[i + 1] - num[i + 2]) + func(i + 2)
		);
}

int main()
{
	for (auto& i : dp) {
		i = INF;
	}
	std::cin.sync_with_stdio(false);
	std::cout.sync_with_stdio(false);
	int N;
	std::cin >> N;
	std::cin >> num[0];
	int temp_n = 1;
	bool is_mode_add = true;
	for (int i = 1; i < N; ++i) {
		std::cin >> op[temp_n];
		std::cin >> num[temp_n];
		bool next_mode = (op[temp_n] == '+');
		if (is_mode_add && next_mode) {
			num[temp_n - 1] += num[temp_n];
		}
		else {
			is_mode_add = next_mode;
			++temp_n;
		}
	}
	//番兵
	op[temp_n] = op[temp_n + 1] = '-';
	num[temp_n] = num[temp_n + 1] = 0;
	//numを累積和に
	for (int i = temp_n - 1; i >= 0; --i) {
		num[i] += num[i + 1];
	}

	li res = (num[0] - num[0 + 1]);
	if (temp_n > 1) {

		res += func(1);
	}
	std::cout << res << std::endl;
}


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

using namespace std;

#define intt long long
const int MAXN = 1003;
const int INF = 2000000003;
int a[MAXN];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

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

Measured memory_bytes: 256
/**
 * C - March
 * https://atcoder.jp/contests/abc089/tasks/abc089_c
 **/
#include<iostream>
#include<string.h>
#include<vector>

#define ll long long

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<string> Sn(N);
    for(int i=0; i<N; ++i) cin >> Sn[i];
    vector<int> map(5, 0);
    for(auto si:Sn) {
        if(si[0]=='M') {
            map[0]++;
        } else if(si[0]=='A') {
            map[1]++;
        } else if(si[0]=='R') {
            map[2]++;
        } else if(si[0]=='C') {
            map[3]++;
        } else if(si[0]=='H') {
            map[4]++;
        }
    }
    // 5文字の内3文字を選んで計算
    long long ans = 0;
    for(int i=0; i<3; i++) {
        for(int j=i+1; j<4; j++) {
            for(int k=j+1; k<5; k++) {
                ans += (ll)map[i] * (ll)map[j] * (ll)map[k];
            }
        }
    }

    cout << ans << endl;
}

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

int main()
{
    int n,a,b,c,d;
    cin >> n>>a>> b>>c>>d;
    int xn=(n%a==0?n/a:n/a+1);
    int yn=(n%c==0?n/c:n/c+1);
    cout << min(b*xn,d*yn)<< endl;
    return 0;

}



Measured memory_bytes: 3136
#include<iostream>
#include<list>
#include<string>
#include<cstdlib>
using namespace std;

int main() {
	int numCom;
	list<int> lis;

//	cin >> numCom;
	scanf("%d", &numCom);
	for (int i = 0; i < numCom; i++) {
		string str;
		cin >> str;
		if (str[0] == 'i') {
			int x;
//			cin >> x;
			scanf("%d", &x);
			lis.push_front(x);
		}
		else if (str[6] == 'F') {
			lis.pop_front();
		}
		else if (str[6] == 'L') {
			lis.pop_back();
		}
		else if (str[0] == 'd') {
			int x;
//			cin >> x;
			scanf("%d", &x);
			for (list<int>::iterator ite = lis.begin(); ite != lis.end(); ite++) {
				if (*ite == x) {
					lis.erase(ite);
					break;
				}
			}
		}
	}

	int i = 0;
	for (list<int>::iterator ite = lis.begin(); ite != lis.end(); ite++) {
		if (i++) cout << " ";
		cout << *ite;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 34484
#include <cstdio>
int main() {
    int N;
    while(scanf("%d",&N),N) {
        int cnt=0;
        bool OK=false;
        for(int i=0;i<N;i++) {
            int k;
            scanf("%d",&k);
            if(k>0) cnt++;
            if(k>1) OK=true;
        }
        if(!OK) printf("NA\n");
        else printf("%d\n",cnt+1);
    }
}

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

int main(){
  int n;
  cin>>n;
  vector<string> s(n);
  rep(i,n) {
    cin>>s[i];
  }
  bool ans = true;
  for(int i=1; i<n; i++) {
    int m = s.at(i-1).size();
    if(s.at(i).at(0)!=s.at(i-1).at(m-1)) {
      cout<<"No"<<endl;
      return 0;
    }
  }
  sort(s.begin(), s.end());
  for(int i=1; i<n; i++) {
    if(s.at(i) == s.at(i-1)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <tuple>
#include <vector>

using namespace std;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<pair<int, vector<int>>> book(n);
    for (size_t i = 0; i < n; ++i) {
        int price;
        vector<int> each_knowledge(m);
        cin >> price;
        for (size_t j = 0; j < m; ++j) {
            cin >> each_knowledge[j];
        }
        book[i] = pair<int, vector<int>>(price, each_knowledge);
    }

    int total_price = -1;
    vector<tuple<int, vector<int>, bool>> results;
    
    for (size_t i = 0; i < n; ++i) {
        size_t current_size = results.size();
        for (size_t j = 0; j < current_size; ++j) {
            bool comp = true;
            vector<int> knowledge(m, 0);
            for (size_t k = 0; k < m; ++k) {
                knowledge[k] = get<1>(results[j])[k] + book[i].second[k];
                comp &= (knowledge[k] >= x);
            }
            int price = get<0>(results[j]) + book[i].first;
            results.emplace_back(price, knowledge, comp);
        }

        bool comp_first = true;
        for (size_t j = 0; j < m; ++j) {
            comp_first &= (book[i].second[j] >= x);
        }
        results.emplace_back(book[i].first, book[i].second, comp_first);
    }
    sort(results.begin(), results.end(), [](const auto& lhs, const auto& rhs){
        return get<0>(lhs) < get<0>(rhs);
    });
    for (const auto& item : results) {
        if (get<2>(item)) {
            total_price = get<0>(item);
            break;
        }
    }
    cout << total_price << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3880
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(const size_t n, const size_t m, const T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; }return 0; }
constexpr ll pow2(const int n) { return 1ll << n; }
constexpr int INF = 1 << 28; constexpr ll LINF = 1ll << 60;
constexpr int MAX = 1e5 + 5; constexpr int MOD = 1e9 + 7; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

vi A(5);

int main() {
	int M = 0;
	int sum = 0;
	rep(i, 5) { 
		cin >> A[i];
		sum += (A[i] + 9) / 10 * 10;
		M = max(M, (A[i] + 9) / 10 * 10 - A[i]);
	}

	write(sum - M);
}

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

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 long long INF = 1LL << 60;

vector<long long> dp(100010, INF);

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &h[i]);
    }
    dp[0] = 0;
    
    for (int i = 1; i < N; i++) {
        for (int j = 1; j <= K; j++) {
            if (i >= j) chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    cout << dp[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define ordered_set tree<int , null_type,less<int , rb_tree_tag,tree_order_statistics_node_update>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 100000000
// order_of_key and *find_by_order

int32_t main() {
	fast;
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int xo = 0;
	for (int i = 0; i < n / 2; i++) {
		xo ^= (a[i] ^ a[n - i - 1]);
	}
	for (int i = 0; i < n; i++) {
		cout << (xo ^ a[i]) << " ";
	}







}

Measured memory_bytes: 5088
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
	String s1 = sc.next();
    String s2 = sc.next();

    String[] c1 = new String[n];
    String[] c2 = new String[n];
    
    for(int i=0; i<n; i++){
      c1[i] = s1.substring(i,i+1);
      c2[i] = s2.substring(i,i+1);
    }
    
    for(int i=0; i<n; i++){
      System.out.print(c1[i]+c2[i]);
    }
    
    System.out.print("\n");
    
  }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}


signed main() {    
    
    int h, w;
    cin >> h >> w;
    vector<string> s(h);

    for(auto&&i:s) cin >> i;

    for(int i = 0; i < w + 2; i++) cout << '#';
    cout << endl;
    for(int i = 0; i < h; i++) {
        cout << '#';
        cout << s[i];
        cout << "#\n";
    }
    for(int i = 0; i < w + 2; i++) cout << '#';
    cout << endl;

  
    return 0;
}



Measured memory_bytes: 256
from collections import deque

S = deque(input())
Q = int(input())
Query = [input().split() for i in range(Q)]
order = 1

for i in range(Q):
    if Query[i][0] == '1':
        order *= -1
    else:
        F = Query[i][1]
        C = Query[i][2]

        if F == '1':
            if order == 1:
                S.appendleft(C)
            else:
                S.append(C)
        else:
            if order == 1:
                S.append(C)
            else:
                S.appendleft(C)

S = ''.join(list(S))

print(S[::order])

Measured memory_bytes: 116312
//24
#include<iostream>
#include<cstring>

using namespace std;

typedef int G[100][100];

void rot(G a,int n){
  G t;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      t[j][n-i-1]=a[i][j];
    }
  }
  memcpy(a,t,sizeof(t));
}

int main(){
  for(int n,m;cin>>n>>m,n|m;){
    G s;
    for(int y=0;y<n;y++){
      for(int x=0;x<n;x++){
	cin>>s[y][x];
      }
    }
    G p;
    for(int y=0;y<m;y++){
      for(int x=0;x<m;x++){
	cin>>p[y][x];
      }
    }
    int py=1000,px=1000;
    for(int r=0;r<4;r++){
      for(int y=0;y<n-m+1;y++){
	for(int x=0;x<n-m+1;x++){
	  bool f=true;
	  int t,l;
	  for(int i=m-1;i>=0;i--){
	    for(int j=m-1;j>=0;j--){
	      f&=p[i][j]==-1||s[y+i][x+j]==p[i][j];
	      if(p[i][j]!=-1){
		t=y+i;
		l=x+j;
	      }
	    }
	  }
	  if(f&&(t<py||(t==py&&l<px))){
	    py=t;
	    px=l;
	  }
	}
      }
      rot(p,m);
    }
    if(py==1000){
      cout<<"NA"<<endl;
    }else{
      cout<<px+1<<' '<<py+1<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1268
/*
    Author : Ritesh Singh
*/
 
#include <bits/stdc++.h>
using namespace std;
#define ict int t;cin>>t;while(t--)
#define lct long long int t;cin>>t;while(t--)
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define sz(x) (ll)(x).size()
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define el '\n'
#define IOS ios_base::sync_with_stdio(false), cin.tie(NULL)
const int mod = 1e9+7;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef set<int> si;
typedef set<ll> sl;
typedef map<string, ll> mapsl;
typedef map<string, int> mapsi;
typedef map<int,int> mapii;
typedef map<ll, ll> mapll;
typedef double db;
 
int32_t main()
{
    IOS;
    ll n; cin>>n; 
    int x = n%1000;
    if(x==0)
        cout<<0<<el;
    else
        cout<<1000-x<<el;

}



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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
int keta(int i){
  int count=1;
  while (i/10>0) {
    i/=10;
    count++;
  }
  return count;
}
int main(){
string S;
cin>>S;
int m=1000000;
for(int i=0;i<S.size()-2;i++){
int a=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
  //cout<<a<<endl;
  m=min(m,abs(a-753));
}
cout<<m<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[310][310];
int s[310][310][310];
int dp[310][310];

int push(int i,int x,int y){
	if(x==0 && y==0) return 0;
	if(dp[x][y]!=-1) return dp[x][y];
	int ans=2147483600;
	if(x>0) ans=push(i,x-1,y)+s[i][x][y];
	if(y>0) ans=min(ans,push(i,x,y-1)+s[i][x][y]);
	return  dp[x][y]=ans;
}
int main(){
	ios::sync_with_stdio(false);
	int h,w;
	cin>>h>>w;
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=h;i++){
		string s;
		cin>>s;
		for(int j=1;j<=w;j++){
			a[i][j]=s[j-1]-'a'+1;
		}
	}
	for(int i=1;i<w;i++){
		for(int j=1;j<=h;j++){
			for(int k=1;k<=h;k++){
				if(a[j][i]==a[k][i+1]) s[i][j][k]=s[i][j-1][k-1]+1;
				else s[i][j][k]=s[i][j-1][k-1];
			}
		}
	}
	int ans=0;
	for(int i=1;i<w;i++){
		memset(dp,-1,sizeof(dp));
		
		ans+=push(i,h,h);
		
	}

	/*for(int k=1;k<=h;k++){
			for(int j=1;j<=h;j++){
			cout<<dp[k][j]<<endl;
			}
		}*/
	cout<<ans;
	
}


Measured memory_bytes: 110848
import re

while True:
    N = int(input())
    if N == 0:
        break
    formula = [input() for _ in range(N)]
    # print(formula)
    stack = []

    for i in reversed(formula):
        # print(stack)
        if re.match("\.*(\*|\+)", i):
            depth = i.count(".")
            i = i.replace(".", "")
            # print(i, depth)
            if i == "+":
                cal_num = 0
            else:
                cal_num = 1
            for s in reversed(stack):
                if re.match("\." * (depth+1) + "\d", s):
                    num = int(s.replace(".", ""))
                    # print(cal_num)
                    if i == "+":
                        cal_num += num
                    else:
                        cal_num *= num
                    stack.pop()
            stack.append("." * depth + str(cal_num))
        else:
            stack.append(i)
    print(stack[0])


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin >>n;
    ll ans=0;
    for (int i = 1; i <=n; ++i) {
        ans+=(n/i)*(1+(n/i))*i/2;//OEISで検索
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <math.h>

int main(void){
	int w, h, x, y, r;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	if(x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	//printf("%d %d %d\n", array[0], array[1], array[2]);
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <string>
#include <cmath>
#include <vector>

using namespace std;

inline string ans(int sx, int sy, int tx, int ty) {
  // (0, 0) --> (1, 1) --> (0, 0)
  // (0, 0) -> (0, 1) -> (1, 1) -> (1, 0) -> (0, 0) -> (-1, 0) -> (-1, 1) -> (-1, 2) -> (0, 2) -> (1, 2) -> (1, 1) -> (2, 1) -> (2, 0) -> (2, -1) -> (1, -1) -> (0, -1) -> (0, 0)
  // up -> right | down -> left | left -> up -> right -> down | right -> down -> left -> up
  int x = tx - sx;
  int y = ty - sy;
  return string(y, 'U') + string(x, 'R')\
    + string(y, 'D') + string(x, 'L')\
    + string(1, 'L') + string(y + 1, 'U') + string(x + 1, 'R') + string(1, 'D')\
    + string(1, 'R') + string(y + 1, 'D') + string(x + 1, 'L') + string(1, 'U');
}

int main (void) {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  string _ans = ans(sx, sy, tx, ty);
  cout << _ans << endl;
  return 0;
}


Measured memory_bytes: 256
def gcd(a,b):
    if a<b:
        a,b = b,a
    if b==0:
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b):
    return (a*b)//gcd(a,b)


n = int(input())
li = [int(input()) for _ in range(n)]

ans = 1
for i in range(n):
    ans = lcm(ans,li[i])
print(ans)


Measured memory_bytes: 3060