akhauriyash/Code-Regression huggingface dataset:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    import math
    input = sys.stdin.readline

    a, b, N = map(int, input().split())
    if N < b:
        print(math.floor(a * N / b))
    else:
        print(math.floor(a * (b-1) / b))


if __name__ == '__main__':
    main()


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


string solve(){
  string res;
  for(int i=0;i<str.size();i++){
    int cnt=0;
    while(str[i]=='+'||str[i]=='-')cnt+=(str[i]=='+')-(str[i]=='-'),i++;
    cnt%=('Z'-'A'+1);
    if(cnt) res+=((str[i]-'A')+cnt+('Z'-'A')+1)%('Z'-'A'+1)+'A';
    else res += str[i];
    if(str[i]=='?')res[res.size()-1]='A';
  }
  
  for(int i=0;i<res.size();i++){ 
    if(res[i]=='['){
      int c=1,j=i+1;
      while(c) c+=(res[j]=='[')-(res[j]==']'),j++;
      reverse(res.begin()+i,res.begin()+j);
      for(int k=i;k<j;k++) 
	if(res[k]=='[')res[k]=']';
	else if(res[k]==']')res[k]='[';
      res.erase(res.begin()+j-1),res.erase(res.begin()+i);
      i--;
    }
  }
  return res;
}


