akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r;








void sol()
{   string a,b;
    cin>>a>>b;
    n=a.size();
    m=b.size();
    if(n+1!=m){cout<<"No";return ;}
    
    int f=1;
    fo(i,n)if(a[i]!=b[i])f=0;
    
    cout<< (f?"Yes":"No") <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

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



ll n, m;

int main(){
	cin >> n >> m;
	
	vector<int> v = {-1,-1,-1};
	for ( int i = 0; i < m; i++ ){
		int s, c;
		cin >> s >> c;
		s--;
		if ( s < n && (v[s] == -1 || v[s] == c) ){
			v[s] = c;
		}
		else {
			cout << -1 << endl;
			return 0;
		}
	}
	
	if ( n == 1 ){
		if ( v[0] == -1 )
			v[0] = 0;
		cout << v[0] << endl;
	}
	else {
		if ( v[0] == 0 ){
			cout << -1 << endl;
		}
		else {
			if ( v[0] == -1 ){
				v[0] = 1;
			}
			ll result = 0;
			
			for ( int i = 0; i < n; i++ ){
				result *= 10;
				if ( v[i] == -1 )
					v[i] = 0;
				result += v[i];
			}
			
			cout << result << endl;
		}
	}
	
	
	return 0;
}



Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let k = it.next().unwrap().parse::<i32>().unwrap();
    let t = it.next().unwrap().parse::<usize>().unwrap();
    let m = (0..t).map(|_| it.next().unwrap().parse::<i32>().unwrap()).max().unwrap();
    println!("{}", std::cmp::max(0, m-(k-m)-1));
}


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

