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

int main()
{
string s ;
cin >> s ;
vector<ll> v(s.size()+1,0);
rep(i,s.size()){
  v[i+1]=v[i]^(1LL<<(s[i]-'a'));
}
map<ll,ll> m;
m[0]=0;
rep(i,s.size()){
  ll mi=1LL<<40;
  rep(j,27){
    ll r=1LL<<j;
    if(j==26)r=0;
    if(m.find(v[i+1]^r)!=m.end()){
      if(r==0)mi=min(mi,m[v[i+1]^r]-1);
      else mi=min(mi,m[v[i+1]^r]);
    }
  }
  m[v[i+1]]=mi+1;
}

cout << (m[v[s.size()]]==0?1:m[v[s.size()]]) << endl;
return 0;
}

Measured memory_bytes: 14468
#include <cstdio>

int main()
{
    int N;
    int H[100];
    if (scanf("%d", &N) == EOF) return -1;
    for (int i = 0; i < N; i++) {
        if (scanf("%d", &H[i]) == EOF) return -1;
    }

    int answer = 0;
    int highest = 0;
    for (int i = 0; i < N; i++) {
        if (H[i] < highest) continue;
        answer++;
        highest = H[i];
    }
    printf("%d\n", answer);
}


Measured memory_bytes: 128
#from collections import defaultdict 
import copy
import math
A,B = map(int, input().split())

num = min(A,B)
tmps = {}
p = 2
for p in range(2, math.ceil(num**0.5)+1):

    if A % p == 0 and B % p == 0:
        tmps[p] = True

    if A % (num//p) == 0 and B % (num//p) == 0:
        tmps[num//p] = True

    p += 1

if num != 1 and  A % num == 0 and B % num == 0:
    tmps[num] = True


d = copy.deepcopy(tmps)
for k in tmps.keys():

    if d.get(k, False):
        aaa = copy.deepcopy(d)
        for n in d.keys():
            if k == n:
                continue
            if n > k and n % k == 0:
                aaa.pop(n)
        d = aaa

print(len(d.keys())+1)



Measured memory_bytes: 5268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const int INF=1<<30,MOD=1000000007;
const ll LINF=1ll<<60;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPARR(i,v) for(int i=0;i<v.size();++i)
#define all(v) (v.begin()),(v.end())
#define bit(n) (1ll<<(n))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"":"im")<<"possible"<<endl
#define Poss(n) cout<<((n)?"P":"Imp")<<"ossible"<<endl
template<typename T>ostream&operator<<(ostream&o,const vector<T>&v){o<<"{";for(T i:v)o<<i<<',';o<<"}";return o;}
template<typename T>ostream&operator<<(ostream&o,const set<T>&v){o<<"{";for(T i:v)o<<i<<',';o<<"}";return o;}
template<typename T,typename U>ostream&operator<<(ostream&o,const pair<T,U>&v){o<<"("<<v.first<<", "<<v.second<<")";return o;}

int main(){
    int n;
    cin>>n;
    REP(i,n){
        int a;
        cin>>a;
        if(a%2){
            cout<<"first"<<endl;
            return 0;
        }
    }
    cout<<"second"<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-10;

int main(){
	int n;
	int debt = 100000;

	cin >> n;

	for(int i = 0; i < n; i++){
		debt += debt/20;
		if((debt % 1000) != 0){
			debt += 1000;
		}
		debt = debt/1000*1000;
	}

	cout << debt <<endl;

	return 0;
}

Measured memory_bytes: 1160
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {

	sc.Split(bufio.ScanWords)
	taxa, taxb := nextInt(), nextInt()

	for i := 1; ; i++ {

		ta := int(float64(i) * 0.08)
		tb := int(float64(i) * 0.10)

		if ta > taxa || tb > taxb {
			fmt.Print(-1)
			return
		}

		if ta != taxa || tb != taxb {
			continue
		}

		fmt.Print(i)
		return
	}

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
int read(){
	int x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)&&ch!='-')
		ch=getchar();
	if (ch=='-')
		f=-1,ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x*f;
}
int n;
vector <int> e[N];
int Log[N],ans=0,f[N];
void solve(int x,int pre){
	int t=0;
	for (auto y : e[x])
		if (y!=pre){
			solve(y,x);
			t|=f[x]&f[y];
			f[x]|=f[y];
		}
	f[x]^=t;
	int k=t?Log[t]+1:0;
	while (k<30&&(f[x]>>k&1))
		k++;
	ans=max(ans,k);
	f[x]|=1<<k;
	f[x]&=~((1<<k)-1);
}
int main(){
	n=read();
	for (int i=1;i<=n;i++)
		e[i].clear();
	for (int i=1;i<n;i++){
		int a=read(),b=read();
		e[a].push_back(b);
		e[b].push_back(a);
	}
	Log[1]=0;
	for (int i=2;i<=n;i++)
		Log[i]=Log[i>>1]+1;
	solve(1,0);
	cout << ans;
	return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

vector<int> u, v;
string s, t;

int main()
{
    ll r, d, x;
    cin >> r >> d >> x;
    for (int i = 0; i < 10; i++)
    {
        x = r * x - d;
        cout << x << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	ll n,m;
	cin >> n >> m;
	vector <ll> a(m);
	for (ll i=0; i< m; i++) {
		cin >> a[i];
		n -= a[i];
	}
	if (n < 0) {
		cout << -1 << endl;
	} else {
		cout << n << endl;
	}
	return 0;
}


Measured memory_bytes: 3228
//AGC 002-A
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if ((long long)a*b <= 0) cout << "Zero" << endl;
	else if (a + b > 0) cout << "Positive" << endl;
	else {
		if ((b - a + 1) % 2 == 1) cout << "Negative" << endl;
		else cout << "Positive" << endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n,i,x=100000,z;
	
	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		x = x * 1.05;
		
		if(x % 1000 != 0.0)
		{
			z = (x / 1000)+1;
			x = z * 1000;
		}
	}
	printf("%d\n",x);

	return 0;
}

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

int N;
string S;
long long cnt[26] = {};
long long ans = 1;
int main() {
  cin >> N >> S;
  for (int i = 0; i < N; i++)
    cnt[int(S[i] - 'a')]++;
  for (int i = 0; i < 26; i++)
    ans = (long long)(ans * (cnt[i] + 1)) % (long long)(1e9 + 7);
  cout << ans - 1 << endl;
  return 0;
}


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

#define N 5010
#define ll long long
#define pii pair<ll,ll>
#define fs first
#define sc second

#define inf 1e16

bool cmp(pii x,pii y)
{
    return x.fs+x.sc<y.fs+y.sc;
}

pii arr[N];
ll dp[N];


int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++) scanf("%lld %lld",&arr[i].fs,&arr[i].sc);
    sort(arr+1,arr+n+1,cmp);
    for(int i=0; i<N; i++)
    {
        dp[i]=inf;
    }
    dp[0]=0;
    for(int i=1; i<=n; i++)
    {
        for(int j=i; j>=1; j--)
        {
            if(dp[j-1]<=arr[i].fs) dp[j]=min(dp[j],dp[j-1]+arr[i].sc);
        }
    }
    int mx=0;
    for(int i=1; i<=n; i++)
    {
        if(dp[i]<inf) mx=i;
    }
    printf("%d\n",mx);




}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, r, maxv=-1*pow(10,9), minv;
    cin >> n;
    for (int i=0; i<n; i++){
        cin >> r;
        if (i == 0) minv = r;
        else {
            maxv = max(maxv, r-minv);
            minv = min(minv, r);
        }
    }
    cout << maxv << endl;
    return 0;
}



