akhauriyash/Code-Regression huggingface dataset:
N,M = list(map(int,input().split()))
x = 1
y = 1

for m in range(M):
    a,b = list(map(int,input().split()))
    if a==1:
      x|=1<<b
    if b==N:
      y|=1<<a

print("IM"*(x&y==1)+"POSSIBLE")

Measured memory_bytes: 3188
s = input()
year = int(s[0:4])
month = int(s[5:7])
day = int(s[8:10])

if year < 2019:
    print('Heisei')
elif year == 2019:
    if month < 4:
        print('Heisei')
    elif month == 4:
        print('Heisei')
    else:
        print('TBD')
else:
    print('TBD')


Measured memory_bytes: 3060
// E - Double Factorial
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	long long n, ans = 0;
	cin >> n;
	if (n % 2 == 0) {
		n /= 2;
		for (long long x = 5; x <= n; x *= 5)
			ans += n / x;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int n,k;cin>>n>>k;
	vector<int> a(n,0);
	for(int i = 0; i < k; i++) {
		int d;cin>>d;
		for(int j = 0; j < d; j++) {
			int x;cin>>x;
			a[x - 1] = 1;
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if (a[i] == 0)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
S = str(input())        
#S = "1700"
s0 = int(S[0:2])
s1 = int(S[2:4])
def MM(x):
    if 1<= x <= 12:
        return True
    else:
        return False
if MM(s0) == True:
    if MM(s1) == True:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if MM(s1) == True:
        print("YYMM")
    else:
        print("NA")

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

using namespace std;

int main()
{
  int a, b;

  scanf("%d %d", &a, &b);

  if ((a + b) % 2 == 0)
    printf("%d", (a + b) / 2);
  else
    printf("%d", (a + b) / 2 + 1);
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}
fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let n: u64 = input();
    let p_vec = input_vec();
    let mut min = std::u64::MAX;
    let mut count = 0;
    for p in p_vec {
        if p <= min {
            count += 1;
        }
        if p < min {
            min = p;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 10492
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vvl a = VV(n, 2, 0, ll);
  re(i, n){
    std::cin >> a[i][0];
    a[i][1] = i;
  }
  sort(all(a));
  reverse(all(a));
  vvl dp = VV(n+1, n+1, 0, ll);
  for(int i=1;i<=n;i++){
    vll now = a[i-1];
    //左にA個
    for(int j=0;j<i;j++){
      //L
      ll idx = j;
      dp[i][j+1] = max(dp[i][j+1], dp[i-1][j]+abs(now[1]-idx)*now[0]);
      //R
      ll amari = i-1-j;
      idx = n - 1 - amari;
      dp[i][j] = max(dp[i][j], dp[i-1][j]+abs(now[1]-idx)*now[0]);
    }
    //ll tmp = 0;
    //for(int j=0;j<=n;j++) tmp = max(tmp, dp[i][j]);
    //std::cout << tmp << '\n';
  }
  ll ans = 0;
  for(int i=0;i<=n;i++) ans = max(ans, dp[n][i]);
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 34544
import sys
from collections import deque, defaultdict
def input(): return sys.stdin.readline().strip()

def main():
    N, u, v = map(int, input().split())
    u -= 1
    v -= 1
    
    edges = [map(int, input().split()) for _ in range(N-1)]

    to = [[] for _ in range(N)]
    for a, b in edges:
        a -= 1
        b -= 1
        to[a].append(b)
        to[b].append(a)
    
    dist  = {key:defaultdict(int) for key in [u, v]}

    def bfs(key):
        q = deque()
        q.append(key)
        while(len(q)):
            now = q.popleft()
            for nv in to[now]:
                if nv == key or dist[key][nv]:
                    continue
                else:
                    dist[key][nv] = dist[key][now] + 1
                    q.append(nv)
    
    for key in [u, v]:
        bfs(key)
    
    ans = 0
    for i in range(N):
        diff = dist[v][i] - dist[u][i]
        if diff > 0:
            ans = max(ans, dist[v][i]-1)

    print(ans)    

if __name__ == "__main__":
    main()

Measured memory_bytes: 110172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll n,a,b;cin>>n>>a>>b;
    vl x(n);rep(i,n) cin>>x[i];
    ll ans=0;
    rep(i,n-1){
        ll d=x[i+1]-x[i];
        ans+=min(d*a,b);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
n=int(input())
p=[]
for i in range(n):
  p.append(input())
M=int(input())
m=[]
for i in range(M):
  m.append(input())

l=[]
for i in p:
  l.append(p.count(i)-m.count(i))
print(max(0,max(l)))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;
int n;
int a[10000];
int cou = 0;

bool prime(int m) {
	if (m == 1) return false;
	else if (m == 2) return true;
	else {
		for (int i = 2; i <= sqrt(m) + 1; i++) {
			if (m%i == 0) return false;
			
			
		}
		return true;
	}
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		if (prime(a[i])) cou++;
	}
	cout << cou << endl;

}

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

int main(){
    cin.tie(0);
    string s;
    cin >> s;
    int q;
    cin >> q;
    s.reserve(q);
    bool rev = 0;
    int x;
    int f;
    char c;
    string before;

    for(int i=0;i<q;i++){
        cin >> x;
        if(x==1){
            rev = !rev;
        }
        else{
            cin >> f >> c;
            if(f==1 and !rev){
                before += c;
            }
            else if(f==1 and rev){
                s += c;
            }
            else if(f==2 and !rev){
                s += c;
            }
            else{
                before += c;
            }
        }
    }

    reverse(before.begin(),before.end());
    before += s;
    auto itr=before.begin();
    auto end=before.end();
    if(!rev){
        cout << before << endl;
    }
    else{
        for(auto itr=before.rbegin();itr!=before.rend();itr++){
            cout << *itr;
        }
        cout << endl;
    }
}


Measured memory_bytes: 1148
#include <iostream>
#include <vector>
#include <string.h>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <sstream>
#include <stack>
#include <iomanip>
#include <climits>
#include <complex>
#include <cmath>
#define fi first
#define se second
#define th second

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, int> di;
typedef vector<int> vi;
typedef multiset<ll, greater<ll>>::iterator iit;
typedef pair<iit, iit> pvi;
typedef complex<double> cd;

const int maxN = 1e3 + 3, MOD = 1e9 + 9, LG = 21;
//NOTE: maxN>2^LG must be held, remember maxN is twice ur biggest polynom
/*
 HAB
 G C
 FED*/

ll n, arr[maxN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    
    cin >> n;
    ll amo;
    cin >> amo;
    for(int i = 0; i < n; i++){
        cin >> arr[i], amo -= arr[i];
    }
    sort(arr, arr + n);
    cout << n + amo / arr[0] << '\n';
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  N = 1e6 + 5;

struct node{
    ll x,y,u,v;
}a[N];

ll mx1=-1e18,mx2=-1e18,mx3=-1e18,mx4=-1e18,mi1=1e18,mi2=1e18,mi3=1e18,mi4=1e18;
int n;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i].x>>a[i].y;
        a[i].u=a[i].x+a[i].y;
        a[i].v=a[i].x-a[i].y;
        mx1=max(mx1,a[i].u);
        mi1=min(mi1,a[i].u);
        mx2=max(mx2,a[i].v);
        mi2=min(mi2,a[i].v);
    }
    cout<<max(mx1-mi1,mx2-mi2)<<'\n';
    return 0;
}


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

int main() {
  int A, B;
  char s[100000];
  scanf("%s", s);
  
  bool app[26];  //app[]="abc"は{a, b, c, \0}と同義
  for (int i = 0; i < 26; i++) {
      app[i] = false;
  }

  for (int i = 0; s[i] != '\0'; i++) { // \0は空
      app[s[i] - 'a'] = true;
  }

  for (int i = 0; i < 26; i++) {
      if(!app[i]) {
          printf("%c\n", (char)(i+'a'));
          return 0;
      }
  }
  puts("None"); 
  
}

Measured memory_bytes: 384
//Why 860?
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(v) ((int)v.size())
#define fill(x, v) memset(x, v, sizeof(x))
#define trace(x) cout << #x << " = " << x << endl
#define FER(i,x,y) for(int (i)=(x);(i)<(y); (i) ++)
#define IFR(i,x,y) for(int (i)=(x);(i)>=(y); (i) --)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define N 402
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef ll T;

char mx[N][N];
ii comp[N*N];
int vis[N][N];
int n, m;
int gid = 1;
int dx[4] = { -1, 1, 0, 0}, dy[4] = {0 ,0 , - 1, 1};

bool ok(int r, int s){
	if(r < 0 || s < 0 || r >=n || s>=m) return false;
	return true;
}

int main(){
	fastio;
	ll ans = 0;
	cin >> n >> m;
	FER(i, 0, n )FER(j ,0 ,m) cin >> mx[i][j];
	FER(i, 0, n) FER(j, 0, m){
		if(vis[i][j]) continue;
		if(mx[i][j] == '.') continue;
		queue< ii > q; q.push({i, j});
		vis[i][j] ++;
		while(!q.empty()){
			ii fr = q.front(); q.pop();
			int x = fr.ff, y = fr.ss;
			if(mx[x][y] == '#') comp[gid].ff ++;
			else comp[gid].ss ++;
			FER(k, 0, 4){
				int r = x + dx[k], s = y + dy[k];
				if(!ok(r,s) || vis[r][s]) continue;
				if(mx[r][s] == mx[x][y]) continue;
				vis[r][s] ++;
				q.push({r,s});
			}
		}
		ans += comp[gid].ff * comp[gid].ss;
		gid ++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int MAX = 100001;

vector<pair<int, int> > g[MAX];
int n;
int d[MAX];

void bfs(int v) {
    rep (i, MAX) d[i] = Inf;
    queue<int> q;
    q.push(v);
    d[v] = 0;
    while (!q.empty()) {
        int u = q.front(); 
        q.pop();
        rep (i, g[u].size()) {
            int x = g[u][i].first;
            int dist = g[u][i].second;
            if (d[x] != Inf) continue;
            d[x] = d[u] + dist; 
            q.push(x);
        }

    }
}

int main() {
    cin >> n;
    rep (i, n - 1) {
        int s, t, w;
        cin >> s >> t >> w;
        g[s].push_back(make_pair(t, w));
        g[t].push_back(make_pair(s, w));
    }
    bfs(0);
    int maxi = 0, next;
    rep (i, n) {
        if (d[i] == Inf) continue;
        if (maxi < d[i]) {
            maxi = d[i];
            next = i;
        }
    }
    bfs(next);
    maxi = 0;
    rep (i, n) {
        if (d[i] == Inf) continue;
        maxi = max(maxi, d[i]);
    }
    cout << maxi << endl;
    
    return 0;
}


Measured memory_bytes: 9768
import sys

H, W = map(int, input().split())
MAP = [list(input()) for i in range(H)]
gawa = ['.' for i in range(W)]
MAP.append(gawa)
MAP.insert(0, gawa)

for i in range(H+2):
    MAP[i].append('.')
    MAP[i].insert(0, '.')

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

for i in range(1, H+1):
    for j in range(1, W+1):
        if MAP[i][j] == '#':
            FRAG = 'No'
            for k in range(4):
                if MAP[i + dx[k]][j + dy[k]] == '#':
                    FRAG = True
            if FRAG != True:
                print(FRAG)
                sys.exit()

print('Yes')

            

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

int N, W;

int main() {
    cin >> N >> W;
    vector<pair<int, int>> item(N); //firstがweight, secondがvalue
    for (int i = 0; i < N; i++) {
        cin >> item[i].first >> item[i].second;
    }
    
    vector<vector<long long>> value(N, vector<long long>(W + 1));
    for (int i = item[0].first; i <= W; i++) {
        value[0][i] = item[0].second;
    }
    for (int i = 1; i < N; i++) {
      int weight = item[i].first;
        for (int j = 1; j <= W; j++) {
            if (j - weight >= 0) {
           	 value[i][j] = max(value[i - 1][j - weight] + item[i].second, value[i - 1][j]);
            } else {
              value[i][j] = value[i - 1][j];
            }
        }
    }
    cout << value[N - 1][W] << endl;
}

Measured memory_bytes: 79360
from collections import defaultdict

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
        
    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)
    


N,M,K = map(int, input().split())
uf = UnionFind(N)
friend = defaultdict(int)
block = defaultdict(int)

for _ in range(M):
    a,b = map(int, input().split())
    friend[a-1] += 1
    friend[b-1] += 1
    uf.union(a-1,b-1)

for _ in range(K):
    a,b = map(int, input().split())
    if uf.same(a-1,b-1):
        block[a-1] += 1
        block[b-1] += 1

result = [uf.size(i) - friend[i] - block[i] - 1 for i in range(N)]
print(' '.join(map(str, result)))

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


int main()
{
    int a, b;cin>>a>>b;
    if(a+b>=a-b&&a+b>=a*b){
        cout<<a+b;
    }
    else if(a-b>=a+b&&a-b>=a*b){
        cout<<a-b;
    }
    else
        cout<<a*b;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
bool f(int x){
    for (int i=2;i<=sqrtl(x);i++){
        if (x%i==0)
            return false;
    }
    return true;
}
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    for (int i=x;;i++){
        if (f(i)){
            cout<<i;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i;
    int ans=0;
    char S[4];
    char T[4];
    scanf("%s",S);
    scanf("%s",T);
    for(i=0;i<3;i++){
    if(T[i]==S[i]){
        ans++;
    }
    }
    printf("%d",ans);
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int H, W, a = 0;
	cin >> H >> W;
	vector<string> s(H);
	for (string& i : s) {
		cin >> i;
		a += count(i.begin(), i.end(), '#');
	}
	queue<pair<int, int>> b;
	b.emplace(0, 0);
	vector<vector<int>> c(H, vector<int>(W, -1));
	c[0][0] = 0;
	while (!b.empty()) {
		if (0 < b.front().first) {
			if ('.' == s[b.front().first - 1][b.front().second] && -1 == c[b.front().first - 1][b.front().second]) {
				b.emplace(b.front().first - 1, b.front().second);
				c[b.front().first - 1][b.front().second] = 1 + c[b.front().first][b.front().second];
			}
		}
		if (0 < b.front().second) {
			if ('.' == s[b.front().first][b.front().second - 1] && -1 == c[b.front().first][b.front().second - 1]) {
				b.emplace(b.front().first, b.front().second - 1);
				c[b.front().first][b.front().second - 1] = 1 + c[b.front().first][b.front().second];
			}
		}
		if (H - 1 > b.front().first) {
			if ('.' == s[1 + b.front().first][b.front().second] && -1 == c[1 + b.front().first][b.front().second]) {
				b.emplace(1 + b.front().first, b.front().second);
				c[1 + b.front().first][b.front().second] = 1 + c[b.front().first][b.front().second];
			}
		}
		if (W - 1 > b.front().second) {
			if ('.' == s[b.front().first][1 + b.front().second] && -1 == c[b.front().first][1 + b.front().second]) {
				b.emplace(b.front().first, 1 + b.front().second);
				c[b.front().first][1 + b.front().second] = 1 + c[b.front().first][b.front().second];
			}
		}
		b.pop();
	}
	if (-1 == c.back().back()) cout << -1;
	else cout << H * W - 1 - a - c.back().back();
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main
{
	
	private void solve()throws Exception
	{
		int n=nextInt();
		BigInteger ans=new BigInteger("1");
		long a[]=new long[n+1];
		boolean flag=true;
		for(int i=1;i<=n;i++)
		{
			a[i]=nextLong();
			if(a[i]==0)
				flag=false;
		}
		if(!flag)
		{
			out.println(0);
			return;
		}
		for(int i=1;i<=n;i++)
		{
			BigInteger x=new BigInteger(Long.toString(a[i]));
			ans=ans.multiply(x);
			if(ans.compareTo(new BigInteger("1000000000000000000"))>0)
			{
				out.println(-1);
				return;
			}
		}
		out.println(ans);
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}

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

int main() {
 int a,b;
  cin>>a>>b;
  int count=0;
  for(int i=a;a<=b;i++){
    if(a%10==a/10000&&a%100/10==a/1000%10){
      count++;
    }
    a++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n,i;
    while(~scanf("%d",&n))
    {
        int a[3010],sum=0;

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

        printf("%d\n",sum-n);
    }

}


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

int main(){
    int ans = 0;
    vector<int> data(3);
    vector<int> dif(2);
    cin >> data[0] >> data[1] >> data[2];
    sort(data.begin(),data.end());

    dif[0] = data[2] - data[0];
    dif[1] = data[2] - data[1];

    dif[0] -= dif[1];
    ans += dif[1];
    if(dif[0] % 2 == 0) ans += dif[0] / 2;
    else ans += 2 + (dif[0] - 1) / 2;
    cout << ans << endl;
    return 0;
}


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

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	string a;
	int i;
	bool q=true;
	cin>>a;
	for (i=0;2*i<a.size()-1;i++){
		if (a[i]!=a[a.size()-1-i]){
			q=false;
			break;
		}
	}
	if (q==true){
		cout<<"Yes";
	}
	else {
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
ans=[]
if n%2:
  for i in range(m):
    ans.append("{} {}".format(i+1,n-i))
else:
  for i in range(m):
    if i+1<=m//2+m%2:
      ans.append("{} {}".format(i+1,n-i))
    else:
      ans.append("{} {}".format(i+1,n-1-i))
print("\n".join(ans))

Measured memory_bytes: 17448
import Control.Monad
import Control.Monad.ST

import Data.Array.ST
import Data.Array.Unboxed

type Idx = (Int,Int)
type STDp s  = STUArray s Idx Int

main = do
    [n,a] <- map read.words<$>getLine::IO[Int]
    ys <- map (flip(-)a.read).words<$>getLine::IO[Int]
    --
    print $ solve n a ys
--
solve :: Int -> Int -> [Int] -> Int
solve n a ys = runST $ do
    dp <- newArray ((0,lb),(n,ub)) 0 :: ST s (STDp s)
    writeArray dp (0,0) 1
    forM_ [(j,i,y)| (j,y)<-zip [1..] ys, i<-[lb..ub]]  $ \(j,i,y) -> do
        if i-y<lb || i-y>ub
            then writeArray dp (j,i) =<< readArray dp (j-1,i)
            else writeArray dp (j,i) =<< (+) <$> readArray dp (j-1,i) <*> readArray dp (j-1,i-y)
    (+ (-1)) <$> readArray dp (n,0)
    where
        lb = n*a*(-1)
        ub = n*a

Measured memory_bytes: 3068
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
const long D = 1000000007;

int main()
{
  string o, e;
  cin >> o >> e;
  while (o.length() > 0 && e.length() > 0)
  {
    cout << o[0] << e[0];
    o.erase(o.begin());
    e.erase(e.begin());
  }
  if (o.length() > 0)
  {
    cout << o[0];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            sS = System.Console.ReadLine().Trim().Split(' ');

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            List<char> cOut = new List<char>();
            for (int i = 0; i < sS[0].Length; i++)
            {
                cOut.Add(sS[0][i]);
                cOut.Add(sS[1][i]);
            }
            string sOut = new string(cOut.ToArray());

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
#include <iostream>

using namespace std;

int main(){
  int N, T;
  cin >> N >> T;
  int ans = 10000;
  for(int i=0;i<N;i++){
    int c, t;
    cin >> c >> t;
    if(t<=T && c < ans){
      ans = c;
    }
  }
  if(ans!=10000){
    cout << ans << endl;
  }else{
    cout << "TLE" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

ll dp[110][110000];

int main() {
    cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(20);

    ll N, W; cin >> N >> W;
    vll w(N+1), v(N+1);
    rep(i,N) cin >> w[i+1] >> v[i+1];

    for(ll i = 1; i <= N; i++) {
        for(ll j = 0; j <= W; j++) {
            dp[i][j] = dp[i-1][j];
            if(j-w[i] >= 0) chmax(dp[i][j], dp[i-1][j-w[i]] + v[i]);
        }
    }
    ll ans = 0;
    rep(j, W+1) chmax(ans, dp[N][j]);
    cout << ans << endl;
}


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

int menu[5] , sum , ans = 643;
bool v[5];

void chack(int t , int x){
    if(x == 4){
        for(int i=0 ;i<5 ;i++ ){
            if(v[i] == false){
                ans = min (ans , t+menu[i]);
            }
        }
    } else {
        for(int i=0 ;i<5 ;i++ ){
            if(v[i] == false){
                sum = (menu[i] / 10) * 10;
                if(menu[i] % 10 > 0){
                    sum +=10;
                }
                v[i] = true;
                chack(t+sum , x+1);
                v[i] = false;
            }
        }
    }    
}

signed main(){
    for(int i=0 ;i<5 ;i++ ){
        cin >> menu[i];
    }
    
    for(int i=0 ;i<5 ;i++ ){
        chack(0 , 0);
    }
    
    cout << ans << endl;
    return(0);
}

Measured memory_bytes: 256
N = int(input())
A = input()
B = input()
C = input()
count = 0
for i in range(N):
	if A[i] == B[i]:
		if A[i] != C[i]:
			count += 1
	elif B[i] == C[i]:
		if B[i] != A[i]:
			count += 1
	elif C[i] == A[i]:
		if C[i] != B[i]:
			count += 1
	else:
		count += 2


print(count)

Measured memory_bytes: 3064
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
  }

  return sum;
}

/*考えを書くスペース
案その１
・まず奇数だけの場合を考える
・P=0の時、全体から奇数だけの場合を引いたものを出力する
　P=1の時、奇数だけの場合を出力する
没案
・bit全探索・・・せいぜいN=25までくらいが限界
・再帰全探索・・・時間が間に合わない
*/
//main.cpp----------------------------
#define max_n 20
#define max_q 200

void solve();
bool dfs(int, int, int);

ll n, q;
ll a[max_n+1];
ll m[max_q+1];

int main() {
  cin >> n;
  rep(i, n) cin >> a[i];
  cin >> q;
  rep(i, q) cin >> m[i];


  solve();

  return 0;
}

void solve() {

  for(int i=0; i<q; ++i) {
    if(dfs(0,0,m[i])) {
      cout << "yes" << endl;
    }else {
      cout << "no" << endl;
    }
  }
}

bool dfs(int i, int sum, int k) {

  if(sum==k) {
    return true;
  }else if(sum>k) {
    return false;
  }else if(i==n) {
    return false;
  }else {
    if(dfs(i+1, sum+a[i], k)||dfs(i+1, sum, k)) {
      return true;
    }else {
      return false;
    }
  }
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
const ll INF = 1001001001001;

int main(){
    ll n; cin >> n;
    if(n%2==0) cout << n << endl;
    else cout << 2*n << endl;
}



Measured memory_bytes: 256
import java.util.*;
class Main {
	public static void main(String[] abcdefg) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		if(n%1000==0)System.out.print(0);
		else System.out.print(1000-n%1000);
		sc.close();
		   
	}
}



Measured memory_bytes: 35664
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;

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

int N, Q;

vector<int> G[200010];
int	X[200010];
int ans[200010];

void dfs(int cur, int par, int sum)
{
	ans[cur] = X[cur] + sum;

	// leaf
	if (G[cur].size() == 1 and G[cur][0] == par) return;

	for (int &nxt : G[cur]) {
		if (nxt == par) continue;
		dfs(nxt, cur, sum + X[cur]);
	}
}

signed main()
{
	cin >> N >> Q;

	rep(i, N-1) {
		int a, b; cin >> a >> b;
		--a,--b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	rep(i, Q) {
		int p, x; cin >> p >> x;
		--p;
		X[p] += x;
	}

	dfs(0, -1, 0);

	rep(i, N) printf("%lld%c", ans[i], i==N-1?'\n':' ');
}


Measured memory_bytes: 25600
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int dp[3001][3001];

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

    int n = s.length(), m = t.length();
    for(int i=0;i<=n;++i) {
        for(int j=0;j<=m;++j) {
            if(i < n && j < m && s[i] == t[j]) {
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);
            }
            if(i < n) dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if(j < m) dp[i][j+1] = max(dp[i][j+1], dp[i][j]);
        }
    }

    string ans = string(dp[n][m], ' ');
    int l = dp[n][m];
    int last_i = n+1, last_j = m+1;
    for(int i=last_i-1;i>=1;--i) {
        for(int j=last_j-1;j>=1;--j) {
            if(dp[i][j] == l && dp[i-1][j] < l && dp[i][j-1] < l) {
                ans[l-1] = s[i-1];
                --l;
                last_i = i;
                last_j = j;
                break;
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 35456
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  ll s;
  cin>>s;
  
  int mi=1000;
  while(s>=100){
    mi=min(mi,abs(753-int(s%1000)));
    s/=10;
  }
  
  cout<<mi<<endl;

  return 0;
}

Measured memory_bytes: 3556
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s,t;
	char c;
	int i,j,mi,f=-1;
	cin >> s >> t;
	for(i=0;i<s.size()-1;i++){
		for(j=i+1;j<s.size();j++){
			if(s[i]>s[j]){
				c=s[i];
				s[i]=s[j];
				s[j]=c;
			}
		}
	}
	for(i=0;i<t.size()-1;i++){
		for(j=i+1;j<t.size();j++){
			if(t[i]<t[j]){
				c=t[i];
				t[i]=t[j];
				t[j]=c;
			}
		}
	}

	mi=s.size();
	if(mi>t.size())
		mi=t.size();
	for(i=0;i<mi;i++){
		if(s[i]>t[i]){
			f=0;
			break;
		}
		if(s[i]<t[i]){
			f=1;
			break;
		}
	}
	if(f==-1 && s.size()<t.size())
		f=1;
	if(f==1)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<math.h>
# define M_PI 3.14159265358979323846
using namespace std;
int main()
{
    double t,n,p,r;
    cin>>t;
    r=2*M_PI*t;
      cout<<fixed<<setprecision(20)<<r<<endl;


    return 0;
}


Measured memory_bytes: 3784
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,1)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a)
	{
		return parent[a]!=a?parent[a]=find(parent[a]):a;
	}
	bool same(int a,int b)
	{
		return find(a)==find(b);
	}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
			rank[b]+=rank[a];
		}
		else
		{
			parent[b]=a;
			rank[a]+=rank[b];
		}
		return true;
	}
};
vector<pair<int,int> >A;
int N,H,W;
long f()
{
	long ret=0;
	vector<vector<int> >G(H);
	vector<bool>ap(W,false);
	for(pair<int,int>p:A)
	{
		G[p.first].push_back(p.second);
		ap[p.second]=true;
	}
	UF uf(W);
	for(int i=0;i<H;i++)
	{
		for(int j=1;j<G[i].size();j++)uf.unite(G[i][j-1],G[i][j]);
	}
	vector<int>B;
	int cnt=0;
	for(int i=0;i<W;i++)
	{
		if(!ap[i])continue;
		cnt++;
		B.push_back(uf.find(i));
	}
	sort(B.begin(),B.end());
	B.erase(unique(B.begin(),B.end()),B.end());
	ret+=N-cnt;
	ret+=cnt-B.size();
	if(B.size()<=1)return ret;
	set<int>L,R;
	for(int g:G[0])L.insert(uf.find(g));
	for(int g:G[H-1])R.insert(uf.find(g));
	cnt=0;
	for(int b:B)cnt+=L.find(b)!=L.end();
	long get=2*(long)B.size()-cnt-1;
	cnt=0;
	for(int b:B)cnt+=R.find(b)!=R.end();
	get=min(get,2*(long)B.size()-cnt-1);
	return ret+get;
}
main()
{
	cin>>N>>H>>W;
	for(int i=0;i<N;i++)
	{
		int x,y;cin>>x>>y;
		x--,y--;
		A.push_back(make_pair(x,y));
	}
	long ans=f();
	for(pair<int,int>&p:A)
	{
		swap(p.first,p.second);
	}
	swap(H,W);
	ans=min(ans,f());
	cout<<ans<<endl;
}



Measured memory_bytes: 7884
#include<stdio.h>
#include<string.h>

#define M 1000000/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+key%(M-1); }

int find(char str[]){
  int i, j, n;
  i=0;
  n=getKey(str);
  while(1){
    j = (h1(n)+h2(n)*i)%M;
    if(strcmp(H[j],str)==0) return 1;
    else if(H[j][0]=='\0' || i>=M) return 0;
    else i=i+1;
  }
  return 0;

}

int insert(char str[]){
  int i, j, n;
  i=0;
  n=getKey(str);
  while(1){
    j = (h1(n)+h2(n)*i)%M;
    if(strcmp(H[j],str)==0) return 1;
    else if(H[j][0]=='\0' || i>=M){
      strcpy(H[j],str);
      return 0;
    }
    else i=i+1;
  }
  return 0;

}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 14280
using System;

class main
{
    public static int Main()
    {
        string input = Console.ReadLine();
        string[] str = input.Split(' ');
        int w = int.Parse(str[0]);
        int h = int.Parse(str[1]);
        int x = int.Parse(str[2]);
        int y = int.Parse(str[3]);
        int r = int.Parse(str[4]);

        if (0 <= (x - r) && (x + r) <= w && 0 <= (y - r) && (y + r) <= h)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }

        return 0;

    }
}

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


int main()
{
  string a,b;
  cin >> a >> b;
  bool bl = true;

    for(int i=0; i<b.size()-1;i++){
        if(a[i]!=b[i])
            bl = false;
    }

    if(bl==true)cout <<"Yes"<<endl;
    else cout <<"No"<<endl;

  return 0;
}




Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main(){
  int n,i;
  int mx = -1;
  string s;
  map<string,int> buf;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> s;
    if(buf[s] == NULL) buf[s] = 0;
    buf[s]++;
    if(buf[s] > mx) mx = buf[s];
  }
  for(auto itr = buf.begin(); itr != buf.end(); itr++){
    if(itr -> second == mx){
      cout << itr->first << endl;
    }
  }
  return 0;
}


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

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> h(n);
	for(int i=0;i<n;i++)
		cin >> h[i];

	sort(h.begin(),h.end());
	
	int ans=h[n-1]-h[0];
	for(int i=0;i<=n-k;i++)
	{
		if(ans>h[i+k-1]-h[i])
		{
			ans=h[i+k-1]-h[i];
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author OmarYasser
 */
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);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner sc, PrintWriter out) {
            int n = sc.nextInt(), m = sc.nextInt();
            int[][] res = new int[n][m];
            int i = 0, j = 0, num = 1, parity = 0;
            int N = sc.nextInt();
            while (N-- > 0) {
                int a = sc.nextInt();
                while (a-- > 0) {
                    res[i][j] = num;
                    if (parity == 0) {
                        j++;
                        if (j == m) {
                            parity = 1;
                            j = m - 1;
                            i++;
                        }
                    } else {
                        j--;
                        if (j == -1) {
                            parity = 0;
                            j = 0;
                            i++;
                        }
                    }
                }
                num++;
            }
            for (int r = 0; r < n; r++) {
                for (int c = 0; c < m; c++) {
                    if (c > 0) out.print(" ");
                    out.print(res[r][c]);
                }
                out.println();
            }
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader f) {
            br = new BufferedReader(f);
        }

        public String next() {
            while (st == null || !st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 23892
#include <stdio.h>

#define LOOP_END 0
#define EXIT_SUCCESS 0
#define INF_LOOP while(1)

int main( void )
{
	unsigned long ulW_Dtc_x;				/*???????????±??????X*/
	unsigned long ulW_Dtc_y;				/*???????????±??????Y*/
	unsigned long ulW_Dcalc;				/*????\???¨?????°*/

	scanf("%ld %ld", &ulW_Dtc_x, &ulW_Dtc_y);	/*???????????±????????\???*/
	/*Y???X??\????????´???X??¨Y?????\?????????*/
	if( ulW_Dtc_x <= ulW_Dtc_y ){
		ulW_Dcalc = ulW_Dtc_x;
		ulW_Dtc_x = ulW_Dtc_y;
		ulW_Dtc_y = ulW_Dcalc;
	}

	/*?????§??¬?´???°?¨??????¨?????????*/
	INF_LOOP{
		ulW_Dcalc = ulW_Dtc_x % ulW_Dtc_y;	/*????\???¨?????°???X % Y??????????????????*/
		/*?¨?????????????0?????´???*/
		if( ulW_Dcalc == LOOP_END){
			break;							/*?????????????????????*/
		}
		ulW_Dtc_x = ulW_Dtc_y;				/*X???Y????????????*/
		ulW_Dtc_y = ulW_Dcalc;				/*Y???????\???¨?????°(X % Y)????????????*/
	}
	printf("%ld\n", ulW_Dtc_y);				/*?????§??¬?´???°?????????*/

	return EXIT_SUCCESS;
}

Measured memory_bytes: 592
#include <iostream>
#include <cmath>
using namespace std;
using uint = unsigned int;

int main() {
	uint N, K, S;
	cin >> N >> K >> S;
	
	uint dans = (S == pow(10, 9)) ? pow(10, 9) - 1 : pow(10, 9); 
	
	for(uint i=0; i<N; i++) {
		if(i < K) {
			cout << S << " "; 
		} else {
			cout << dans << " ";
		}
	}
	
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll h,w;
char s[2000][2000];
pair<ll,ll> a[2000][2000];
ll hashr[2000][2000],hashc[2000][2000];
void solve()
{
    ll b=-1,cnt = 0;
    for(ll i=0;i<h;i++)
    {
		cnt=0;
		b=-1;
        for(ll j=0;j<w;j++)
        {
            if(j==hashr[i][cnt])
            {
                a[i][j].first=-1;
                cnt++;
                b=hashr[i][cnt-1];
            }
            else
            {
                a[i][j].first = hashr[i][cnt]-b-1;
            }
            
        }
        
    }
   
    for(ll i=0;i<w;i++)
    {
		cnt=0;
		b=-1;
        for(ll j=0;j<h;j++)
        {
            if(j==hashc[i][cnt])
            {
                a[j][i].second=-1;
                cnt++;
                b=hashc[i][cnt-1];
            }
            else
            {
                a[j][i].second = hashc[i][cnt]-b-1;
            }
            
        }
     
    }
    
    ll max1=-1;
    for(ll i=0;i<h;i++)
    {
        for(ll j=0;j<w;j++)
        {
        	if(s[i][j]=='.')
            max1 = max(max1 , a[i][j].first + a[i][j].second - 1);
        }
    }
    
    cout<<max1;
}
int main() {
	
	ll cnt=0;
	cin>>h>>w;
	for(ll i=0;i<h;i++)
	{
	    cnt = 0;
	    for(ll j=0;j<w;j++)
	    {
	        cin>>s[i][j];
	        if(s[i][j]=='#')
	        {
	            hashr[i][cnt++]=j;
	            
	        }
	        
	    }
	    hashr[i][cnt] = w;
	    
	}
	
	for(ll i=0;i<w;i++)
	{
	    cnt = 0;
	    for(ll j=0;j<h;j++)
	    {
	        
	        if(s[j][i]=='#')
	        {
	            hashc[i][cnt++]=j;
	        }
	        
	    }
	    hashc[i][cnt] = h;
	}
	solve();
	return 0;
}


Measured memory_bytes: 129152
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int N, X;
    cin >> N >> X;

    vector<int> p(N + 1);
    p[0] = 1;
    FOR(i, 1, N) {
        p[i] = p[i - 1] * 2 + 1;
    }

    vector<int> sum(N + 1);
    sum[0] = 1;
    FOR(i, 1, N) {
        sum[i] = sum[i - 1] * 2 + 3;
    }

    int ans = 0;
    REV(i, N, 0) {
        if (X <= 0) break;
        if (X == sum[i]) {
            ans += p[i];
            X -= sum[i];
            continue;
        }
        if (X > sum[i]) {
            ans += p[i] + 1;
            X -= sum[i] + 1;
            i++;
            continue;
        }

        X -= 1LL;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
using namespace std;
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
typedef long long ll;
const ll inf = 0x3f3f3f3f3f3f3f3f;
#define ull unsigned long long
const int maxn = 1e6+10;
const ll mod=1e9+7;
#define MAXN 40100
ll gcd(ll T, ll b) { return b == 0 ? T : gcd(b, T % b); }
ll lcm(ll T, ll b) { return T / gcd(T, b) * b; }
ll mul(ll a,ll b, ll c) {
    ll ans = 0;
    while(b) {
        if(b&1) {
            ans= (ans+a)%c;
            b--;
        }
        b>>=1;
        a=(a+a)%c;
    }
    return ans;
}
 
ll powmod(ll a,ll b,ll c) {
    ll ans = 1;
    while(b) {
        if(b&1) {
            ans = mul(ans,a,c);
            b--;
        }
        b>>=1;
        a=mul(a,a,c);
    }
    return ans ;
}
 
ll exgcd(ll a,ll b,ll &x,ll &y) {
    if(b==0)
    {
        x=1;y=0;
        return a; 
    }
    ll r=exgcd(b,a%b,x,y);
    ll temp=y;
    y=x-(a/b)*y;
    x=temp;
    return r;
}

const ll INF = 0x3f3f3f3f3f3f3f3f;


int main() {
    char s[1050],t[1050];
    cin>>s>>t;
    int len1=strlen(s),len2=strlen(t);
    int maxx=-1;
    for(int i=0;i<=len1-len2;i++) {
        int cnt=0;
        for(int j=0;j<len2;j++) {
            if(s[i+j]==t[j]) {
                cnt++;
            }
        }
        maxx=max(maxx,cnt);
    } 
    cout<<len2-maxx<<endl;
    return 0;
}






Measured memory_bytes: 3564
n = input()
n = int(n)
a = n % 10
if n > 999:
    exit()
if a == 2 or a==4 or a==5 or a==7 or a==9:
    print("hon")
elif a==0 or a==1 or a==6 or a==8:
    print("pon")
elif a==3:
    print("bon")

Measured memory_bytes: 9180
#include<stdio.h>
int main()
{
    long n;
    long long m;
    scanf("%li %I64d",&n,&m);
    long i=m/n;
    while(i>1)
    {
        if(m%i==0)
            break;

        i--;
    }
    printf("%li\n",i);
    return 0;
}


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

using namespace std;

#define lint long long

int main(){
    vector<int> A(3);
    cin >> A[0] >> A[1] >> A[2];
    
    sort(A.begin(), A.end());
    
    
    if((A[1] + A[0]) % 2 == 0){
        cout << (2 * A[2] - A[1] - A[0]) / 2 << endl;
    } else {
        cout << (2 * A[2] - A[1] - A[0]) / 2 + 2 << endl;
    }
}

Measured memory_bytes: 256
mod=1000000007
#from https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2019/0106_educational_dp_2

n=int(input())
dp=[0] * (1<<n)
dp[0]=1
curr={0}
for i in range(n):
    compatibilities=[1<<i for i,v in enumerate(input().split()) if v=="1"]
    nxt=set()
    for k in curr:
        p=dp[k]%mod
        for c in compatibilities:
            if k&c: continue
            dp[k|c]+=p
            nxt.add(k|c)
    curr=nxt

print(dp[(1<<n)-1]%mod)


Measured memory_bytes: 137188