int main(){
  while(1){
    str.clear();
    cin>>str;
    if(str==".")break;
    cout <<solve()<<endl;
  }


  

  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#include <iostream> 
#include <string> 
#define lli long long int
#define deb1(x) cout<<#x<<" :: "<<x<<"\n";
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define deb3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define deb(v) for(lli i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define all(a) a.begin(),a.end()
#define ll long long
using namespace std;
#define f first
#define sd second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sz(x) (ll)x.size()
#define vl vector<lli>
#define pii pair<lli,lli>
lli mod=998244353;
using namespace std;
lli t,n,u,x,y,k;
const lli N = 100001;
lli po(lli i,lli j){
    lli ans=1;
    for(lli l=1;l<=j;++l)ans*=i;
    return ans;
}
int main(){
    fast
     t=1;
//    cin>>t;
    while(t--){
        cin>>n>>x>>k;
        map<lli,lli>m;
        vl a;
        a.push_back(x);
        m[x]=0;
        lli cnt=1,fl=0,s=x;
        for(int i=2;i<=n;++i){
            y=a[a.size()-1]*a[a.size()-1];
            y=y%k;
            s+=y;
//            deb3(i,y,s)
            if(m[y]!=0){
//                deb1(m[y])
                lli sum=0,r=0,ans=0;
                vl b;
//                for(int j=0;j<a.size();++j)cout<<a[j]<<" ";
//                cout<<endl;
                for(int j=0;j<m[y];++j)ans+=a[j];
                for(int j=m[y];j<i-1;++j){
                    sum+=a[j];
                    b.push_back(sum);
                    ++r;
                }
//                deb2(r,sum)
                lli an=((n-i+1)/r)*sum;
//                deb1(an)
                if((n-i+1)%r!=0){
//                    for(int j=0;j<b.size();++j)cout<<b[j]<<" ";
//                cout<<endl;
//                deb1((n-i+1)%r)
                    an+=b[(n-i+1)%r-1];
                }
                ans+=an+sum;
//                deb1(ans)
                cout<<ans<<endl;
                fl=1;
                break;
               
                
            }else m[y]=cnt;
            ++cnt;
            a.push_back(y);
        }
        if(!fl)cout<<s<<endl;
        
        
    }
}

Measured memory_bytes: 7512
--http://www.nct9.ne.jp/m_hiroi/light/lua07.html
Stack = {}

function Stack.new()
  local obj = { buff = {} }
  return setmetatable(obj, {__index = Stack})
end

function Stack:push(x)
  table.insert(self.buff, x)
end

function Stack:pop()
  return table.remove(self.buff)
end

function Stack:top()
  return self.buff[#self.buff]
end

function Stack:isEmpty()
  return #self.buff == 0
end

--------------------------------------------------------

local n,k=io.read("*n","*n")
local edge={}
for i=1,n do
    edge[i]={}
end
for i=1,n-1 do
    local a,b=io.read("*n","*n")
    edge[a][b]=false
    edge[b][a]=false
end

local pattern=k
local stack=Stack.new()
stack:push(1)

while not stack:isEmpty() do
    local a=stack:pop()
    local available_colors=k-1
    if a>1 then
        available_colors=available_colors-1
    end
    for b,_ in pairs(edge[a]) do
        if not edge[a][b] then
            edge[a][b]=true
            edge[b][a]=true
            stack:push(b)
            pattern=pattern*available_colors%1000000007
            available_colors=available_colors-1
        end
    end
end
print(pattern)

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

int main(void){

  int P, Q, R;
  int ABC[3];
  int min;

  scanf("%d",&P);
  scanf("%d",&Q);
  scanf("%d",&R);

  ABC[0] = P + Q;
  ABC[1] = R + Q;
  ABC[2] = P + R;

  min = ABC[0];

  for(int i=1; i<3 ; i++){
    if(min>ABC[i]){
      min = ABC[i];
    }
  }

  printf("%d",min);

  return 0;
}


Measured memory_bytes: 128
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
    n = int(input())
    res = 0
    for c in range(1,n):
        ab = n - c
        col = collections.Counter(prime_factorize(ab))
        r = 1
        for count in col.values():
            r *= count+1
        res += r
    print(res)


if __name__ == "__main__":
    main()

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto& e : a) cin >> e;
    a.insert(a.begin(), 0), a.push_back(0);
    
    vector<int> gl(n+2), gr(n+2);
    gl[0] = 0, gr[n+1] = 0;
    for (int i = 0; i + 1 <= n + 1; i++) gl[i+1] = max(gl[i], a[i+1]);
    for (int i = n + 1; i - 1 >= 0; i--) gr[i-1] = max(gr[i], a[i-1]);

    for (int i = 1; i <= n; i++) {
        cout << max(gl[i-1], gr[i+1]) << endl;
    }
}


Measured memory_bytes: 3952
S = list(input())

if S[0] != 0: a = int(''.join(S[:2]))
else: a = int(S[1])
if S[2] != 0: b = int(''.join(S[2:]))
else: b = int(S[3])

if 1 <= a <= 12:
    if 1 <= b <= 12:
        ans = 'AMBIGUOUS'
    else:
        ans = 'MMYY'
else:
    if 1 <= b <= 12:
        ans = 'YYMM'
    else:
        ans = 'NA'

print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

// A
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int a=scn.nextInt();
		int b=scn.nextInt();
		int t=scn.nextInt();
		System.out.println(t/a*b);
	}

}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    if(n>81)
        printf("No");
    else
    {
        for(int i=1;i<=9;i++)
            for(int j=1;j<=9;j++)
            if(i*j==n)
        {
            printf("Yes");
            return 0;
        }
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

#define MAXN 100000
int N,M;
struct Edge{
    int v,w[2];
    Edge(){}
    Edge(int a,int w1,int w2){
        v=a,w[0]=w1,w[1]=w2;
    }
};
vector<Edge> G[MAXN+5];

bool vis[MAXN+5];
long long dist[2][MAXN+5];
void SPFA(int S,int opt){
    memset(vis,0,sizeof vis);
    memset(dist[opt],0x3f,sizeof dist[opt]);
    queue<int> Q;Q.push(S);
    dist[opt][S]=0;vis[S]=1;
    while(!Q.empty()){
        int u=Q.front();
        vis[u]=0;Q.pop();
        for(int i=0;i<int(G[u].size());i++){
            int v=G[u][i].v,w=G[u][i].w[opt];
            if(dist[opt][v]>dist[opt][u]+w){
                dist[opt][v]=dist[opt][u]+w;
                if(!vis[v]){
                    vis[v]=1;
                    Q.push(v);
                }
            }
        }
    }
}

long long Ans[MAXN+5];
int main(){
    int S,T;
    scanf("%d%d%d%d",&N,&M,&S,&T);
    for(int i=1;i<=M;i++){
        int u,v,w1,w2;
        scanf("%d%d%d%d",&u,&v,&w1,&w2);
        G[u].push_back(Edge(v,w1,w2));
        G[v].push_back(Edge(u,w1,w2));
    }
    SPFA(S,0);
    SPFA(T,1);
    Ans[N]=dist[0][N]+dist[1][N];
    for(int i=N-1;i>=1;i--)
        Ans[i]=min(Ans[i+1],dist[0][i]+dist[1][i]);
    for(int i=1;i<=N;i++)
        printf("%lld\n",1000000000000000ll-Ans[i]);
}


Measured memory_bytes: 10880
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
#include <cassert>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PP(p) cout<<(p)<<" ";
#define INF 1e18

typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
//int dy[8]={1,1,1,0,-1,-1,-1,0};
//int dx[8]={-1,0,1,1,1,0,-1,-1};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

int pic(int n,int d){
    rep(i,d-1)n/=10;

    return n%10;
}
unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}/*
bool check(int n){
    int d =GetDigit(n);
    bool f = true;
    for(int i= 1;i<d;i++){
        if(abs(pic(n,i)-pic(n,i+1))>1){
            f = false;
        }
    }
    return f;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vi a;
    int k,cnt=0;
    cin>>k;
    for(int i = 1;;i++){
        if(check(i)){
            cnt++;
            if(cnt==k){
                cout << i << endl;
                return 0;
            }
        }
    }
    return 0;
}*/
signed main(){
    queue<int> q;
    int cnt = 0,k;
    cin>>k;
    for(int i = 1;i<10;i++)q.push(i);
    int t;
    while(true){
        t = q.front();
        q.pop();
        int t1 = t%10;
     //   int tm = pic(t,GetDigit(t));
        if(t1!=0){
            q.push(10*t+t1-1);
            if(cnt==k)break;
        }
        q.push(10*t+t1);
        cnt++;
        if(cnt==k)break;
        if(t1!=9){
            q.push(10*t+t1+1);
            if(cnt==k)break;
        }      
    }
    cout << t << endl;
}