Measured memory_bytes: 3096
<?php
define('MOD',  pow(10, 9) + 7);
define('LIM', 100001);
$x2[0] = $x3[0] = 1;
for ($i = 1; $i < LIM; $i++) {
    $x2[$i] = $x2[$i - 1] * 2;
    $x2[$i] %= MOD;
    $x3[$i] = $x3[$i - 1] * 3;
    $x3[$i] %= MOD;
}

fscanf(STDIN, "%s", $S);
$len = strlen($S);
$cnt = 0;
$ans = 0;
for ($i = 0; $i < $len; $i++) {
    if ($S[$i] == "1") {
        // printf("3^%d 2^%d\n", $len - $i - 1, $cnt);
        $ans += $x2[$cnt] * $x3[$len - $i - 1];
        $ans %= MOD;
        $cnt++;
    }
}
$ans += $x2[$cnt];
$ans %= MOD;

echo $ans;


Measured memory_bytes: 14840
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x ,ans = 12345678;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n,vector<int>(m));
  for (int i = 0; i < n; i++)
  {
    cin >> c[i];
    for (int j = 0; j < m; j++)
    {
      cin >> a[i][j];
    }
    
  }
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    int anss = 0;
    vector<int> d(m);
    for (int i = 0; i < n; i++)
    {
      if ((tmp>>i)&1)
      {
        for (int j = 0; j < m; j++)
        {
          d[j] += a[i][j];
        }
        anss += c[i];
      }
      
    }
    bool test = true;
    for (int i = 0; i < m; i++)
    {
      if (d[i] < x)
      {
        test = false;
        
      }
      
    }
    if (test)
    {
      ans = min(ans, anss);
    }
    
  }
  if (ans == 12345678)
  {
    cout << -1 <<endl;
  }else
  {
    cout << ans << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
	int n;
	cin>>n;
	cout<<(n*(n-2)+n%2)/2<<endl;
	f(i,n){
		f(j,n){
			if(i<j&&i+j+1+n%2!=n) cout<<i+1<<" "<<j+1<<endl;
		}
	}
	return 0;
}


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

