akhauriyash/Code-Regression huggingface dataset:
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<s.size()/2;++i)
        if(s[i]!=s[s.size()-i-1])
            ++cnt;
    cout<<cnt;
    return 0;
}


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

int main() {
	int k;
	cin >> k;
	vector<int> r(k), c(k);
	vector<int> rf(8), cf(8);
	vector<vector<char>> ans(8, vector<char>(8, '.'));
	rep(i, k) {
		cin >> r[i] >> c[i];
		rf[r[i]] = 1;
		cf[c[i]] = 1;
		ans[r[i]][c[i]] = 'Q';
	}
	vector<int> vr, vc;
	rep(i, 8) {
		if (!rf[i]) vr.push_back(i);
		if (!cf[i]) vc.push_back(i);
	}
	sort(vr.begin(), vr.end());
	sort(vc.begin(), vc.end());
	do {
		do {
			bool ok = true;
			rep(i, 8 - k) rep(j, k) {
				if (abs(vr[i] - r[j]) == abs(vc[i] - c[j])) ok = false;
			}
			rep(i, 8 - k) rep(j, 8 - k) {
				if (i == j) continue;
				if (abs(vr[i] - vr[j]) == abs(vc[i] - vc[j])) ok = false;
			}
			if (ok) {
				rep(i, 8 - k) ans[vr[i]][vc[i]] = 'Q';
			}
		} while (next_permutation(vc.begin(), vc.end()));
	} while (next_permutation(vr.begin(), vr.end()));
	rep(i, 8) {
		rep(j, 8) cout << ans[i][j];
		cout << endl;
	}
	return 0;
}


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

