akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
//{{{ read()
inline int read(){
	register int x=0,f=1;
	register char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')	f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x*f;
}
//}}}
const double Pi=acos(-1);
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int a=read(),b=read(),h=read(),m=read();
	double t1=1.0*(h*60+m)/(12*60)*Pi*2,t2=1.0*m/60*Pi*2;
	double x1=a*cos(t1),y1=a*sin(t1),x2=b*cos(t2),y2=b*sin(t2);
	printf("%.10lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
	return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    ll a;
    cin >> a;
    string tmp1 = to_string(a);
    reverse(tmp1.begin(), tmp1.end());
    string s = "";
    ll ans = 0;
    rep(i, tmp1.size()) {
        ans += tmp1[i]-'0';
    }
    rep(i, tmp1.size()) {
        s = tmp1[i] + s;
        ll t = stol(s);
        ll t2 = a - (t+1);
        string tmp3 = to_string(t2);
        ll t3 = 0;
        rep(i, tmp3.size()) {
            t3 += tmp3[i]-'0';
        }
        ans = max(ans, t3);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//def
#include <iostream>

#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <map>

using namespace std;

#define rep(i,q) for(int i = 0; (q) > i; i++)
#define anyfill(n,s) setw(n) << setfill(s)
#define pb push_back
#define MOD 1000000007
int main(){
  int x,y,z,k;cin>>x>>y>>z>>k;

  //a
  vector<long long> a;
  rep(i,x){
    long long tmp;cin>>tmp;
    a.push_back(tmp);
  }
  sort(a.begin(),a.end(),greater<int>());

  vector<long long>a_beta;
  a_beta.push_back(0);
  for(int i = 1; a.size() > i; i++){
    a_beta.push_back(a[0]-a[i]);
  }

  //b
  vector<long long> b;
  rep(i,y){
    long long tmp;cin>>tmp;
    b.push_back(tmp);
  }
  sort(b.begin(),b.end(),greater<int>());

  vector<long long>b_beta;
  b_beta.push_back(0);
  for(int i = 1; b.size() > i; i++){
    b_beta.push_back(b[0]-b[i]);
  }

  //c
  vector<long long> c;
  rep(i,z){
    long long tmp;cin>>tmp;
    c.push_back(tmp);
  }
  sort(c.begin(),c.end(),greater<int>());

  vector<long long>c_beta;
  c_beta.push_back(0);
  for(int i = 1; c.size() > i; i++){
    c_beta.push_back(c[0]-c[i]);
  }
  


  vector<long long>ans;
  for(int i = 0; a_beta.size() > i; i++){
    ans.push_back(a_beta[i]);
  }
  for(int i = 1; b_beta.size() > i; i++){
    for(int j = 0; a_beta.size() > j; j++){
      ans.push_back(b_beta[i]+ans[j]);
    }
  }
  sort(ans.begin(),ans.end());
  while(k < ans.size())ans.pop_back();
  int fr = ans.size();

  for(int i = 1; c_beta.size() > i; i++){
    for(int j = 0; fr > j; j++){
      ans.push_back(c_beta[i]+ans[j]);
    }
  }
  sort(ans.begin(),ans.end());
  while(k < ans.size())ans.pop_back();

  long long ret = a[0]+b[0]+c[0];
  for(int i = 0; k > i; i++){
    cout << ret - ans[i] << endl;
  }
}
//4 6
//1 5
//3 8


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

using namespace std;

const int N = 2103;

int n, m;
int top, fi[N], ne[N << 1], to[N << 1];
int fa[N][N], from[N][N];
bool line[N][N];
int res;
queue<int> q;

void add(int u, int v);
void getfa(int t, int fa, int p);
void buildGraph(int u, int v);
void getres(int t, int fa, int p);

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 2, u, v; i <= n; ++i) {
    scanf("%d%d", &u, &v);
    add(u, v), add(v, u);
  }
  for (int i = 1; i <= n; ++i) getfa(i, 0, i);
  for (int i = 1, u, v; i <= m; ++i) {
    scanf("%d%d", &u, &v);
    buildGraph(u, v);
  }
  for (int i = 1; i <= n; ++i) getres(i, i, i);
  printf("%d\n", res / 2);
  return 0;
}

void add(int u, int v) {
  ne[++top] = fi[u], fi[u] = top, to[top] = v;
}

void getfa(int t, int f, int p) {
  fa[p][t] = f;
  for (int i = fi[t]; i; i = ne[i]) {
    if (to[i] == f) continue;
    getfa(to[i], t, p);
  }
}