Measured memory_bytes: 50232
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AMaximizeTheFormula solver = new AMaximizeTheFormula();
        solver.solve(1, in, out);
        out.close();
    }

    static class AMaximizeTheFormula {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[] ns = new int[]{in.nextInt(), in.nextInt(), in.nextInt()};
            Arrays.sort(ns);
            out.println(10 * ns[2] + ns[1] + ns[0]);
        }

    }
}



Measured memory_bytes: 22996
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
lop = []
p1 = 0
p2 = 0
p3 = 0
pm = 0
for i in range(n):
    p1 += float((abs(x[i]-y[i])))
    
for i in range(n):
    p2 += abs((x[i]-y[i]))**2
    
for i in range(n):
    p3 += (abs((x[i]-y[i])))**3
    
for i in range(n):
    lop.append(float((abs(x[i]-y[i]))))
    
print(p1)
print(p2**(1/2))
print(p3**(1/3))
print(max(lop))


Measured memory_bytes: 5648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  char a,b;
  cin >> a >> b;
  if((a=='H'&&b=='H')||(a=='D'&&b=='D')) {
    cout << "H" << endl;
  }
  else cout << "D" << endl;
}

Measured memory_bytes: 256
import numpy as np

n, k = map(int, input().split())
a = np.array(input().split(), np.int64)

a = np.sort(a)
zero = a[a == 0]
pos = a[a > 0]
neg = a[a < 0]