fn enumerate(p: &[(u64, u64)]) -> Vec<(u64, u64)> {
    assert!(p.iter().all(|p| p.0 > 0 && p.1 > 0));
    let mut a = vec![(0, 0)];
    for &(v, w) in p.iter() {
        let mut b = a.clone();
        for b in b.iter_mut() {
            b.0 += v;
            b.1 += w;
        }
        let mut c = vec![];
        while !a.is_empty() && !b.is_empty() {
            let &(p, q) = a.last().unwrap();
            let &(r, s) = b.last().unwrap();
            if q >= s {
                c.push((p, q));
                a.pop();
            } else {
                c.push((r, s));
                b.pop();
            }
        }
        for p in a.into_iter().rev().chain(b.into_iter().rev()) {
            c.push(p);
        }
        c.reverse();
        a = c;
    }
    let mut max = a[0].0;
    for a in a.iter_mut().skip(1) {
        max = std::cmp::max(max, a.0);
        a.0 = max;
    }
    a
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let limit: u64 = it.next().unwrap().parse().unwrap();
    let p: Vec<(u64, u64)> = (0..n).map(|_| {
        let v: u64 = it.next().unwrap().parse().unwrap();
        let u: u64 = it.next().unwrap().parse().unwrap();
        (v, u)
    }).collect();
    let m = n / 2;
    let (l, r) = p.split_at(m);
    let (f, b) = (enumerate(l), enumerate(r));
    let mut ans = 0;
    let mut i = 0;
    let mut j = b.len();
    while i < f.len() && j > 0 {
        if f[i].1 + b[j - 1].1 <= limit {
            ans = std::cmp::max(ans, f[i].0 + b[j - 1].0);
            i += 1;
        } else {
            j -= 1;
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}



Measured memory_bytes: 56408
#include <stdio.h>
int main(void){
int a,b,c,x;
int count,count2,count3;
int ans=0;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
scanf("%d",&x);
for(count=0;count<=a;count++){
    for(count2=0;count2<=b;count2++){
        for(count3=0;count3<=c;count3++){
if(500*count+100*count2+50*count3==x){ans++;}
        }
    }
}
printf("%d",ans);
return 0;

}

Measured memory_bytes: 256
import sys

if sys.platform =='ios':
	sys.stdin=open('inputFile.txt')
		
#+++++

def main():
	n = int(input())
	ll=list(map(int, input().split()))
	
	count=0
	for i in range(n-2):
		a=ll[i]
		b=ll[i+1]
		c=ll[i+2]
		#print(a,b,c)
		if (a < b and b < c) or (a>b and  b>c) :
			count+=1
			#print(a,b,c)
	return count

	

if __name__ == "__main__":
	print(main())
	
	

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,cntt=0,ans=0,a[100000],b,c,cmp,data,m,h,w,x,y,xcmp=0,ycmp=0,sum=0;

string s;

vector<int> z;

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

       rep(i,3){
           cin >> a[i];
           if(a[i]==5){
               cnt++;
           }
           else if(a[i]==7){
               cntt++;
           }
       }
       YES(cnt==2 && cntt==1);
return 0;
}


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

int main () {
    int N, Y;
    cin >> N >> Y;
    int a = -1, b = -1, c = -1;
    for ( int i = 0; i <= N; i++) {
        for ( int j = 0; i+j <= N; j++){
            int k = N - i - j;
            int sum = i * 10000 + j * 5000 + k * 1000;
            if ( sum == Y) { 
                a = i;
                b = j;
                c = k;
                break;
            }
        }
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
char s[10];
int c[10][10],f[10];
int h,w,k,ans=0;
int judge(int x,int y)
{
	int tot=0;
	//printf("\n");
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)
	{
		if((f[i]&x)==0&&(f[j]&y)==0)tot+=c[i][j];
	//	printf("%d %d\n",(f[i]&x),(f[j]&y));
	}
	//printf("%d\n",tot);
	if(tot==k)return 1;
	return 0;
}
int main()
{
    f[0]=1;
    for(int i=1;i<=6;i++)f[i]=f[i-1]*2;
    scanf("%d%d%d",&h,&w,&k);
    for(int i=0;i<h;i++)
    {
    	scanf("%s",s);
    	for(int j=0;j<w;j++)if(s[j]=='#')
    		c[i][j]=1;
	}
	for(int i=0;i<f[h];i++)for(int j=0;j<f[w];j++)
		if(judge(i,j))ans++;
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1708
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    A, B, C = map(int, input().split())
    if A < C < B:
        print('Yes')
    elif B < C < A:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


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

const int MAXN = 101010;

int n, m;

int ind[MAXN];

class Road {
public:
	int t, next;
}e[MAXN * 2];
int p[MAXN];
int z = -1;

int vis[MAXN];

void add(int u, int v) {
	++z;
	e[z].t = v;
	e[z].next = p[u];
	p[u] = z;
}

int cnt = 0;

bool dfs(int u, int fa) {
	//cout<<u<<" "<<fa<<endl;
	int cnt1 = 0, cnt2 = 0;
	for(int tmp = p[u]; tmp != -1; tmp = e[tmp].next) {
		if(e[tmp].t != fa) {
			cnt1++;
			cnt2 += dfs(e[tmp].t, u);
		}
	}
	if(cnt1 - 1 > cnt2) {
		cnt += cnt1 - 1 - cnt2;
		return true;
	}
	return cnt2;
}

int main() {
	memset(p, -1, sizeof(p));
	
	scanf("%d", &n);
	int u, v;
	for(int i = 1; i < n; ++i) {
		scanf("%d%d", &u, &v);
		ind[u]++, ind[v]++;
		add(u, v);
		add(v, u);
	}
	int mx = 0, mxp;
	for(int i = 0; i < n; ++i)
		if(ind[i] > mx) {
			mx = ind[i];
			mxp = i;
		}
	if(mx <= 2) {
		puts("1");
		return 0;
	}
	dfs(mxp, -1);
	printf("%d\n", cnt);

	return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a <= c && c <= b) cout << "Yes" << endl;
  else cout << "No" << endl;
} 






Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class question {
public:
	int N, K;
	vector<int> h;
	void ans() {
		cin >> N >> K;
		h.resize(N);
		REP(i, N) cin >> h[i];
		sort(h.begin(), h.end());
		int mn = INT_MAX;
		REP(i, N - K + 1) {
			mn = min(mn, h[i + K - 1] - h[i]);
		}
		cout << mn << "\n";
	}
};

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

	question q;
	q.ans();

	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin()) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
    for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
    cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
//    // FASTIO
//     ///*
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
//     freopen("out.txt", "w", stdout);
//     freopen("error.txt", "w", stderr);
// #endif
// //*/

    double n;
    scanf("%lf", &n);
    int odd = (n + 1.0) / 2.0;
    dbg(odd);
    double ans = (odd / n);
    printf("%.10lf", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
string s;
cin>>s;
for(int i=0;i<3;i++)
{
    if(s[i]=='9') s[i]='1';
    else s[i]='9';
}
cout<<s<<endl;
return 0;
 
    
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int abs(int x){
    if(x<0) return -x;
    else return x;
}
int main() {
    int n,t,a;
    cin>>n>>t>>a;
    vector<float> h(n);
    for(int i=0;i<n;i++){
       cin>>h.at(i); 
       h.at(i)=t-h.at(i)*0.006;
    } 
    float minimum=10000000;
    int index=0;
    for(int i=0;i<n;i++){
        float mini_if=0;
        mini_if=abs(a-h.at(i));
        if(minimum>=mini_if){
            minimum=mini_if;
            index=i;
        }
    }
    cout<<index+1<<endl;


}

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

typedef long long ll;
typedef unsigned long long ull;
typedef  unsigned int uint;
typedef  long double ld;


int main()
{

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

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	string s;
	cin >> s;


	if (s[2] == s[3] && s[4] == s[5])
		cout << "Yes\n";
	else
		cout << "No\n";


	return 0;
}

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

int main() {

int N;
int A = 0;
cin >> N;
  
  for (int i = 0; i < N; i++){
    int B, C;
    cin >> B >> C;
    A += C-B+1;
  }
  
  cout << A << endl;
}


Measured memory_bytes: 256
from itertools import accumulate
n = int(input())
a = [0]+list(map(int,input().split()))+[0]
s = [abs(a[i]-a[i+1]) for i in range(n+1)]
s = sum(s)
for i in range(1,n+1):
    print(s+abs(a[i-1]-a[i+1])-(abs(a[i-1]-a[i])+abs(a[i]-a[i+1])))

Measured memory_bytes: 65772
h,w=map(int,input().split())
n=10
dist=[list(map(int,input().split())) for _ in range(n)]
a=[list(map(int,input().split())) for _ in range(h)]
for k in range(n):
  for i in range(n):
    for j in range(n):
      dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j])
