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


int main()
{
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		long long  t = (lower_bound(a.begin(), a.end(), b[i]) - a.begin());
		long long  s =  n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());
		ans += t * s;
	}
	cout << ans << endl;
	return 0;

}



Measured memory_bytes: 1536
n,m=map(int,input().split())
a = [list(map(int,input().split())) for _ in range(m)]

ret=[0 for _ in range(n)]
for i in range(n):  
  for ai in a:
    if i+1 in ai:
      ret[i]+=1
for i in ret:
  print(i)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

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

  int S_len = S.size();
  vector<char> Conv( S_len );
  rep( i, 0, S_len ) {
    Conv.at(i) = S[i] + N;
    if ( 'Z'<Conv.at(i) ) Conv.at(i) -= 26;
    cout << Conv.at(i);
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for(ll i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1,gtest=1;
//	cin>>test;
	while(test--)
	{
		ll x,i=100,u;
		int ans=0;
		cin>>x;
		while(i<x)
		{
			ans++;
			u=i/100;
			i+=u;
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  int n,m;cin >>n>>m;
  vector<int> v(n,0);
  vector<bool> trying(n,true);
  int cnt_pen =0;
  int cnt_ac = 0;
  for(int i=0; i<m;++i){
    int p;
    string s;
    cin >>p>>s;
    if(s=="WA"){
      ++v[p-1];
    } else {
      if(trying[p-1]){
        cnt_pen += v[p-1];
        ++cnt_ac;
        trying[p-1]=false;
      }
    }
  }
  cout << cnt_ac << " "<<cnt_pen<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long
main(){
	int n,r=0;
	cin>>n;
	vector<string> s(n);
	for(auto& i:s){
		cin>>i;
		sort(i.begin(),i.end());
	}
	sort(s.begin(),s.end());
	int a=0,b=0;
	while(b<n){
		while(b+1<n&&s[a]==s[b+1])b++;
		r+=(b-a+1)*(b-a)/2;
		a=b=b+1;
	}
	cout<<r;
}

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

#define int long long

int32_t main(){
	map<string,int> mp = {{"SUN",0}, {"MON",1}, {"TUE",2},
				{"WED",3}, {"THU",4}, {"FRI",5}, {"SAT",6}} ;
	string s ;
	cin >> s ;
	cout << 7-mp[s] ;
	return 0 ;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a[10];
	int i,j,k,box;
	for(i=0;i<=9;i++){
		scanf("%d",&a[i]);
	}
	box=0;
	for(j=0;j<=9-1;j++){
		for(k=j+1;k<=9;k++){
			if(a[j]<=a[k]){
				box=a[j];
				a[j]=a[k];
				a[k]=box;
			}
		}
	}
	printf("%d\n",a[0]);
	printf("%d\n",a[1]);
	printf("%d\n",a[2]);
	return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
	int n; cin >> n;
	vector<int> s;
	int sum = 0;
	for (int i = 0; i < n; ++i) {
		int a; cin >> a;
		sum += a;
		s.push_back(a);
	}
	int m = sum % 10 == 0 ? 0 : sum;
	for (int i = 0; i < n; ++i) {
		m = max(m, (sum - s[i])%10 == 0 ? 0 : sum - s[i]);
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;
int MOD = 1e9 + 7;

struct Query {
	int w, v;
};

int main() {
	int N;
	cin >> N;
	vector<vector<int>> good;   //男性、相性のいい人
	good.resize(N+1);
	for (int n = 1; n <= N; n++) {
		for (int girl = 0; girl < N; girl++) {
			int g;
			cin >> g;
			if (g == 1)good[n].push_back(girl);
		}
	}
	vector<vector<long long>> DP;
	vector<int> order((1<<N),0);
	for (int code = 0; code < (1 << N); code++) order[code] = code;
	sort(order.begin(), order.end(), [=](int code1, int code2) {
		int c1 = 0;
		for (int n = 0; n < N; n++) {
			if ((code1 & (1 << n)))c1++;
		}
		int c2 = 0;
		for (int n = 0; n < N; n++) {
			if ((code2 & (1 << n)))c2++;
		}
		return c1 < c2;
	});
	DP.resize(N + 1, vector<long long>((1 << N), 0));
	DP[0][0] = 1;
	for (int counter = 0,code = order[counter]; counter < (1 << N)-1; counter++) {
		code = order[counter];
		int n = 0;
		for (int c = 0; c < N; c++) {
			if ((code & (1 << c)))n++;
		}
		DP[n][code] %= MOD;
		for (int girl : good[n+1]) {
			if ((code & (1 << girl)))continue;   //すでに取られているので
			DP[n+1][(code | (1 << girl))] += DP[n][code];
		}
	}
	cout << DP[N][(1 << N) - 1]%MOD << endl;
	return 0;
}

Measured memory_bytes: 385408
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int cnt0 = 0;
    int cnt1 = 0;

    for(int i=0; i<s.length(); i++){
      if( s.charAt(i) == '0')
        ++cnt0;
      else
        ++cnt1;
    }
    int cntMin = Math.min(cnt0, cnt1);
    if(cntMin == 0)
      System.out.println(0);
    else
      System.out.println(cntMin*2);
  }
}

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

int main(){
  int i,j,k,cnt=0;
  int R,G,B,n;
  cin>>R>>G>>B>>n;
  for(i=0;;i++){
    int p=R*i;
    if(p>n)break;
    for(j=0;;j++){
      int q=p+G*j;
      if(q>n)break;
      for(k=(n-q)/B;;k++){
        int r=q+B*k;
        if(r==n)cnt++;
        if(r>n)break;
      }
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
// Young Maids
// * frank_c1
// * 2017 / 09 / 27 

#include <bits/stdc++.h>
using namespace std;

const int maxn = (int)(2e5) + 5;
int a[maxn], ps[maxn], T[maxn << 2][2], M;

inline int Q(int s, int t, int c) {
	int ret = (int)(1e9);
	for (s += M - 1, t += M + 1; s ^ t ^ 1; s >>= 1, t >>= 1) {
		if (~s & 1) ret = min(ret, T[s ^ 1][c]);
		if ( t & 1) ret = min(ret, T[t ^ 1][c]);
	} return ret;
}

struct node {
	int l, r, c, s, t;

	node(int _l, int _r, int _c) {
		l = _l; r = _r; c = _c;
		s = ps[Q(l, r, c)]; t = ps[Q(s, r, c ^ 1)];
	}
};

bool operator < (node x, node y) {
	return a[x.s] > a[y.s];
}

priority_queue<node> q;

int main() {
	int n;
	scanf("%d", &n);
	for (M = 1; M <= n; M <<= 1);
	memset(T, 0x3f, sizeof(T));
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), ps[a[i]] = i, T[i + M][i & 1] = a[i];
	for (int i = M; i; --i) for (int j = 0; j < 2; ++j) T[i][j] = min(T[i << 1][j], T[i << 1 | 1][j]);
	q.push(node(1, n, 1));
	while (!q.empty()) {
		node u = q.top(); q.pop();
		printf("%d %d ", a[u.s], a[u.t]);
		if (u.l < u.s) q.push(node(u.l, u.s - 1, u.c));
		if (u.t < u.r) q.push(node(u.t + 1, u.r, u.c));
		if (u.s + 1 < u.t) q.push(node(u.s + 1, u.t - 1, u.c ^ 1));
	} putchar('\n');
	return 0;
}

Measured memory_bytes: 10228
#include <stdio.h>
#include <stdlib.h>

typedef struct num {
  int idx;
  int cnt;
}num;

int cmp(const void *x, const void *y) {
  return ((num *)y)->cnt - ((num *)x)->cnt;
}

int main() {
  int n, v, ans=0;
  scanf("%d", &n);
  num me[100005], mo[100005];
  for (int i=0; i<100000; i++) {
    me[i].cnt=0; me[i].idx=i;
    mo[i].cnt=0; mo[i].idx=i;
  }
  for (int i=0; i<n; i++) {
    scanf("%d", &v);
    if (i%2==1) me[v-1].cnt++;
    else mo[v-1].cnt++;
  }
  qsort(me, 100000, sizeof(num), cmp);
  qsort(mo, 100000, sizeof(num), cmp);
  if (me[0].idx == mo[0].idx) {
    if (me[1].cnt < mo[1].cnt) ans += n-me[0].cnt-mo[1].cnt;
    else ans += n-me[1].cnt-mo[0].cnt;
  }else ans += n-me[0].cnt-mo[0].cnt;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2352
#include <algorithm>
#include <iostream>

using namespace std;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)


bool le(int h1, int w1, int h2, int w2)
{
    int d1 = h1*h1 + w1*w1;
    int d2 = h2*h2 + w2*w2;

    return d1 < d2 || (d1 == d2 && h1 < h2);
}

int main()
{
    int h, w;

    while(cin >> h >> w, h && w){
        int rh = 1000;
        int rw = rh;

        reps(i, 1, 151){
            reps(j, i+1, 151){
                if(le(h, w, i, j) && le(i, j, rh, rw)){
                    rh = i;
                    rw = j;
                }
            }
        }

        cout << rh <<' ' << rw << endl;
    }
}

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

long long a , b;

int main(void) {
	cin>> a >> b;
	if(a * b < 0) {
		puts("Zero"); return 0;
	}
	if(a > 0) {
		puts("Positive"); return 0;
	}
	if((b - a) % 2 == 0) {
		puts("Negative");
	}
	else puts("Positive");
} 

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

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

const int INF = 1000000007;

int main(void){
	string S; cin>>S;
	int w; cin>>w;
	string s;

	for(int i=0;i<S.size();i+=w){
		s += S[i];
	}

	printf("%s\n", s.c_str());

	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++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#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 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

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

  int ma = 0;
  int mi = 1001001001;
  rep(i, n){
    int a; cin >>a;
    chmax(ma, a);
    chmin(mi, a);
  }

  cout << ma - mi << endl;

  return 0;
}


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

#define ll long long
#define ull unsigned long long

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    ll N;
    ll sum = 0;
    ll maxi = 0;
    cin >> N;
    for(ll i = 0;i < N;i++) {
        ll temp;
        cin >> temp;
        sum += temp;
        maxi = max(maxi, temp);
    }
    if(sum - maxi > maxi) puts("Yes");
    else puts("No");
    return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    string s;
    cin >> s;
    REP(i, s.size()) if(i % 2 == 0) cout << s[i];
    cout << endl;
}


Measured memory_bytes: 592
from collections import deque

n = int(input())
num_list = []
for i in range(n):
    num_list.append(list(map(int,input().split())))

num_of_operations = num_list[0][0]

vec = deque('')

for i in range(len(num_list)):
    operation = num_list[i][0]

    if(operation == 0):
        d = num_list[i][1]
        if(d == 0): vec.appendleft(num_list[i][2])
        elif(d == 1): vec.append(num_list[i][2])
            
            
    elif(operation == 1):
        p = num_list[i][1]
        print(vec[p])

    elif(operation == 2):
        d = num_list[i][1]
        if(d == 0): vec.popleft() 
        elif(d == 1): vec.pop()         

    #print(vec)


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

int main(){
	int n;
	cin >> n;
	double x[10];
	string u[10];
	double sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> u[i];
		if (u[i] == "JPY") {
			sum += x[i];
		}
		else {
			sum += x[i] * 380000;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

class Main {
	public static Scanner sc = new Scanner(in);
	public static Random rand=new Random();

	public void run() {
		TCase:while(true){
			int n=sc.nextInt();
			if(n==0)return;
			int W=sc.nextInt(),H=sc.nextInt();
			boolean[][] kaki=new boolean[W][H];
			for(int i=0;i<n;i++){
				kaki[sc.nextInt()-1][sc.nextInt()-1]=true;
			}
			int S=sc.nextInt(),T=sc.nextInt();

			int max=0;
			for(int xs=0;xs<W;xs++)for(int ys=0;ys<H;ys++){
				if(xs+S<=W && ys+T<=H){
					int sum=0;
					for(int x=xs;x<xs+S;x++)for(int y=ys;y<ys+T;y++){
						if(kaki[x][y])sum++;
					}
					max=Math.max(sum,max);
				}
			}

			ln(max);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}

	public int[] nextIntArray(int n){
		int[] res=new int[n];
		for(int i=0;i<n;i++){
			res[i]=sc.nextInt();
		}
		return res;
	}
	public static void pr(Object o) {
		out.print(o);
	}
	public static void ln(Object o) {
		out.println(o);
	}
	public static void ln() {
		out.println();
	}
}

Measured memory_bytes: 35548
#!/usr/bin/env python3
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
s = [0] * (M - 1)
for i in range(M - 1):
    s[i] = X[i + 1] - X[i]
s.sort()
print(sum(s[:-N + 1]) if N != 1 else sum(s))


Measured memory_bytes: 13968
#include<bits/stdc++.h>
using namespace std;
const int N=6000,mod=1000000007;
typedef long long ll;
int dp[N][N],f[N],p[N],n,ans;
vector<int>g[N];

int dfs(int x,int fa=-1){
	int sz=1;dp[x][1]=1;
	for(int i:g[x])if(i!=fa){
		int si=dfs(i,x);
		for(int j=0;j<=si;++j){
			if(j%2==0){
				int tmp=(ll)dp[i][j]*p[j]%mod;
				tmp=(mod-tmp)%mod;
				for(int k=0;k<=sz;++k)
					f[k]=(f[k]+(ll)dp[x][k]*tmp)%mod;
			}
			for(int k=0;k<=sz;++k)
				f[k+j]=(f[k+j]+(ll)dp[x][k]*dp[i][j])%mod;
		}
		sz+=si;
		for(int j=0;j<=sz;++j)dp[x][j]=f[j],f[j]=0;
	}
	return sz;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;p[0]=1;
	for(int i=2;i<=n;i+=2)p[i]=(ll)p[i-2]*(i-1)%mod;
	for(int i=1;i<n;++i){
		int x,y;cin>>x>>y;
		g[x].push_back(y);g[y].push_back(x);
	}
	dfs(1);
	for(int i=2;i<=n;i+=2)ans=(ans+(ll)dp[1][i]*p[i])%mod;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 118656
#include<bits/stdc++.h>
#define F(a,b,c,d) for (register int a=b;a<=c;a+=d)
#define FD(a,b,c,d) for (register int a=b;a>=c;a-=d)
using namespace std;
int main(){
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[1]-a[0]+a[2]-a[1]<<endl;
	return 0;
}



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

const int N = 1e5+5;
int n;
string s;
bool a[N];

int main()
{
    cin >> n;
    int l = 0, r = n;
    cout << 0 << endl;
    cin >> s;
    if (s[0] == 'V') return 0;
    if (s[0] == 'M') a[0] = a[n] = 0;
    else a[0] = a[n] = 1;
    int mid = (l+r)/2;
    while(1)
    {
        cout << mid << endl;
        cin >> s;
        if (s[0] == 'V') break;
        if (s[0] == 'M') a[mid] = 0;
        else a[mid] = 1;
        if ((a[l] == a[mid] && (mid-l) % 2 == 1) || (a[l] != a[mid] && (mid-l) % 2 == 0))
        {
            r = mid;
            mid = (l+r)/2;
        }
        else
        {
            l = mid;
            mid = (l+r)/2;
        }
    }
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
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;
}
constexpr int mod = 998244353;
constexpr long long inf = 3e18;

int N,K;
int dp[200005],L[10],R[10];
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>N>>K;
	rep(i,K)cin>>L[i]>>R[i];
	dp[0]=1;dp[1]=-1;
	rep(i,N-1){
		(dp[i+1]+=dp[i])%=mod;
		rep(j,K){
			if(i+L[j]>=N)continue;
			(dp[i+L[j]]+=dp[i])%=mod;
			(dp[min(i+R[j]+1,N)]-=dp[i]-mod)%=mod;
		}
	}
	cout<<dp[N-1]<<"\n";
}

Measured memory_bytes: 5136
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

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

//********************************template END****************************************//

void solve(void){
	string a, b;
	cin >> a >> b;
	int l = a.size();
	rep(l, i)
	{
		if (a.substr(i) + a.substr(0, i) == b)
		{
			cout << "Yes" << endl;
			return;
		}
	}

	cout << "No" << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }

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

  cout << (n - b) / (a + b) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int plusOne = Integer.parseInt(scanner.next());
        int zero = Integer.parseInt(scanner.next());
	    int minusOne = Integer.parseInt(scanner.next());
      	int amount = Integer.parseInt(scanner.next());
		int ans = 0;
      for (int i=0; i<amount; i++) {
      	if (i < plusOne) {
        	ans = ans + 1;
        } else if (i < plusOne + zero) {
        	ans = ans;
        } else {
        	ans = ans - 1;
        }
      }

      System.out.println(ans);

    }
}


Measured memory_bytes: 27152
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;


ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}

int main()
{
    ll n,k,sum=0;cin>>n>>k;
    vll h(n);cin_pl(n,h);
    if(k<n){
    sort(all(h));
    rep(i,k)
    {
        h.pop_back();
    }
    rep(i,h.size())
    {
        sum+=h[i];
    }
    cout<<sum;}
    else cout<<0;
    
}


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

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

  vector<char> num(200000);
  int j = 0;
  for(int i = 0; i < N.length(); i++){
    num.at(i) = N[i];
  }

  int C = 0;
  rep(a,N.length()){
    C += num.at(a) - '0';
  }

  if(C%9==0)  cout << "Yes" << endl;
  if(C%9!=0)  cout << "No" << endl;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m,goukei;
  string ans="Yes";
  cin>>n>>m;
  vector<int> vec(n);
  goukei=0;
  for(int i=0; i<n; i++){
    cin>>vec.at(i);
    goukei=goukei+vec.at(i);
  }
  sort(vec.begin(),vec.end());
  if(vec.at(n-m)*4*m<goukei){
    ans="No";
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define INF 1000000

int main()
{
  int n, m, c[21];
  
  cin >> n >> m;

  int dp[n + 1];
  
  for(int i = 0; i < m; i++){
    cin >> c[i];
  }
  for(int i = 0; i <= n; i++){
    dp[i] = INF;
  }
  
  dp[0] = 0;

  for(int i = 0; i < m; i++){
    for(int j = 0; j <= n; j++){
      if(j + c[i] > n){
        break;
      }
      if(dp[j] == INF){
        continue;
      }
      dp[j + c[i]] = min(dp[j + c[i]], dp[j] + 1);
    }
  }
  cout << dp[n] << endl;
}

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

int A, B, C, X, cnt=0;

int main(){
    cin >> A >> B >> C >> X;
    
    for(int i=0; i<=A; i++){
        for(int j=0; j<=B; j++){
            for(int k=0; k<=C; k++){
                if(i*500+j*100+k*50==X)
                    cnt++;
            }
        }
    }
    
    cout << cnt << endl;
}


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

using namespace std;

int main()
{
    int n;

    scanf("%d", &n);
    for (int i = 0; i <= n; i++) {
        if (1ll * (i + 1) * (i + 1) > n) {
            printf("%d\n", i * i);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

A = [A,B]

import itertools

C = list(itertools.combinations([i for i in range(n)], n//2))
D = [[0] * 2 for i in range(n)]


def sw(G):
    a = 0
    # print("G",G)
    for i in range(len(G)):
        j = i
        while G[j] != i:
            j += 1
        for k in range(j, i, -1):
            ss = G[k]
            G[k] = G[k-1]
            G[k-1] = ss
            a += 1
            # print(G)
    # print(a)
    return a

ans = float("inf")

for i in range(len(C)):
    D = [[0] * 2 for i in range(n//2)]
    E = [[0] * 2 for i in range(n - n//2)]
    L = [0] * n
    for k in range(len(C[i])):
        D[k][0] = A[(C[i][k]+1)%2][C[i][k]]
        D[k][1] = C[i][k]
        L[C[i][k]] = 1
    l = 0
    for k in range(n):
        if L[k] == 0:
            E[l][0] = A[k%2][k]
            E[l][1] = k
            l += 1
    D.sort(key=lambda x:x[1])
    D.sort()
    E.sort(key=lambda x:x[1])
    E.sort()
    F = []
    for i in range(n):
        if i % 2 == 0:
            F.append(E[i//2])
        else:
            F.append(D[i//2])
    # print(F)
    ok = 1
    for i in range(len(F)-1):
        if F[i][0] > F[i+1][0]:
            ok = 0
    # print("ok",ok)
    if ok == 1:
        ans0 = sw([F[i][1] for i in range(n)])
        ans = min(ans, ans0)
    
if ans == float("inf"):
    ans = -1
print(ans)
    




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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  int W,a,b;cin>>W>>a>>b;
  if(a+W<b)cout<<b-a-W<<endl;
  else if(b+W<a)cout<<a-b-W<<endl;
  else cout<<0<<endl;
}
   





Measured memory_bytes: 256
n=int(input())
sp=[]
sp=[list(map(str,input().split())) for i in range(n)]

for i in range(n):
    if int(sp[i][1])==0:
        sp[i][1]=float('inf')
    else:
        sp[i][1]=1/int(sp[i][1])
ps=sorted(sp)
for i in range(n):
    print(sp.index(ps[i])+1)

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

int main(){
    string str, str1, str2, str3, str11, str22, ans="No";
    cin >> str;

    int n = str.length();

    str22 = str2 = str.substr((n+1)/2);
    str11 = str1 = str.substr(0, (n-1)/2);

    reverse(str1.begin(), str1.end());
    reverse(str2.begin(), str2.end());

    str3 = str2 + str[(n+1)/2-1] + str1;

    if(str3 == str && str2 == str22 && str11 == str1){
        ans = "Yes";
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    vector<P> suzu;
    if(N%2){
        int l=1,r=N;
        while(l<r){
            suzu.emplace_back(l,r);
            l++;
            r--;
        }        
    }else{
        int l=1,r=N;
        bool mid = false;
        while(l<r){
            if(!mid and r-l<=N/2){
                r--;
                mid = true;
            }
            suzu.emplace_back(l,r);
            l++;
            r--;
        }
    }
    for(int i=0; i<M; i++){
        cout << suzu[i].first << " " << suzu[i].second << enld;
    }
    return 0;
}


Measured memory_bytes: 4220
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,k,ans;
int main()
{
	scanf("%d%d",&n,&k);
	ans=k;
	for(int i=1;i<n;i++)
		ans*=(k-1);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
<?php
 
$input = file_get_contents('php://stdin');
$chars = str_split(strtolower($input));
 
$alphabet = array_fill_keys(range('a', 'z'), 0);
foreach ($chars as $c) {
    if (! ctype_alpha($c)) { continue; }

    $alphabet[$c]++;
}
 
foreach ($alphabet as $char => $count) {
    printf('%s : %d%s', $char, $count, PHP_EOL);
}

Measured memory_bytes: 6796
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  char a;
  cin >> a;
  if (isupper(a)) {
    cout << "A" << endl;
  }
  else {
    cout << "a" << endl;
  }
  return 0;
}

Measured memory_bytes: 3600
# ABC 159 B
import math
s = str(input())
N = len(s)
def check_pal(s):
  res = 0
  l = len(s)
  half = math.floor(l/2)
  for i in range(half):
    res += int(s[i] == s[-i-1])
  if res == half:
  	return True
  else:
    return False

a = int((N-1)/2)
b = int((N+3)/2)
bool1 = check_pal(s)
bool2 = check_pal(s[:a])
bool3 = check_pal(s[b-1:])

if bool1*bool2*bool3:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include "vector"
#include "set"
#include "map"
#include "unordered_set"
#include "unordered_map"
#include "string"
#include "iostream"
#include "algorithm"
#include "queue"

using namespace std;

#define ll long long
#define INF 2e9
#define MOD 998244353

typedef vector<int> vi;
typedef pair<int, int> pii;


template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    bool first = true;
    for (const auto& x : v) {
        if (!first) {
            os << " ";
        }
        first = false;
        os << x;
    }
    return os;
}

template<typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& elem : v) {
        is >> elem;
    }
    return is;
}


void solve() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' << y;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

    if (0) {
        int tests;
        cin >> tests;
        for (int i=1; i<= tests; i++) {
            //cout << "Case #" << i << ": ";
            solve();
            cout << endl;
        }
    } else {
        solve();
        cout << endl;
    }

    return 0;
}

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

#define print2(a, b) cerr << "(" << a << "," << b << ")" << endl
#define print3(a, b, c) cerr << "(" << a << "," << b << "," << c << ")" << endl

const string YES = "Yes";
const string NO = "No";

void solve(long long N){
    bool ok = false;
    for (int i = 0; i <= N / 4; i++) {
        if ((N - 4 * i) % 7 == 0) {
            ok = true;
            break;
        }
    }
    cout << (ok ? YES : NO) << endl;
}

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


Measured memory_bytes: 256
from collections import Counter


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

def main():
    N, M = map(int, input().split())

    MOD = 10**9 + 7
    

    MAX_N = 5 * (10 ** 5)
    # comb init
    fac = [0] *  MAX_N
    finv = [0] *  MAX_N 
    inv = [0] *  MAX_N

    fac[0] = 1; fac[1] = 1
    finv[0] = 1; finv[1] = 1
    inv[1] = 1

    for i in range(2, MAX_N):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = -inv[MOD%i] * (MOD//i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD
    
    def COM(n, k):
        if n < k : return 0
        if n < 0 or k < 0 : return 0
        return (fac[n] * finv[n-k] % MOD) * finv[k] % MOD

    
    pf = prime_factorize(M)
    pc = Counter(pf)

    ans = 1
    for _, val in pc.items():
        ans *= COM(val + N - 1, N - 1)
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 62728
N = int(input())
A = map(int, input().split())
MOD = 1000000007
ans = 1
cnt = [3 if i == 0 else 0 for i in range(N + 1)]

for a in A:
    ans = ans * cnt[a] % MOD

    cnt[a] -= 1
    cnt[a+1] += 1

print(ans)


Measured memory_bytes: 10764
import java.util.Scanner;
class Main{
	
	Scanner sc = new Scanner(System.in);
	int x;
	int i;
	
	void rp2(){
		
		x = sc.nextInt();
	
		for(i=1; x!=0; i++){
			System.out.println("Case "+i+": "+x);
			x = sc.nextInt();
		}
	}
	
	public static void main(String[]agrs){
		new Main().rp2();
	}
}
	

Measured memory_bytes: 33076
import math
a,b,h,m = map(int, input().split())

deg_a = (60 * h + m) * (360 / (60 * 12))
deg_b = m * (360 / 60)
deg = abs(deg_a - deg_b)
rad = math.radians(deg)

c2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(rad)
print(c2 ** 0.5)

Measured memory_bytes: 9512
program main
	implicit none
	integer :: A, B, K
	integer :: counter, i
	counter = 0
	read(*, *) A, B, K
	do i = min(A, B), 1, -1
		if(mod(A, i) == 0 .AND. mod(B, i) == 0) then
			counter = counter + 1
			if(counter == K) then
				write(*, *) i
				exit
			end if
		end if
	end do
end program main

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>
#include <regex>
#include <random>

#define ll long long
#define ld long double
#define ull unsigned ll
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int> 
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vector<int>>
#define forn(it,from,to) for(int (it)=from; (it)<to; (it)++)
const int  Inf = 2 * 1000 * 1000 * 1000;
ll LINF = (ll)4e18;
using namespace std;
#define M_PI       3.14159265358979323846   // pi

void max_self(ll &a, ll b) {
	a = max(a, b);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("sum.in", "r", stdin);
	//freopen("sum.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, W;
	cin >> n >> W;

	vector<ll>D(n * W + 1, 0);

	for (int i = 1; i <= n; i++) {
		ll w, cost;
		cin >> w >> cost;

		for (int j = W - w; j >= 0; j--) {
			max_self(D[j + w], D[j] + cost);
		}
	}
	ll mx = 0;
	for (auto &x : D) mx = max(mx, x);
	cout << mx;
 	return 0;
}

Measured memory_bytes: 78336
#include "iostream"
using namespace std;
 
int main(){
  
  char n[5]={0};
    
  cin >> n[1] >> n[2] >>n[3] >>n[4];
  
  if(n[1]==n[2] && n[3]==n[4] && n[1]!=n[3]){
    cout << "Yes";
  }else if(n[1]!=n[2] && n[2]==n[3] && n[1]==n[4]){
    cout << "Yes";
  }else if(n[1]!=n[2] && n[1]==n[3] && n[2]==n[4]){
    cout << "Yes";
  }else{
    cout << "No";
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,bool>switches;

int main()
{

    int n,m;
    cin >> n >> m;
    vector<int> v[15];
    vector<int> k(m+2);
    for(int i = 0; i < m; i++)
    {
        cin >> k[i];
        for(int j = 0; j < k[i]; j++)
        {
            int x;
            cin >> x;
            v[i].push_back(x);
            v[i][j]--;
        }
    }
    int cnt = 0;
    vector<int> bulb(m+2);
    for(int i = 0; i < m; i++) cin >> bulb[i];

  /*cerr << n << " "<<m <<endl;
  for(int i = 0; i < m; i++){
    cerr << k[i] <<"---> ";
    for(int j = 0; j < k[i]; j++)
        cerr << v[i][j] << " ";
    cerr << endl;
  }
  for(int i = 0; i < m; i++) cerr << bulb[i] << " ";
    cerr << endl;*/

    for(int i = 0; i < (1 << n); i++)
    {
        bool is_all_on = true;
        for(int j = 0; j < m; j++)
        {
            int kth = k[j]; // switch
            int pth = bulb[j];//odd or even
            int num = 0;
            for(int l = 0; l < kth; l++)
            {
                int x = v[j][l]; //xth no switch
                if(i & (1 << x)) // switch state on
                {
                    num++;
                    //switches[j + 1] = true;
                    //cerr << (j + 1)<< " ";
                }
                //else cerr << "0f ";
            }

            if(num %2 != pth){
                is_all_on = false;
                break;
            }
        }
        if(is_all_on) cnt++;
        //cerr << endl;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long N,M;
    cin >> N >> M;
    vector<long long>a(N);
    long long cnt = 0;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        a[i]/=2;
        if(i == 0) {
            cnt = a[i];
            continue;
        }
        cnt = cnt/__gcd(cnt,a[i])*a[i];
        if(cnt > M) {
            cout << 0 << endl;
            return 0;
        }
    }
    for(int i = 0; i < N; i++) {
        if(cnt/a[i]%2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (M-cnt)/(cnt*2)+1LL << endl;
}

Measured memory_bytes: 1024
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;

long long gcd(long long x, long long y){
			if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }
int main(){
int N;
cin >> N;
vector<long long> t(N+1);
vector<long long> x(N+1);
vector<long long> y(N+1);
for(int i = 1; i < N+1; i++){
	cin >> t[i] >> x[i] >> y[i];
}
t[0] = 0;
x[0] = 0;
y[0] = 0;

for(int i = 1; i <= N;i++){
	int tmpt = t[i]-t[i-1];
	int tmpx = abs(x[i]-x[i-1]);
	int tmpy = abs(y[i]-y[i-1]);
	if(tmpt<tmpx+tmpy){
		cout << "No" << endl;
		return 0;
	}
	else{
		if(tmpt%2!=(tmpx+tmpy)%2){
			cout << "No" << endl;
			return 0;
		}

	}
}

cout << "Yes" << endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
        String s = sc.next();
        int l = s.length();

        for (int i = 1; i < l; i++) {
            if (s.substring(0,(l-i)/2).equals(s.substring((l-i)/2, l-i))) {
                System.out.println(l-i);
                break;
            }
        }

		sc.close();
	}
}


Measured memory_bytes: 22996
n,l = map(int,input().split())
f = l+n-1
if f < 0:
  print((n-1)*l+((n-2)*(n-1))//2)
elif l <= 0 and f >= 0:
  print(n*l+(n-1)*n//2)
else:
  print((n-1)*l+((n-1)*n)//2)

      


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

using namespace std;

int main()
{
  int N, D, X, count=0;
  cin >> N >> D >> X;
  count += X;
  vector<int> A(N);
  for (int j=0; j < N; ++j) {
    cin >> A[j];
  }
  for (int j=0; j < N; ++j) {
    for (int k=1; k <= D; k+=A[j]) {
      if (k <= D) count += 1;
    }
  }
  cout << count << endl;
}

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;


int main() {
    int N;
    cin >> N;
    vector<int> D(N);
    rep(i, N) cin >> D[i];

    vector<int> cnt(13);
    cnt[0]++;
    rep(i, N) cnt[D[i]]++;

    // 同じDが3つ以上あれば s = 0
    // D = 0, 12 は2つだけで s = 0
    for (int D = 0; D < 13; D++) {
        if ((D == 0 || D == 12) && cnt[D] >= 2) {
            cout << 0 << endl;
            return 0;
        } else if (cnt[D] >= 3) {
            cout << 0 << endl;
            return 0;
        }
    }

    int ans = 0, s;
    for (int bit = 0; bit < 1 << 13; bit++) {
        s = 12;
        vector<bool> time = vector<bool>(25, false);
        time[0] = true;
        time[24] = true;
        for (int D = 1; D < 13; D++) {
            if (cnt[D] == 2) {
                // 同じDが2個) 常に D, 24-D の2つを使用
                time[D] = true;
                time[24 - D] = true;
            } else if (cnt[D] == 1) {
                if (bit >> D & 1) {
                    // 同じDが1個) ビットが立っていれば 24-D を使用
                    time[24 - D] = true;
                } else {
                    time[D] = true;
                }
            }
        }
        vector<int> time_list;
        rep(D, 25) if (time[D]) time_list.push_back(D);
        for (int i = 0; i < time_list.size() - 1; i++) {
            s = min(s, time_list[i + 1] - time_list[i]);
        }
        ans = max(ans, s);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> vec(4, 0);
	for(int i = 0; i < n; ++i){
		char c;
		cin>>c;
		if(c == 'G')vec[0]++;
		if(c == 'W')vec[1]++;
		if(c == 'Y')vec[2]++;
		if(c == 'P')vec[3]++;
	}
	int res = 0;
	for(int i = 0; i < 4; ++i){
		if(vec[i] > 0)res++;
	}
	if(res == 3){
		cout<<"Three"<<endl;
		return 0;
	}
	if(res == 4){
		cout<<"Four"<<endl;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vi a(m);
    rep(i, m) cin >> a[i];
    ll sm = accumulate(a.begin(), a.end(), 0LL);
    ll ans = n - sm;
    if (ans < 0) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long h,w,ans=1000000000,a,b,c,d;
  cin >> h >> w;
  if(h%3==0 or w%3==0){
    cout << 0 << endl;
    return 0;
  }
  a=min(h,w)/2;
  b=min(h,w)/2+min(h,w)%2;
  c=max(h,w)/2;
  d=max(h,w)/2+max(h,w)%2;
  for(int i=1;i<max(h,w);i++){
    ans=min(ans,max(min(h,w)*i,b*(max(h,w)-i))-min(min(h,w)*i,a*(max(h,w)-i)));
  }
  for(int i=1;i<min(h,w);i++){
    ans=min(ans,max(max(h,w)*i,d*(min(h,w)-i))-min(max(h,w)*i,c*(min(h,w)-i)));
  }
  ans=min(ans,min(h,w));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    ab = sorted([list(map(int, input().split())) for i in range(N)], reverse=True)
    cd = sorted([list(map(int, input().split())) for i in range(N)])

    check = [False] * N
    ans = 0
    for i in range(N):
        a, b = ab[i]
        min_ = int(1e5)
        ind = -1
        for i in range(N):
            if not check[i]:
                c, d = cd[i]
                if c > a and d > b:
                    if min_ > d:
                        min_ = d
                        ind = i
        if ind != -1:
            check[ind] = True
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<stdio.h>
 
int main(){
 
    int x,y,ans;
 
    for(x=1;x<10;x++) {
        for(y=1;y<10;y++) {
            ans = x*y;
            printf("%dx%d=%d\n",x,y,ans);
        }
    }
 
    return 0;
}

Measured memory_bytes: 524
/*
 * Transformation.c
 *
 *  Created on: 2015/02/13
 *
 */

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

int main(void){
	int a,b,q;
	char str[1024],C[1024];

	scanf("%s",str);
	scanf("%d",&q);

	for(;q;q--){
		scanf("%s %d %d",C,&a,&b);
		if(!strcmp(C,"replace")){
			scanf("%s",C);
			memcpy(str+a,C,b-a+1);
		}

		else if(!strcmp(C,"reverse")){
			int i;
			strncpy(C,str+a,b-a+1);
			for(i=b;i>=a;i--) str[i]=C[b-i];
		}

		else if(!strcmp(C,"print")){
			strncpy(C,str+a,b-a+1);
			C[b-a+1]=0;
			printf("%s\n",C);
		}

	}
	return 0;
}

Measured memory_bytes: 620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

LL dp[212345][4] = {};

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; cin >> N;
    VL A(N);
    REP(i,N) cin >> A[i];

    REP(i,212345) REP(j,4) dp[i][j] = -LINF;

    //dp[0][0] = 0;
    dp[1][0] = A[0];
    dp[2][1] = A[1];
    dp[3][0] = A[0] + A[2];
    dp[3][2] = A[2];

    for(int i = 4; i <= N; i++){

        REP(j,3){
            chmax(dp[i][j],dp[i-2][j] + A[i-1]);

            if(j-1 >= 0) chmax(dp[i][j],dp[i-3][j-1] + A[i-1]);
            
            if(j-2 >= 0) chmax(dp[i][j],dp[i-4][j-2] + A[i-1]);
        }
    }
    if(N%2 == 1){
        LL ans = -LINF;

        chmax(ans,dp[N-2][0]);
        chmax(ans,dp[N-1][1]);
        chmax(ans,dp[N][2]);
        cout << ans << endl;
    }else{
        LL ans = max(dp[N][1],dp[N-1][0]);
        cout << ans << endl;

    }


}

Measured memory_bytes: 11372