akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 7;
const LL LINF = INF * INF;

const int N = 107;
const int MAX = 1007;
int n, w;
PII a[N];
int dp[N][N * MAX];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

	cin >> n >> w;
	FOR(i, 0, n)
		cin >> a[i].X >> a[i].Y;
	
	FOR(i, 0, n)
		FOR(j, 0, MAX * N)
			dp[i][j] = INF;
	
	dp[0][a[0].Y] = a[0].X;
	dp[0][0] = 0;
	FOR(i, 1, n)
	{
		FOR(j, 0, N * MAX)
			dp[i][j] = dp[i - 1][j];
		
		FOR(j, 0, N * MAX - a[i].Y + 1)
			if (dp[i - 1][j] <= w)
				dp[i][j + a[i].Y] = min(dp[i][j + a[i].Y], dp[i - 1][j] + a[i].X);	
	}
	
	//debug(dp[1][6]);
	//debug(N * MAX)
	int ans  = 0;	
	FOR(i, 1, N * MAX)
		if (dp[n - 1][i] <= w)
			ans = i;
	
	cout << ans << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 43264
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i)
static const ll INFTY = 1L << 62L;
bool solver(ll *a, ll *b, ll N)
{
    ll r = 0;
    rep(i, 0, N)
    {
        r += b[i] - a[i];
    }
    if (r < 0)
        return false;
    else
    {
        ll cnt1 = 0, cnt2 = 0;
        rep(i, 0, N)
        {
            ll tmp = b[i] - a[i];
            if (tmp > 0)
            {
                cnt1 += ceil((double)tmp / 2.0);
            }
            else
            {
                cnt2 += -tmp;
            }
        }
        if (cnt1 > r || cnt2 > r)
            return false;
    }
    return true;
}
int main()
{
    ll N;
    cin >> N;
    ll a[N], b[N];
    rep(i, 0, N) cin >> a[i];
    rep(i, 0, N) cin >> b[i];
    if (solver(a, b, N))
        cout << "Yes\n";
    else
    {
        cout << "No\n";
    }
}

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

#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define rep(i,n) reps(i,0,n)
#define rrep(i,n) for(int i=n-1; i>=0: i--)
#define X first
#define Y second
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const ll INF = 1e9;