ans=0
for i in range(h):
  for j in range(w):
    if a[i][j]!=-1:ans+=dist[a[i][j]][1]
print(ans)


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

int main()
{
	int n;
	cin >> n;
	vector<int> v;
	int x;
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		v.push_back(x);
	}
	long long int count = 0;
	int dif;
	for (int i = 1; i < n; i++)
	{
		dif = abs(v[i] - v[i - 1]);
		if (v[i - 1] > v[i])
		{
			v[i] = v[i - 1];
			count = count + dif;
		}
	}
	cout << count << "\n";
}


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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;


int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n,k;
    cin>>n>>k;
    vector<int> pos,neg;
    vector<int> a(n);
    for(int i=0;i<n;++i){
        int ai;cin>>ai;
        a[i] = ai;
        if(ai >= 0)pos.push_back(ai);
        else neg.push_back(ai);
    }
    sort(pos.begin(),pos.end());
    sort(neg.rbegin(),neg.rend());
    bool positive;
    if((int)neg.size() == n){
        if(k%2 == 1){
            positive = false;
        }else {
            positive = true;
        }
    }else {
        if(k == n){
            if(((int)neg.size())%2){
                positive = false;
            }else {
                positive = true;
            }
        }else {
            positive = true;
        }
    }
    ll ans = 1ll;
    if(!positive){
        sort(a.begin(),a.end(),[](int x,int y){
            return abs(x) < abs(y);
        });
        for(int i=0;i<k;++i){
            ans *= (a[i]%mo + mo)%mo;
            ans %= mo;
        }
    }else {
        if(k%2){
            k--;
            ans *= pos.back();
            pos.pop_back();
        }
        vector<ll> p2;
        while((int)pos.size() >=2){
            ll tmp = 1ll;
            tmp *= pos.back();pos.pop_back();
            tmp *= pos.back();pos.pop_back();
            p2.push_back(tmp);
        }
        while((int)neg.size() >= 2){
            ll tmp = neg.back();neg.pop_back();
            tmp *= neg.back();neg.pop_back();
            p2.push_back(tmp);
        }
        sort(p2.rbegin(),p2.rend());
        for(int i=0;i<k/2;++i){
            ans *= (p2[i]%mo+mo);
            ans %= mo;
        }
    }
    cout << ans << endl;
    return 0;
    
}


Measured memory_bytes: 6320
//
#if 0
#include <atcoder/fenwicktree>
#include <atcoder/segtree>
#include <atcoder/lazysegtree>
#include <atcoder/string>
#include <atcoder/math>
#include <atcoder/convolution>
#include <atcoder/modint>
#include <atcoder/dsu>
#include <atcoder/maxflow>
#include <atcoder/mincostflow>
#include <atcoder/scc>
#include <atcoder/twosat>
#endif
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if (S[S.size() - 1] == 's')
    {
        S.push_back('e');
        S.push_back('s');
    }
    else
    {
        S.push_back('s');
    }
    cout << S;
    return 0;
}