void buildGraph(int u, int v) {
  if (from[u][v] == v) return ;
  if (from[u][v]) return buildGraph(from[u][v], v);
  if (from[v][u]) return buildGraph(from[v][u], u);
  line[u][v] = line[v][u] = true;
  from[u][v] = v, from[v][u] = u;

  vector<pair<int, int> > need;

  for (int times = 1; times <= 2; ++times) {
    q.push(v);
    while (!q.empty()) {
      int f = q.front();
      q.pop();
      for (int i = fi[f]; i; i = ne[i]) {
        if (to[i] == fa[u][f]) continue;
        if (from[u][to[i]]) {
          line[from[u][to[i]]][u] = line[u][from[u][to[i]]] = false;
          need.push_back(make_pair(from[u][to[i]], v));
        } else {
          from[u][to[i]] = v;
          q.push(to[i]);
        }
      }
    }
    swap(u, v);
  }

  for (int i = need.size() - 1; i >= 0; --i) 
    buildGraph(need[i].first, need[i].second);
}

void getres(int t, int f, int p) {
  if (line[f][t]) f = t, res++;
  for (int i = fi[t]; i; i = ne[i]) {
    if (to[i] == fa[p][t]) continue;
    getres(to[i], f, p);
  }
}

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

void solve()
{
	int n;
	cin>>n;
	n^=1;
	cout<<n<<endl;
}