def f(x):
    """count the number of products , <= x"""
    cnt_tpl = 0
    # zero and ...
    if x >= 0:
        cnt_tpl += len(zero) * n
    # positive and ...
    cnt_tpl += np.searchsorted(a, x // pos, side='right').sum()
    # negative and ...
    cnt_tpl += (n - np.searchsorted(a, (-x - 1) // (-neg), side='right')).sum()
    # a^2
    cnt_tpl -= np.count_nonzero(a * a <= x)
    assert cnt_tpl % 2 == 0
    return cnt_tpl // 2

left = -10 ** 18
right = 10 ** 18
while left + 1 < right:
    x = (left + right) // 2
    if f(x) >= k:
        right = x
    else:
        left = x

print(right)

Measured memory_bytes: 34632
def f1(t, si, ei)
  for i in si..ei
    t[i] -= 1
  end
end

n = gets.chomp.to_i
t = gets.chomp.split(' ').map {|v| v.to_i }
num = 0
si = 0
while si < t.length
  if t[si] == 0
    si += 1
    next
  end

  ei = si
  while ei < t.length
    if t[ei + 1] == 0 or (ei + 1) == t.length
      f1(t, si, ei)
      num += 1
      break
    end
    ei += 1
  end
end

puts num


Measured memory_bytes: 1788
#include <stdio.h>
int main(void){
    
    int a;
    int b;
    int c;
    
    scanf("%d%d%d", &a, &b, &c);
    
    if(a<c){
        
        if(c<b){
            
            printf("Yes");
            
            return 0;
        }
        
    }
    
    if(b<c){
        
        if(c<a){
            
            printf("Yes");
            
            return 0;
        }
        
    }
    
    printf("No");
    
    return 0;
    
}

Measured memory_bytes: 128
import sys
from collections import deque
sys.setrecursionlimit(1000*1000)

H,W = map(int,list(input().split()))
grid = []
for i in range(H):
  S = input()
  grid.append( [S[i] for i in range(W) ])

#方向ベクトル 今回は右と下への移動のみを考える　
#つまり行と列番号を増やす向きのみ考える
dx = [1,0]
dy = [0,1]

#####白マスの中を泳ぐdfsの定義
def wdfs(h,w,grid,seen,l_b):
  #白マスの時にかぎり以下を行う
  if seen[h][w] == False and grid[h][w] == ".":
    seen[h][w] = True
    for i in range(2):
      new_h = h + dy[i]
      new_w = w + dx[i]

      #場外アウトしたり、移動先が壁の場合はスルー
      if (new_h<0 or new_w <0 or new_h>=H or new_w >= W ):
        continue
      #移動先が黒マスの時はスルー
      elif grid[new_h][new_w] == "#":
        l_b.append([new_h,new_w])
        continue
      #移動先が探索済みの場合スルー
      elif seen[new_h][new_w] == True:
        continue
      wdfs(new_h,new_w,grid,seen,l_b)  
  #最初のマスが黒かった時    
  else:
    l_b.append([h,w])           
#####dfsの定義

#####黒マスの中を泳ぐdfsの定義
def bdfs(h,w,grid,seen,l_w):
  if seen[h][w] == False:
    seen[h][w] = True
    
    for i in range(2):
      new_h = h + dy[i]
      new_w = w + dx[i]

      #場外アウトの場合はスルー
      if (new_h<0 or new_w <0 or new_h>=H or new_w >= W ):
        continue
      #移動先が白マスの時はスルー
      elif grid[new_h][new_w] == ".":
        l_w.append([new_h,new_w])
        continue
      #移動先が探索済みの場合スルー
      elif seen[new_h][new_w] == True:
        continue
      bdfs(new_h,new_w,grid,seen,l_w)  
#####dfsの定義

#探索
seen = [ [False for i in range(W)] for i in range(H) ]
cnt = 0
l_w =deque( [[0,0]] )
l_b =deque([])


while seen[H-1][W-1] == False:
  while len(l_w) > 0: 
    w = l_w.popleft()
    wdfs(w[0],w[1],grid,seen,l_b)
  if seen[H-1][W-1] == True:
    break

  cnt = cnt+1

  while len(l_b) > 0: 
    b = l_b.popleft()
    bdfs(b[0],b[1],grid,seen,l_w)
  if seen[H-1][W-1] == True:
    break

###
print(cnt)

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)a
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    ll a, v;
    ll b, w;
    cin >> a >> v >> b >> w;
    ll t;
    cin >> t;
    ll dist = abs(a - b);
    ll speed = v - w;
    bool works = dist <= t * speed;
    cout << (works ? "YES" : "NO");
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


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

const int mod=1e9 +7;
void solve(){
    int h,w;
    cin>>h>>w;
    vector<string> mat(h);
    for(int i=0;i<h;i++) cin>>mat[i];
    vector<vector<int>> dp(h,vector<int>(w));
    dp[h-1][w-1]=1;
    for(int i=h-1;i>=0;i--){
        for(int j=w-1;j>=0;j--){
            if(mat[i][j]=='#') continue;
            if(i+1<h && mat[i+1][j]=='.') dp[i][j]=(dp[i][j]+dp[i+1][j])%mod;
            if(j+1<w && mat[i][j+1]=='.') dp[i][j]=(dp[i][j]+dp[i][j+1])%mod;
        }
    }
    cout<<dp[0][0];
}

int main() {
	// your code goes here
	//freopen("inptmp0.txt","r",stdin);
	int T;
	
	//cin>>T;
	T=1;
	while(T--){
	    solve();
	}
	return 0;
}


Measured memory_bytes: 9492
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<int> H(N);
  for (auto &x: H) {
    std::cin >> x;
  }
  std::vector<int> max(N);
  for (int i: range(0, M)) {
    int a, b;
    std::cin >> a >> b;
    --a; --b;
    chmax(max[a], H[b]);
    chmax(max[b], H[a]);
  }
  int ans = 0;
  for (int i: range(0, N)) {
    if (H[i] > max[i]) {
      ++ans;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b;
  cin >> a >> b;

  cout << (a < 10 && b < 10 ? a * b : -1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(ll a=0;a<b;++a)
#define REP(a,b,c,d) for(ll a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int ans = 0, N; cin >> N;
	string A, B, C; cin >> A >> B >> C;
	if (A == B && B == C) ans = 0;
	else {
		rep(i, N) {
			if (A[i] == B[i] && A[i] == C[i])continue;
			if (A[i] == B[i] || B[i] == C[i] || A[i] == C[i])ans += 1;
			else ans += 2;
		}
	}
	cout << ans << endl;
	cin >> N;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
using std::cin;
using std::cout;
using std::vector;
using std::sort;

int main(){
    long long int n,k,ans=0;
    cin>>n>>k;
    if(n<=k){
        cout << 0 << '\n';
    }else{
        vector<int> hs;
        for(int i = 0;i<n;++i){
            int tmp;
            cin>>tmp;
            hs.push_back(tmp);
        }
        sort(hs.begin(),hs.end());
        for(int i = 0;i<(hs.size()-k);i++){
            ans+=hs[i];
        }
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
using namespace std;

int main()
{
	fast;
	ll n,x,y; cin>>n>>x>>y;
	vector<ll>ans(n+1,0);
	for(ll i = 1; i<= n-1; i++)
	{
		for(ll j = i+1; j <= n; j++)
		{
			ll dist = min( j-i, min(1 + abs(x-i) + abs(y - j),1 + abs(x-j) + abs(y - i)));
			ans[dist]++;		
		}
	}
	for(ll i = 1; i <= n-1; i++) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln = '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    vector<ll> B(N+1);
    rep(i,N) B[i+1] = A[i]+B[i];
    auto get=[&](int l, int r) {return B[r]-B[l];};
    auto calc=[&](int l, int r) {
        int ng = l;
        int ok = r;
        while (ok-ng>1) {
            int mid = (ok+ng)/2;
            if (get(l,mid)>=get(mid,r)) ok = mid;
            else ng = mid;
        }
        return ok;
    };

    ll ans = 1e18;
    for (int c = 2; c < N-1; c++) {
        ll maxL = 0, minL = 0, maxR = 0, minR = 0;
        int b = calc(0,c);
        int d = calc(c,N);
        if (b==c) {
            maxL = get(b-1,c);
            minL = get(0,b-1);
        } else if (b==1) {
            maxL = get(0,b);
            minL = get(b,c);
        } else {
            maxL = min(get(0,b),get(b-1,c));
            minL = max(get(b,c),get(0,b-1));
        }
        if (d==N) {
            maxR = get(d-1,N);
            minR = get(c,d-1);
        } else if (d==c+1) {
            maxR = get(c,d);
            minR = get(d,N);
        } else {
            maxR = min(get(c,d),get(d-1,N));
            minR = max(get(d,N),get(c,d-1));
        }
        chmin(ans,max(maxR,maxL)-min(minL,minR));
    }

    cout << ans << ln;
}


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

int main() {
	//parameter 定義
	int D,smax,select;
	//SFL = 0;
	vector<vector<int>> s(D, vector<int>(26));
	vector<int> c(26);
	vector<int> last(26,0);
	//D,s,c入力
	cin >> D;
	for (int i = 0; i < 26; i++) {
		cin >> c.at(i);
	}
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++) {
			cin >> s.at(i).at(j);
		}
	}
	for (int i = 0; i < 365; i++) {
		select = 1;
		smax = s.at(i).at(0);
		for (int j = 0; j < 26; j++) {
			if (smax < s.at(i).at(j)) {
				smax = s.at(i).at(j);
				select = j;
			}
		}
		cout << select << endl;
    }
}

Measured memory_bytes: 7752
#include <bits/stdc++.h>
using namespace std;
int n,m,x,sum,ans=1e9;
vector<vector<int> >a;
vector<int>c;
int b;
int main(){
	scanf("%d%d%d",&n,&m,&x);
	a.resize(n,vector<int>(m));
	c.resize(n);
	for(int i=0;i<n;i++){
		scanf("%d",&c[i]);
		for(int j=0;j<m;j++)scanf("%d",&a[i][j]);
	}
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<m;j++){
			b=0;
			for(int k=0;k<n;k++){
				if(i&(1<<k))b+=a[k][j];
			}
			if(b<x){
				b=-1;
				break;
			}
		}
		if(b!=-1){
			sum=0;
			for(int k=0;k<n;k++){
				if(i&(1<<k))sum+=c[k];
			}		
			ans=min(ans,sum);
		}
	}
	if(ans==1e9)printf("%d",-1);
	else printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3724
import math

 

 
N,M = map(int,input().split())
S = input()
T = input()


def lcd(n,m):
    return int(n * m / gcd(n,m))
def gcd(n,m):
    if n % m == 0:
        return m
    else:
        return gcd(m,n % m)
#    return int(m*n/math.gcd(n,m))
    
def prove(n,m):
    n_i = int(lcd(n,m)/n)
    m_i = int(lcd(n,m)/m)
    n_list=[S[m_i*i] for i in range(gcd(n,m))]
    m_list=[T[n_i*i] for i in range(gcd(n,m))]
#    print(c)
#    print(pair[m])
    if n_list==m_list:
        return lcd(n,m)
    else:
        return -1


print(prove(N,M))



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

int main() {
  string a,b,c;
  cin>>a>>b>>c;
  if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])puts("YES");
  else puts("NO");
  return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
 int X;
 cin>>X;
 if(X==3||X==5||X==7)
 cout<<"YES"<<endl;
 else
 cout<<"NO"<<endl;
 




  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int main()
{
    int n;int a[100005],flag=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<n&&flag==0;i++)
    {
        if(a[i]>a[i+1]||a[i]>a[i-1])
            a[i]-=1;
        if(a[i]>a[i+1]||a[i-1]>a[i]) flag=1;
    }
    if(flag) printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 640
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def main():
    n = int(input())
    pi = math.pi
    print(2 * n * pi)


if __name__ == '__main__':
    main()

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

int main (){
	string s;cin>>s;
	sort(s.begin(),s.end());
	if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
    return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int X,Y,Z;
    Scd3(X,Y,Z);

    int K;
    Scd(K);

    vl a(X), b(Y), c(Z);
    Rep(i,X) Scll(a[i]);
    Rep(i,Y) Scll(b[i]);
    Rep(i,Z) Scll(c[i]);

    vl p;
    Rep(i,X) Rep(j,Y){
        p.push_back(a[i]+b[j]);
    }

    sort( p.rbegin(), p.rend() );


    vl q( p.begin(), p.begin()+min(K,(int)p.size()) );

    vl ans;
    Rep(i,q.size()) Rep(j,Z){
        ans.push_back(q[i]+c[j]);
    }

    sort( ans.rbegin(), ans.rend() );

    Rep(i,K){
        printf ("%lld\n", ans[i] );
    }

    return 0;
}





Measured memory_bytes: 42984
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <fstream>

using namespace std;

int main()
{

//	cut here before submit 
//	freopen("testcase.cc", "r", stdin);
	const string key[] = { "the", "this", "that" };

	string str = "";
	
	while (getline (cin, str )){
		int len = str.length();
		int i,j;
		vector <bool> match (3, false);

		for (j = 0; j < 26; ++j){
			string curr = str;
			for (i = 0; i < len; ++i){
				if ( isalpha(str[i]) ){
					curr[i] = (str[i] - 'a' + j) % 26 + 'a';
				} // end if
			} // end for

			for (i = 0; i < 3; ++i){
				if ( curr.find(key[i]) != string::npos ){
					match[i] = true;
				} // end if
			} // end for
			if ((int)count(match.begin(), match.end(), true ) > 0){
				cout << curr << endl;
				break;
			} // end if
		} // end for
	} // end while
		
	return 0;
}

Measured memory_bytes: 0
// #include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
const int INF = (int)2e9 + 1;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, temp;
  cin >> N;

  vector<int> seq;
  vector<int> slime;

  int n2 = 1 << N;
  for (int i = 0; i < n2; i++) {
    cin >> temp;
    seq.push_back(temp);
  }
  sort(seq.begin(), seq.end());
  slime.push_back(seq.back());
  seq.back() = -INF;
  int cnt;

  for (int i = 0; i < N; i++) {
    vector<int> pre = slime;
    sort(pre.begin(), pre.end());
    cnt = n2 - 1;
    while (pre.size() > 0 && cnt >= 0) {
      if (seq[cnt] == -INF) {
        cnt--;
        continue;
      }
      if (seq[cnt] < pre.back()) {
        slime.push_back(seq[cnt]);
        pre.pop_back();
        seq[cnt] = -INF;
      }
      cnt--;
    }
    if (!pre.empty()) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long w,n;
	string s;
	cin >> w >> n;
	long long ans[w];
	for(int i=0;i<w;i++){
		ans[i]=i+1;
	}
	for(int i=0;i<n;i++){
		cin >> s;
		for(int j=0;j<s.size();j++){
			if(s[j]==','){
				string ss=s.substr(0,j),tt=s.substr(j+1,s.size()-j-1);
				swap(ans[atoi(ss.c_str())-1],ans[atoi(tt.c_str())-1]);
			}
		}
	}
	for(int i=0;i<w;i++){
		cout << ans[i] << endl;
	}
	return 0;
}



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

int main() {
  
  vector<int> vec(5);
  
  for (int i = 0; i < 5; i++){
    int x;
    cin >> x;
    vec.at(i) = x;
  }
  
  for (int i = 0; i < 5; i++){
    if (vec.at(i)  == 0){
      cout << i + 1 << endl;
    }
  }
  
}




Measured memory_bytes: 3592
"use strict"

function Main(stdin){
stdin = stdin.trim().split("\n").reverse();
var stdout = [];
function input(){return stdin.pop()};
function print(x){stdout.push(x)};


var s = input()
var n = s.length
var x = new Array(n)
var ans = 0

if (s[0]=="A" || s[0]=="T" || s[0]=="C"|| s[0]=="G"){
    x[0] = 1; ans = 1
}else{
    x[0] = 0; ans = 0
}
for (var i = 1; i < n; i++){
    if (s[i]=="A" || s[i]=="T" || s[i]=="C"|| s[i]=="G"){
        x[i] = x[i-1] + 1
    }else{
        x[i] = 0
    }
    ans = Math.max(ans, x[i])
}
print(ans)




stdout = stdout.join("\n");
console.log(stdout);
return stdout
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 7372
#!/usr/bin/env python3
import sys
import collections


def solve(n: int, V: "List[int]"):

    ev = V[0::2]
    ov = V[1::2]

    ec = collections.Counter(ev)
    oc = collections.Counter(ov)

    em = ec.most_common()
    om = oc.most_common()

    if em[0][0] != om[0][0]:
        print( n-em[0][1]-om[0][1])
    else:
        if len(em) == 1 and len(om) == 1:
            print(n-em[0][1])
        elif  len(em) == 1:
            print( n-em[0][1]-om[1][1])
        elif  len(om) == 1:
            print( n-em[1][1]-om[0][1])
        else:
            print(min(n-em[0][1]-om[1][1], n-em[1][1]-om[0][1]))

            



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    v = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, v)

if __name__ == '__main__':
    main()


Measured memory_bytes: 30492
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second > b.second; }

ll solve(string S) {
    ll res = 0;
    for (int i = 0, j = S.size() - 1; i < j; ) {
        if (S[i] == S[j]) ++i, --j;
        else if (S[i] == 'x') ++res, ++i;
        else if (S[j] == 'x') ++res, --j;
        else return -1;
    }
    return res;
}

int main() {
    string S;
    while (cin >> S) cout << solve(S) << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int dp[60][60][60][60][2][3];
int A[60],B[60];
int n,m;
int dfs(int L1,int L2,int R1,int R2,int turn,int pass,int SA,int SB)
{
	int&ans=dp[L1][L2][R1][R2][turn][pass];
	if(ans>-1e9&&ans<1e9)return ans;
	if(turn==0)
	{
		if(L2<n)
		{
			ans=max(ans,dfs(L1,L2+1,R1,R2,1,0,SA+max(A[L2],0),A[L2]<0?0:SB));
		}
		if(L1!=L2||R1!=R2)ans=max(ans,dfs(L2,L2,R2,R2,1,0,0,0)+SA-SB);
		else ans=max(ans,pass==1?0:dfs(L2,L2,R2,R2,1,1,0,0));
	}
	else
	{
		if(R2<m)
		{
			ans=min(ans,dfs(L1,L2,R1,R2+1,0,0,B[R2]<0?0:SA,SB+max(B[R2],0)));
		}
		if(L1!=L2||R1!=R2)ans=min(ans,dfs(L2,L2,R2,R2,0,0,0,0)+SA-SB);
		else ans=min(ans,pass==1?0:dfs(L2,L2,R2,R2,0,1,0,0));
	}
	return ans;
}
main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>A[i];
	for(int i=0;i<m;i++)cin>>B[i];
	for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)
	{
		for(int k=0;k<=m;k++)for(int l=0;l<=m;l++)
		{
			for(int o=0;o<2;o++)for(int p=0;p<3;p++)
			{
				dp[i][j][k][l][o][p]=o?1e9:-1e9;
			}
		}
	}
	cout<<dfs(0,0,0,0,0,0,0,0)<<endl;
}



Measured memory_bytes: 199484
#include<stdio.h>
#include<stdlib.h>
#define PI 3.141592653589
 
int main()
{
  int h,w,i,j;
  while(1)
    {
      scanf("%d %d",&h,&w);
      if(h == 0 && w == 0) break;
      for(i = 0; i < h; i++)
    {
      for(j = 0; j < w; j++)
        {
          if((i+j) % 2 == 0) printf("#");
          else printf(".");
        }
      printf("\n");
    }
      printf("\n");
    }
  return 0;
}


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

int main()
{
  int n, l;
  cin >> n >> l;
  vector<string> a;
  for(int i=0; i<n; i++){
    string s;
    cin >> s;
    a.push_back(s);
  }
  sort(a.begin(), a.end());
  for(int i=0; i<n; i++) cout << a[i];
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<vector<pair<int,int> > > z(n);
    int i,j;
    for(i=0; i<n; i++) {
        int m;
        scanf("%d", &m);
        for(j=0; j<m; j++) {
            int x,y;
            scanf("%d%d", &x, &y); x--;
            z[i].push_back(make_pair(x,y));
        }
    }

    int max=0;
    int k;
    for(k=0; k<(1<<n); k++) {
        int cnt0=0;
        for(i=0; i<n; i++) {
            if(k & (1<<i)) {
                cnt0++;
                int bad=0;
                int siz=(int)z[i].size();
                for(j=0; j<siz; j++) {
                    int x=z[i][j].first;
                    int y=z[i][j].second;
                    if(y==1) {
                        if(!(k & (1<<x))) {
                            bad=1;
                            break;
                        }
                    }
                    else {
                        if(k & (1<<x)) {
                            bad=1;
                            break;
                        }
                    }
                }
                if(bad) {
                    break;
                }
            }
        }
        if(i==n) {
            max=MAX(max,cnt0);
        }
    }
    printf("%d\n", max);

    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){

		
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		double[] x = new double[n];
		double[] y = new double[n];
		double d1 = 0;
		double sum2 = 0;
		double d2 = 0;
		double sum3 = 0;
		double d3 = 0;
		double d4 = 0;
		
		for(int i = 0; i < n; i++){
			x[i] = scan.nextDouble();
		}
		for(int i = 0; i < n; i++){
			y[i] = scan.nextDouble();
		}
		for(int i = 0; i < n; i++){
			d1 += Math.abs(x[i] - y[i]);
			sum2 += Math.pow((Math.abs(x[i] - y[i])), 2);
			sum3 += Math.pow((Math.abs(x[i] - y[i])), 3);
			d4 = Math.max(d4, Math.abs(x[i] - y[i]));
		}		
		d2 += Math.sqrt(sum2);
		d3 += Math.cbrt(sum3);
		System.out.println(d1);
		System.out.println(d2);
		System.out.println(d3);
		System.out.println(d4);
	}
}

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