Measured memory_bytes: 3040
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close(); 
		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				if (i * j == n) {
					System.out.println("Yes");
					System.exit(0);
				}				
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
int main(){
  int n,i,count=0,max=0;
  scanf("%d",&n);
  int h[n+2];
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
    max+=h[i];
  }
  h[n]=0;
  while(max!=0){
    for(i=0;i<n;i++){
      if(h[i]!=0 && h[i+1]==0)
        count++;
      if(h[i]!=0){
        h[i]--;
        max--;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 128
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    n = II()
    h = LI()
    dp = [0 for i in range(n)]
    dp[1] = abs(h[0] - h[1])
    for i in range(2,n):
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]))
    print(dp[n-1])
    return

#B
def B():
    n, K = LI()
    h = LI()
    dp = [float("INF") for i in range(n + K + 1)]
    dp[0] = 0
    for i in range(n):
        for k in range(1, K + 1):
            if i + k >= n:
                break
            dp[i + k] = min(dp[i + k], dp[i] + abs(h[i] - h[i + k]))
    print(dp[n-1])
    return

#C
def C():
    n = II()
    abc = LIR(n)
    dp = [0 for i in range(3 * n + 1)]
    dp[0] = abc[0][0]
    dp[1] = abc[0][1]
    dp[2] = abc[0][2]
    for i in range(1,n):
        dp[3 * i] = max(dp[3 * i], dp[3 * (i - 1) + 1] + abc[i][0], dp[3 * (i - 1) + 2] + abc[i][0])
        dp[3 * i + 1] = max(dp[3 * i + 1], dp[3 * (i - 1) + 2] + abc[i][1], dp[3 * (i - 1)] + abc[i][1])
        dp[3 * i + 2] = max(dp[3 * i + 2], dp[3 * (i - 1) + 1] + abc[i][2], dp[3 * (i - 1)] + abc[i][2])
    dp[3 * n] = max(dp)
    print(dp[3*n])

    return

#D
def D():
    """N個の品物があります。 品物には 1,2,…,Nと番号が振られています。 
    各 i (1≤i≤N) について、品物i の重さはwi で、価値はvi です。
    太郎君は、N 個の品物のうちいくつかを選び、ナップサックに入れて持ち帰ることにしました。 
    ナップサックの容量は W であり、持ち帰る品物の重さの総和は W以下でなければなりません。
    太郎君が持ち帰る品物の価値の総和の最大値を求めてください
    
    入力はすべて整数である。
    1≤N≤100
    1≤W≤10**5
    1≤wi≤W
    1≤vi≤10**9"""
    n, w = LI()
    wv = LIR(n)
    dp = [[0 for k in range(w + 1)] for i in range(n + 2)]
    for i in range(1,n + 1):
        for j in range(w + 1):
            if j < wv[i-1][0]:
                dp[i + 1][j] = dp[i][j]
            else:
                dp[i + 1][j] = max(dp[i][j], dp[i][j - wv[i - 1][0]] + wv[i - 1][1])
    print(dp[n+1][w])

    
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I():
    return 
#J

#K

#L

#M
#N
# O
# P
# Q
# R
# S
# T
# U
# V
# W
# X
# Y
# Z


#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 172028
import java.util.Scanner;
import java.math.BigInteger;

public class Main {

    public static void main(String[] args) {
        BigInteger a, b;
        Scanner scanner = new Scanner(System.in);
        a = scanner.nextBigInteger();
        b = scanner.nextBigInteger();
        scanner.close();

        int res;

        // compare a with b
        res = a.compareTo(b);

        String str1 = "EQUAL ";
        String str2 = "GREATER ";
        String str3 = "LESS";

        if (res == 0)
            System.out.println(str1);
        else if (res == 1)
            System.out.println(str2);
        else if (res == -1)
            System.out.println(str3);
    }
}

Measured memory_bytes: 22740
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){

int n,q;
int h1=0,m1=0,s1=0,h2=0,m2=0,s2=0;
while(1){
cin>>n;if(n==0)break;
long long int N[90800]={};
for(int i=0;i<n;i++)
{scanf("%d:%d:%d",&h1,&m1,&s1);
scanf("%d:%d:%d",&h2,&m2,&s2);
long int L1=h1*3600+m1*60+s1;
long int L2=h2*3600+m2*60+s2;
for(int j=L1;j<L2;j++)
	N[j]++;
}
int max=0;
for(int i=0;i<90800;i++)
{if(N[i]>max)max=N[i];}
cout<<max<<endl;
}
return 0;
}