int main(){
	int D, E;
	while(cin >> D >> E, D|E){
		double ans = INF;
		rep(x,D+1){
			int y = D-x;
			double d = abs( sqrt(x*x + y*y) - E );
			ans = min(ans, d);
		}
		printf("%.9f\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3104
program sample
	integer ::a,b,c,d
    
    read(*,*) a,b,c,d
    
    if (a+b==c+d) then
    	write(*,*) 'Balanced'
    else if (a+b<c+d) then
    	write(*,*) 'Right'
    else
    	write(*,*) 'Left'
    end if
    stop
end program sample

Measured memory_bytes: 2860
# -*- coding: utf-8 -*-

N = int(input())
H_list = list(map(int,input().split()))
counter = 0
max_list = []
for i in range(N-1):
    a = H_list[i]
    b = H_list[i+1]
    if a >= b:
        counter += 1
    if a < b:
        max_list.append(counter)
        counter = 0
max_list.append(counter)

print(max(max_list))

Measured memory_bytes: 14224
import java.io.*;
 
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int line1 = Integer.parseInt(br.readLine());
		int[] array = new int[line1+1];
		String[] line2 = br.readLine().split(" ");
		for(int i = 0; i < line1 ; i++) {
			array[i+1] = Integer.parseInt(line2[i]);
		}
		System.out.println(metodo(line1, array));
	}
	
	public static int metodo(int N, int[] array) {
		int[] array1 = new int[N+1];
		array1[2] = Math.abs(array[1] - array[2]);
		for(int i = 3; i <= N; i++) {
				array1[i] = Math.min(array1[i-1] + Math.abs(array[i-1] - array[i]), array1[i-2] + Math.abs(array[i-2]-array[i]));
			}		
		return array1[N];
	}
}

Measured memory_bytes: 38104
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    ll ans = 0;
    rep(i, n) for (int j = i + 1; j < n; j++)
    {
        ans += a[i] * a[j];
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int a,b,c,d,e;
  int cnt;
  cin >> a >> b >> c >> d >> e;
  int k = min((a-1)%10,min((b-1)%10,min((c-1)%10,min((d-1)%10,(e-1)%10)))) + 1;
  cnt = (a+9)/10 + (b+9)/10 + (c+9)/10 + (d+9)/10 + (e+9)/10;
  
  cout << cnt * 10 + k - 10;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	string s;
	cin >> s;
	if (s == "ABC")
		cout << "ARC\n";
	else
		cout << "ABC\n";
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#define MN 100000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,head[MN+5],cnt=0,b[MN+5],s[MN+5],l[MN+5],r[MN+5],flag=1,g,dep[MN+5];
struct edge{int to,next;}e[MN*2+5];
inline void ins(int f,int t)
{
    e[++cnt]=(edge){t,head[f]};head[f]=cnt;
    e[++cnt]=(edge){f,head[t]};head[t]=cnt;
}
void dfs(int x,int fa)
{
    l[x]=b[x]?s[x]:-1e6;r[x]=b[x]?s[x]:1e6;
    if(s[x]) g=(dep[x]&1)^(s[x]&1);
    for(int i=head[x];i;i=e[i].next) if(e[i].to!=fa)
    {
        dep[e[i].to]=dep[x]+1,dfs(e[i].to,x);
        l[x]=max(l[x],l[e[i].to]-1);
        r[x]=min(r[x],r[e[i].to]+1);
    }
}
void Solve(int x,int fa,int lt,int rt)
{
    int ll=max(lt,l[x]),rr=min(rt,r[x]),nxt=ll+((ll&1)!=(g^(dep[x]&1)));
    if(nxt>rr) flag=0; else lt=rt=s[x]=nxt;
    for(int i=head[x];i;i=e[i].next) if(e[i].to!=fa) Solve(e[i].to,x,lt-1,rt+1);
}
int main()
{
    n=read();
    for(int i=1;i<n;++i) ins(read(),read());
    for(int K=read(),j;K--;) j=read(),b[j]=1,s[j]=read();
    dfs(1,0);Solve(1,0,-1e6,1e6);
    if(!flag) return 0*puts("No");puts("Yes");
    for(int i=1;i<=n;++i) printf("%d\n",s[i]);
    return 0;
}



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

int main()
{
  int n, k, x, y; cin >> n >> k >> x >> y;
  int ans = 0;

  if (n <= k) ans += x * n;
  else ans += k * x + (n - k) * y;

  cout << ans << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>
int main(void){
    int a,b,c,d,e,x,y;
    scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
    x=a;
    if(a>b){
        x=b;
        if(b>c){
            x=c;
        }
    }
    if(a>c){
        x=c;
        if(c>b){
            x=b;
        }
    }
    y=d;
    if(d>e){
        y=e;
    }
    printf("%d\n",x+y-50);
    return 0;
}

Measured memory_bytes: 1844
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	int a = 0, b = 0;
	string o, e;
	cin >> o >> e;
	rep(i, o.size() + e.size()) {
		if (i % 2 == 0) {
			cout << o[a];
			a++;
		}
		else {
			cout << e[b];
			b++;
		}
	}
	return 0;
}

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

char s[10][10];
int a[20],b[20],c[20],d[20];

void dfs(int x){
  
  int i;
  
  if(c[x] == 1)
    dfs(x + 1);
  if(x == 8){
      for(i = 0;i < 8;i++) printf("%s\n",s[i]);
      return;
    }
  
  for(i = 0;i < 8;i++){
    if(a[i] == 0 && b[x+i] == 0 && d[x-i+8] == 0) {
	  a[i] = 1;
	  b[x+i] = 1;
	  d[x-i+8] = 1;
	  s[x][i] = 'Q';
	  dfs(x+1);
	  a[i] = 0;
	  b[x+i] = 0;
	  d[x-i+8] = 0;
	  s[x][i] = '.';
      }
  }
}

int main(){

  int i,j,k,r,q;
  
  scanf("%d",&k);
  
  for(i = 0;i < 8;i++)
    for(j = 0;j < 8;j++)
      s[i][j]='.';
  
  for(i = 0;i < k;i++) {
      scanf("%d%d",&r,&q);
      s[r][q] = 'Q';
      a[q] = 1;
      b[r+q] = 1;
      d[r-q+8] = 1;
      c[r]=1;
  }
  dfs(0);
  
  return 0;
  
}



Measured memory_bytes: 2084
k = int(input())
# a,bの最大公約数


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


gcdl = [[0]*k*2 for _ in range(k*2)]
for a in range(1, k+1):
    for b in range(1, k+1):
        gcdl[a][b] = gcd(a, b)

ansl = [[[-1]*k*2 for _ in range(k*2)] for _ in range(k*2)]
ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            if ansl[a][b][c] == -1:
                t = gcd(c, gcdl[a][b])
                ansl[a][b][c] = t
                ansl[a][c][b] = t
                ansl[b][a][c] = t
                ansl[b][c][a] = t
                ansl[c][b][a] = t
                ansl[c][a][b] = t
            else:
                t = ansl[a][b][c]
            ans += t
print(ans)


Measured memory_bytes: 585372
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n, a, b;
/**********************************************/

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

    int ans = 0;

    while(n){
        int sum = 0;
        int num = n;
        while(num){
            sum += num%10;
            num/=10;
        }

        if(sum >= a && sum <= b){
            ans += n;
        }
        n--;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();

function main(){
  for(var i = 1, len = input[0] - 0; i <=len; i++){
    var c = input[i].split(' ');
    var xa = +c[0], ya = +c[1], ra = +c[2], xb = +c[3], yb = +c[4], rb = +c[5];

    var r = Math.sqrt((xa-xb)*(xa-xb) + (ya-yb)*(ya-yb));

    if(r > ra + rb){
      console.log(0);
    }else if(r < ra - rb){
      console.log(2);
    }else if(r < rb - ra){
      console.log(-2);
    }else{
      console.log(1);
    }
    
    
  }

}
     

Measured memory_bytes: 7644
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>

using namespace std;

#define INF 999999999

int main(){
	int n, k, t, u, v, l, d[200], cal[10000], have=0, run=0;
	double ans = 0;
	cin >> n >> k >> t >> u >> v >> l;
	for(int i=0; i<l; i++){
		cal[i] = 0;
	}
	for(int i=0; i<n; i++){
		cin >> d[i];
		cal[ d[i]-1 ] = 1;
	}
	
	int running = 0, walking =0;
	
	for(int i=0; i<l; i++){
		if(have > 0 && run == 0){
			running++;
			have--;
			run = v * t - 1;
		}
		else if(run > 0){
			running++;
			run--;
		}
		else{
			walking++;
		}
		
		if(cal[i] == 1 && have < k){
			have++;
		}
		else if(cal[i] == 1 && have == k){
			run = v * t;
		}
	}
	
	ans = (double)running / (double)v + (double)walking / (double)u;
	
	printf("%.7f\n", ans);
	
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 300010;

int n, m, b[15], p[15], a[15];

int f(){
    int v[n], ret = 0;
    vector<int> s, t;
    rep(i, n)if(b[i] == 1) s.push_back(i);
    rep(i, n)if(a[i] == 1) t.push_back(i);
    if(s.size() != t.size()) return 1000;
    rep(i, s.size()) ret += abs(s[i] - t[i]);
    return ret;
}

int main(){
    scanf("%d%d", &n, &m);
    rep(i, n) scanf("%d", &b[i]);
    rep(i, m) scanf("%d", &p[i]);
    int ans = 1000;
    rep(i, 2){
        for(int cur=0, j=0; j<m; ++j){
            rep(k, p[j]) a[cur++] = (j%2) ^ i;
        }
        chmin(ans, f());
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 3276
N = int(input())

csf = [list(map(int, input().split())) for _ in range(N - 1)]
for i in range(N):
    t = 0
    for j in range(i, N - 1):
        c, s, f = csf[j]
        if t < s:
            t = s
        elif t % f == 0:
            t = t
        else:
            t = (t + f) - (t % f)
        t += c

    print(t)


Measured memory_bytes: 3188
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

typedef long long llint;
typedef pair<int, int> pii;

const int B = 27397, MOD = 1e9 + 7;
const int B1 = 33941, MOD1 = 1e9 + 9;

const int MAXN = 2e5 + 10;

int n, m;
int cnt[MAXN];

int main(void) {
  scanf("%d%d", &n, &m);

  bool ok = false;
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b); --a; --b;
    cnt[b] += a == 0;
    cnt[a] += b == (n - 1);
    ok |= cnt[a] == 2 || cnt[b] == 2;
  }

  if (ok)
    printf("POSSIBLE\n");
  else
    printf("IMPOSSIBLE\n");
  return 0;
}



Measured memory_bytes: 1024
import java.util.*;

public class Main {
    static public void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int p = 0;
            if(m == -1 && f == -1 && r == -1) break;
            if(m == -1 || f == -1){
                System.out.println("F");
            }else{
                p = m+f;
                if(p >= 80){
                    System.out.println("A");
                }else if(p >= 65){
                    System.out.println("B");
                }else if(p >= 50){
                    System.out.println("C");
                }else if(p >= 30){
                    if(r >= 50){
                        System.out.println("C");
                    }else{
                        System.out.println("D");
                    }
                }else{
                    System.out.println("F");
                }
            }
            
        }
        sc.close();
    }
}


Measured memory_bytes: 26120
def main():
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())
    if a <= b:
        if b + w*t <= a + v*t:
            print("YES")
        else:
            print("NO")
    else:
        if a - v*t <= b - w*t:
            print("YES")
        else:
            print("NO")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9192
#include<stdio.h>

int main(){
    int i,j,input,flag = 0;
    int data[5];

    while(scanf("%d",&input) != EOF){
        if(flag++)puts("");
        for(i = 0;i < 5;i++){
            data[4 - i] = input % 10;
            input /= 10;
        }
        for(i = 0;i < 8;i++){
            for(j = 0;j < 5;j++){
                switch(i){
                    case 0:
                    case 1:
                        if(data[j] / 5 == i){
                            printf("*");
                        }else{
                            printf(" ");
                        }
                        break;
                    case 2:
                        printf("=");
                        break;
                    default:
                        if(data[j] % 5 == i - 3){
                            printf(" ");
                        }else{
                            printf("*");
                        }
                        break;
                }
            }
            puts("");
        }
    }
    return 0;
}

Measured memory_bytes: 584
#include<stdio.h>
int main()
{
	int i,j,A,B,a,b;
	a=999999;
	b=999999;
	for(i=0;i<3;i++){
		scanf("%d",&A);
		if(a>A){
			a=A;
		}
	}
	for(i=0;i<2;i++){
		scanf("%d",&B);
			if(b>B){
			b=B;
		}
	}
		a=a+b-50;
	printf("%d\n",a);
	return 0;
	}

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

using namespace std;

#define db(x) cout << (x) << '\n';
#define all(x) x.begin(),x.end()
#define UNIQUE(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define LB(v,x) lower_bound(all(v),x)
#define UB(v,x) upper_bound(all(v),x)
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define PF push_front
#define int long long
#define double long double
#define trick int m = (l+r)>>1,lc=n<<1,rc=lc|1

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

int dy[]={0,1,1,1,0,-1,-1,-1};
int dx[]={-1,-1,0,1,1,1,0,-1};
const int maxn = 1e5;
const int OO = 1e18;
const int mod = 1e9 + 7;
const double PI = acos(-1);

void maxself(int &a,int b)
{a=max(a,b);}
void minself(int &a,int b)
{a=min(a,b);}

vector<vi> g(maxn);

bool ans[3][3];
int32_t main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);
	
	int mk[3][3];
	for(int i=0;i<3;i++)
	for(int j=0;j<3;j++)
	cin >> mk[i][j];
	int n;
	cin >> n;
	
	for(int i=0;i<n;i++)
	{
		int a;
		cin >> a;
		for(int z=0;z<3;z++)
		for(int q=0;q<3;q++)
		{
			if(mk[z][q]==a)
			ans[z][q] = 1;
		}
	}
	bool f=1;
	for(int i=0;i<3;i++)
	if(ans[i][i]==0)
	f=0;
	if(f)
	{
		cout << "Yes";
		return 0;
	}
	f=1;
	if(ans[0][2] and ans[1][1] and ans[2][0])
	{
		cout << "Yes";
		return 0;
	}
	for(int i=0;i<3;i++)
	{
		f=1;
		for(int j=0;j<3;j++)
		{
			if(ans[i][j]==0)
			f=0;
		}
		if(f)
		{
			cout << "Yes";
			return 0;
		}
	}
	for(int i=0;i<3;i++)
	{
		f=1;
		for(int j=0;j<3;j++)
		{
			if(ans[j][i]==0)
			f=0;
		}
		if(f)
		{
			cout << "Yes";
			return 0;
		}
	}
	
	cout << "No";
	return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define N (int)2e5