int main(){


  int n,a[1000],r[50000],c=0;
  
  while(1){
    cin >> n;
    if(n==0) break;
    for(int i=0; i<n;++i){
      cin >> a[i];
    }

    if(a[0]==a[1]){
      r[c] == 0;
    }else if(a[0]>a[1]){
      r[c] =a[0]-a[1] ;
    }else   r[c] =a[1]-a[0] ;
    
    for(int i=0; i<n;++i){
      if(r[c]==0) break;
      for(int k=0; k<n;++k){
	if(a[i]==a[k]){
	  if(i!=k) r[c] = a[i] - a[k];
	}else if(a[i]>a[k]){
	  if(r[c] > a[i]-a[k]) r[c] = a[i]-a[k];
	}else if(r[c] > a[k]-a[i]) r[c] = a[k]-a[i];
      }
    }
    ++c;
  }

  for(int i=0; i<c;++i){
    cout << r[i] << endl;
  }
  
  
  return 0;
}



Measured memory_bytes: 2992
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

s = input()
n = len(s)
mod = 10 ** 9 + 7

dp = [[0]*13 for _ in range(n+1)]
dp[0][0]=1

for i in range(n):
    c = -1 if s[i] == '?' else ord(s[i]) - ord('0')
    for j in range(10):
        if c != -1 and c != j:
            continue
        for ki in range(13):
            dp[i+1][(ki*10+j)%13] += dp[i][ki]
    for j in range(13):
        dp[i+1][j] %= mod