Measured memory_bytes: 1956
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, m, msk[1009], a[1009], b[1009], c;
long long dp[1009][5000];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		for (int j = 0; j < b[i]; j++) {
			cin >> c;
			c--;
			msk[i] = msk[i] ^ (1 << c);
		}
	}
	int N = 1 << n;
	for (int i = 0; i < m; i++) {
		for (int j = 1; j < N; j++) {
			dp[i][j] = 1e10;
		}
	}
	for (int j = 1; j < N; j++) {
		if ((msk[0] & j) == j) {
			dp[0][j] = a[0];
		}
	}

	for (int i = 1; i < m; i++) {
		for (int j = 1; j < N; j++) {
			dp[i][j] = min(dp[i - 1][j], dp[i - 1][j ^ (msk[i] & j)] + a[i]);
		}
	}
	if (dp[m - 1][N - 1] == 1e10)
		cout << -1 << E;
	else
		cout << dp[m - 1][N - 1] << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 39168
#include <iostream>

using namespace std;

int main(){
    int a,b,c,count = 3;
    cin >> a >> b >> c;
    if(a == b)count--;
    if(b == c)count--;
    if(a == c)count--;

    if(count == 0)count++;

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var a = ReadNextInt();
            var b = ReadNextInt();
            var c = ReadNextInt();
            var ans = a <= c && c <= b ? "Yes" : "No";
            Console.WriteLine(ans);
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static BigInteger ReadBigInteger() => BigInteger.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static BigInteger[] ReadBigIntegerArray() => ReadStringArray().ParseBigInteger().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
        public static IEnumerable<BigInteger> ParseBigInteger(this IEnumerable<string> source) => source.Select(BigInteger.Parse);

        public static string[] Buffer = new string[] { };
        public static int Index;
        public static string ReadStringNext()
        {
            if (Buffer.Length == 0 || Buffer.Length <= Index)
            {
                Buffer = ReadStringArray();
                Index = 0;
            }
            return Buffer[Index++];
        }
        public static int ReadNextInt() => int.Parse(ReadStringNext());
        public static long ReadNextLong() => long.Parse(ReadStringNext());
        public static BigInteger ReadNextBigInteger() => BigInteger.Parse(ReadStringNext());
    }
}


Measured memory_bytes: 13140
import sys
import numpy as np

h,w = [int(x) for x in sys.stdin.readline().split()]
n = int(input())
a = [int(x) for x in sys.stdin.readline().split()]
s = h*w

l = []

for i,x in enumerate(a):
	for j in range(x):
		l.append(i+1)

l = np.array(l).reshape((h,w))

for i,x in enumerate(l):
	if i % 2 == 0:
		print(' '.join(map(str, x)))
	else:
		print(' '.join(map(str, reversed(x))))

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int h,w;
int n;
int ans[10];

int main(){
  scanf("%d%d%d",&h,&w,&n);
  set<pii> nurare;
  set<pii> checks;
  REP(i,n){
    int a,b;
    scanf("%d%d",&a,&b);
    --a;--b;
    nurare.insert(pii(a,b));
    FOR(j,-2,3)FOR(k,-2,3){
      int y=a+j,x=b+k;
      if(y<0||x<0||y>=h-2||x>=w-2)continue;
      checks.insert(pii(y,x));
    }
  }
  for(const pii& P:checks){
    int py = P.first, px = P.second;
    int tmp = 0;
    REP(i,3)REP(j,3)tmp += nurare.count(pii(py+i,px+j));
    ans[tmp]+=1;
  }
  // ans[0]
  ll a0 = 0;
  a0 = (ll)(h-2)*(ll)(w-2);
  a0 -= checks.size();
  a0 += ans[0];
  printf("%lld\n",a0);
  FOR(i,1,10){
    printf("%d\n",ans[i]);
  }
  return 0;
}


Measured memory_bytes: 122112
N = int(input())  #参加人数
M = int(input())  #ゲーム回数
t = list(map(int, input().split()))  #ゲーム毎のターゲット
r = [0 for _ in range(N)]  #参加者毎の点数
for i in range(M):
	e = list(map(int, input().split()))  #予想
	for j in range(len(e)):
		if t[i] == e[j]: #予想があったったら
			r[j] += 1
		else:
			r[t[i]-1] += 1

