akhauriyash/Code-Regression huggingface dataset:
package main

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for D - Dice in Line
	var N, K int
	fmt.Scan(&N, &K)

	sc.Split(bufio.ScanWords)
	p := make([]int, N)
	var temp int
	sum := make([]int, N)
	for i := 0; i < N; i++ {
		p[i] = nextInt()
		temp += p[i]
		sum[i] = temp
	}

	var max int
	var maxNum int
	var count int
	for i := 0; i < N-K+1; i++ {
		//count = 0
		//for j := 0; j < K; j++ {
		//	count += p[i+j]
		//}
		if i == 0 {
			count = sum[i+K-1]
		} else {
			count = sum[i+K-1] - sum[i-1]
		}

		if max < count {
			max = count
			maxNum = i
		}
	}

	var ans float64
	for i := 0; i < K; i++ {
		ans += (float64(p[maxNum+i]) + 1.0) / 2.0
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5896
n=int(input())

res=n

for i in range(n+1):
    cc=0
    t=i
    while t>0:
        cc+=t%6
        t//=6
    t=n-i
    while t>0:
        cc+=t%9
        t//=9
    res=min(res,cc)

print(res)


Measured memory_bytes: 3060
N = int(input())
arr = [list(map(int, input().split())) for i in range(2)]
max_sum = 0    

for i in range(N):
    r = 0
    sum1 = 0
    for j in range(N):
        if j == i:
            sum1 += arr[r][j]
            r = 1
        sum1 += arr[r][j]
    
    if sum1 > max_sum:
        max_sum = sum1
        
print(max_sum)

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

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

	int res = *max_element(h, h+n);
	for (int i = 0; i <= n-k; ++i)
		res = min(res, h[i+k-1] - h[i]);

	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 640
n,m,c=input().split()
n,m,c=int(n),int(m),int(c)

b=input().split()
d=0
for i in range(n):
    x=0
    a=input().split()
    for j in range(m):
        x+=int(a[j])*int(b[j])
    if x+c>0:
        d+=1

print(d)


Measured memory_bytes: 3060
def extgcd(a,b):
  r=[1,0,a]
  w=[0,1,b]
  while w[2]!=1:
    q=r[2]//w[2]
    r2=w
    w2=[r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
    r=r2
    w=w2
  return [w[0],w[1]]
def mod_inv(a,m):
  x=extgcd(a,m)[0]
  return (m+x%m)%m

n,a,b=map(int,input().split())
mod=10**9+7
x=1;y=1
for i in range(a):
  x*=(n-i)
  x%=mod
for i in range(a):
  x*=mod_inv(i+1,mod)
  x%=mod
for i in range(b):
  y*=(n-i)
  y%=mod
for i in range(b):
  y*=mod_inv(i+1,mod)
  y%=mod
z=pow(2,n,mod)
print((z-1-x-y+mod)%mod)

Measured memory_bytes: 44156
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    ll N, M;
    cin >> N >> M;
    ll a[M], b[M];
    ll c[M][N] = {};
    ll bit[M] = {};
    FOR(i, 0, M) {
        cin >> a[i] >> b[i];
        FOR(j, 0, b[i]) {
            int x;
            cin >> x;
            c[i][x - 1] = 1;
        }
        FOR(j, 0, N) {
            bit[i] *= 2;
            bit[i] += c[i][j];
        }
    }
    vector<ll> DP(pow2(N), numeric_limits<ll>::max());
    DP[0] = 0;
    FOR(i, 0, DP.size()) {
        if (DP[i] == numeric_limits<ll>::max()) continue;
        FOR(j, 0, M) {
            DP[i | bit[j]] = min(DP[i | bit[j]], DP[i] + a[j]);
        }
    }
    cout << (DP[pow2(N) - 1] == numeric_limits<ll>::max() ? -1 : DP[pow2(N) - 1]) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
using namespace std;
typedef long long ll;
int main(){
   #ifndef ONLINE_JUDGE 
      FILE_READ_IN 
      FILE_READ_OUT 
   #endif
     int n; cin>>n;
     cout<<(n*(n+1))/2;
   
   return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
int main(){
    int q;cin>>q;
    vstr x(q),y(q);
    rep(i,q)cin>>x[i]>>y[i];
    vin ans(q);
    rep(i,q){
        int sx=x[i].size();
        int sy=y[i].size();
        vvin dp(sx+1,vin(sy+1,0));
        rep(j,sx){
            rep(k,sy){
                if(x[i][j]==y[i][k])dp[j+1][k+1]=max(dp[j][k]+1,max(dp[j+1][k],dp[j][k+1]));
                else dp[j+1][k+1]=max(dp[j+1][k],dp[j][k+1]);
            }
        }
        ans[i]=dp[sx][sy];
    }
    rep(i,q)cout<<ans[i]<<endl;
}


Measured memory_bytes: 6828
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    vector<ll>a(n);
    ll last=0;
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        if(i==0){
            if(a[i]>0){
                cout<<-1<<endl;
                return 0;
            }
        }else{
            if(a[i]>a[i-1]+1){
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    ll ans=0;
    for(int i=n-1;i>0;i--){
        if(a[i]==a[i-1]+1)ans++;
        else ans+=a[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    int a;
    scanf("%d",&a);
    for(;a>0;a--){
        double a1,a2,b1,b2,c1,c2,x1,y1,x2,y2,x3,y3;
        double x,y,r;
        scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
        a1=2*(x2-x1),b1=2*(y2-y1);
        c1=x1*x1-x2*x2+y1*y1-y2*y2;
        a2=2*(x3-x1),b2=2*(y3-y1);
        c2=x1*x1-x3*x3+y1*y1-y3*y3;
        x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
        y=(c1*a2-c2*a1)/(a1*b2-a2*b1);
        r=hypot(x-x1,y-y1);
        printf("%.3lf %.3lf %.3lf\n",x,y,r);
    }
    return 0;
}

Measured memory_bytes: 1096
import sys
sys.setrecursionlimit(int(1e5+10))

def search_dist(g, dist, e):
    for b, c in g.get(e):
        if dist[b] is not None:
            continue
        dist[b] = dist[e] + c
        search_dist(g, dist, b)

def main():
    g = {}
    N = int(input())
    for i in range(N+1):
        g[i] = []
    for _ in range(N-1):
        a, b, c = list(map(int, input().split(' ')))
        g[a] += [(b, c)]
        g[b] += [(a, c)]
    Q, K = list(map(int, input().split(' ')))
    dist = [None]*(N+1)
    dist[K] = 0
    search_dist(g, dist, K)
    cood = []
    for _ in range(Q):
        cood.append(list(map(int, input().split(' '))))

    for x, y in cood:
        print(dist[x]+dist[y])

if __name__ == '__main__':
    main()


Measured memory_bytes: 157060
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

int main(void) {
  ll n,k;cin>>n>>k;
  vector<ll> G;
  ll a;

  rep(i,0,n-1) {
    cin>>a;
    a--;
    G.push_back(a);
  }

  queue<ll> todo;
  todo.push(0);
  vector<bool> seen(n, false);

  ll target = 0;

  rep(i,1,n) {
    ll tar = todo.front();
    todo.pop();
    todo.push(G[tar]);

    if(seen[tar]) {
      target = tar;
      break;
    }

    seen[tar] = true;
  }

  queue<ll> todo2;
  todo2.push(0);
  bool mark = false;
  vector<ll> Sub;
  vector<ll> Main;
  ll cnt = 0;
  rep(i,1,n) {
    ll tar = todo2.front();
    if(mark && tar==target) {
      break;
    }
    if(tar==target) {
      mark=true;
    } else {
      cnt++;
    }
    if(mark) {
      Sub.push_back(tar);
    }
    Main.push_back(tar);
    todo2.pop();
    todo2.push(G[tar]);
  }

// pr("====");
//   pr(target);
// pr("====");
// pr("====");
// 
// for(auto s:Sub) {
//   pr(s);
// }
// 
// pr("====");
// 

   if(k>(cnt+1-Sub.size())) {
    ll tar = (k-(cnt+1-Sub.size()))%(Sub.size());
    pr(Sub[tar]+1);
   } else {
     pr(Main[k]+1);
   }
   // for(auto m:Main) {
   //   pr(m);
   // }
  // pr(k-(cnt+1-Sub.size()));

  return 0;
}

#if 0
6 2
6 5 2 5 3 2
6 1
6 5 2 5 3 2
#endif



Measured memory_bytes: 9528
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

bool comp(pair<ll,ll> L, pair<ll,ll> R){
	return L.second > R.second;
}

int main(){
	ll n;
	cin >> n;
	vector<ll> v(n);
	REP(i,n) cin >> v[i];
	
	map<ll,ll> codd,ceven;
	REP(i,n){
		if(i%2){
			codd[v[i]]++;
		}else{
			ceven[v[i]]++;
		}
	}
	
	vector<pair<ll,ll>> odd,even;
	for(auto x: codd) odd.push_back(x);
	for(auto x: ceven) even.push_back(x);
	sort(odd.begin(),odd.end(),comp);
	sort(even.begin(),even.end(),comp);
	
	ll ans;
	if(odd[0].first!=even[0].first){
		ans = n/2 - odd[0].second;
		ans += n/2 - even[0].second;
	}else if(1==odd.size() || 1==even.size()){
		ans = n/2;
	}else{
		ans = n - odd[0].second - even[1].second;
		chmin(ans, n - odd[1].second - even[0].second);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 12532
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll power(ll x, ll n, ll P){
    if(n == 0) return 1LL;
    ll res = power(x * x % P, n/2, P);
    if(n % 2 == 1) res = res * x % P;
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,P;
    cin >> N >> P;
    string S;
    cin >> S;
    ll val[200010] = {};
    rep(i,0,N){
        val[i] = power(10, N-1-i, P) * (S[i] - '0') % P;
    }
    ll sum[200010] = {};
    rep(i,0,N) (sum[i+1] = sum[i] + val[i]) %= P;
    ll cnt[10010] = {};
    ll ans = 0;
    if(P == 2){
        rep(i,0,N){
            if((S[i]-'0') % 2 == 0){
                ans += i+1;
            }
        }
    }else if(P == 5){
        rep(i,0,N){
            if((S[i]-'0') % 5 == 0){
                ans += i+1;
            }
        }
    }else{
        rep(i,0,N+1){
            ans += cnt[sum[i]];
            cnt[sum[i]]++;
        }
    }
    print(ans);

    

}


Measured memory_bytes: 3732
import java.util.*;
import java.io.*;
class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int[] x = new int[10];
	for(int i=0; i<10; i++)
	    x[i]=sc.nextInt();
	Arrays.sort(x);
	System.out.printf("%d\n%d\n%d\n",x[9],x[8],x[7]);
    }
}

Measured memory_bytes: 12000
#include <stdio.h>

int main(){
	int angka[110];
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&angka[i]);
	}
	for(n=n-1;n>=0;n--){
		if(n==0){
		printf("%d\n",angka[n]);	
		}else{
		printf("%d ",angka[n]);}
	}
	return 0;
}


Measured memory_bytes: 2108
import sys

n, m = list(map(int, input().split()))
swi = []
for _ in range(m):
    k, *sss = list(map(int, input().split()))
    t = 0
    for s in sss:
        t += 1 << (s - 1)
    swi.append(t)
ppp = list(map(int, input().split()))

ans = 0
for i in range(1 << n):
    for s, p in zip(swi, ppp):
        t = i & s
        c = bin(t).count('1') % 2
        if c != p:
            break
    else:
        ans += 1
print(ans)


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

using namespace std;

const int maxn = 1e4+10, maxs = 110, mod = 1e9+7;

vector<int> digit;

int n, d, dp[maxn][maxs][2];

void add_self(int &a, int b){
    a += b;
    if(a>=mod){
        a -= mod;
    }
}

int solve(int pos, int sum, bool flag){
    if(dp[pos][sum][flag] != -1) return dp[pos][sum][flag];
    if(pos == n) return (sum%d == 0 ? 1 : 0);

    if(flag){
        int tot = 0;

        for(int i=0; i<=digit[pos]; i++){
            add_self(tot, solve(pos+1, (sum+i)%d, (i == digit[pos])));
        }

        return dp[pos][sum][flag] = tot;
    }
    else{
        int tot = 0;

        for(int i=0; i<=9; i++){
            add_self(tot, solve(pos+1, (sum+i)%d, 0));
        }

        return dp[pos][sum][flag] = tot;
    }
}

int calc(string k){
    n = (int)k.size();

    digit.resize(n);

    for(int i=0; i<n; i++) digit[i] = k[i] - '0';

    memset(dp, -1, sizeof dp);

    int ans = solve(0, 0, 1) - 1;

    if(ans == -1) ans += mod;

    return ans;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    string k;

    cin >> k >> d;

    cout << calc(k) << endl;

    return 0;
}


Measured memory_bytes: 9728
#include<iostream>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int P, Q, R; std::cin >> P >> Q >> R;
  fin(P+Q+R - std::max(P, std::max(Q, R)));
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
template<class T> void chmin(T& x, T y){if(x < y) x = y;}
template<class T> void chmax(T& x, T y){if(x > y) x = y;}
const ll mod = 1e9 + 7;
int N, M;
int S[2010];
int T[2010];
ll dp[2010];
int main(){
    cin >> N >> M;
    for(int i = 1; i <= N; i++) cin >> S[i];
    for(int i = 1; i <= M; i++) cin >> T[i];
    for(int i = 1; i <= N; i++){
        ll sum = 0;
        for(int j = 1; j <= M; j++){
            ll s = dp[j];
            if(S[i] == T[j]){
                dp[j] += sum + 1;
                dp[j] %= mod;
            }
            sum += s;
            sum %= mod;
        }
    }
    ll res = 1;
    for(int i = 1; i <= M; i++){
        res += dp[i];
        res %= mod;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

const ll INF = 1e18;

int main() {
  int n;
  cin >> n;
  vl a(n);
  REP(i, n) cin >> a[i];
  v(vl) dp(n+1, vl(2, -INF));
  dp[0][0] = a[0];
  dp[0][1] = -a[0];
  FOR(i, 1, n) {
    chmax(dp[i][0], dp[i-1][0] + a[i]);
    chmax(dp[i][0], dp[i-1][1] - a[i]);
    if(i==n-1) continue;
    chmax(dp[i][1], dp[i-1][0] - a[i]);
    chmax(dp[i][1], dp[i-1][1] + a[i]);
  }
  ll ans = dp[n-1][0];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6528
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Set colorSet = new HashSet();
    Scanner sc = new Scanner(System.in);
    int color1 = sc.nextInt();
    int color2 = sc.nextInt();
    int color3 = sc.nextInt();

    colorSet.add(color1);
    colorSet.add(color2);
    colorSet.add(color3);

    System.out.println(colorSet.size());
  }
}


Measured memory_bytes: 21588
int main(void) {
  char a[100000];
  int cnt=0;
  int cnt2=0;
  int i,ans;

scanf("%s",a );

for ( i = 0; a[i]!='\0'; i++) {
  if (i%2==0) {
    if (a[i]=='1') {
      cnt++;
    }
  }
  if (i%2==1) {
    if (a[i]=='0') {
      cnt++;
    }
  }
}

for ( i = 0; a[i]!='\0'; i++) {
  if (i%2==0) {
    if (a[i]=='0') {
      cnt2++;
    }
  }
  if (i%2==1) {
    if (a[i]=='1') {
      cnt2++;
    }
  }
}

if (cnt>=cnt2) {
  ans=cnt2;
}
else {
  ans=cnt;
}

printf("%d\n",ans );

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using Graphi = vector<vi>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};

int main(){

    int n; cin >> n;
    vector<int> x(n),y(n),h(n);
    rep(i,n) cin >> x.at(i) >> y.at(i) >> h.at(i);

    ll height_temp;
    int k = 0;
    while(h.at(k) == 0) k++;
    int x_ans,y_ans;
    bool ok;
    rep(X,101){
        rep(Y,101){
            ok = true;
            height_temp = h.at(k) + abs(X-x.at(k)) +abs(Y-y.at(k));
            rep(i,n){
                if(max(height_temp - abs(X-x.at(i)) - abs(Y-y.at(i)),0LL) != h.at(i)) ok = false; 
            }
            if(ok){
                x_ans = X;
                y_ans = Y;
                break;
            }
        }
        if(ok) break;
    }
    cout << x_ans sp y_ans sp height_temp << endl;

    return 0;

}

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

using namespace std;

using int64 = long long;

int64 Solve() {
  int n, p;
  cin >> n >> p;
  int e = 0;
  int o = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x % 2 == 1) {
      o++;
    } else {
      e++;
    }
  }

  if (p == 1 && o == 0) {
    return 0;
  }

  int64 ans = 1;
  for (int i = 0; i < e; i++) ans *= 2;
  for (int i = 0; i < o - 1; i++) ans *= 2;
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  cout << Solve() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define push push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<long long> V;
typedef vector<V> VV;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 62;
const int INF = 1 << 30;

int main()
{

    long long h, w, ans;

    cin >> h >> w;
    if(h==1 or w==1){
        ans=1;
    }else{
        ans = (h * w + 1) / 2;
    }
    cout <<ans<< endl;
}


Measured memory_bytes: 256
import std.algorithm;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;

immutable string NO = "IMPOSSIBLE";

auto solve(long A, long B){
    auto K = (A + B) / 2;
    return (abs(A - K) == abs(B - K)) ? K.to!string : NO;
}

void main(){
    auto input = stdin.byLine.map!split.joiner;

    long A;
    A = input.front.to!long;
    input.popFront;

    long B;
    B = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(A, B);
    else
        solve(A, B).writeln;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int Square(int n)
{
    int i;
    for(i=1; n>0; i+=2)
    {
        n-=i;
    }
    if(n==0)
        return 1;
    else
        return 0;
}
int main()
{
    int a,b,c;
    scanf("%d %d",&a,&b);
    int i=1;
    c=b;
    while(1)
    {
        c=c/10;
        if(c!=0)
        {
           i=i*10;
        }
        else
        {
            i=i*10;
            break;
        }
    }
    int n;
    n=(a*i)+b;
    if(Square(n))
       printf("Yes\n");
    else
       printf("No\n");
    return 0;
}


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  int N, K;
  cin >> N >> K;
  int ans = 1;
  rep(i, N) {
    if (ans*2>=ans+K){
      ans += K;
    }else{
      ans *= 2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}
long long gcd(long long a,long long b){
  if(b==0){
    return a;
  }
  return gcd(b,a%b);
}
long long lcm(long long a,long long b){
  long long g=gcd(a,b);
  return a/g*b;
}
long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}






int main(){
  int A,B;
  cin>>A>>B;
  if(B%A==0){
    cout<<A+B<<endl;
  }else{
    cout<<B-A<<endl;
  }
  



}



  
  



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

typedef long long int LL;
#define REP(n) for(LL i = 0; i < (n); i++)
#define COUT(val) cout << (val) << endl
#define CIN(val) cin >> (val)
#define SORT(vec) sort(vec.begin(), vec.end())
#define SORT_GRE(vec) sort(vec.begin(), vec.end(), greater<LL>())

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '2') ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main(void)
{
	string *card = new string[3];
	for (int i = 0; i < 3; ++i) {
		cin >> card[i];
	}

	int turn = 0;
	while (true) {
		if (card[turn].length() == 0)	break;
		char tmp = card[turn][0];
		card[turn].erase(0, 1);

		if (tmp == 'a')	turn = 0;
		else if (tmp == 'b')	turn = 1;
		else if (tmp == 'c')	turn = 2;
	}

	if (turn == 0) cout << 'A' << endl;
	else if (turn == 1) cout << 'B' << endl;
	else if (turn == 2) cout << 'C' << endl;

	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
 
if N % 2 == 1:
  for i in range(1,M+1):
    print(i,N-i+1)
else:
  if N/4 >= M:
    for i in range(1,M+1):
      print(i,N-i+1)
  else:
    for i in range(1,(N//4)+1):
      print(i,N-i+1)
    for j in range(1,M-(N//4)+1):
      print(N//2-j,N//2+j)

Measured memory_bytes: 9280
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 5e5 + 10; 
const int block_size = 1000;

int cnt[N];
int A[N];
int cur = 0;

void remove(int idx){
   cnt[A[idx]]--;
   if(cnt[A[idx]] == 0) --cur;
}

void add(int idx){
   if(cnt[A[idx]] == 0) ++cur;
   cnt[A[idx]]++;
}

int get_answer(){
   return cur;
}

struct Query {
    int l, r, idx;
    bool operator<(Query other) const
    {
        return make_pair(l / block_size, r) <
               make_pair(other.l / block_size, other.r);
    }
};

vector<int> mo_s_algorithm(vector<Query> queries) {
    vector<int> answers(queries.size());
    sort(queries.begin(), queries.end());

    // TODO: initialize data structure

    int cur_l = 0;
    int cur_r = -1;
    // invariant: data structure will always reflect the range [cur_l, cur_r]
    for (Query q : queries) {
        while (cur_l > q.l) {
            cur_l--;
            add(cur_l);
        }
        while (cur_r < q.r) {
            cur_r++;
            add(cur_r);
        }
        while (cur_l < q.l) {
            remove(cur_l);
            cur_l++;
        }
        while (cur_r > q.r) {
            remove(cur_r);
            cur_r--;
        }
        answers[q.idx] = get_answer();
    }
    return answers;
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,q;
   cin >> n >> q;
   vector<Query> Q(q);
   f(i,0,n){
      cin >> A[i];
   }
   f(i,0,q){
      int l,r;
      cin >> l >> r;
      --l,--r;
      Q[i].l = l, Q[i].r = r;
      Q[i].idx = i;
   }
   vector<int> R = mo_s_algorithm(Q);
   f(i,0,q){
      cout << R[i] << '\n';
   }
   return 0;
} 

Measured memory_bytes: 38444
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;

const int INF = 1 << 29;
typedef pair<int, int> P;


int main(void)
{
	int n, q; cin >> n;
	vector<int> s(n);
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
	}
	int ans = 0;
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		int t; cin >> t;
		vector<int>::iterator it = lower_bound(s.begin(), s.end(), t);
		if(it != s.end() && *it == t) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1532
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	n, m = tin()
	#s = input()
	is_red_in = [0]*n
	is_red_in[0] = 1
	num_of_ball = [1] * n
	for _ in range(m):
		f, t = tin()
		f, t = f-1, t-1
		num_of_ball[f] -= 1
		num_of_ball[t] += 1
		if is_red_in[f] == 1:
			is_red_in[t] = 1
		if num_of_ball[f] == 0:
			is_red_in[f] = 0
	return sum(is_red_in)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 10416
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();

        int odd = 0;
        int eve = 0;
        for (int i = 1; i <= k; i++) {
            if (i % 2 == 0) {
                eve++;
            } else {
                odd++;
            }
        }
        System.out.println(eve * odd);
    }
}



Measured memory_bytes: 20052
n = int(input())
ans = True
already = set()
memory = 0
for i in range(n):
    w = input()
    if (memory == 0 or memory == w[0]) and not w in already:
        memory = w[len(w)-1]
        already.add(w)
    else:
        ans = False
if ans:
    print("Yes")
else:
    print("No")

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

struct Node { int parent, left, right; };
Node T[25];
int dep[25];
int h[25];

void SetDepth(int node, int d) {
  dep[node] = d;
  if (T[node].right != -1) SetDepth(T[node].right, d + 1);
  if (T[node].left != -1) SetDepth(T[node].left, d + 1);
}

int SetHeight(int u) {
  int h1 = 0, h2 = 0;
  if (T[u].left != -1) h1 = SetHeight(T[u].left) + 1;
  if (T[u].right != -1) h2 = SetHeight(T[u].right) + 1;
  h[u] = max(h1, h2);
  return h[u];
}

void Print(int u) {
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].parent << ", ";
  if (T[u].parent != -1) {
    if (T[T[u].parent].left == u) cout << "sibling = " << T[T[u].parent].right << ", ";
    else if (T[T[u].parent].right == u) cout << "sibling = " << T[T[u].parent].left << ", ";
    else cout << "sibling = " << -1 << ", ";
  } else cout << "sibling = " << -1 << ", ";
  cout << "degree = " << (T[u].left != -1) + (T[u].right != -1) << ", ";
  cout << "depth = " << dep[u] << ", ";
  cout << "height = " << h[u] << ", ";
  if (T[u].parent == -1) cout << "root";
  else if (T[u].left == -1 && T[u].right == -1) cout << "leaf";
  else cout << "internal node";
  cout << endl;
}

int main() {
  int n; cin >> n;
  for (int i = 0; i < n; i++) T[i] = {-1,-1,-1};

  for (int i = 0; i < n; i++) {
    int id, left, right; cin >> id >> left >> right;
    T[id] = {-1,left,right};
  }

  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) if (T[i].left == j || T[i].right == j) T[j].parent = i;

  int root = 0;
  for (int i = 0; i < n; i++) if (T[i].parent == -1) root = i;
  SetDepth(root, 0);
  SetHeight(root);

  for (int i = 0; i < n; i++) Print(i);

  return 0;
}



Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

bool data[90][90];
int w, h, dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1};

int dfs(int y, int x, int d){
  int res = d;
  for(int i=0;i<4;i++){
    int ny = y + dy[i];
    int nx = x + dx[i];
    if(0<=ny && ny<h && 0<=nx && nx<w && data[ny][nx]){
      data[ny][nx] = false;
      res = max(res, dfs(ny, nx, d+1));
      data[ny][nx] = true;
    }
  }
  return res;
}

main(){
  while(scanf("%d %d", &w, &h) && (w|h)){
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) scanf("%d", &data[i][j]);
    int ans = 0;
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(data[i][j]) ans = max(ans, dfs(i, j, 0));
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 0
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

constexpr int64_t kModBase = 1'000'000'007;

int64_t pow(int64_t a, int64_t b) {
  if(b == 0) return 1;
  int64_t half_pow = pow(a, b / 2);
  return half_pow * half_pow * ((b & 1) ? a : 1) % kModBase;
}

int64_t solve(const char *s, int64_t len) {
  int64_t ans = pow(3, len - 1);
  const char *p = s;
  p++;
  while (*p == '0') p++;
  ans += 2 * (*p == '1' ? solve(p, len - (p - s)) : 1);
  return ans % kModBase;
}

int main(int argc, char *argv[]) {
  string s;
  cin >> s;
  cout << solve(s.c_str(), s.size()) << endl;
  return 0;
}


Measured memory_bytes: 2048
class FactMod:

    def __init__(self, n, mod):
        self.mod = mod
        self.f = [1] * (n + 1)
        for i in range(1, n + 1):
            self.f[i] = self.f[i - 1] * i % mod

        self.inv = [pow(self.f[-1], mod - 2, mod)]
        for i in reversed(range(1, n + 1)):
            self.inv.append(self.inv[-1] * i % mod)
        self.inv.reverse()

    def fact(self, n):
        """
        :return: n!
        """
        return self.f[n]

    def comb(self, n, r):
        """
        :return: nCr
        """
        return self.f[n] * self.inv[n - r] * self.inv[r] % self.mod


N, M, K = map(int, input().split())
mod = 10 ** 9 + 7

NM = N * M

ans = 0
for i in range(1, N):
    ans += (i * M * M * (N - i)) % mod
    ans %= mod

for i in range(1, M):
    ans += (i * N * N * (M - i)) % mod
    ans %= mod

factmod = FactMod(NM - 2, mod)
ans *= factmod.comb(NM - 2, K - 2)
ans %= mod
print(ans)


Measured memory_bytes: 18988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    vector<pi> v, v1;
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;
        v.push_back({x, i});
    }
    v1 = v;
    sort(v1.begin(), v1.end());
    for(int i=0;i<n;i++)
    {
        if(v1.back() != v[i]) cout << v1.back().first << '\n';
        else cout << v1[n-2].first << '\n';
    }
}

Measured memory_bytes: 4848
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=[[] for _ in range(N)]
    for i in range(N):
        a[i]=LI()
    
    #dp[S]は状態Sから何通りあるか？男性は1から順に，女性マッチング情報がS   
    M=pow(2,N) 
    dp=[0]*M
    dp[0]=1
    p=[1]*(N+3)
    for i in range(N+2):
        p[i+1]=p[i]*2


    def make(L):
        #itertoolsのリストから整数を生成
        res=0
        for i in range(len(L)):
            res+=p[L[i]]
        return res

    import itertools
    
    for man in range(N):
        for ite in itertools.combinations(range(N),man):
            S=make(ite)
            if dp[S]==0:
                continue
            for i in range(N):
                if (S>>i)&1==0:#i桁目が立っていない
                    if a[man][i]==1:
                        dp[S+(1<<i)]+=dp[S]
                        dp[S+(1<<i)]%=mod
                        
        
    
    print(dp[-1])

                    
                    
    
        
    

main()


Measured memory_bytes: 60636
N=int(input())
H=list(map(int,input().split()))
flag=1
count=1
max=0
for i in range(N):
    if H[i]>max:
        max=H[i]
    if max-1>H[i]:
        flag=0
        break

if flag==0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 63856
#include<iostream>
using namespace std;
#include <vector>
#define re(i,n) for(int i = 0; i < n; i++)

int main() {
    std::string s;
    cin >> s;
    int ss = 0;
    re(i, int(s.size())) ss = ss + int(s[i] - '0');
    if (ss % 9 == 0 || s == "0")
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

    typedef long long int ll;
    #define pb         push_back
    #define mp         make_pair
    #define F          first
    #define S          second
    #define fl(i,a,b)  for(ll i=a;i<b;i++)
    #define pll        pair<ll,ll>
    #define pii        pair<int,int>
    #define all(v)     v.begin(),v.end()
    #define M 1000000007
    #define tr(v, it) for(auto it = v.begin(); it != v.end(); it++)
    #define fast   ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed;
    using namespace std;

    int main()
    {
            fast
          string s,t;
          cin>>s>>t;
          int dp[s.length()+1][t.length()+1];
          for(int i=0;  i<=s.length(); i++)
            dp[i][0]=0;
          for(int i=0;  i<=t.length(); i++)
            dp[0][i]=0;


            string ans="";
         for(int i=1;i <=s.length(); i++)
         {
             for(int j=1; j<=t.length(); j++)
             {
                 if(s[i-1]==t[j-1])
                    {
                        dp[i][j]=dp[i-1][j-1]+1;
                    }
                else
                {
                    dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
                }
             }
         }

         int i=s.length(),j=t.length();
         while(i>0 && j>0)
         {
             if(s[i-1]==t[j-1])
              {
                  ans+=s[i-1];
                  i--;
                  j--;
              }
              else
              {
                  if(dp[i-1][j]>=dp[i][j-1])
                    i--;
                  else
                    j--;
              }
         }
         reverse(ans.begin(), ans.end());
         cout<<ans;


        return 0;

    }



Measured memory_bytes: 38784
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep = ' ', end = '\n'):
    print(*var, file=sys.stderr, end = end, sep = sep)

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

s, t = input().split()
print(t + s)

Measured memory_bytes: 3316
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)44e12;//ごめん
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	int i,n;cin>>n;
	int gen=0,gx=0,gy=0;
	for(i=0;i<n;i++){
		int t,x,y;cin>>t>>x>>y;
		int dis=abs(gx-x)+abs(gy-y);
		if(t-gen<dis||((t-gen)%2!=(dis%2))){cout<<"No"<<endl;RE;}
	}
	cout<<"Yes"<<endl;
	RE;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int a, b;cin >> a >> b;

    int ans = 0;

    for(int i = a; i<=b; i++){
        int l1 = i/10000, l2 = i/1000 - 10*l1;
        int r1 = i%10, r2 = (i/10) % 10;
        if(l1 == r1 && l2 == r2) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const int INF = 1e9;
const double pi=acos(-1);
using namespace std;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
  int x,y;
  cin >> x >> y;
  if((x+y)%3!=0)cout<<0<<endl;
  else{
    int n = (2*y-x)/3;
    int m = (2*x-y)/3;
    if(n<0 || m<0){
      cout << 0 << endl;
    }
    else{
      COMinit();
      cout << COM(n+m,m) << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           (long long)1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigint        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(aint(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

template <typename T>
T ceil(T a, T b){ return (a+b-1)/b; }


template<typename T>
T binpow(T a, T b, T m) {
    a %= m;
    T res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
void solve(){
    int n, m;
    cin>>n>>m;
    int sx, sy;
    cin>>sx>>sy;
    sx--, sy--;
    int tx, ty;
    cin>>tx>>ty;
    tx--, ty--;
    vector<vector<char>> a(n, vector<char>(m));
    vector<vector<int>> d(n, vector<int>(m, inf));
    FOR(i, 0, n) {
        FOR(j, 0, m){
            cin>>a[i][j];
        }
    }
    deque<pair<int, int>> q;
    q.push_back({sx, sy});
    d[sx][sy] = 0;
    while(!q.empty()) {
        int x = q.front().F, y = q.front().S;
        q.pop_front();
        if(y+1<m) {
            if(a[x][y+1]=='.') {
                if(d[x][y+1] > d[x][y]){
                    q.push_front({x, y+1});
                    d[x][y+1] = d[x][y];
                }
            }
        }
        if(y-1>=0) {
            if(a[x][y-1]=='.') {
                if(d[x][y-1] > d[x][y]){
                    q.push_front({x, y-1});
                    d[x][y-1] = d[x][y];
                }
            }
        }
        if(x+1<n) {
            if(a[x+1][y]=='.') {
                if(d[x+1][y]>d[x][y]){
                    q.push_front({x+1, y});
                    d[x+1][y] = d[x][y];
                }
            } 
        }
        if(x-1>=0) {
            if(a[x-1][y]=='.') {
                if(d[x-1][y]>d[x][y]){
                    q.push_front({x-1, y});
                    d[x-1][y] = d[x][y];
                }
            } 
        }
        for(int i = -2; i<=2; i++) {
            for(int j = -2; j<=2; j++) {
                if(x+i>=0 and x+i<n and y+j>=0 and y+j <=m) {
                    if(a[x+i][y+j]=='.') {
                        if(d[x+i][y+j]>d[x][y]+1){
                            q.push_back({x+i, y+j});
                            d[x+i][y+j] = d[x][y]+1;
                        }
                    }
                }
            }
        }

    } 
    d[tx][ty]==inf?cout<<-1:cout<<d[tx][ty];
    //cout<<(d[tx][ty]==inf)?-1:d[tx][ty];
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);     
    int t=1;
    //cin>>t;
    FOR(i, 1, t+1){ 
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
 
}


Measured memory_bytes: 12500