res = dp[n][5]

print(res)

Measured memory_bytes: 63888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,a,b,x,i,s=0;
	cin>>n>>a>>b;
	x=n/(a+b);
	s=x*a;
	ll z=n-x*(a+b);
	s=s+min(z,a);
	cout<<s;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=998244353;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2LL*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll n, m;
ll vv[111], s;

int main(void)
{
	cin>>n; int i;
	for(i=1 ; i<=n ; i++) cin>>vv[i];
	for(i=1 ; i<=n ; i++) s+=vv[i];
	cin>>m; int u, v;
	for(i=1 ; i<=m ; i++)
	{
		cin>>u>>v;
		cout<<s-vv[u]+v<<"\n";
	}
	return 0;
}

// 제출하기 전에 생각햇나요?
// it may be easier/harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int):
    if N%1000==0:
        print(0)
    else:
        print(1000-(N%1000))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

struct dice{
	int top;
	int front;
	int left;
	int right;
	int back;
	int bottom;
};

void ClockwiseTop(dice *X){
	int c = X->front;
	X->front  = X->right;
	X->right  = X->back;
	X->back   = X->left;
	X->left   = c;
}

void ClockwiseFront(dice *X){
	int c = X->top;
	X->top    = X->left;
	X->left   = X->bottom;
	X->bottom = X->right;
	X->right  = c;
}