int main()
{
    int N; cin>>N;
    map<long, int> x;
    long s=0;
    for(int i=0; i<N; ++i) {
        int a;
        cin>>a;
        x[s+=a]++;
    }
    long res=x[0];
    for(auto& p: x) {
        long t=p.second;
        res+=(t-1)*t/2;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 12800
#include <iostream>

using namespace std;

int p[30];

int main()
{
	int res, n, i;
	cin>>n;
	for (i=1; i<=n; i++) cin>>p[i];
	res = 0;
	for (i=2; i<n; i++) if (p[i-1] < p[i] && p[i] < p[i+1] || p[i+1] < p[i] && p[i] < p[i-1]) res ++;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
 
  int main(){
     int N , T;
scanf("%d%d",&N,&T);
int cost = 1e9;
for(int i =0  ;i < N ; ++i){
int x , t;
scanf("%d%d",&x,&t);
if(t <= T)cost = min(cost , x);
}
if(cost == 1e9)printf("TLE");
else printf("%d",cost);
  }

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

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  
  if(s.size() <= k){
    cout << s << endl;
  }
  else{
    for(int i=0; i<k; i++){
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
  
	return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>

int main(){

    int ans = 0;

    int N;
    scanf("%d", &N);

    int V[N], C[N],gain[N];

    for (int i = 0; i < N; i++){
        scanf("%d", &V[i]);
    }

     for (int i = 0; i < N; i++){
        scanf("%d",&C[i]);
    }

    for (int i = 0; i < N; i++){
        gain[i] = V[i] - C[i];
    }

    for (int i = 0; i < N; i++){

        if(gain[i] > 0){
            ans += gain[i];
        }
    }

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt();
	    int k=sc.nextInt();
	    LinkedList<Long> l=new LinkedList<>();
	    
	    for(int i=1;i<=k;i++) {
	    	l.add(sc.nextLong());
	    }
	    
        for(int i=k+1;i<=n;i++) {
	    	long tmp=sc.nextLong();
	    	if(l.poll()<tmp) System.out.println("Yes");
	    	else  System.out.println("No");
	    	l.add(tmp);
	    }
	    
	

	    
	}
}


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

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    multiset<ll> x;
    for(int i = 0; i < n; ++i){
        ll a;
        cin >> a;
        auto it = x.lower_bound(a);
        if(it == x.begin()){
            x.insert(it, a);
        }else{
            x.erase(--it);
            x.insert(++it, a);
        }
    }
    cout << x.size() << endl;
    return 0;
}


Measured memory_bytes: 4992
const inputText = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split(/\s/)
  .map((i) => parseInt(i));

const left = inputText[0] + inputText[1];
const right = inputText[2] + inputText[3];

if (left < right) {
  console.log("Right");
} else if (left > right) {
  console.log("Left");
} else {
  console.log("Balanced");
}


Measured memory_bytes: 11468
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
n=N()
l=L()
sx=0
for i in l:
    sx^=i
ans=[]
for i in l:
    ans.append(sx^i)
print(" ".join(map(str,ans)))

Measured memory_bytes: 116044
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 110
#define int long long
using namespace std;
int n ,a[N][N] ,vis[N] ,ans ,res ,tmp ,x ,y;
void check(){
    for(int i = 1 ; i <= n ; ++ i)
        for(int j = 1 ; j <= n ; ++ j){
            if(a[i][j] == -1) continue;
            if(vis[i] == 1 && vis[j] == 1 && a[i][j] == 0) return ;
            if(vis[i] == 1 && vis[j] == 0 && a[i][j] == 1) return ;
        }
    int res = 0;
    for(int i = 1 ; i <= n ; ++ i) res += vis[i];
    ans = max(ans ,res);
}
void dfs(int x){
    if(x == n + 1) {check() ;return;}
    vis[x] = 0;
    dfs(x + 1);
    vis[x] = 1;
    dfs(x + 1);
}
signed main(){
    scanf("%lld" ,&n);
    memset(a ,-1 ,sizeof(a));
    for(int i = 1 ; i <= n ; ++ i) {
        scanf("%lld" ,&tmp);
        for(int j = 1 ; j <= tmp ; ++ j) scanf("%lld%lld" ,&x ,&y) ,a[i][x] = y;
    }
    dfs(1);
    printf("%lld" ,ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		HashSet<Integer> A = new HashSet<>();
		for(int i = 0;i < N;i++){
			A.add(sc.nextInt());
		}
		sc.close();
		System.out.println(A.size()==N ? "YES" : "NO");

	}

}

Measured memory_bytes: 99872
#include<bits/stdc++.h>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;
int main(){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d;
    e=a+b;
    f=c+d;
    if(e>f) cout<<"Left"<<endl;
    else if(e==f) cout<<"Balanced"<<endl;
    else cout<<"Right"<<endl;
}

Measured memory_bytes: 256
<?php
list($k, $a, $b) = ints();
if ($b - $a <= 2) exit((string) ($k + 1));
echo 1 + min($k, $a - 1) + intdiv($k - min($k, $a - 1), 2) * ($b - $a) + ($k - min($k, $a - 1)) % 2;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16348
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(m)]

lst=[1]*n
anslst=[0]*n
anslst[0]=1

for x,y in xy:
    x,y=x-1,y-1
    if anslst[x]==1:
        anslst[y]=1
    lst[x]-=1
    lst[y]+=1
    if lst[x]==0:
        anslst[x]=0

print(sum(anslst))

Measured memory_bytes: 90956
import java.util.Scanner;


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

		int a, b;
		boolean exist;

		for(int i = 0;;i++){
			a = sc.nextInt();
			b = sc.nextInt();
			if(a == 0 && b == 0) break;
			exist = false;

			if(i != 0) System.out.println();
			for(int j = a; j <= b; j++){
				if((j % 4 == 0 && j % 100 != 0) || j % 400 == 0){
					System.out.println(j);
					exist = true;
				}
			}

			if(exist == false) System.out.println("NA");
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  cin>>n;
  vector<int> h(n);
  int i=0;
  for(int i=0;i<n;i++)
  {
    cin>>h[i];
  }
  
  vector<int> cost(n);
  for(int i=0;i<n;i++)
  {
    if(i==0)
      cost[i]=0;
    else if(i==1)
      cost[i]=abs(h[i]-h[i-1]);
    else
      cost[i]=min(cost[i-1]+abs(h[i]-h[i-1]),cost[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<cost[n-1]<<endl;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef double ld;
ll a[100005];
int main()
{ 
ios_base::sync_with_stdio(false);

cin.tie(NULL);
//freopen("input.txt", "r", stdin);
//freopen("output.txt","w",stdout);
ll a,b;
cin>>a>>b;
if(a>8||b>8)
{
	cout<<":(";
}
else cout<<"Yay!";
return 0;
}       

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

using namespace std;

int main()
{
  int N, M;
  string S[100];
  int sum[10002] = {};

  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    cin >> S[i];
  }

  for(int i = 0; i < M; i++) {
    for(int j = 0; j < N; j++) {
      if(S[i][j] == 'W') ++sum[j + 1];
    }
  }

  for(int i = 1; i <= N; i++) {
    sum[i] += sum[i - 1];
  }

  int ret = 1 << 30;

  for(int i = 0; i <= N; i++) {
    ret = min(ret, M * i - 2 * sum[i]);
  }

  for(int i = 0; i <= N; i++) {
    if(ret == M * i - 2 * sum[i]) {
      cout << i << " " << i + 1 << endl;
      break;
    }
  }

}

Measured memory_bytes: 4540
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int n;
int a[105];
int minx = 0x3f3f3f3f;
int main(){
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a+1,a+1+n);
	for(int i = 1; i <= a[n]; i++){
		int cnt = 0;
		for(int j = 1; j <= n; j++){
			cnt += pow(a[j]-i,2);
		}
			if(cnt <= minx) minx = cnt;
	}
	cout << minx << endl;
}


Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d", $x);
$base=100;
$ans =0;

if($x==100){
echo 0;
}else{
for($i=0;$i<$x;++$i){
  $base=floor($base*1.01);
  if($base < $x){
  $ans=$ans+1;
  }else{
  echo $ans+1;
    break;
  }  
}
}

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

int main() {
  int n;
  cin>>n;
  vector<int>a(n),b(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    if(b[i]<=a[n/2-1])cout<<a[n/2]<<endl;
    else cout<<a[n/2-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3840
/*
 * Articulation Points
 * Find articulation points of a given undirected graph G(V,E).
 *
 * A vertex in an undirected graph is an articulation point (or cut vertex) iff
 * removing it disconnects the graph.
 *
 * Input
 * |V| |E|
 * s0 t0
 * s1 t1
 * :
 * s|E|−1 t|E|−1
 * , where |V| is the number of vertices and |E| is the number of edges in the
 * graph. The graph vertices are named with the numbers 0, 1,..., |V|-1
 * respectively.
 *
 * si and ti represent source and target verticess of i-th edge (undirected).
 *
 * Output
 * A list of articulation points of the graph G ordered by name.
 *
 * Constraints
 * 1 ≤ |V| ≤ 100,000
 * 0 ≤ |E| ≤ 100,000
 * The graph is connected
 * There are no parallel edges
 * There are no self-loops
 */

#include <algorithm>
#include <iostream>
#include <set>
#include <stack>

#define MAXN 101000
#define MAXM 101000

using namespace std;

struct edge {
  int to, next;
} E[2 * MAXM];

struct dfsdata {
  int id, parent;
  bool after;
};

int LE[MAXN];

int main() {
  fill(LE, LE + MAXN, -1);
  int n, m;
  cin >> n >> m;
  for (int src, dst, i = 0; i < 2 * m; i += 2) {
    cin >> src >> dst;
    E[i] = {dst, LE[src]};
    E[i + 1] = {src, LE[dst]};
    LE[src] = i;
    LE[dst] = i + 1;
  }

  int parent[MAXN]{0}, pre[MAXN]{0}, low[MAXN]{0};
  fill(parent, parent + MAXN, -1);
  stack<dfsdata> dfs;
  dfs.push({0, -1, false});
  bool visited[MAXN]{false};
  int clk = 0;
  while (!dfs.empty()) {
    dfsdata d = dfs.top();
    dfs.pop();
    if (visited[d.id] && !d.after)
      low[d.parent] = min(low[d.parent], pre[d.id]);
    if (visited[d.id] && d.after)
      low[d.parent] = min(low[d.parent], low[d.id]);
    if (!visited[d.id]) {
      visited[d.id] = true;
      parent[d.id] = d.parent;
      pre[d.id] = ++clk;
      low[d.id] = pre[d.id];
      dfs.push({d.id, d.parent, true});
      for (int e = LE[d.id]; e != -1; e = E[e].next)
        dfs.push({E[e].to, d.id, false});
    }
  }

  int n_children[MAXN]{0};
  for (int i = 0; i < n; ++i)
    if (parent[i] >= 0)
      n_children[parent[i]]++;

  set<int> cuts;
  for (int i = 0; i < n; ++i) {
    if (parent[i] == -1 && n_children[i] > 1)
      cuts.insert(i);
    if (parent[i] >= 0 && parent[parent[i]] != -1 && low[i] >= pre[parent[i]])
      cuts.insert(parent[i]);
  }
  for (int cut : cuts)
    cout << cut << endl;
}


Measured memory_bytes: 6288
#include <stdio.h>
#include <stdlib.h>
int ans[200000];
int n, q;
int a[200000], b[200000], p[200000], x[200000];
int *tree[200000];
int cnt[200000];
int cnts[200000];

int DFS(int now_v, int before_v) {//v:現在の頂点　bv:前にいた頂点
    int i, new_v;
    
	for(i = 0; i < cnt[now_v]; i++){//iをvの個数分だけループ
		new_v = tree[now_v][i];//お隣の頂点
		if (before_v != new_v){//逆流を防ぐため，自分が前にいたところには行かない
			ans[new_v] += ans[now_v];
			DFS(new_v, now_v);//現在の自分の位置を，前にいたところに変え，お隣の頂点に移動
		}
	}
	return 0;
}

int main(void){
    scanf("%d%d", &n, &q);
    int i, j;
    for(i = 0; i < n; i++){
        cnt[i] = 0;
        ans[i] = 0;
        cnts[i] = 0;
    }
    
    for(i = 0; i < n - 1; i++){
        scanf("%d%d", &a[i], &b[i]);
        a[i]--;
        b[i]--;
        cnt[a[i]]++;
        cnt[b[i]]++;
    }
    for(i = 0; i < q; i++){
        scanf("%d%d", &p[i], &x[i]);
        p[i]--;
    }

    //普通にメモリ確保すると足りなくなるので，可変長配列で確保する
    for(i = 0; i < n; i++){
        tree[i] = (int *)malloc(sizeof(int)*(cnt[i] + 1));
        if(tree[i] == NULL){
            return 0;
        }
    }

    for(i = 0; i < n - 1; i++){
        tree[a[i]][cnts[a[i]]] = b[i];
        tree[b[i]][cnts[b[i]]] = a[i];
        cnts[a[i]]++;
        cnts[b[i]]++;
    }

    for(i = 0; i < q; i++) {
		ans[p[i]] += x[i];
	}

	DFS(0, -1);

    for(i = 0; i < n; i++){
        printf("%d", ans[i]);
        if(i == n - 1){
            break;
        }
        printf(" ");
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 28244
#include <bits/stdc++.h>
#define int long long int
#define MAXN 1000000007
#define endl '\n'
using namespace std;

void solve(){
    int s, w; cin >> s >> w;

    cout << ((w>=s)?"unsafe":"safe");
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();


    ll c= 0, mx= 0, n;

    cin>> n;

    ll h[n];

    cin>> h[0];
    for(int i=1; i<n; i++ )
    {
        cin>> h[i];

        if(h[i]> h[i-1])
        {
            if(mx< c)
            mx= c;
            c= 0;
        }
        else
            c++;
    }

    cout << (c> mx? c: mx);
    nl;


    return 0;
}





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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)



typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////



ll SOLVE(){
    string s;cin>>s;
    rep(i,0,s.size()-1){
        if(s[i]=='?')cout<<"D";
        else cout<<s[i];
    }
    
    return 0;
}

int main(){fastio
    
    clock_t start = clock();
    SOLVE();
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    cerr<<endl<<time<<"ms"<<endl;
    
    return 0;
}



Measured memory_bytes: 3980
# A - Multiple of 2 and N
# https://beta.atcoder.jp/contests/abc102/tasks/abc102_a

# A_Multiple_of_2_and_N.py

N = int(input())

if N == 1:
    print(2)
elif N%2 == 0:
    print(N)
else:
    print(N*2)


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, W;
	cin >> n >> W;

	vl dp(W+1);
	while (n--) {
		ll w, v;
		cin >> w >> v;
		FORD(s,w,W+1) dp[s] = max(dp[s], dp[s-w]+v);
	}
	cout << dp[W] << endl;
}



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

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

        }



        return 0;
}


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

int main(){
    int n, pf = 0;
    cin >> n;
    int d[n];
    for(int i = 0; i < n; i++) cin >> d[i];
    for(int i = 0; i < n; i++){
        for(int j = i; j < n; j++) if(i != j) pf += d[i] * d[j];
    }
    cout << pf << endl;
}

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

int main(){
    int N, D, A; cin >> N >> D >> A;
    vector<P> monster(N);
    rep(i, N){
        int x, h; cin >> x >> h;
        monster[i] = {x, h};
    }
    sort(monster.begin(), monster.end());
    vector<ll> attack_cnt(N+1);
    vector<ll> required_cnt(N);
    rep(i, N){
        required_cnt[i] = ceil((double)monster[i].second / A);
    }
    ll ans = 0;
    int idx = 0;
    rep(i, N){
        while(monster[idx].first <= monster[i].first + 2 * D && idx < N) idx++;
        int nowattack = max((ll)0, required_cnt[i] - attack_cnt[i]);
        ans += nowattack;
        attack_cnt[i] += nowattack;
        attack_cnt[idx] -= nowattack;
        attack_cnt[i+1] += attack_cnt[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7892
from fractions import gcd
from functools import reduce


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


def solve(string):
    n, m, *a = map(int, string.split())
    l = reduce(lcm, a)
    c = 1
    while a[0] % (2 * c) == 0:
        c *= 2
    f = (a[0] // c) % 2
    for _a in a:
        if _a % c > 0 or (_a // c) % 2 != f:
            return "0"
    return str(max((m - l // 2) // l + 1, 0))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 17172
#include <cstdio>
#include <algorithm>
#include <limits.h>
using namespace std;

const int N = 100000 + 5;
int n, cnt, k;
char info[N];

int main() {
	scanf ("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i) {
		scanf ("%c", &info[i]);
		while (info[i] != 'L' && info[i] != 'R')
			scanf ("%c", &info[i]);
		if (i != 1 && info[i] != info[i - 1]) cnt++;
	}
	cnt++;
	while (k) {
	if (cnt == 1) break;
		cnt = cnt > 2 ? cnt - 2 : cnt - 1;
		k--;
	}
	printf ("%d\n", n - cnt);
	return 0;
}

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

int main(){
  int k,a,b;
  cin >> k >> a >> b;
  if(b-a+1 >= k)
    cout << "OK";
  else if((a/k+1)*k <= b)
    cout << "OK";
  else if(a/k*k == a)
    cout << "OK";
  else
    cout << "NG";
}
  

Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int k,x;
    cin >> k >> x;
    REP(i,x-k+1,x+k) if (i >= -1000000 && i <= 1000000) cout << i << " ";
    cout << endl;
}

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

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

int main(void)
{
    int n, k;
    cin >> n >> k;

    bool dislikes[10] = {false};
    for (int i = 0, x; i < k; i++)
    {
        cin >> x;
        dislikes[x] = true;
    }

    auto valid = [&](int x) {
        while (x)
        {
            int d = x % 10;
            if (dislikes[d])
                return false;
            x /= 10;
        }
        return true;
    };

    for (int p = n; p < 100001; p++)
        if (valid(p))
        {
            cout << p << endl;
            break;
        }
}


Measured memory_bytes: 3188
def burger(n, x):
    if x < 1:
        return 0

    # base case
    if (n, x) == (0, 1):
        return 1

    if x <= 1 + size[n - 1]:
        return burger(n - 1, x - 1)
    else:
        return p_num[n - 1] + 1 + burger(n - 1, min(x - 2 - size[n - 1], size[n - 1]))
    # x-2-sizeだと前lvバーガー+バンのことがあり、バンを外す


n, x = map(int, input().split())
size, p_num = [1], [1]
for i in range(1, 50 + 1):
    size.append(size[-1] * 2 + 3)
    p_num.append(p_num[-1] * 2 + 1)

print(burger(n, x))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
#define tl 1'000'000'007
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int cnt= 1;
    char f= s[0];
    FOR(i,1,s.size()){
        if(s[i]==s[i-1]) continue;
        else cnt++;
    }
    cout << cnt-1 << endl;
}


Measured memory_bytes: 512
#abc084d
import math

def is_prime(n):
 if n == 2:
  return True
 if n < 2 or n%2==0:
  return False
 for i in xrange(3, int(math.sqrt(n))+1, 2):
  if n%i == 0:
   return False
 return True

ls=[]
a=0
for i in xrange(10**5):
 if is_prime(i) and is_prime((i+1)/2):
  a+=1
 ls.append(a)
n=int(raw_input())
for i in xrange(n):
 l,r=map(int,raw_input().split())
 print ls[r]-ls[l-1]


Measured memory_bytes: 3948
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int X;

int main(){
    cin>>X;
    if(X==3||X==5||X==7){
        out("YES");
    }
    else{
        out("NO");
    }
}


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

int main() {
 string a;
  cin>>a;
  int p=(a.size()+a.size()%2)/2;
  
  for(int i=0;i<p;i++){
    cout<<a.at(2*i);
  }
  
  cout<<endl;
  
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	int n;
	scanf(" %d", &n);
	for(int i=0; i<n; ++i){
		long a;
		int p[8], q[8];
		scanf(" %ld", &a);
	
		for(int i=0; i<8; ++i){
			p[i] = ( a%(long)pow(10,8-i) ) / pow(10,7-i);
			q[i]=p[i];
			//printf("%d:%d\n", i, p[i]);
		}	
		
		sort(p, p+8);
		sort(q, q+8, greater<int>());
		
		long x=0, y=0;
		for(int i=0; i<8; ++i){
			x+=p[i]*pow(10,7-i);
			y+=q[i]*pow(10,7-i);
		}
	
		printf("%ld\n", y-x);
	}


	return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

template <typename T> inline void print(T val) { cout << val << '\n'; }

template <typename Iterator> inline void print(Iterator begin, Iterator end) {
  for (auto it = begin; it != end; it = next(it)) {
    cout << *it << ' ';
  }
  cout << '\n';
}

template <class T> inline T square(T x) {
  T result;
  result = x * x;
  return result;
};

#ifdef LOCAL
#define DBG_MACRO_NO_WARNING
#include <dbg.h>
#else
#define dbg(...) 0
#endif

const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);

  auto start = chrono::steady_clock::now();
#endif

  ull x;
  cin >> x;

  long double a = 100;
  ll y = 0;

  while (a < x) {
    ++y;
    a *= 1.01;
    ll b = a;
    a = b;
    dbg(a);
  }

  print(y);

#ifdef LOCAL
  auto end = chrono::steady_clock::now();
  auto diff = end - start;

  cout << "Duration: " << chrono::duration<double, milli>(diff).count() << " ms"
       << '\n';
#endif

  return 0;
}


Measured memory_bytes: 3632
H,W,K,*c = open(0).read().split()
H = int(H)
W = int(W)
K = int(K)
ans = 0

selectedh = [False for i in range(H)]
selectedw = [False for i in range(W)]
for i in range(2 ** (H)):
    for j in range(H):
        if i >> j & 1:
            selectedh[j] = True
        else:
            selectedh[j] = False
    for i in range(2 ** (W)):
        for j in range(W):
            if i >> j & 1:
                selectedw[j] = True
            else:
                selectedw[j] = False
        temp = 0
        for k in range(H):
            if selectedh[k] == True:
                continue
            else:
                for l in range(W):
                    if selectedw[l] == True:
                        continue
                    else:
                        if c[k][l] == '#':
                            temp += 1
        if temp == K:
            ans += 1
print(ans)

Measured memory_bytes: 9244
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
typedef ll Def;
vi ga;
class DIJ{
	public:
	struct edge{
		Def to,cost;
	};
	vector<vector<edge> >G;
	Def n,L;
	vector<vector<Def> >d;//distance
//	Def d[510][50][2];
	DIJ(Def size,Def l){
		n=size;
		L=l;//??????
		G=vector<vector<edge> >(n);
	}
	void add_edge(Def a,Def b,Def c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);
		// G[b].pb(ee);
	}
	void dij(Def s,Def g){
		d=vector<vector<Def> >(n,vector<Def>(n+1,inf));
		d[s][0]=0;
		priority_queue<tp>q;
		q.push(tp(0,s,0));
		while(!q.empty()){
			Def cost,pos,t;
			tie(cost,pos,t)=q.top();
			cost*=-1;
			q.pop();
			if(cost>d[pos][t])continue;
			rep(i,G[pos].size()){
				edge e=G[pos][i];
				Def to=e.to;
				Def ncost=cost+e.cost;//??????
				Def nt=t;//-e.cost;//??????
				if(ncost<d[to][nt]){
					d[to][nt]=ncost;
					q.push(tp(-ncost,to,nt));
				}
				nt++;
				ncost-=e.cost;
				if(nt<=n&&ncost<d[to][nt]){
					d[to][nt]=ncost;
					q.push(tp(-ncost,to,nt));
				}
			}
		}
		if(d[g][0]==L)cout<<0<<endl;
		else loop(i,1,n+1)if(d[g][i]<=L){cout<<i<<endl;break;}
	}
};
signed main(){
	int n,m,c;
	while(cin>>n>>m>>c,n){
		DIJ dij(n,c);
		rep(i,m){
			int a,b,c;
			cin>>a>>b>>c;
			a--;b--;
			dij.add_edge(a,b,c);
		}
		dij.dij(0,n-1);
	}
	
}


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

int main(){
  int N, i;
  scanf("%d", &N);
  for(i = 0; i < N; i++){
    int Y, M, D, j;
    scanf("%d%d%d", &Y, &M, &D);
    for(j = 1; ; j++){
      if(Y % 3 == 0){
        if(D < 20){
          D++;
        }
        else{
          D = 1;
          if(M < 10){
            M++;
          }
          else{
            M = 1;
            Y++;
          }
        }
      }
      else{
        if(M % 2 == 1){
          if(D < 20){
            D++;
          }
          else{
            D = 1;
            M++;
          }
        }
        else{
          if(D < 19){
            D++;
          }
          else{
            D = 1;
            if(M < 10){
              M++;
            }
            else{
              M = 1;
              Y++;
            }
          }
        }
      }
      if(Y == 1000){
        break;
      }
    }
    printf("%d\n", j);
  }
  return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define repl(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    int n,k;
    cin >> n >> k;
    vector<int> snuke(n,0);
    rep(i,k){
        int d;
        cin >> d;
        rep(j,d){
            int a;
            cin >> a;
            snuke.at(a-1)++;
        }
    }
    int res = 0;
    for(auto a : snuke)if(a == 0)res++;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;

main(){
    int n;cin>>n;
    ll l[n];
    for(int i=0;i<n;i++) cin>>l[i];
    int count=0;
    sort(l,l+n);
    for(int i=0;i<n;i++){
        for(int j=(i+1);j<n;j++){
            for(int k=(j+1);k<n;k++){
                if((l[i]==l[j]) || (l[i]==l[k]) || (l[j]==l[k])) continue;
                if((l[i]+l[j])>l[k]) count++;
            }
        }
    }
    cout<<count;
}

Measured memory_bytes: 3640
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        String line;
        
        while(!"0 0".equals(line = sc.nextLine())){
            String[] str = line.split(" ");
            int n = Integer.parseInt(str[0]);
            int x = Integer.parseInt(str[1]);
            int count = 0;
            if(n>x) n = x-2;
            for(int i = 1;i <= n-2;i++){
                for(int j = i+1;j <= n-1; j++){
                    for(int k = j+1;k<=n;k++){
                        if((i+j+k)==x) count++;
                    }
                }
            }
        System.out.println(count);
        }

    }
}



Measured memory_bytes: 26608
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    cout << ((s[5] == '0' && s[6] < '5') ? "Heisei" : "TBD") << endl;

    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())

if a==1 :
    if b==2:
        print(3)
    elif b==3:
        print(2)
elif a ==2 :
    if b==1:
        print(3)
    elif b==3:
        print(1)
else:
    if b==1:
        print(2)
    elif b==2:
        print(1)

Measured memory_bytes: 3060
#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>
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)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    int ans = 1;
    for(int i=1;i*i<=m;i++){
        if(m%i==0){
            int num = m/i;
            if(num>=n)ans=max(ans,i);

            num=i;
            if(num>=n)ans=max(ans,m/i);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/*بسم الله الرحمن الرحيم*/
/*“Dengan menyebut nama Allah yang Maha Pengasih lagi Maha Penyayang”*/
/*“In the name of Allah, Most Gracious, Most Merciful”*/
/********************************************************************************************************\__
                                                                                                          |
        author  :   Althafa Dhia Syauqi   ||    email   :    daltafa@gmail.com                              ||
        SMAN 10 Samarinda, Kalimantan Timur.                                                    ||
                                                                                                          ||
/********************************************************************************************************/
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep_k(i,n) for(int x=i;x<n;x++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_n(i,n) for(int i=1;i<=(n);i++)
#define rep_all(k) for(auto x:k)
#define endl '\n'
#define mod 1e9+7
#define pb push_back
#define READ(f)         freopen(f, "r", stdin)
#define WRITE(f)        freopen(f, "w", stdout)
#define maxSort         sort(all(v),greater<int>())
#define rSort           sort(v.rbegin(),v.rend())
#define FOREACH(i,c) for (typeof((c).end()) i = (c).begin(); i != (c).end(); ++i)
#define RESET(c,v) memset(c, v, sizeof(c))
#define sqr(x)          ((x)*(x))
#define qube(x)         ((x)*(x)*(x))
using namespace std;
void optimization()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll t,h,w,a,b,ans=0;
int main()
{
	optimization();
    cin>>t;
  rep(i,t)
    {
    cin >> h;
    if(h%2!=0)
     {
      cout<<"first"<<endl;
      exit(0);
      }
    }
  cout <<"second"<<endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#define mod 1000000007
using namespace std;

int main()
{
    //int m,n,o=0,i,j,k,sum=0;
    long long int m,n,o,i,j,k,sum=0;
    //vector <int> v;
    //float f,g,h;
    //char c,d;
    //string a;
    cin>>n;
    int *na=new int [n+1];
    int *nb=new int [n];
    for(i=0;i<n+1;i++) cin>>na[i];
    for(i=0;i<n;i++) cin>>nb[i];
    for(i=0;i<n;i++)
    {
        if(nb[i]<=na[i]) sum+=nb[i];
        else
        {
            sum+=na[i];
            nb[i]-=na[i];
            if(nb[i]<=na[i+1])
            {
                sum+=nb[i];
                na[i+1]-=nb[i];
            }
            else
            {
                sum+=na[i+1];
                na[i+1]=0;
            }
        }
    }
    cout<<sum;
    //cin>>m>>c>>n>>d>>i;
    //cin>>f>>g;
    //cin>>c;
    delete [] na;
    delete [] nb;
    return 0;
}



Measured memory_bytes: 1024
// Written By NewbieChd
#include <iostream>
#include <iomanip>
#include <cmath>
// #define double long double
using namespace std;

const int maxN = 100003;
const double eps = 1e-10;
inline double absolute(double x) { return x >= 0 ? x : -x; }
inline double square(double x) { return x * x; }

struct Vector {
    double x, y;
    Vector() {}
    Vector(double x, double y) : x(x), y(y) {}
    friend Vector operator+(const Vector& a, const Vector& b) { return Vector(a.x + b.x, a.y + b.y); }
    friend Vector operator-(const Vector& a, const Vector& b) { return Vector(a.x - b.x, a.y - b.y); }
    friend Vector operator*(const Vector& a, const double& b) { return Vector(a.x * b, a.y * b); }
    friend Vector operator/(const Vector& a, const double& b) { return Vector(a.x / b, a.y / b); }
    inline double length() { return sqrt(square(x) + square(y)); }
    inline void read() { cin >> x >> y; }
    inline void write() { cout << fixed << setprecision(10) << x << ' ' << y << '\n'; }
};
inline double distance(Vector a, Vector b) { return sqrt(square(b.x - a.x) + square(b.y - a.y)); }
inline double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
inline double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }

inline Vector project(Vector a, Vector b, Vector c) {
    b = a - b;
    return b * (dot(b, c - a) / square(b.length())) + a;
}
inline Vector reflect(Vector a, Vector b, Vector c) {
    a = project(a, b, c);
    return a * 2 - c;
}

int main() {
    ios::sync_with_stdio(false);
    Vector a, b, c;
    a.read(), b.read(), b = b - a;
    int Q;
    for (cin >> Q; Q; --Q) {
        c.read(), c = c - a;
        if (absolute(cross(b, c)) > eps) {
            if (cross(b, c) > 0)
                printf("COUNTER_CLOCKWISE\n");
            else
                printf("CLOCKWISE\n");
        }
        else {
            if (dot(b, c) < 0)
                printf("ONLINE_BACK\n");
            else
                printf(b.length() < c.length() ? "ONLINE_FRONT\n" : "ON_SEGMENT\n");
        }
    }
    return 0;
}



Measured memory_bytes: 3236
A = input()
B = input()
C = input()

turn = 'a'
while(True):
    if turn == 'a':
        if not A:
            print('A')
            break
            
        turn = A[0]
        A = A[1:]
        
    if turn == 'b':
        if not B:
            print('B')
            break
        
        turn = B[0]
        B = B[1:]
    
    if turn == 'c':
        if not C:
            print('C')
            break
        
        turn = C[0]
        C = C[1:]

Measured memory_bytes: 3064
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))

long long gcd(long long a, long long b){
    if(a<b){
        swap(a,b);
    }
    while(b){
        long long r = a%b;
        a=b;
        b=r;
    }
    return a;
}

int lcm(int a, int  b){
    return (a*b)/gcd(a,b);
}

int isPrim(int a){
    if(a==1){
        return 0;
    }
    for(int i=2;i<=(a+1)/2;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}

long long mod_pow(long long x, long long n, long long mod){
    //xのn乗を計算するのにn乗を2進表記にして計算
    //x^22 = x^16 + x^4 + x^2
    long long ret=1;
    while(n>0){
        if(n%2==1){
            ret=(ret*x)%mod;//答えに付加
        }
        x=(x*x)%mod;//2乗
        n=n/2;
    }
    return ret;
}


struct XX{
    int d=0;
    int a=0;
    int k=0;
    int t=0;
};

class xxIntu {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
        if((riLeft.a+riLeft.k) == (riRight.a+riRight.k)){
            return riLeft.a < riRight.a;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
        }
        //第1条件
        return (riLeft.a+riLeft.k) < (riRight.a+riRight.k);
    }
};
/*bool operator< (const XX &riLeft, const XX &riRight){
    return riLeft.d < riRight.d;
};*/


int main(int argc, const char * argv[])
{
    //std::ios::sync_with_stdio(false);
    //scanf("%s",S);
    //scanf("%d",&N);
    //getline(cin, target);
    //cin >> x >> y;
    //テスト用
    //ifstream ifs( "1_06.txt" );
    //ifs >> a;
    //ここから

    int N;
    cin >> N;
    int a[100000];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    int ans=0;
    for(int i=0;i<N;i++){
        int j=a[a[i]-1];
        if(j==i+1){
            ans++;
        }
    }
    
    cout << ans/2 << endl;
    
    //ここまで
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    //printf("%f\n",pow(2,ans.size()));
    
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define maxn 1000005
set<int> col[maxn];
struct Edge
{
	int fr,to,val;
	Edge(){}
	Edge(int a,int b,int c):fr(a),to(b),val(c){}
}eg[maxn<<1];
struct Data
{
	int first,second;
	Data(){}
	Data(int a,int b):first(a),second(b){}
	friend inline bool operator < (Data a,Data b)
		{
			return a.first==b.first?a.second<b.second:a.first<b.first;
		}
};
priority_queue<Data> q;
int head[maxn],edgenum,dis[maxn],vis[maxn];
inline void add(int fr,int to,int val)
{
	eg[++edgenum]=Edge(head[fr],to,val);
	head[fr]=edgenum;
}
inline void dijskra(int st=1)
{
	memset(dis,0x3f,sizeof(dis));
	dis[st]=0;
	q.push(Data(dis[st],st));
	while(!q.empty())
	{
		int id=q.top().second;
		q.pop();
		if(vis[id]) continue;
		vis[id]=1;
		for(int i=head[id];i;i=eg[i].fr)
		{
			int to=eg[i].to,val=!col[id].count(eg[i].val);
			if(dis[to]>dis[id]+val)
			{
				dis[to]=dis[id]+val;
				q.push(Data(-dis[to],to));
				col[to].clear();
				col[to].insert(eg[i].val);
			}
			else if(dis[to]==dis[id]+val)
				col[to].insert(eg[i].val);
		}
	}
}
int main()
{
	int n,m,a,b,c;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i)
	{
		scanf("%d%d%d",&a,&b,&c);
		add(a,b,c),add(b,a,c);
	}
	dijskra();
	if(dis[n]==0x3f3f3f3f) puts("-1");
	else printf("%d\n",dis[n]);
	return 0;
}

Measured memory_bytes: 73976
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        if(a > b) {
            System.out.println("a > b");
        } else if(a < b) {
            System.out.println("a < b");
        } else if(a == b) {
            System.out.println("a == b");
        }
        scan.close();
    }
}


Measured memory_bytes: 26272