Measured memory_bytes: 5116
//JSD
#include<iostream>
#include<vector>
#include<set>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<limits.h>
#define ll long long 
using namespace std;

int main(){
	ll int n;	
	ll m;
	cin>>n>>m;
	if(n!=m)	cout<<"No\n";
	else cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int N;
    string S;
    cin >> N >> S;
    int left = 0, right = N - 1;
    int ans = 0;
    while (true) {
        while (left <= right && S[left] != 'W') left += 1;
        while (left <= right && S[right] != 'R') right -= 1; 
        if (left >= right) break;
        ans += 1;
        left += 1, right -= 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
	int T;
	while(cin >> T, T){
		vector<int> in;
		int a;
		for(int i = 0; i < T; i++){
			cin >> a;
			in.push_back(a);
		}
		sort(in.begin(), in.end());
		int ans = 0;
		for(int i = 1; i < in.size()-1; i++){
			ans += in[i];
		}
		cout << (int)(ans / (in.size()-2)) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1220
#include<iostream>
using namespace std;
int main (void){
long long n,k=2;
cin >> n;
long long count=0;
for(int i=1;i<=25;i++){
	k *=5;
	count += n/k;
}
  if(n%2==1){cout <<0;
  	}else{
		cout << count ;
  }
return 0;
}


Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2019/03/09
 *      Author: family
 */


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int xn[100] = {0};
int ym[100] = {0};


int main()
{
	int n, m, x, y;
	int i = 0;
	int maxx, miny;
	scanf("%d %d %d %d", &n, &m, &x, &y);
	maxx = x;
	miny = y;
	for(i = 0; i < n; i++) {
		scanf("%d", &xn[i]);
		if(maxx < xn[i]) {
			maxx = xn[i];
		}
	}
	for(i = 0; i < m; i++) {
		scanf("%d", &ym[i]);
		if(miny > ym[i]) {
			miny = ym[i];
		}
	}
	if (maxx > x) {

	}
	if (maxx < miny)  {
		printf("No War\n");
	} else {
		printf("War\n");
	}

	return 0;
}


Measured memory_bytes: 384
from sys import stdin
from collections import deque
def main():
  _map, _input, _int = map, stdin.readline, int
  n, q = _map(_int, _input().split())
  values = [0] * n
  links = [[] for _ in range(n)]
  for _ in range(n - 1):
    a, b = _map(_int, _input().split())
    links[a - 1].append(b - 1)
    links[b - 1].append(a - 1)
  for _ in range(q):
    p, x = _map(_int, _input().split())
    values[p - 1] += x
  d = deque()
  d.append((0, -1))
  while len(d) != 0:
    i, p = d.popleft()
    for j in links[i]:
      if j == p:
        continue
      values[j] += values[i]
      d.append((j, i))
  print(*values)
main()

Measured memory_bytes: 62132
t = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(t[int(input()) - 1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int cr = 0;
  rep(i, n) {
    if (s[i] == '0') cr++;
  }
  cout << min(cr, n-cr)*2 << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

/*** chmax, chmin ***/
// a < b ならば a を b で更新
// 更新されたら true を返す
template <typename T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
// a > b ならば a を b で更新
// 更新されたら true を返す
template <typename T>
bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
/*** chmax, chmin ここまで ***/

void Main()
{
    int n;
    cin >> n;
  	string s;
  	map<string, int> mp;

  	rep(i,n) {
      cin >> s;
      mp[s]++;
    }
  
  	int mx = 0;
  	for (auto p:mp){
    	chmax(mx, p.second);
    }
  	
	for (auto p:mp){
    	if(p.second == mx) {
			cout << p.first << endl;
        }
    }
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

int sum(vector<int> a){
  int sum=0;
  for(int i=0;i<a.size();++i){
    sum=sum+a.at(i);
  }
  return sum;
}

int main(){
  int N;
  cin>>N;
  vector<int> h(N);
  for(int i=0;i<N;++i){
    cin>>h.at(i);
  }

  int count=0;

  while(sum(h)!=0){
    
    int ind1=0;
    while(h.at(ind1)==0){
      ++ind1;
    }
        
    int m=h.at(ind1);
    int ind2=ind1;
    
    for(int j=ind1;j<N && h.at(j)!=0;++j){
      m=min(m,h.at(j));
      ++ind2;
    }
    
    
    for(int j=ind1;j<ind2;++j){
      h.at(j)=h.at(j)-m;
    }
    
    count=count+m;
  }

  cout<<count<<endl;
}

Measured memory_bytes: 256
n = input()
a = map(int, raw_input().split())
a.sort()
x = a[-1]
s = x
p = a[0]
for i in a:
    if s >= abs((x/2)-i):
        s = (x/2)-i
        p = i
    else:
        print x, p
        break
else:
    print a[1], a[0]


Measured memory_bytes: 11388
#define FNAME ""
 
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cassert>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <string>
 
#define hash padjf9srpi
#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forn(i, n) for (int i = 0; i < (n); i++)
#define fornr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define forab(i, a, b) for (int i = (a); i < (b); i++)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
 
#ifdef _WIN32
    #define I64 "%I64d"
#else
    #define I64 "%lld"
#endif
 
using namespace std;
 
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;                                                                                                                                                                                      
typedef vector <int> vi;
 
template <class T> T sqr(const T &a) {return a * a;}

int a[100][100], b[100][100];


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
    	string s;
    	cin >> s;
    	for (int j = 0; j < n; j++) {
    		a[i][j] = s[j] == '.';
    	}
    }
    for (int i = 0; i < m; i++) {
    	string s;
    	cin >> s;
    	for (int j = 0; j < m; j++) {
    		b[i][j] = s[j] == '.';
    	}
    }
    for (int i = 0; i <= n - m; i++) {
    	for (int j = 0; j <= n - m; j++) {
    		bool ok = true;
    		for (int i1 = 0; i1 < m; i1++) {
    			for (int j1 = 0; j1 < m; j1++) {
    				if (a[i + i1][j + j1] != b[i1][j1])ok =false;
    			}
    		}
    		if (ok) {
    			cout << "Yes";
    			return 0;
    		}
    	}
    }
    cout << "No";
    
    
    return 0;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
MOD = 10**9 + 7


def comb(n: int, k: int, MOD: int) -> int:
    if n < k or n < 0 or k < 0:
        return 0
    k = min(k, n - k)
    if k == 0:
        return 1
    iinv = [1] * (k + 1)
    ans = n
    for i in range(2, k + 1):
        iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD
        ans *= (n + 1 - i) * iinv[i] % MOD
        ans %= MOD
    return ans


# ans = ((1 << n) - 1) % MOD
ans = (pow(2, n, MOD) - 1) % MOD
ans -= comb(n, a, MOD)
ans -= comb(n, b, MOD)
ans %= MOD
print(ans)


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

#define int long long
#define ll long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define fro(i,j,n) for(int i = (j);i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second
const int mod = 1e9 + 7;
int add(int a,int b){
	return (a + b)%mod;
}
int sub(int a,int b){
	return add(a,mod - 1);
}
int mul(int a,int b){
	return (a*b)%mod;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int n,m;
    cin >> n >> m;
    int a[n];
    ffor(i,n) cin >> a[i];
    vvi adj(n);
    vector<bool> ok(n,true);
    ffor(i,m){
    	int x,y;
    	cin >> x >> y;
    	--x,--y;
    	adj[x].push_back(y);
    	adj[y].push_back(x);
    }
    for(int i = 0;i < n;++i){
    	if(!ok[i])continue;
    	for(auto x : adj[i]){
    		if(a[x] > a[i]){
    			ok[i] = false;
    			break;
    		}else if(a[x] == a[i]){
    			ok[x] = false;
    			ok[i] = false;
    			break;
    		}else{
    			ok[x] = false;
    		}
    	}
    }
    int ans = 0;
    ffor(i,n){
    	if(ok[i]){
    		ans++;
    	}
    }
    cout << ans;
}

Measured memory_bytes: 9796
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define llinf LONG_LONG_MAX
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcount(n)
#define endl '\n'
const ll N=3e4+5,mod=1000000007,bit=60;
signed main()
{
    fast;
    ll pro=1,temp,t,i,j,l,r,n,m,mid,z,k,x,y,rem,carry=0,ind,ans=0,mx=-llinf,mn=llinf,cnt=0,curr=0,prev,next,sum=0,flag=1,i1=-1,i2=-1;
    cin>>x;
    for(i=1;i<=9;i++)
    {
    	for(j=1;j<=9;j++)
    	{
    		if(i*j==x)
    		{
    			return cout<<"Yes",0;
    		}
    	}
    }
    cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define fi(i,start,end) for(int i=start; i<end; ++i)
#define fd(i,end,start) for(int i=end-1; i>=start; --i)
#define pb push_back
#define mz(a) memset(a,0,sizeof(a))
#define nl cout<<endl;
#define ip(n) cin>>n;
#define op(n) cout<<n;
#define FT() int t; cin>>t; while(t--)
#define inparr fi(i,0,n) ip(a[i]);
#define dispar fi(i,0,n) op(a[i]); nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

void solve()
{
	string s;
	cin>>s;
	string ans;
	if(s[s.length()-1]=='s')
	{
		ans = s + "es";
		cout<<ans;
	}
	else
	{
		ans = s+"s";
		cout<<ans;
	}
}
int main()
{
	/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif*/
	
	//FT()
		solve();

	/*#ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif*/
	return 0;
}


Measured memory_bytes: 3632
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#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
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

map<int,int> mp;
int a[3];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  for(int i=0;i<3;i++){
    cin >> a[i];
    mp[a[i]]++;
  }
  for(int i=0;i<3;i++){
    if(mp[a[i]]<2){
      cout << a[i] << endl;
    }
  }


return 0;
}
///....


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

using namespace std;

#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x=a*c,y=a*d,z=b*c,w=b*d;
    int ans=max(max(x,y),max(z,w));
    cout<<ans<<endl;

}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	int a[s.length()];
	for(int i = 0; i<s.length(); i++)
		a[i] = s[i]-'0';
	map<int,int>m;
	ll ans =0, rem = 0,ten=1;
	for(int i= s.length()-1;i>=0; i--)
	{
		rem = (ten*a[i]+rem)%2019;
		ten = ten*10%2019;
		// ans = 10*rem;
		// rem = (ans+a[i])%2019;
		m[rem]++;
	}
	ans = 0;
	for(auto i:m)
	{
		int y = i.second;
		if(i.first==0)
			ans += (y*(y+1))/2;
		else
			ans += (y*(y-1))/2;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
  int a, b=0, c=0, d=0;
  cin >> a;

  b += a%3600;  //分
  c += b%60;  //秒

  cout<<a/3600<<":"<<b/60<<":"<<c<<endl;

  return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

ll gcd(ll a, ll b) {
    while (b) {
        ll c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main() {
    ios::sync_with_stdio(false);
    int n, y = 0;
    ll a[200005] = {}, b[200005] = {}, z = 1, p[200005] = {1};
    map<pair<ll, ll>, int> m;
    set<pair<ll, ll>> s;
    cin >> n;
    for (int i = 1; i <= n; i++) p[i] = p[i - 1] * 2 % mod;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        ll g = gcd(abs(a[i]), abs(b[i]));
        if (g == 0) {
            y++;
            continue;
        }
        a[i] /= g; b[i] /= g;
        m[{a[i], b[i]}]++;
    }
    for (auto i : m) if (s.find(i.first) == s.end()) {
        ll c, d, x = i.first.first, y = i.first.second;
        s.insert({x, y});
        s.insert({-y, x});
        s.insert({-x, -y});
        s.insert({y, -x});
        c = m[{x, y}] + m[{-x, -y}];
        d = m[{-y, x}] + m[{y, -x}];
        z = z * (p[c] + p[d] - 1) % mod;
    }
    cout << (z + mod - 1 + y) % mod;
}


Measured memory_bytes: 108328
s = input().rstrip()

a = int(s[:2])
b = int(s[2:])
if 1 <= a <= 12 and 1 <= b <= 12:
    print("AMBIGUOUS")
elif (a == 0 or 13 <= a <= 99) and 1 <= b <= 12:
    print("YYMM")
elif 1 <= a <= 12 and (b == 0 or 13 <= b <= 99):
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 9084
#include<iostream>
#include <complex>
#include <cmath>
#include<cstdio>
using namespace std;
typedef complex<double> xy_t;

xy_t P[110];
double cross_product(xy_t a, xy_t b) { 
    return (conj(a)*b).imag(); 
}

const double eps = 1e-11;
double x[4], y[4];
int N;
int main() {
    cin >> N; // 問題数
    for (int t=0; t<N; ++t) {
        for (int i=0; i<4; ++i) cin >> x[i] >> y[i]; // x0,y0..x3,y3
        xy_t a[2] = {
        xy_t(x[0],y[0]) - xy_t(x[1],y[1]),
        xy_t(x[2],y[2]) - xy_t(x[3],y[3])
        };
        bool p = abs(cross_product(a[0],a[1])) < eps;
        cout << (p ? "YES" : "NO") << endl;
    }
}



Measured memory_bytes: 3176
from collections import deque

# 入力
H,W = map(int, input().split())
S = [input() for i in range(H)]
C = sum(s.count('.') for s in S)

dd = ((-1,0), (0, -1), (1,0), (0,1))
que = deque([(0,0,0)])
used = {(0,0)}

res = None
while que :
    s, t, cost = que.popleft()
    if s == H-1 and t == W-1:
        res = cost
        break
    for di, dj in dd:
        ni = s + di; nj = t + dj
        if(not 0 <= ni < H) or (not 0 <= nj < W) or S[ni][nj] == '#' or (ni,nj) in used:
            continue
        used.add((ni,nj))
        que.append((ni,nj,cost+1))

# 結果出力
if res:
    print(C - 1 - res)
else:
    print(-1)


Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <cstring>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
using namespace std;

const int INF = 100000000;
int V, E;
int dist[16][16];
int dp[(1<<16)+1][16];

int rec(int bit, int v){
  if (dp[bit][v] != -1) return dp[bit][v];
  if (bit == (1<<v)){
    if (dist[0][v] == -1)
      return dp[bit][v] = INF;
    else
      return dp[bit][v] = dist[0][v];
  }
  int res = INF;
  int prev_bit = bit & ~(1<<v);
  rep(u, V){
    if (!(prev_bit & (1<<u))) continue;
    if (dist[u][v] == -1) continue;
    if (res > rec(prev_bit, u) + dist[u][v]){
      res = rec(prev_bit, u) + dist[u][v];
    }
  }
  return dp[bit][v] = res;
}

int main(){
  cin >> V >> E;
  memset(dist, -1, sizeof(dist));
  memset(dp, -1, sizeof(dp));
  int s, t, d;
  rep(i, E){
    cin >> s >> t >> d;
    dist[s][t] = d;
  }
  int res = INF;
  res = rec((1<<V)-1, 0);
  if (res == INF)
    cout << -1 << endl;
  else
    cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 7204
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
using graph = vector<vector<int>>;

const double pi = 3.14159265358979323846;
const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	int dif1 = x2 - x1, dif2 = y2 - y1;
	cout << x2 - dif2 << " " << y2 + dif1 << " " << x1 - dif2 << " " << y1 + dif1 << endl; 
} 

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define N_MAX 100005
#define MOD (1000000007)

using namespace std;

typedef long long int Int;

Int dp[N_MAX];
Int h[N_MAX];

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

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

    dp[0] = 0;
    dp[1] = dp[0]+abs(h[1]-h[0]);
    for(int i = 2;i < N;i++) {
        dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
    }

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

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,b,i;
  list<int>a;
  cin>>n;
  string s;
  list<int>::iterator it;
  while(n--){
    cin>>s;
    if(s.size()<=6){
      cin>>b;
      if(s[0]=='i')a.push_front(b);
      else{
        it=a.begin();
        while(it!=a.end()){
          if(*it==b){a.erase(it);break;}
          it++;
        }
      }
    }
    else{
      if(s[6]=='F')a.pop_front();
      else a.pop_back();
    }
  }
  it=a.begin();
  for(i=0;it!=a.end();it++,i++){
    if(i)cout<<' ';
    cout<<(*it);
  }
  cout<<endl;
}


Measured memory_bytes: 34252
#include<stdio.h>

#define mod 1000000007

long long dp[100001][13];
long long ten[100001];

int main(){
	int n,i;
	char s[100001];
	scanf("%s",s);
	for(i=0;s[i]!=0;i++);
	n=i;
	ten[0]=1;
	for(i=1;i<=n;i++){
		ten[i]=ten[i-1]*10;
		ten[i]%=13;
	}
	for(i=0;i<n;i++){
		int j=n-1-i;
		if(i==0){
			if(s[j]=='?'){
				for(int k=0;k<10;k++)dp[0][k]=1;
			}else dp[0][s[j]-'0']=1;
		}
		else {
			if(s[j]=='?'){
				for(int k=0;k<13;k++){
					for(int l=0;l<10;l++){
						dp[i][(k+l*ten[i])%13]+=dp[i-1][k];
						dp[i][(k+l*ten[i])%13]%=mod;
					}
				}
			}
			else {
				for(int k=0;k<13;k++){
					dp[i][(k+(s[j]-'0')*ten[i])%13]+=dp[i-1][k];
					dp[i][(k+(s[j]-'0')*ten[i])%13]%=mod;
				}
			}
		}
	}
	printf("%lld\n",dp[n-1][5]);
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> void mmax(T &m, const T q) { if (m < q) m = q; }
template<typename T> void mmin(T &m, const T q) { if (m > q) m = q; }
template<typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;


int main()
{
    lint A;
    cin >> A;
    lint B;
    cin >> B;
    cout << ((A <= 8 and B <= 8) ? "Yay!" : ":(") << endl;
    return 0;
}


Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)              cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)              cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}



int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll cur=0;
    ll maxi=0;
    for(ll i=0; i<n; i++){
        if(s[i]=='I') cur++;
        else cur--;

        maxi=max(maxi,cur);
    }
    cout << maxi;
    return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
import java.util.*;

public class Main{

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

        // input
        long num = scan.nextLong();
        long a = scan.nextLong();
        long b = scan.nextLong();

        // answer
        if(num == 1 && a != b){
            System.out.println(0);
        } else if (a > b){
            System.out.println(0);
        } else {
            System.out.println((b - a) * (num - 2) + 1);
        }
        

    }
}

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

const int MAX_N = 10000001;

bool is_prime[MAX_N];

void calc_prime(int n){
	for(int i = 0; i <= n; ++i)
		is_prime[i] = true;
	is_prime[0] = is_prime[1] = 0;
	
	for(int i = 2; i <= n / 2; ++i){
		if(is_prime[i])
			for(int j = 2 * i; j <= n; j += i)
				is_prime[j] = false;
	}
}

int main() {
	int n;
	calc_prime(MAX_N);
	while(1){
		cin >> n;
		if(n == 0)
			break;

		int c = n;
		while(1){
			if(is_prime[c - 8] && is_prime[c - 6] && is_prime[c - 2] && is_prime[c]){
				cout << c << endl;
				break;
			}
			c--;
		}
	}
	return 0;
}

Measured memory_bytes: 10924
#include<stdio.h>
int c,i=0;
int a[10000];
int main(){
scanf("%d",&c);
for(int k=0;k<c;k++){
scanf("%d",&a[k]);
for(int j=0;a[k]%2==0;i++)a[k]=a[k]/2;
}
printf("%d",i);
return 0;
}


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

using namespace std;

/* Template file for Online Algorithmic Competitions */
/* Typedefs */
    /* Basic types */
    typedef long long           ll;
    typedef unsigned long long ull;
    /* STL containers */
    typedef vector <int>    vi;
    typedef vector <ll>     vll;
    typedef pair <int, int> pii;
    typedef pair <ll, ll>   pll;
    typedef vector < pii >  vpii;
    typedef vector < pll >  vpll;
    typedef vector <string> vs;
    typedef vector < vi >   vvi;
/* Macros */
    /* Loops */
    #define fl(i, a, b)     for(int i(a); i<(b); i++)
    #define rep(i, n)       fl(i, 0, n)
    #define rep1(i, n)      fl(i, 1, n)
    #define rfl(i, a, b)    for(int i(a);i>=(b);i--)
    /* Algorithmic functions */
    #define srt(v)          sort((v).begin(),(v).end())
    /* STL container methods */
    #define pb              push_back
    #define mp              make_pair
    /* String methods */
    #define slen(s)         s.length()
    /* Shorthand notations */
    #define F               first
    #define S               second
    #define MOD             1000000007
    #define MAX             100010
    #define re              return 
    #define sz(x)           ((int) (x).size())
    #define all(x)          (x).begin(), (x).end()
    #define sqr(x)          ((x) * (x))
    #define fill(x, y)      memset(x, y, sizeof(x))
/* Templates */
template<class T> T abs(T x) { re x > 0 ? x : -x; }

int main(){

    int w;
    string s, res;

    cin >> s;
    cin >> w;

    int n = slen(s);

    rep(i, n){
        if(i % w == 0){
            res += s[i];
        }
    }
    cout << res;
    return 0;
}

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

int main(){
    int n;
    int i,j;
    int ja,ma;
    int cj,cm;
    cin >> n;
    cin >> ja >> ma;
    cin >> cj >> cm;
    for(i=0;ja>0;i++) ja -= cj;
    for(j=0;ma>0;j++) ma -= cm;
    if(i < j) cout << n - j << endl;
    else if(i > j) cout << n - i << endl;
    else cout << n - i << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

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

signed main() {
	string S;
	int K;
	cin >> S >> K;

	set<char> st;
	rep(i, S.size()) st.insert(S[i]);

	set<string> st2;

	itrep(it, st) {
		char ch = *it;
		rep(i, S.size()) {
			if (S[i] != ch) continue;
			rep(j, 10) {
				if (i + j >= S.size()) break;
				st2.insert(S.substr(i, j + 1));
			}
		}

		if (st2.size() >= K) break;
	}

	auto it = st2.begin();
	K--;
	while (K) {
		K--;
		it++;
	}

	cout << *it << endl;

    return 0;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0); cin.tie(0);

	int L;
	cin >> L;
	int hbit = (int)log2(L);
	cout << hbit + 1 << ' ' << hbit * 2 + (__builtin_popcount(L) - 1) << endl;
	for (int i = 1; i <= hbit; ++i) {
		cout << i << ' ' << i + 1 << ' ' << (1 << (i - 1)) << endl;
		cout << i << ' ' << i + 1 << " 0" << endl;
	}
	int curw = (1 << hbit);
	for (int i = 0; i < hbit; ++i) if ((L & (1 << i))) {
		cout << i + 1 << ' ' << hbit + 1 << ' ' << curw << endl;
		curw += (1 << i);
	}

	return 0;
}

Measured memory_bytes: 256
#define mod 1000000007
#define INF 1000000000
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	long long n;
	cin >> n;
	string ans;
	while (n > 0) {
		n -= 1;
		ans += char('a' + n % 26);
		n /= 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << '\n';
	
	return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

struct UnionFind {
  vector<int> data; // 根の場合は集合の大きさ*-1、子の場合は親の番号が入る
  UnionFind(int size) : data(size, -1) { }
  bool link(int x, int y) { //新たな併合を行うとtrue
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  int root(int x) { // 代表元を返す
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) { // 要素xが含まれる集合の大きさ
    return -data[root(x)];
  }
  bool same(int x, int y) { // 同じ集合ならtrue
    return root(x) == root(y);
  }
};

int nextInt() { int x; scanf("%d", &x); return x;}

const ll INF = 1LL << 61;

const int MAX_N = 212345;
ll A[MAX_N];

struct Edge {
  int a;
  int b;
  ll w;
  bool operator < (const Edge& o) const {
    return w < o.w;
  }
};

struct Entry {
  int origin;
  int v;
  ll w;
  bool operator < (const Entry& o) const {
    return w > o.w; // priority_queue
  }
};

int origin[2 * MAX_N];
ll dist[2 * MAX_N];

int main2() {
  int N = nextInt();
  ll D = nextInt();
  REP(i, N) A[i] = nextInt();


  // REP(i, N) {
    // REP(j, N) {
      // if (i == j) cout << "-\t";
      // else cout << (A[i] + A[j] + abs(i-j)*D) << "\t";
    // }
    // cout << endl;
  // }

  CLR(origin, -1);

  // ボロノイ図
  vector<Edge> es;
  
  priority_queue<Entry> pq;
  REP(i, N) pq.push({i, i, 0});
  while (!pq.empty()) {
    Entry cur = pq.top(); pq.pop();
    const int v = cur.v;
    if (origin[v] != -1) continue;
    origin[v] = cur.origin;
    dist[v] = cur.w;

    vector<pair<int, ll>> nxt;
    if (v < N) {
      nxt.push_back({v + N, A[v]});
    } else {
      nxt.push_back({v - N, A[v-N]});
      if (v - 1 >= N) nxt.push_back({v - 1, D});
      if (v + 1 < 2*N) nxt.push_back({v + 1, D});
    }

    for (auto nei : nxt) {
      int u = nei.first;
      ll w = nei.second;
      if (origin[u] == -1) {
        pq.push({cur.origin, u, cur.w+w});
      } else {
        if (origin[u] != origin[v])
          es.push_back( { origin[u], origin[v], dist[u] + dist[v] + w });
      }
    }

  }
  // pv(origin + N, origin + 2*N);
  // pv(dist + N, dist + 2*N);

  ll ans = 0;
  UnionFind uf(N);
  sort(ALL(es));
  
  for (Edge e : es) {
    // cout << e.a << " " << e.b << " " << e.w << endl;
    if (uf.link(e.a, e.b)) {
      ans += e.w;
    }
  }
  

  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 19052
#include <iostream>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <iomanip>
#include <math.h>
#include <algorithm>
#define oo 1000000007
#define maxN 207
using namespace std;

int f[2][207][207];
int a[207][207];
int b[1007];

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("serv.inp", "r", stdin);
//    freopen("serv.out", "w", stdout);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
//    int n, m;
//    cin >> n >> m;
//
//    for (int i = 1; i <= n; ++i) {
//        for (int j = 1; j <= n; ++j) {
//            cin >> a[i][j];
//        }
//    }
//
//    for (int u = 1; u <= n; ++u) {
//        for (int v = 1; v <= n; ++v) {
//            f[0][u][v] = oo;
//        }
//    }
//    f[0][2][3] = 0;
//
//    int ans = oo;
//    b[0] = 1;
//
//    for (int i = 1; i <= m; ++i) {
//        cin >> b[i];
//        int i0 = 1-i%2;
//        int i1 = i%2;
//
//        for (int u = 1; u <= n; ++u) {
//            for (int v = 1; v <= n; ++v) {
//                f[i1][u][v] = oo;
//            }
//        }
//        for (int u = 1; u <= n; ++u) {
//            for (int v = 1; v <= n; ++v) {
//                f[i1][u][v] = min(f[i1][u][v], f[i0][u][v]+a[b[i-1]][b[i]]);
//                f[i1][u][b[i-1]] = min(f[i1][u][b[i-1]], f[i0][u][b[i-1]]+a[v][b[i]]);
//                f[i1][b[i-1]][u] = min(f[i1][b[i-1]][u], f[i0][u][v]+a[v][b[i]]);
//                f[i1][v][b[i-1]] = min(f[i1][v][b[i-1]], f[i0][v][b[i-1]]+a[u][b[i]]);
//                f[i1][b[i-1]][v] = min(f[i1][b[i-1]][v], f[i0][b[i-1]][v]+a[u][b[i]]);
//                if (i == m) ans = min({ans, f[i1][u][v], f[i1][u][b[i-1]],
//                                            f[i1][b[i-1]][u], f[i1][v][b[i-1]], f[i1][b[i-1]][v]});
//            }
//        }
//    }
//
//
//    cout << ans << endl;
    int x;
    cin >> x;
    cout << 1-x << endl;
    return 0;
}

Measured memory_bytes: 3176