void ClockwiseRight(dice *X){
	int c = X->top;
	X->top    = X->front;
	X->front  = X->bottom;
	X->bottom = X->back;
	X->back   = c;
}

void ClockwiseBottom(dice *X){
	ClockwiseTop(X);
	ClockwiseTop(X);
	ClockwiseTop(X);
}

void ClockwiseBack(dice *X){
	ClockwiseFront(X);
	ClockwiseFront(X);
	ClockwiseFront(X);
}

void ClockwiseLeft(dice *X){
	ClockwiseRight(X);
	ClockwiseRight(X);
	ClockwiseRight(X);
}

void TwiceClockwiseTop(dice *X){
	ClockwiseTop(X);
	ClockwiseTop(X);
}

void TwiceClockwiseRight(dice *X){
	ClockwiseRight(X);
	ClockwiseRight(X);
}

dice ArrengeTop(int a, dice B){
	if(B.front  == a) ClockwiseRight(&B);
	if(B.right  == a) ClockwiseBack(&B);
	if(B.left   == a) ClockwiseFront(&B);
	if(B.back   == a) ClockwiseLeft(&B);
	if(B.bottom == a) TwiceClockwiseRight(&B);
	return B;
}

dice ArrengeFront(int a, dice B){
	if(B.right  == a) ClockwiseTop(&B);
	if(B.left   == a) ClockwiseBottom(&B);
	if(B.back   == a) TwiceClockwiseTop(&B);
	return B;
}

bool Flag(dice A, dice B){
	if(B.top    != A.top   ) return false;
	if(B.front  != A.front ) return false;
	if(B.right  != A.right ) return false;
	if(B.left   != A.left  ) return false;
	if(B.back   != A.back  ) return false;
	if(B.bottom != A.bottom) return false;
	return true;
}

bool Judge(dice A, dice B){
	B = ArrengeTop(A.top, B);
	B = ArrengeFront(A.front, B);	
	return Flag(A, B);
}

dice Enter(dice X){
	cin >> X.top;
	cin >> X.front;
	cin >> X.right;
	cin >> X.left;
	cin >> X.back;
	cin >> X.bottom;
	return X;
}

int main(){
	int n;
	cin >> n;
	vector<dice> PowerX;
	for(int i = 0; i < n; i++){
		dice X = Enter(X);
		PowerX.push_back(X);
	}
	bool Answer = true;
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			if(Judge(PowerX[i], PowerX[j]) == true ) Answer = false;
		}
	}
	if(Answer == false) cout << "No"  << endl;
	if(Answer == true ) cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1216