for i in r: print(i)  #結果出力



Measured memory_bytes: 5628
#include<iostream>
#include<string>
#include<cmath>
//#include<array>
#include<algorithm>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>

using namespace std;
using LLI = long long int;

//vector<int>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//vector<int>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//vector<int>dir_x2 = { 0,0,1,-1 };
//vector<int>dir_y2 = { 1,-1,0,0 };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI tmp, r;
//	if (x < y) {
//		tmp = x;
//		x = y;
//		y = tmp;
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x,LLI y) {
//	return x / gcd(x,y) * y;
//}

//long nCr(int n,int r) {
//	long ans = 1;
//	for (int i = n; i > n - r;i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1;i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

int main(void) {
	int N, a, res = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		while (a % 2 == 0) {
			a /= 2;
			res++;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	X = int(input())
	ans = 0
	ans += int(X // 500) * 1000
	ans += int((X % 500) // 5) * 5
	print(ans)
	
if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
#define r(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#include <bits/stdc++.h>
#include <cmath>
#include <fstream>
#define f first
#define endl "\n"
#define s second
#define pb push_back
#define ms(a,b) memset(a,b,sizeof(a))
#define fori(a,b) for(__typeof(a) i=a,ENDI=b;i<ENDI;i++)
#define forj(a,b) for(__typeof(a) j=a,ENDJ=b;j<ENDJ;j++)
typedef long long ll;
using namespace std;
char _;

int main(){	
	int num;
	r(num);
	if(num%1000==0) cout << "0"  << endl; 
	else cout << 1000-(num%1000) << endl;
}


Measured memory_bytes: 3588
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b;
    rep3(i,1,4){
        if(i!=a&&i!=b){
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 888
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Set<Integer> list = new HashSet<>();

		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if (list.contains(a)) {
				list.remove(a);
			} else {
				list.add(a);
			}
		}

		System.out.println(list.size());

		sc.close();

	}

}

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

int main() {
    long long int a, b,  soma, sub, mult;
    cin >> a >> b;
    soma = a + b;
    sub = a - b;
    mult = a * b;

    if(soma > sub){
        if(soma > mult){
            cout << soma << endl;
        }
        else{
            cout << mult <<endl;
        }
    }
    else{
        if(sub > mult){
            cout << sub << endl;
        }
        else{
            cout << mult << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <set>

using namespace std;
typedef long long ll;
const int MAXN = 300100;

int N;
int arr[MAXN];

bool check (int l, int r)
{
    //cout << l << " " << r << "\n";

    int mlo = MAXN, mhi = 0;
    for (int i = l; i <= r; i++)
    {
        mlo = min (mlo, arr[i]);
        mhi = max (mhi, arr[i]);
    }
    if (mlo != l || mhi != r)
        return false;
    set <int> s;

    int cm = -1;
    for (int i = l; i <= r; i += 2)
        s.insert(i);
    for (int i = l; i <= r; i += 2)
    {
        if (cm > arr[i])
        {
            if (*s.begin() < arr[i])
                return false;
        }
        s.erase(arr[i]);
        cm = max (cm, arr[i]);
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> arr[i];
        arr[i]--;
    }

    bool works = true;
    for (int i = 0; i < N; i++)
    {
        if (arr[i] != i)
        {
            int cloc = i;
            while (cloc < N - 2)
            {
                if (arr[cloc+1] != cloc + 1)
                    break;
                if (arr[cloc+2] == cloc + 2)
                    break;
                cloc += 2;
            }
            if (!check (i, cloc))
                works = false;
            i = cloc;
        }
    }

    if (works) cout << "Yes\n";
    else cout << "No\n";
}

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

int main() {
  ll n;
  cin >> n;
  map<ll,ll> a;
  for(ll i=0;i<n;i++) {
    ll temp;
    cin >> temp;
    a[temp]++;
  }
  
  cout << a.size()+a.size()%2-1 << endl;
}

Measured memory_bytes: 6528
fn main() {
    let mut line: String = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    let chars: Vec<&str> = line.trim().split(' ').collect();
    if chars[0] == chars[1] {
        println!("=")
    } else if chars[0] < chars[1] {
        println!("<")
    } else {
        println!(">")
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? ((x) : -(x)))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
int grid[85][85];
int val[85][85][2];
int dp[85][85][12805];
int mini;

void go(int y, int x, int cur) {
	int &ret = dp[y][x][cur];
	if (ret != 0) return;
	ret = 1;
	int v = val[y][x][0] - val[y][x][1];
	if (y == N && x == M) {
		mini = min(mini, abs(cur + v - 6400));
		mini = min(mini, abs(cur - v - 6400));
		return;
	}
	if (y + 1 <= N) {
		go(y + 1, x, cur + v);
		go(y + 1, x, cur - v);
	}
	if (x + 1 <= M) {
		go(y, x + 1, cur + v);
		go(y, x + 1, cur - v);
	}
	return;
}

int main()
{
	int i, j;
	scanf("%d%d", &N, &M);
	for (int k = 0; k < 2; ++k) {
		for (i = 1; i <= N; ++i) {
			for (j = 1; j <= M; ++j) {
				scanf("%d", &val[i][j][k]);
			}
		}
	}
	mini = INF;
	go(1, 1, 6400);
	printf("%d", mini);
	return 0;
}

Measured memory_bytes: 342400
def mi():
    return map(int, input().split())

def main():
    N = int(input())
    W = [input() for _ in range(N)]
    if len(set(W)) != N:
        print('No')
        return
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            print('No')
            return
    print('Yes')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <iostream>
using namespace std;
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
typedef long long ll;
typedef long double ld;

int main()
{
    ll k,n;
    cin>>k>>n;
    vector<ll> position(n);
    vector<ll> dist(n);

    for(ll i=0;i<n;i++){
        cin>>position[i];
    }

    ll res=0;
    for(ll i=0;i<n;i++){
        if(i<n-1){
            dist[i]=position[i+1]-position[i];
        }else{
            dist[i]=position[0]+(k-position[n-1]);
        }
        res+=dist[i];
    }
    //positon[0]からスタート=dist[0]から加算
    
    ll i_max = *std::max_element(dist.begin(),dist.end());
    
    res-=i_max;
    cout<<res<<endl;
    
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;
typedef long long ll;

string n;

int main(){
  cin >> n;
  rep(i, n.size()){
    if (n[i]=='1') n[i]='9';
    else n[i]='1';
  }
  cout << n << endl;
}


Measured memory_bytes: 3548
N=int(input())
A=[0 for x in range(1001)]

def devPrime(a):
  cnt=2
  res=a
  while res>1:
    while res%cnt==0:
      res/=cnt
      A[cnt]+=1
    cnt+=1
for i in range(2,N+1):
  devPrime(i)
ans=1
for i in range(len(A)):
  ans*=(A[i]+1)
  ans%=1000000007
print(ans)

Measured memory_bytes: 3064
import Data.List
f::Integer->Integer->[Integer]
f _ 1=[]
f m n
   |n `mod` m==0 =m:f m (n `div` m)
   |otherwise=f (m+1) n

f2::[[[Integer]]]->[Int]
f2 []=[]
f2 (x:xs)=product (map (+1) (map length x)):(f2 xs)

main = do
       a<-getLine
       let b=read a::Integer
       print $ length $ filter (==8)$ f2 $ map group $ map (f 2) $ [1,3..b] 

Measured memory_bytes: 764
#include <stdio.h>

int dir_x[] = {1, -1};
int dir_y[] = {1, -1};

int main(void)
{
    while(1){
        int N, W, H, S, T;
        int field[101][101] = {{0}};

        scanf("%d", &N);
        if(N == 0)
            break;
        scanf("%d %d", &W, &H);

        int i;
        int tx, ty;
        for(i = 0; i < N; i++){
            scanf("%d %d", &tx, &ty);
            field[ty][tx] = 1;
        }
        scanf("%d %d", &S, &T);

        int max = 0;
        int sx, sy;
        for(sx = 1; sx <= W; sx++){
            for(sy = 1; sy <= H; sy++){

                int j;
                for(j = 0; j < 2; j++){
                    int k;
                    for(k = 0; k < 2; k++){
                        tx = sx;
                        ty = sy;
                        int g_x = tx + dir_x[j] * S;
                        int g_y = ty + dir_y[k] * T;
                        if(tx + dir_x[j] * S - dir_x[j] <= W && tx + dir_x[j] * S - dir_x[j] > 0 && ty + dir_y[k] * T - dir_y[k] <= H && ty + dir_y[k] * T - dir_y[k] > 0){
                            int temp = 0;
                            for(tx = sx; tx != g_x; tx += dir_x[j])
                                for(ty = sy; ty != g_y; ty += dir_y[k]){
                                    if(field[ty][tx])
                                        temp++;
                                }
                            if(temp > max)
                                max = temp;
                        }
                    }
                }
            }
        }

        printf("%d\n", max);
    }

    return 0;
}

Measured memory_bytes: 648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int x = Integer.parseInt(br.readLine());
		System.out.println((int)Math.pow(x, 3));
	}

}

Measured memory_bytes: 24216
def main():
    N = int(input())
    B = [float('inf')] + list(map(int, input().split())) + [float('inf')]
    A = []
    for i in range(N):
        A.append(min(B[i], B[i+1]))
    print(sum(A))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main(){
    ll N,x,cnt=0,dif;
    cin>>N>>x;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
    }

    if(a.at(0)>x){
        cnt+=a.at(0)-x;
        a.at(0)-=a.at(0)-x;
    }
    for(int j=1;j<N;j++){
        dif=a.at(j)+a.at(j-1);
        if(dif>x){
            a.at(j)-=dif-x;
            cnt+=dif-x;
        }
            
    }
    cout<<cnt<<endl;
}

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

int main(){
    int a, b, c, d, tmp;
    string s;
    cin >> s;
    a = s[0]-'0';
    for(int i=0; i<2; i++){
	b=0;
	if(i)
	    b -= s[1]-'0';
	else
	    b += s[1]-'0';
	for(int j=0; j<2; j++){
	    c=0;
	    if(j)
		c -= s[2]-'0';
	    else
		c += s[2]-'0';
	    for(int k=0; k<2; k++){
		d=0;
		if(k)
		    d -= s[3]-'0';
		else
		    d += s[3]-'0';
		tmp = a+b+c+d;
		if(tmp == 7){
		    cout << s[0];
		    if(i)
			cout << "-";
		    else
			cout << "+";
		    cout << s[1];
		    if(j)
			cout << "-";
		    else
			cout << "+";
		    cout << s[2];
		    if(k)
			cout << "-";
		    else
			cout << "+";
		    cout << s[3];
		    cout << "=7" << endl;
		    return 0;
		}
	    }
	}
    }

}




Measured memory_bytes: 256
import java.util.*;
public class Main {
		
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), A = sc.nextInt(), B =sc.nextInt();
		long X[] = new long[N];
		for(int i=0;i<N;i++)X[i]=sc.nextLong();
		sc.close();
		
		long ans = 0;
		
		for(int i=0;i<N-1;i++) {
			ans += Math.min((X[i+1]-X[i])*A, B);
		}
		
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 49992
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int k;
	cin>>k;
	if (b == 0 || c==0){
		cout <<  "No" << endl;
		return 0;
	}
	while (k--){
		if (b<= a){
			b*=2;
		}else{
			c *=2;
		}
	}
	if (c>b && b>a){
		cout << "Yes" <<endl;
	}else{
		cout << "No" << endl;
	}
}

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

using namespace std;

const int MAXN = 100 + 7;
const int MAXW = 100000 + 7;
const int INF = 1000000000 + 7;

typedef long long ll;

int N, W;
int v[MAXN], w[MAXN];
ll dp[MAXN][MAXW];

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

  for(int i = 1; i <= N; ++i) {
    cin >> w[i] >> v[i];
  }

  for(int i = 1; i <= N; ++i) {
    for(int j = 0; j <= W; ++j) {
      if(w[i] > j) {
        //weight of item i is larger than remaining weights available
        //we CANNOT insert it into our bag
        dp[i][j] = dp[i - 1][j];
      } else {
        //it is possible to put item i into our bag
        //check which one is better:
        //to take this item
        dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
        //or to not take this item
        dp[i][j] = max(dp[i][j], dp[i - 1][j]);
      }
    }
  }

  ll ans = 0ll;
  for(int i = 0; i <= W; ++i) {
    ans = max(ans, dp[N][i]);
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 79360
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min

int main() {
  long int N, K;
  std::cin >> N >> K;
  
  long int times = N / K;
  long int num1 = std::abs(N - (times * K));
  long int num2 = std::abs(N - (times + 1) * K);
  if(num1 < num2) std::cout << num1 << std::endl;
  else std::cout << num2 << std::endl; 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int A, B;
    cin >> A >> B;
    int ans = 0;
    if(A == B) {
        ans = A + B;
    } else if(A > B) {
        ans = A + (A - 1);
    } else if(B > A) {
        ans = B + (B - 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256