int n,memo[N],c[N];

int dp(int curr) {
    if (curr == n) return 0;
    if (curr > n) return 1e9;
    int &sol = memo[curr];
    if (sol != -1) return sol;
    sol = min(
        dp(curr + 1) + abs(c[curr] - c[curr + 1]) ,
        dp(curr + 2) + abs(c[curr] - c[curr + 2])
    );
    return sol;
}

int main() {
    scanf("%d" , &n);
    for (int i = 1 ; i <= n ; i++)
        scanf("%d" , &c[i]);
    memset (memo , -1 , sizeof memo);
    printf("%d\n" , dp(1));
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define all(x) (x).begin(),(x).end()

int main() {
    int k, x;
    cin >> k >> x;

    int min = x - (k - 1);
    int max = x + (k - 1);

    int c = min;
    while (c <= max) {
        cout << c << " ";

        c++;
    }
    cout << endl << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    private static void solve() {
        final Scanner scanner = new Scanner(System.in);

        while (true) {
            final int r = scanner.nextInt();
            final int c = scanner.nextInt();
            if (r == 0 && c == 0) {
                break;
            }
            System.out.println((r * c) % 2 == 0 ? "yes" : "no");
        }
    }

    public static void main(String... args) {
        solve();
    }
}

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

Measured memory_bytes: 1152
mod = 1000000007

def pw(x, n):
    if n == 0: return 1
    elif n == 1: return x
    elif n % 2 == 0:
        return pw(x, n // 2) ** 2 % mod
    else:
        return x * pw(x, n // 2) ** 2 % mod

def dv(x, y):
    return x * pow(y, mod - 2, mod) % mod

def comb(n, r):
    p, q = 1, 1
    if n < r or n < 0 or r < 0: return 0
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return dv(p, q)

n, a, b = map(int, input().split())
ans = pow(2, n, mod) - 1 + mod * 10
if a <= n: ans -= comb(n, a)
if b <= n: ans -= comb(n, b)
print(ans % mod)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;

struct RUQ{
  ll size;
  ll *tree;
  vi history;
  RUQ(ll sz){
    ll logsize; for(logsize=0;(1ll<<logsize)<=sz;logsize++);
    size=(1ll<<logsize);
    tree=new ll[size*2-1]; REP(i, size*2-1) tree[i]=0;
  }
  void update(ll s,ll t,ll x){
    ll id=history.size();
    updatesub(s,t,0,size,0,id);
    history.push_back(x);
  }
  void updatesub(ll s,ll t,ll l,ll r,ll k,ll id){
    if(r<=s||t<=l||l>=r) return;
    if(l+1==r) {tree[k]=id; return;}
    if(s<=l&&r<=t) {tree[k]=id; return;}
    ll mid=(l+r+1)/2;
    updatesub(s,t,l,mid,k*2+1,id);
    updatesub(s,t,mid,r,k*2+2,id);
  }
  ll find(ll i){
    ll k=size+i-1;
    ll recent=tree[k];
    while(k>0){
      k=(k-1)/2;
      recent=max(recent,tree[k]);
    }
    return history[recent];
  }
};

int main(){
  ll n,q; cin>>n>>q;
  RUQ ruq(n);
  ruq.update(0,n,(1ll<<31)-1);
  REP(i,q){
    ll com;cin>>com;
    if(com==0) {ll s,t,x; cin>>s>>t>>x; ruq.update(s,t+1,x);}
    else {ll i; cin>>i; cout<<ruq.find(i)<<endl;}
  }
}

Measured memory_bytes: 5888
#include<iostream>
using namespace std;
#include<cstdio>
#include<cmath>
#include<complex>

typedef complex<double> point;

int main()
{
    point z, a, b, h;
	double cx, cy, r;
	int q;
	scanf("%lf %lf %lf", &cx, &cy, &r);
	z.real(cx), z.imag(cy);

	double ax, ay, bx, by, hx, hy, scale;
	double coord[4];
	scanf("%d", &q);
	for(int i = 0; i < q; i++){
		scanf("%lf %lf %lf %lf", &ax, &ay, &bx, &by);
		a.real(ax), a.imag(ay), b.real(bx), b.imag(by);
		h = a + (b - a) * (((z - a) / (b - a)).real());
		if(h != z){
			scale = sqrt((r * r) / norm(h - z) - 1);
			hx = h.real(), hy = h.imag();
			coord[0] = hx - (hy - cy) * scale;
			coord[1] = hy + (hx - cx) * scale;
			coord[2] = hx + (hy - cy) * scale;
			coord[3] = hy - (hx - cx) * scale;
		}else{
			scale = r / sqrt(norm(a - b));
			coord[0] = cx + (ax - bx) * scale;
			coord[1] = cy + (ay - by) * scale;
			coord[2] = cx - (ax - bx) * scale;
			coord[3] = cy - (ay - by) * scale;
		}
		if(coord[0] > coord[2]){ swap(coord[0], coord[2]), swap(coord[1], coord[3]); }
		if(coord[0] == coord[2] && coord[1] > coord[3]){ swap(coord[1], coord[3]); }
		printf("%.12f %.12f %.12f %.12f\n", coord[0], coord[1], coord[2], coord[3]);
	}
    return 0;
}

Measured memory_bytes: 1268
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#define M 10000
#define E 500000
 
typedef struct edge {
    int from, to, cost;
} Ed;
Ed e[E];
int d[M];
 
void sp(int,int);

int main(int argc,char* argv[])
{
    int vn, en, an;
    int i, j, vi;
    scanf("%d", &vn);
 
    en=0;
    for(i=0; i<vn; i++) {
        scanf("%d", &vi);
        scanf("%d", &an);
        for(j=1; j<=an; j++) {
            e[en].from=vi;
            scanf("%d %d", &e[en].to, &e[en].cost);
            en++;
        }
    }
     
    sp(vn, en);
    for(i=0; i<vn; i++) {
        printf("%d %d\n", i, d[i]);
    }
    return 0;
}
void sp(int vn, int en)
{
    int i, new=1;
    for(i=1; i<vn; i++) d[i]=INT_MAX;
     
    while(new) {
        new=0;
        for(i=0; i<en; i++) {
            if(d[e[i].from] !=INT_MAX && d[e[i].from]+e[i].cost < d[e[i].to]) {
                d[e[i].to] = d[e[i].from]+e[i].cost;
                new++;
            }
        }
    }
}

Measured memory_bytes: 6460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S,T;cin>>S>>T;
    cout<<T<<S<<endl;
}




Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define MAXN 200000
#define MO 1000000007
#define INF 0x3FFFFFFF
using namespace std;
int n,X,Y;
int c[MAXN+5],w[MAXN+5];
int fact[MAXN+5],inv[MAXN+5];
int minpos[MAXN+5],minval[MAXN+5];
int cnt[MAXN+5];
bool vis[MAXN+5];
vector<int> G[MAXN+5];
int PowMod(int a,int b)
{
	int ret=1;
	while(b)
	{
		if(b&1)
			ret=1LL*ret*a%MO;
		a=1LL*a*a%MO;
		b>>=1;
	}
	return ret;
}
void Init()
{
	for(int i=0;i<=MAXN+3;i++)
		minval[i]=INF;
	fact[0]=1;
	for(int i=1;i<=MAXN;i++)
		fact[i]=1LL*fact[i-1]*i%MO;
	inv[MAXN]=PowMod(fact[MAXN],MO-2);
	for(int i=MAXN-1;i>=0;i--)
		inv[i]=1LL*inv[i+1]*(1LL*i+1LL)%MO;
}
void DFS(int u)
{
	vis[u]=true;
	for(int i=0;i<(int)G[u].size();i++)
	{
		int v=G[u][i];
		if(vis[v]==false)
			DFS(v);
	}
}
int C(int a,int b)
{
	return 1LL*fact[a]*inv[b]%MO*inv[a-b]%MO;
}
int main()
{
//	freopen("colorball.in","r",stdin);
//	freopen("colorball.out","w",stdout);
	Init();
	scanf("%d %d %d",&n,&X,&Y);
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d",&c[i],&w[i]);
		if(minval[c[i]]>w[i])
		{
			minval[c[i]]=w[i];
			minpos[c[i]]=i;
		}
	}
	for(int i=1;i<=n;i++)
		if(i!=minpos[c[i]]&&w[i]+minval[c[i]]<=X)
			G[i].push_back(minpos[c[i]]),G[minpos[c[i]]].push_back(i);
	int mn1=INF,mn2=INF;
	int mnp1,mnp2;
	//先找最小值 
	for(int i=1;i<=n;i++)
		if(w[i]<mn1)
			mn1=w[i],mnp1=i;
	//再找与最小值颜色不同的最小值 
	for(int i=1;i<=n;i++)
		if(w[i]<mn2&&c[i]!=c[mnp1])
			mn2=w[i],mnp2=i;
	for(int i=1;i<=n;i++)
	{
		if(i==mnp1)
			continue;
		if(c[i]!=c[mnp1]&&w[i]+w[mnp1]<=Y)
			G[i].push_back(mnp1),G[mnp1].push_back(i);
		else if(mn2!=INF&&c[i]!=c[mnp2]&&w[i]+w[mnp2]<=Y)
			G[i].push_back(mnp2),G[mnp2].push_back(i);
	}
	DFS(mnp1);
	for(int i=1;i<=n;i++)
		if(vis[i]==true)
			cnt[c[i]]++;
	int tot=0,ans=1;
	for(int i=1;i<=n;i++)
		tot+=cnt[i];
	for(int i=1;i<=n;i++)
		if(cnt[i])
		{
			ans=1LL*ans*C(tot,cnt[i])%MO;
			tot-=cnt[i];
		}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

string s[100005];
long long ans = 0LL;

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}
	sort(s, s + n);
	for (int i = 0, j; i < n; i = j) {
		j = i;
		while (s[j] == s[i])
			++j;
		ans += (long long)(j - i) * (j - i - 1) / 2;
		i = j;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5760
// https://atcoder.jp/contests/abc069/tasks/abc069_b

#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  string s, r;

  cin >> s;

  cout << s.front() + to_string(s.length() - 2) + s.back() << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll a[100010][3];
ll dp[100010][3];

int main() {
    int N; cin >> N;
    REP(i,N){
        REP(j,3){
            cin >> a[i][j];
        }
    }
    REP(i,N){
        REP(j,3){
            REP(k,3){
                if(j != k){
                    if(dp[i+1][k]<dp[i][j] + a[i][k]){
                        dp[i+1][k] = dp[i][j] + a[i][k];
                    }
                }  
            }
        }
    }
    ll res = 0;
    REP(i,3){
        if(res<dp[N][i]){
            res = dp[N][i];
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 4992
n = int(input())
a = list(map(int, input().split()))
a.append(999)
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum = 0

for i in range(n):
    sum = sum + b[a[i]-1]
    if a[i+1] - a[i] == 1:
        sum += c[a[i]-1]
print(sum)

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

int main(void){
    char s[200001];
    char t[200001];
    scanf("%s", s);
    scanf("%s", t);

    int rs[26];
    int rt[26];
    for(int i = 0; i < 26; i++){rs[i] = -1; rt[i] = -1;}

    int n = strlen(s);
    int a, b;
    for(int i = 0; i < n; i++){
        a = s[i] - 'a';
        b = t[i] - 'a';
        
        if(rs[a] != -1 || rt[b] != -1){
        //僕だけかもですが、一見rs[a] != b;だけで事足りると思ったのですが
        //これはs側のある文字Xがt側のある文字Yに対応しているかをチェックしていて
        //一つの文字が複数の文字に対応していてはいけないということをいえてるんですが
        //これだけだと、s側の文字XとQがYに対応している場合をアウトにできないので
        //rt[b] != aをすることで、そのアウトを除けるようになります
            if(rs[a] != b || rt[b] != a){
                printf("No\n");
                return 0;
            }
        }
        //自分側のアルファベットに、自分側と対応する相手側のアルファベットの
        //番目を入れる。
        rs[a] = b;
        rt[b] = a;
    }

    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <fstream>
#include <map>
#include <cassert>
#include <sstream>
#include <numeric>
#include <regex>
#include <cctype>
#include <utility>
#include <stdio.h>
#include <set>
#include <queue>
#include <deque>
#include <stack>

typedef long long ll;

#define vi vector<int>
#define vs vector<string>
#define vc vector<char>
#define MOD 1000000007
#define pb push_back
#define llnums vector<ll>
#define FOR(i,n) for(int i{0}; i < n; ++i)

using namespace std;

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int arr[123];
  FOR(i, 123) {
      arr[i] = 0;
  }
  string w;
  cin >> w;
  for (auto const& a: w) {
      arr[a]++;
  }
  bool ok=true;
  for (int i=97; i < 123; i++) {
      if (arr[i] % 2 != 0) {
          ok =false;
          break;
      }
  }
  if (ok) {cout << "Yes\n";}
  else {cout << "No\n";}
  return 0;
}








Measured memory_bytes: 3688
#include<bits/stdc++.h>
#define vi vector<int>
#define pp pair<int,int>
#define all(x) x.begin(),x.end()
#define pb push_back
#define forx(i,x) for(int i=0;i<x;i++)
#define int long long
using namespace std;
 main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	vector<int> p(m),y(m);
	vector<int> g[n+1];
	for(int i=0;i<m;i++) 
	{
	cin>>p[i]>>y[i];
	g[p[i]].pb(y[i]);
	
	}
	for(int i=0;i<n;i++)
	{
		sort(all(g[i+1]));
	}
	for(int i=0;i<m;i++)
	{
		int loc=lower_bound(all(g[p[i]]),y[i])-g[p[i]].begin();
		int est=loc;
		int first=p[i];
		int num=first*((int)1e6)+est+1;
		int tmp=num;
		int dig=0;
		while(tmp) tmp/=10,dig++;
		if(dig<12)
		{
			for(int i=0;i<12-dig;i++)
			{
				cout<<0;
			}
		}
		cout<<num<<endl;
		
	}
	
	


}


Measured memory_bytes: 8576
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n, m; std::cin >> n >> m;
    std::vector<int> l(m), r(m);
    std::vector<long long> c(m);
    for (int i = 0; i < m; i++) {
        std::cin >> l[i] >> r[i] >> c[i];
        l[i]--; r[i]--;
    }
    std::vector<int> id(m);
    std::iota(id.begin(), id.end(), 0);
    std::sort(id.begin(), id.end(), [&](int i, int j) {
        return l[i] < l[j];
    });
    std::reverse(id.begin(), id.end());
    std::vector<long long> dist(n, 1e18);
    dist[0] = 0;
    std::priority_queue<
        std::pair<long long, int>,
        std::vector<std::pair<long long, int>>,
        std::greater<std::pair<long long, int>>> que;
    que.emplace(0, 0);
    while (!que.empty()) {
        int pos = que.top().second;
        que.pop();
        if (id.empty()) break;

        while (!id.empty() && l[id.back()] <= pos) {
            if (dist[r[id.back()]] <= dist[pos] + c[id.back()]) {
                id.pop_back();
                continue;
            }
            dist[r[id.back()]] = dist[pos] + c[id.back()];
            que.emplace(dist[r[id.back()]], r[id.back()]);
            id.pop_back();
        }
    }
    std::cout << (dist[n - 1] == 1e18 ? -1 : dist[n - 1]) << std::endl;
    return 0;
}


Measured memory_bytes: 4980
#include<bits/stdc++.h>
#define ll long long
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl;
using namespace std;
int main()
{
    ll N,W,total_value=0,ans=0;
    scanf("%lld%lld",&N,&W);
    ll weight[N+5],value[N+5];
    for(ll i=0;i<N;++i)
    {
        scanf("%lld%lld",&weight[i],&value[i]);
        total_value+=value[i];
    }
    ll dp[total_value+5];
    for(ll i=0;i<total_value+5;++i)
    {
        dp[i]=100000000000000;
    }
    dp[0]=0;
    for(ll i=0;i<N;++i)
    {
        for(ll pre_value=total_value-value[i];pre_value>=0;--pre_value)
        {
            dp[pre_value+value[i]]=min(dp[pre_value+value[i]],dp[pre_value]+weight[i]);
        }
    }
    for(ll i=0;i<=total_value;++i)
    {
        if(dp[i]<=W)
        {
            ans=max(ans,i);
        }
    }
    printf("%lld",ans);
    return 0;
}




Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
#include<numeric>
using namespace std;
typedef long long ll;
//ll mod = 1e9+7;
ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    vector<ll> absum(n);
    ll ans = 0;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        absum[i] = a + b;
        ans -= b;
    }
    sort(absum.begin(), absum.end());
    reverse(absum.begin(), absum.end());
    rep(i, n) {
        if ( i & 1 ) {
            continue;
        }
        else {
            ans += absum[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include<bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;




#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   200007
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

ll a[N];


int main()
{
    string g;
    cin>>g;
    ll l =g.length();
    if(g[l-1]=='s')cout<<g<<"es"<<endl;
    else cout<<g<<"s"<<endl;
    //main();
    return 0;
}





















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

int main() {
  int x,y,ans;
  cin>>x;
  y=x/500;
  x=x-y*500;
  ans=y*1000;
  y=x/5;
  ans=ans+y*5;
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

char field[60][60];

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

int h, w;

void solve(){
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (field[i][j] == '#'){
                bool flag = false;
                for (int k = 0; k < 4; ++k) {
                    int x = i + dx[k], y = j + dy[k];
                    if (0 <= x && x < h && 0 <= y && y < w && field[x][y] == '#'){
                        flag = true;
                        break;
                    }
                }
                if (!flag){
                    cout << "No" << endl;
                    return;
                }
            }
        }
    }

    cout << "Yes" << endl;
}

int main() {
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> field[i][j];
        }
    }

    solve();

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

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

	ll N = S.size();

	ll ans = 0;
	REP(i, N / 2) {
		if (S[i] != S[N - 1 - i]) ans++;
	}

	cout << ans << endl;

	return 0;
}

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

void solve(long long N, long long K){
	double res = 0.0, d = 1.0;
	// res += d*max(N-K-1, 0LL)/N;
	// if (K == 1) printf("%.16f\n", 1.0);
	// while (K > 1) {
	// 	if ((K+1)/2 <= N) res += d*max((K+1)/2, 0LL)/N;
	// 	d /= 2.0;
	// 	K = (K+1)/2;
	// }
	for (int i = 1; i <= N; i++) {
		int two = 1;
		while (i*two < K) {
			two *= 2;
		}
		res += 1.0/two/N;
		// cout << i << " " << 1.0/two/N << endl;
	}
	printf("%.16f\n", res);
}

int main(){	
	long long N;
	long long K;
	scanf("%lld",&N);
	scanf("%lld",&K);
	solve(N, K);
	return 0;
}



Measured memory_bytes: 256
N, Ma, Mb = map(int, input().split())
items = []
for i in range(N):
    a, b, c = map(int, input().split())
    items.append((a, b, c))

a_sum = sum([item[0] for item in items])
b_sum = sum([item[1] for item in items])
inf = float("inf")
dp = [[[inf for _ in range(401)] for _ in range(401)] for i in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
    for a in range(a_sum + 1):
        for b in range(b_sum + 1):
            dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b])
            dp[i + 1][a + items[i][0]][b + items[i][1]] = min(dp[i + 1][a + items[i][0]][b + items[i][1]],
                                                              dp[i][a][b] + items[i][2])
ans = inf
for a in range(1, a_sum + 1):
    for b in range(1, b_sum + 1):
        if a * Mb == b * Ma:
            ans = min(ans, dp[N][a][b])
if ans != inf:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 146140
# Aizu Problem 0083: Era Transformation
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def era_transformation(y, m, d):
    if int(m) < 10:
        m = '0' + m
    if int(d) < 10:
        d = '0' + d
    date = int(y + m + d)
    y = int(y)
    m = int(m)
    d = int(d)
    if date < 18680908:
        print("pre-meiji")
        return
    elif date <= 19120729:
        print("meiji", y - 1868 + 1, m, d)
    elif date <= 19261224:
        print("taisho", y - 1912 + 1, m, d)
    elif date <= 19890107:
        print("showa", y - 1926 + 1, m, d)
    else:
        print("heisei", y - 1989 + 1, m, d)

    
for line in sys.stdin:
    y, m, d = line.split()
    era_transformation(y, m, d)

Measured memory_bytes: 7760