int main()
{
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3608
N,M=gets.split.map(&:to_i)
A=*C=[]
M.times do
  A<<gets.to_i
  C<<gets.split.map(&:to_i).inject(0){|s,i|s+2**(i-1)}
end

dp=Array.new(2**N){10**9}
dp[0]=0
M.times do |i|
  nex=*dp
  (2**N).times do |j|
    k=j|C[i]
    nex[k]=[nex[k],dp[j]+A[i]].min
  end
  dp=nex
end
p dp[2**N-1]==10**9 ? -1 : dp[2**N-1]


Measured memory_bytes: 20348
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();

        Stack<Integer> st = new Stack<>();
        int min=200001;
        int cnt=0;
        for(int i=0;i<N;i++){
            int p = sc.nextInt();
            if(p < min){
                min = p;
                cnt ++;
            }
        }
        System.out.println(cnt);
    }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    int h,w;
    cin>>h>>w;
    char graph[h][w];
    rep(i,h)rep(j,w)cin>>graph[i][j];
    int ans=0;
    rep(i,h){
        rep(j,w){
            if (graph[i][j]=='#')continue;
            else{
                vvi d(h,vi(w,1000));
                d[i][j]=0;
                queue<pair<int,int>> q;
                q.push({i,j});
                while(q.size()!=0){
                    auto p1=q.front();
                    q.pop();
                    vector<pair<int,int>> move;
                    move.push_back(make_pair(1,0));
                    move.push_back(make_pair(-1,0));
                    move.push_back(make_pair(0,1));
                    move.push_back(make_pair(0,-1));
                    for (auto p:move){
                        int dx=p.fi,dy=p.se;
                        int x=dx+p1.fi,y=dy+p1.se;
                        if (x<0 || y<0 || x>=h || y>=w)continue;
                        else if (graph[x][y]=='#')continue;
                        else if (d[x][y]<=d[p1.fi][p1.se]+1)continue;
                        else{
                            d[x][y]=d[p1.fi][p1.se]+1;
                            q.push({x,y});
                        }
                    }
                }
                rep(k,h){
                    rep(l,w){
                        if (d[k][l]!=1000){
                            ans=max(ans,d[k][l]);
                        }
                    }
                }
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

int main() {
	string str,str1,s;
	cin>>str;
	s="s";
    int n;
    n=str.size();
    if(str[n-1]==s[0])
    {
        str1="es";
        str.append(str1);
    }
    else
    {
        str1="s";
        str.append(str1);
    }
    cout<<str;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#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 repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;

int n, m;

int G[50][50];
bool visited[50];

void dfs(int v) {
  visited[v] = true;
  rep(i, n) {
    if (G[v][i] == 1) {
      if (visited[i] == false) {
        dfs(i);
      }
    }
  }
}

int main() {
  int ans = 0;
  cin >> n >> m;
  vector<pair<int, int>> p(m);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    p[i] = make_pair(a, b);
    G[a][b] = 1;
    G[b][a] = 1;
  }
  rep(i, m) {
    G[p[i].first][p[i].second] = 0;
    G[p[i].second][p[i].first] = 0;
    rep(j, n) { visited[j] = false; }
    dfs(0);
    int cnt = 0;
    rep(j, n) {
      if (visited[j]) cnt++;
    }
    if (cnt != n) ans++;
    G[p[i].first][p[i].second] = 1;
    G[p[i].second][p[i].first] = 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
MOD = 10**9+7
N = int(input())
ans = 1
ary = defaultdict(int)
for i in range(1, N+1):
    n = i
    m = 2
    while n > 1:
        if not n % m:
            ary[m] += 1
            n //= m
            m = 1
        m += 1
for v in dict(ary).values():
    ans *= v+1
    ans %= MOD
print(ans)


Measured memory_bytes: 41072
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>

int howmany(char s[], int st, int gl, int c){
    int num = 0;
    for(int i = st; i < gl; i++){
        if(s[i] == c)
        num++;
    }
    return num;
}
int maxchar(char s[], int n){
    int m = -1;
    for(int i = 1; i <= n; i++){
        int iscontained[30] = {0};
        int temp = 0;

        for(int j = 0; j < i; j++){
            iscontained[s[j] - 'a'] = 1;
        }
        for(int j = i; j < n; j++){
            if(iscontained[s[j] - 'a'] == 1){
                iscontained[s[j] - 'a'] = 0;
                temp ++;
            }
        }
        //printf("%d", m);
        m = (int)fmax(m, temp);
    }
    
    return m;
}
int main(){
    int n,m;
    scanf("%d",&n);
    char s[120];
    scanf("%s",s);
    
    m = maxchar(s, n);

    printf("%d", m);

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll A,B,C,K;

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin >> A >> B >> C >> K;
    if(K&1){
        if(B-A>(ll)1e18) cout << "Unfair" <<"\n";
        else cout << B-A <<"\n";
    }
    else{
        if(A-B>(ll)1e18) cout << "Unfair" << "\n";
        else cout << A-B <<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
if a == 0:
    print(0)
elif n <= a:
    print(n)
else:
    div = n // (a + b)
    rem = n % (a + b)
    if rem <= a:
        print(div * a + rem)
    else:
        print(div * a + a)


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

LL a[35], P[35], N[35];
vector<int> ans;

void pos(int n);
void neg(int n);

int main()
{
    for(int i = 0, j = 1; i <= 31; i++, j *= 2)
        a[i] = i % 2? -j: j;

    for(int i = 0; i <= 31; i++){
        if(a[i] > 0)
            P[i] = a[i];
        P[i] += P[i - 1];
        if(a[i] < 0)
            N[i] = a[i];
        N[i] += N[i - 1];
    }


    int n;
    cin >> n;

    if(!n)
        return cout << 0 << '\n', 0;

    if(n > 0)
        pos(n);
    else if(n < 0)
        neg(n);

    sort(All(ans));

    int it = 0, L = ans.size();
    string s;

    for(int i = 0; i <= 31; i++){
        if(i == ans[it]){
            s.Pb('1'), it++;
            if(it == L)
                break;
        }
        else
            s.Pb('0');
    }

    reverse(All(s));

    cout << s << '\n';
    return 0;
}

void pos(int n)
{
    for(int i = 0; i <= 31; i++){
        if(P[i] >= n){
            ans.Pb(i);
            int x = n - a[i];
            if(x > 0)
                pos(x);
            else if(x < 0)
                neg(x);
            return;
        }
    }
}

void neg(int n)
{
    for(int i = 0; i <= 31; i++){
        if(N[i] <= n){
            ans.Pb(i);
            int x = n - a[i];
            if(x > 0)
                pos(x);
            else if(x < 0)
                neg(x);
            return;
        }
    }
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// leave to tomorrow anything that can be done today
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,a,b;
    cin>>n>>a>>b;
    ll soma=a+b;
    ll calc=(n/soma)*a;
    n%=soma;
    calc+=min(n,a);
    cout<<calc<<"\n";
    return 0;   
}   

Measured memory_bytes: 256
n,q=map(int,input().split())
s=input()
td=[list(input().split()) for _ in range(q)]
def func0(x):
  # はじめx(0-indexed)にいるゴーレムが0から左にいき消滅するか
  for t,d in td:
    if t==s[x]:
      if d=='R':x+=1
      if d=='L':x-=1
    if x<0:return True
    if x>n-1:return False
  return False
def funcN(x):
  # はじめx(0-indexed)にいるゴーレムがn-1から右にいき消滅するか
  for t,d in td:
    if t==s[x]:
      if d=='R':x+=1
      if d=='L':x-=1
    if x<0:return False
    if x>n-1:return True
  return False

l,r=-1,n
while r-l>1:
  x=(l+r)//2
  if func0(x):
    l,r=x,r
  else:
    l,r=l,x
a=l
l,r=-1,n
while r-l>1:
  x=(l+r)//2
  if funcN(x):
    l,r=l,x
  else:
    l,r=x,r
b=r
print(n-(a+1)-(n-b))

Measured memory_bytes: 116584
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <math.h>

using namespace std;
#define ll long long

int main()
{
    //freopen("aa_input.txt", "r", stdin);
    int N, L;
    cin>>N>>L;
    int min = 100000000000;
    int ans = 0;
    int i;
    for(i=1; i<=N; i++){
        ans += (L+i-1);
        if((L+i-1)<=0){
            min=L+i-1;
        }
        else if((L+i-1)<min && min != 0 && min>0){
            min = L+i-1;
        }
    }
    cout<<ans-min<<endl;
    return 0;
}
/*

riaadmorshed@gmail.com

*/

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int ans = 0;
		int ans1 = 0;
		int ans2 = 0;
		int ans3 = 0;
		ans1 = N % 10;
		ans2 = N % 100;
		ans2 = ans2 / 10;
		ans3 = N / 100;
		if(ans3 == 7 || ans2 == 7 || ans1 == 7){
			ans = 1;
		}
		if(ans == 1){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
		stdIn.close();
	}
}

Measured memory_bytes: 35620
Program Tenka2019B

integer n,k
character(10) s,ans

read(*,*) n,s,k

do i=1,n
 if (s(i:i)==s(k:k)) then
  ans(i:i)=s(i:i)
 else
  ans(i:i)='*'
 end if
end do

write(*,*) ans(:n)

stop
end

Measured memory_bytes: 768
N = 10100
ps = []

isp = Array.new(N,true)
(2..N).step 2 do |i|
  isp[i] = false
end
(3..N).step(2) do |i|
  next unless isp[i]
  ps << i
  ((i+i)..N).step(i) do |j|
    isp[j] = false
  end
end

tps = ps.each_cons(2).select{|p,q| q-p==2}

while (n=gets.to_i)!=0
  ans = tps.select{ |pair| pair[1] <= n }.last
  puts ans.join(' ')
end

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

#define ll long long 

ll n,k;
ll a[100005];
ll dp[100005];
const ll Inf = 1e10;
ll MinCostToReachFromNToZero(ll N){
	if(N <= 0)return 0;
  	if(dp[N] != -1)return dp[N];
  	ll ans = Inf;
  	for(int i = 1; i <= k; i++){
    	if(N - i >= 0){
        	ans = min(ans,(abs(a[N]-a[N-i]) + MinCostToReachFromNToZero(N-i)));
        }
    }
  	//cout << N << " " << ans << "\n";
  	return dp[N] = ans;
}
int main(){
	cin >> n >> k;
  	for(ll i = 0; i < n; i++)cin >> a[i];
  	for(ll i = 0; i < n+1; i++)dp[i] = -1;
  
	cout << MinCostToReachFromNToZero(n-1) << endl;
  	return 0;
}


Measured memory_bytes: 9876
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

N, K = [int(x) for x in stdin.readline().rstrip().split()]
h = [int(x) for x in stdin.readline().rstrip().split()]

# add dummy
h = h + [INF, INF, INF]

# 足場iにいるときの最小コスト
dp = [INF] * (N+10)
dp[0] = 0

for i in range(N):
    for j in range(i+1, i+K+1):
        if j > N-1:
            continue
        dp[j] = min(dp[j], abs(h[i] - h[j])+dp[i])

print(dp[N-1])

Measured memory_bytes: 79032
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string s, t;

int main()
{
	in >> s >> t;
	std::sort(s.begin(), s.end());
	std::sort(t.rbegin(), t.rend());
	if (s < t) { out << "Yes" << std::endl; }
	else { out << "No" << std::endl; }
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif

static void A_task();

int main()
{
	A_task();
	
	fflush(stdout);
	return 0;
}

static bool backToB(int A, int B, int C, int D, char* szS)
{
	bool back = false;
	int nowPos = D;

	while (nowPos > B) {
		if (szS[nowPos - 1] == '.') {
			nowPos--;
		}
		else if (szS[nowPos - 2] == '.') {
			nowPos -= 2;
		}
		else {
			break;
		}
	}
	
	if (nowPos == B) {
		back = true;
	}
	return back;
}

static bool escapeB(int B, int D, int & newD, char* szS)
{
	bool escape = false;
	int nowPos = D;
	while (nowPos >= B) {

		if ((szS[nowPos - 1] == '.') && (szS[nowPos + 1] == '.')) {
			newD = nowPos;
			escape = true;
			break;
		}
		else if (szS[nowPos - 1] == '.') {
			nowPos--;
		}
		else if (szS[nowPos - 2] == '.') {
			nowPos -= 2;
		}
		else {
			break;
		}
	}
	return escape;
}


static bool backToA(int A, int B, int C, int D, char* szS) 
{
	bool back = false;
	int nowPos = C;
	int nowD = D;
	while (nowPos > A) {
		if (((nowPos - 1) == D) || ((nowPos - 2) == D)) {
			if (!escapeB(B, D, nowD, szS)) {
				break;
			}
			else {
				szS[D] = '.';
				szS[nowD] = 'F';
				D = -100;
			}
		}

		if (szS[nowPos - 1] == '.') {
			nowPos--;
		}
		else if (szS[nowPos - 2] == '.') {
			nowPos -= 2;
		}
		else {
			break;
		}
	}

	if ((nowPos == A) && (backToB(A, B, C, nowD, szS))) {
		back = true;
	}

	return back;
}

static void A_task()
{
	int N, A, B, C, D;
	scanf(" %d %d %d %d %d", &N, &A, &B, &C, &D);

	auto szS = new char[N + 1];
	memset(szS, 0, N + 1);
	scanf(" %s", szS);

	const char* ans = "No\n";
	if (backToA(A - 1, B - 1, C - 1, D - 1, szS)) {
		ans = "Yes\n";
	}
	printf(ans);

	delete[] szS;
}


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

int main()
{
	int a,b,c,d,sum=0;
	string s,m,n;
    cin>>s>>m>>n;
    cout<<s[0]<<m[1]<<n[2];
	
	
	return 0;
}
	

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int A, B, C;

int main(void)
{
  cin >> A >> B >> C;
  int ans = max(C - (A - B), 0);
  cout << ans << endl;
  return 0;
}


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

namespace CSharpSample01
{
	class Program
	{

		static void Main(string[] args)
		{
			var N = int.Parse(Console.ReadLine());
			int answer = N % 1000;

			if(answer != 0)
			{
				answer -= 1000;
				answer = answer * -1;
			}

			Console.WriteLine(answer);

		}
	}
}

Measured memory_bytes: 27532
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    ll n,k;
    cin >> n >> k;
    ll a,b;
    vector<ll> cnt(1e6);
    rep(i,n) {
        cin >> a >> b;
        cnt[a-1] += b;
    }
    ll cum = 0;
    for (int i = 0; i < 1e6; i++)
    {
        cum += cnt[i];
        if (cum >= k) {
            cout << i+1 << endl;
            return 0;
        }
    }    
    return 0;
}

Measured memory_bytes: 8064
#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)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep (i, n) cin >> a[i];
    int ans = 0;
    rep (i, n) {
        while (i + 1 < n && a[i] == a[i + 1]) i++;
        if (i + 1 < n && a[i] < a[i + 1]) {
            while (i + 1 < n && a[i] <= a[i + 1]) i++;
        } else if (i + 1 < n && a[i] > a[i + 1]) {
            while (i + 1 < n && a[i] >= a[i + 1]) i++;
        }
        ans++;
    }
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>  
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
ll l=1000000007;
string alphabet="abcdefghijklmnopqrstuvwxyz";

int main() {
  int n; cin>>n;
  vector<pii> v(n);
  rep(i,n){
    cin>>v[i].second;  
    v[i].second--;
  }

  vector<int> num(n);
  rep(i,n){
    num[i]=i;
  }//int x=2;num.erase(num.begin()+x);
  int ans=0;
  rep(i,n){
    int x=v[n-i-1].second;
    if(num.size()<x+1){ans=-1;break;}
    v[n-i-1].first=num[x];
    num.erase(num.begin()+x);
  }
  if(ans==0){
    sort(v.begin(), v.end());
    rep(i,n){cout<<v[i].second+1<<endl;}
  }
  else{cout<<ans;}
}



Measured memory_bytes: 3600
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.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++)
void chmin(int &a, int b) { if (a > b) a = b; }

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };
char da[4] = { 'R', 'L', 'D', 'U' };
char dax[4] = { -1, 1, -1, 1 };
char dax2[4] = { 1, -1, 1, -1 };
ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }
template<typename T>
struct edge {

	int src, to;
	T cost;

	edge(int to, T cost) : src(-1), to(to), cost(cost) {}

	edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

	bool operator<(const edge<T> e1) {
		return cost < e1.cost;
	}


	edge &operator=(const int &x) {
		to = x;
		return *this;
	}

	operator int() const { return to; }

};
template<typename T>
using Edge = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edge<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

int vis[100005];
UnWeightedGraph G;
vector<int> solve(int s) {
	stack<int> sta;
	vector<int> ans;
	sta.push(s);
	ans.push_back(s);
	while (!sta.empty()) {
		ll cur = sta.top();
		vis[cur] = 1;
		sta.pop();
		rep(i, G[cur].size()) {
			if (vis[G[cur][i]] == 0) {
				sta.push(G[cur][i]);
				ans.push_back(G[cur][i]);
				break;
			}
		}
	}

	rep(i, G[s].size()) {
		if (vis[G[s][i]] == 0) {
			sta.push(G[s][i]);
			ans.insert(ans.begin(), G[s][i]);
			break;
		}
	}

	while (!sta.empty()) {
		ll cur = sta.top();
		vis[cur] = 1;
		sta.pop();
		rep(i, G[cur].size()) {
			if (vis[G[cur][i]] == 0) {
				sta.push(G[cur][i]);
				ans.insert(ans.begin(), G[cur][i]);
				break;
			}
		}


	}

	return ans;
}


int main() {
	ll N, M;

	cin >> N >> M;
	G.resize(N);
	rep(i, M) {
		ll A, B;
		cin >> A >> B;
		A--, B--;
		G[A].emplace_back(B);
		G[B].emplace_back(A);
	}


	vector<int> ans = solve(0);

	cout << ans.size() << endl;

	rep(i, ans.size()) {
		cout << ans[i]+1 << " ";
	}
	
	return 0;

}

Measured memory_bytes: 7160
#include<cstdio>
#include<iostream>
#include<set>
using namespace std;
char s[5];
int main(){
    while(cin>>s){
            set<char>a;
        for(int i=0;i<3;i++){
            a.insert(s[i]);

        }
    if(a.size()==3)printf("Yes\n");
    else printf("No\n");
    }


return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#include <list>

using LL = long long;

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

const int inf = 0x7fffffff;
const LL linf = 0x7fffffffffffffff;

int read()
{
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f; 
}

bool a[100];

int main()
{   
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            a[i*j]=1;
        }
    }

    puts(a[read()]?"Yes":"No");

    return 0;
}


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

string toUpper(string s) {
	string t = s;
	for (int i = 0; i < s.size(); i++) {
		t[i] = toupper(s[i]);
	}
	return t;
}

int main()
{
	string target, source;
	
	cin >> target;
	target = toUpper(target);

	int cnt = 0;

	while (1) {
		cin >> source;
		if (source == "END_OF_TEXT")break;
		source = toUpper(source);
		if (target == source)cnt++;
	}
	cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3188
package main

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

func dummy() {
	math.Abs(1.0)
}

/************I/O***********/

var (
	// ReadString returns a WORD string.
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

// ReadFloat64 returns an float64.
func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func readFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = readFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func readRuneSlice() []rune {
	return []rune(readString())
}

/*********math********/
func mod(val int, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func minInt(val ...int) int {
	res := val[0]
	for i := 1; i < len(val); i++ {
		if res > val[i] {
			res = val[i]
		}
	}
	return res
}
func maxInt(val ...int) int {
	res := val[0]
	for i := 1; i < len(val); i++ {
		if res < val[i] {
			res = val[i]
		}
	}
	return res
}

const MOD = 1000000007

func main() {
	n := readInt()
	wMax := readInt()
	w := make([]int, n)
	v := make([]int, n)
	for i := 0; i < n; i++ {
		w[i] = readInt()
		v[i] = readInt()
	}
	dp := make([][]int, n+1)
	for i := 0; i <= wMax; i++ {
		dp[0] = append(dp[0], 0)
	}

	for i := 1; i <= n; i++ {
		dp[i] = append(dp[i], 0)
		for j := 1; j <= wMax; j++ {
			if j < w[i-1] {
				dp[i] = append(dp[i], dp[i-1][j])
			} else {
				dp[i] = append(dp[i], maxInt(dp[i-1][j], dp[i-1][j-w[i-1]]+v[i-1]))
			}
		}
	}
	fmt.Println(dp[n][wMax])

}


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

int a, b, c, N;

int main()
{
    while (cin >> a >> b >> c)
    {
        if (a == 0 && b == 0 && c == 0)
            return 0;
        cin >> N;
        vector<int> A(a, 1), B(b, 1), C(c, 1);
        int p[N], q[N], r[N], s[N];
        for (int i = 0; i < N; i++)
        {
            cin >> p[i] >> q[i] >> r[i] >> s[i];
            q[i] -= a, r[i] -= a + b;
            if (s[i] == 1)
                A[p[i] - 1] = 2, B[q[i] - 1] = 2, C[r[i] - 1] = 2;
            else
                A[p[i] - 1] = max(1, A[p[i] - 1]), B[q[i] - 1] = max(1, B[q[i] - 1]), C[r[i] - 1] = max(1, C[r[i] - 1]);
        }
        for (int i = 0; i < N; i++)
        {
            if (s[i] == 0)
            {
                if (A[p[i] - 1] == 2 && B[q[i] - 1] == 2 && C[r[i] - 1] == 1)
                    C[r[i] - 1] = 0;
                if (A[p[i] - 1] == 2 && B[q[i] - 1] == 1 && C[r[i] - 1] == 2)
                    B[q[i] - 1] = 0;
                if (A[p[i] - 1] == 1 && B[q[i] - 1] == 2 && C[r[i] - 1] == 2)
                    A[p[i] - 1] = 0;
            }
        }
        for (int i = 0; i < a; i++)
        {
            if (A[i] == 2)
                A[i] = 1;
            else if (A[i] == 1)
                A[i] = 2;
            cout << A[i] << endl;
        }
        for (int i = 0; i < b; i++)
        {
            if (B[i] == 2)
                B[i] = 1;
            else if (B[i] == 1)
                B[i] = 2;
            cout << B[i] << endl;
        }
        for (int i = 0; i < c; i++)
        {

            if (C[i] == 2)
                C[i] = 1;
            else if (C[i] == 1)
                C[i] = 2;
            cout << C[i] << endl;
        }
    }
}


Measured memory_bytes: 3108
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#define pb push_back
using namespace std;
int n,m;

int mitih[1500000],mitiw[1500000];

int main(void){
  int i,j,x,tmp,res;
  vector<int> h,w;
  while(scanf("%d %d",&n,&m),n|m){
    h.clear(),w.clear();
    for(i=1;i<=n;i++) {
      cin>>x;
      h.pb(x);
    }
    for(i=1;i<=m;i++){
      cin>>x;
      w.pb(x);      
    }
    //set<int> st1,st2;
    vector<int> s1,s2;
    for(i=0;i<n;i++){
      tmp=0;
      for(j=i;j<n;j++){
	tmp+=h[j];
	s1.pb(tmp);
      }
    }
    for(i=0;i<m;i++){
      tmp=0;
      for(j=i;j<m;j++){
	tmp+=w[j];
	s2.pb(tmp);
      }
    }
    h.clear();w.clear();
    //for(auto itr=st1.begin();itr!=st1.end();++itr) h.pb(*itr);
    //for(auto itr=st2.begin();itr!=st2.end();++itr) w.pb(*itr);
    i=j=res=0;
    sort(s1.begin(),s1.end());
    sort(s2.begin(),s2.end());
    tmp=max(s1[s1.size()-1],s2[s2.size()-1]);
    /*
    for(i=0;i<s1.size();i++) printf("%d ",s1[i]);
    printf("\n");
    for(i=0;i<s2.size();i++) printf("%d ",s2[i]);
    printf("\n");
    */
    //printf("5\n");
    
    map<int,int> mp1,mp2;
    //tmp=max(s1.size(),s2.size());
    for(i=0;i<tmp;i++){
      mp1[i]=mp2[i]=0;
    }
    for(i=0;i<s1.size();i++) mp1[s1[i]]++;
    for(i=0;i<s2.size();i++) mp2[s2[i]]++;
    for(i=0;i<=tmp;i++){
      //printf("%d : %d %d\n",i,mp1[i],mp2[i]);
      res+=mp1[i]*mp2[i];
    }
    
    printf("%d\n",res);
  }
  return 0;
}


/*
int solveninaritakattananika(){
  int i,j,k,n;
  int res=0;
  n=max(h[h.size()-1],w[w.size()-1]);
  for(k=1;k<=n;k++){
    for(i=0;i<h[h.size()-1]-k+1;i++){
      for(j=0;j<w[w.size()-1]-k+1;j++){
	if(mitih[i]==1&&mitih[i+k]==1&&mitiw[j]==1&&mitiw[j+k]==1) res++;
	//printf("%d %d %d %d : ",mitih[i],mitiw[j+k],mitih[i+k],mitiw[j]);
	//printf("(%d,%d) k=%d  res=%d\n",i,j,k,res);
      }
    }
  }
  return res;
}
*/

Measured memory_bytes: 54552
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (a >= k) cout << k << endl;
	else if (a + b >= k) cout << a << endl;
	else cout << a - (k - (a + b)) << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
struct edge { int to, cost; };
struct state {
	int pos, cost, pt, rem;
	// position, cost, previous t (0 or 2), rem
};
bool operator<(const state& s1, const state& s2) {
	return s1.cost < s2.cost;
}
int N, M, X, a, b, c;
int main() {
	cin >> N >> M >> X;
	vector<int> T(N);
	for (int i = 0; i < N; i++) cin >> T[i];
	vector<vector<edge> > G(N);
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> c; a--, b--;
		G[a].push_back(edge{ b, c });
		G[b].push_back(edge{ a, c });
	}
	vector<vector<vector<int> > > dist(N, vector<vector<int> >(X + 1, vector<int>(2, 999999999))); dist[0][X][0] = 0;
	priority_queue<state> que; que.push(state{ 0, 0, 0, X });
	while (!que.empty()) {
		state s = que.top(); que.pop();
		for (edge e : G[s.pos]) {
			int r = max(s.rem - e.cost, 0), p = s.pt;
			if (r > 0 && ((s.pt << 1) ^ T[e.to]) == 2) continue;
			if (T[e.to] != 1) r = X, p = T[e.to] >> 1;
			if (dist[e.to][r][p] > dist[s.pos][s.rem][s.pt] + e.cost) {
				dist[e.to][r][p] = dist[s.pos][s.rem][s.pt] + e.cost;
				que.push(state{ e.to, -dist[e.to][r][p], p, r });
			}
		}
	}
	int ret = 999999999;
	for (int i = 0; i <= X; i++) {
		ret = min(ret, min(dist[N - 1][i][0], dist[N - 1][i][1]));
	}
	cout << ret << endl;
	return 0;
}

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

long long int N, T, t, pt, ans;

int main(){
    scanf("%lld%lld%lld", &N, &T, &pt);
    for(int i = 1; i < N; ++i){
        scanf("%lld", &t);
        ans += min(t - pt, T);
        pt = t;
    }
    cout << ans + T << endl;
    return 0;
}


Measured memory_bytes: 256
N, x = map(int, input().split())
a = [int(i) for i in input().split()]

ret = float('inf')
dp = [float('inf')] * N
for i in range(N) :
    for j in range(N) :
        dp[(j+i)%N] = min(dp[(j+i)%N], a[j])
    ret = min(ret, sum(dp) + x * i)
print(ret)

Measured memory_bytes: 42588
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
constexpr const int INF=1<<30,MOD=1000000007;constexpr const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
#ifndef LOCAL
struct osd{template<class T>osd&operator<(const T&t){return*this;}template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;template<class...T>void _print(osd&a,T&&...t){}
#define cerr cer_
#endif
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}template<class T>istream&operator>(istream&i,T&t){return i>>t;}
void _print(ostream&s){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<t<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}template<class...T>void dprint(T&&...t){_print(cerr,t...);}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<p.F<' '<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>p.F>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>queue<T>&operator<<(queue<T>&q,const T&t){q.push(t);return q;}template<class T>queue<T>&operator<<(T&t,queue<T>&q){t=q.front();q.pop();return q;}
template<class T>deque<T>&operator>>(const T&t,deque<T>&q){q.push_front(t);return q;}template<class T>deque<T>&operator<<(T&t,deque<T>&q){t=q.front();q.pop_front();return q;}
template<class T>deque<T>&operator<<(deque<T>&q,const T&t){q.push_back(t);return q;}template<class T>deque<T>&operator>>(deque<T>&q,T&t){t=q.back(t);q.pop_back();return q;}
template<class T>stack<T>&operator<<(stack<T>&s,const T&t){s.push(t);return s;}template<class T>stack<T>&operator>>(stack<T>&s,T&t){t=s.top();s.pop();return s;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
int n,d;
cin>n>d;
cout<(n+2*d)/(2*d+1)<endl;

    return 0;
}


Measured memory_bytes: 256
"後ろからたどる必要はなかった...
普通に前からたどればOK"

#a→bに到達可能か？
# def isAccessible(a, s, t)
#   (a[s-1] == t) ? true : false
# end 

N = gets.to_i
a = []
N.times.map{a << gets.to_i}


start = 1
target = 2
1.upto N do |i|
  start = a[start-1]
  if start == target
    puts i
    exit
  end
end
puts -1

#下、TLEくらいました
# 1.upto N do |e|
#   1.upto N do |i|
#     if isAccessible(a, i, target)
#       target = i
#       if target == 1
#         puts e
#         exit
#       end
#       break
#     end
#   end
# end
# puts -1

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    ll n ;
    cin >> n ;
    vll a(n) ;
    ll sum = 0 ;
    REP(i,n){
        cin >> a[i] ;
        sum = (sum^a[i]) ;
    }
    REP(i,n){
        cout << (sum^a[i]) <<" " ;
    }
    cout << endl;




    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 4824
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define lli long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// int const mod = 7340033;
int const mod = 1e9+7;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}
 
int inverse(int x){
    return power(x,mod-2,mod);
}

int const N = 1e5+5;
int const inf = 1e18;


void solve(){
    int i,j,l;
    int n;
    int m;
    cin>>n>>m;
    if(m>=n) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}   

int32_t main(){
    IOS;
    int t;
    t = 1;
    // pre();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

/*

*/

Measured memory_bytes: 256
#include <iostream>

using namespace std;



int main()
{
    string N;
    long long T = 0;
    getline(cin, N);
    for (int i = 0; i<N.size(); i++)
    {
        T = T+ (N[i]-'0');
    }
    if (T%9 == 0)   cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3700
#include <iostream>
using namespace std;
int main(void){
    int n;
    while(true){
        cin >> n;
        if(n==0)break;
        int maxp=0,maxv=-1,p,a,b;
        for(int i=0;i<n;i++){
            cin >> p >> a >> b;
            if(maxv < (a+b)){
                maxv = a+b;
                maxp = p;
            }
        }
        cout << maxp << " " << maxv << endl;
    }
    return 0;
}


Measured memory_bytes: 3060
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>
#include <stack>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}
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() {
    string s; cin >> s;
    int res = 0;
    stack<char> st;
    rep(i, 0, s.size()) {
        if (st.empty() || st.top() == s[i]) st.push(s[i]);
        else {
            res += 2;
            st.pop();
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 512
//##MohK
//19/02/2020.... 3,21.
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a;
    cin>>a;
    for(ll i=a;i>0;i--){
        ll c=sqrt(i);
        if(c*c==i){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <map>

#define FOR(i,a,b) for(long long int i =(a); i <(b);i++)
#define REP(i,N)   FOR(i,0,N)
#define debug(x)   cout << #x << " = " << x << endl;
#define MOD (int)(1e+9)+7
using namespace std;

map <int,int> mp;

int prime[168] = {  2,  3,  5,  7, 11, 13, 17, 19, 23, 29,
                    31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
                    73, 79, 83, 89, 97,101,103,107,109,113,
                    127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};

void div(int N){

    if(N == 0) return;
    int x = N;
    for(int i = 0;i<168;++i){
        while(1){
            if(x < prime[i]) break;
            if(x % prime[i] == 0){
                x /= prime[i];
                mp[prime[i]]++;
            }else{
                break;
            }
        }
        if(x == 1)break;
    }
    div(N-1);
}


int main(void){
    
    int N;
    cin >> N;

    div(N);
    long long int ans = 1;
    for(auto it = mp.begin();it!=mp.end();++it){
        //cout << (*it).first << ":" << (*it).second << endl;
        ans *= ((*it).second+1);
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256