akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
	int baris,kolom,syarat,temp=0;
	scanf("%d %d %d", &baris, &kolom, &syarat);
	if(baris>kolom){
		temp=syarat/baris;
		//printf("temp adalah %d\n", temp);
		if(syarat%baris==0){
			printf("%d\n", temp);
		}
		else printf("%d\n", temp+1);
	}
	else{
		temp=syarat/kolom;
		if(syarat%kolom==0){
			printf("%d\n", temp);
		}
		else printf("%d\n", temp+1);
	}
	return 0;
}

Measured memory_bytes: 1700
import math


def main():
    # n = int(input())
    a, b = map(int, input().split())
    # a = list(map(int, input().split()))
    # s = input()
    # h = [int(input()) for _ in rane(n)]
    count = 0
    if a < b:
        count += b
        b = b - 1
    else:
        count += a
        a = a - 1
    if a < b:
        count += b
        b = b - 1
    else:
        count += a
        a = a - 1

    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61864
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

func main() {
	var S string
	fmt.Scanf("%s\n", &S)
	s := []string{"Sunny", "Cloudy", "Rainy"}
	for i, ss := range s {
		if ss == S {
			fmt.Println(s[(i+1)%3])
		}
	}
}


Measured memory_bytes: 512
c, num = map(int, input().split(" "))
arr = list(map(int, input().split(" ")))
t = True
while t:
    for x in arr:
        if str(x) in str(c):
            break
    else:
        t = False
        break
    
    c += 1
    
if not t:
    print(c)

Measured memory_bytes: 3060
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    for(ll i=0;i<N;i++){
        cin>>A[i];
        A[i] *= 2;
    }
    ll all_sum=0;
    for(ll i=0;i<N;i++){
        all_sum+=A[i];
    }
    ll _sum = 0;
    for(ll i=1;i<N;i+=2){
        _sum+=A[i];
    } 
    _sum*=2;
    ll result=(all_sum-_sum)/2;
    cout<<result<<" ";
    for(ll i=0;i<N-1;i++){
        ll res = A[i]-result;
        cout<<res<<" ";
        result = res;
    }
    cout<<endl;
}

Measured memory_bytes: 2048
//om nama sivaya
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define pb push_back
using namespace std;
void solve(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    bool dp[k+1];
    dp[0]=false;
    for(int i=1;i<=k;i++){
        dp[i]=false;
        for(int j=0;j<n;j++){
            if(i>=a[j] && dp[i-a[j]]==false)
            dp[i]=true;
        }
    }
    if(dp[k])
    cout<<"First";
    else
    cout<<"Second";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
long long int b,z,m,n;
int main()
{
	scanf("%lld%lld%lld",&n,&m,&b);
	if(m>=n)
	{
		printf("1\n");
		return 0;
	}
	if(m<=b)
	{
		printf("-1\n");
		return 0;
	}
	else if((n-m)%(m-b)>=1)
		z=1;
	printf("%lld\n",((n-m)/(m-b)+z)*2+1);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <math.h>

using namespace std;

int main(){
	long long int l, r;
	cin >> l >> r;

	if (r - l>1e4){
		cout << 0 << endl;
		return 0;
	}

	while (true){
		if (l > 2019){
			l -= 2019;
		}
		else{
			break;
		}
	}

	while (true){
		if (r > 2019){
			r -= 2019;
		}
		else{
			break;
		}
	}

	int saisyo = 0;
	bool first = true;

	for (int i = l; i < r; i++){
		for (int j = i + 1; j <= r; j++){
			int mod = (i*j) % 2019;

			if (first){
				saisyo = mod;
				first = false;
			}
			else{
				if (saisyo > mod){
					saisyo = mod;
				}
			}

			//cout << mod << endl;
		}
	}

	//int nd[10][10];

	//for (int i =0; i<n; i++){
	//	for (int j =0; j<d; j++){
	//		cin >> nd[i][j];
	//	}
	//}

	//int count = 0;


	//for (int i = 0; i < n; i++){
	//	for (int p = i + 1; p < n; p++){
	//		double kyori = 0;
	//		double kei = 0;
	//		for (int j = 0; j < d; j++){
	//			kei += pow((nd[i][j] - nd[p][j]), 2);

	//			//if (i == n - 1){
	//			//	kei += pow((nd[i][j] - nd[0][j]), 2);
	//			//}
	//			//else{
	//			//	kei += pow((nd[i][j] - nd[i + 1][j]), 2);
	//			//}
	//		}
	//		kyori = sqrt(kei);
	//		//cout << kyori << endl;
	//		if (ceil(kyori) != floor(kyori)) {
	//			
	//		}
	//		else {
	//			++count;
	//		}
	//	}
	//}

	cout << saisyo << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<list>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<iterator>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

signed main() {
	int n;
	cin >> n;
	int i;
	cin >> i;
	cout << n - i+1
		<< endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> edge;

int n,k;
edge ans[100][10000];

int main(){
  scanf("%d%d",&n,&k);
  if(n/2 < k){
    puts("-1");
    return 0;
  }
  
  for(int i=0;i<n-1;i+=2){
    int lim = min(k,i/2);
    for(int j=0;j<lim;j++){
      ans[j][i-1] = edge(j,i);
      ans[j][i] = edge(i/2+j,i+1);
    }
    if(lim!=k){
      for(int j=0;j<i/2;j++){
	ans[lim][2*j] = edge(i/2+j,i);
	ans[lim][2*j+1]	= edge(j,i+1);
      }
      ans[lim][i] = edge(i,i+1);
    }
  }

  if(n&1){
    for(int i=0;i<k;i++)ans[i][n-2] = edge(i,n-1);
  }

  for(int i=0;i<k;i++){
    if(i)puts("");
    for(int j=0;j<n-1;j++){
      printf("%d %d\n",ans[i][j].first+1, ans[i][j].second+1);
    }
  }
}

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

int main() {
    int k, ans = 0;
    cin >> k;
    int mod = 7, co = 1;
    while (mod % k != 0 && co != 1000000) {
        mod %= k;
        mod *= 10;
        mod += 7;
        co++;
    }
    if (co == 1000000)
        cout << -1 << endl;
    else
        cout << co << endl;
    return 0;
}

Measured memory_bytes: 3512
import math

n, k = map(int, input().split())


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1, k + 1):
    if n - k + 1 >= i:
        tmp1 = combinations_count(k - 1, i - 1) % 1000000007
        tmp2 = combinations_count(n - k + 1, i) % 1000000007
        ans = (tmp1 * tmp2) % 1000000007
        print(ans)
    else:
        print(0)


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <map>
#define ll long long

using namespace std;

int main(void){
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    s.insert(0, "#");
    s.push_back('#');
    bool ans = true;
    if(c < d){
        for(ll i = a; i <= d-1; i++){
            if(s[i]=='#' && s[i+1]=='#')
                ans = false;
        }
    }
    else if(c > d){
        ans = false;
        for(ll i = b; i <= d; i++){
            if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.')
                ans = true;
        }
        for(ll i = a; i <= c-1; i++){
            if(s[i]=='#' && s[i+1]=='#')
                ans = false;
        }
    }
    if(ans == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

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

    ll N, W, wi, vi, vj;
    cin >> N >> W;

    ll ans = 0;
    unordered_map<ll, ll> current, tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> wi >> vi;
        if (wi > W) continue;

        tmp.clear();
        tmp = current;

        if (tmp.count(vi)) tmp[vi] = min(tmp.at(vi), wi);
        else tmp[vi] = wi;
        ans = max(ans, vi);

        for (auto it = current.begin(); it != current.end(); ++it)
        {
            vj = vi + it->first;
            if ((it->second + wi) <= W)
            {
                if (tmp.count(vj)) tmp[vj] = min(tmp.at(vj), it->second + wi);
                else tmp[vj] = it->second + wi;
                ans = max(ans, vj);
            }
        }

        current = tmp;
    }

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


Measured memory_bytes: 4376
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cctype>
#include <stack>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long lolo;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef unsigned long long ulolo;

const int maxn = (int)2e5 + 5;
const int INF = 0x3f3f3f3f;
const lolo inf = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
const int MOD = 1000000007;

template<class T>
inline void read(T &x) {
    x = 0; T flag = 1;char c;
    do { c = (char) getchar(); if (c == '-') break; } while (c < '0' || c > '9');
    if (c == '-') { c = '0', flag = -1;}
    do { x = x * 10 + c - '0';c = (char) getchar();} while (c >= '0' && c <= '9');
    x *= flag;
}
template<class T>
inline void out(T x) {
    if (x > 9) out(x / 10);
    x = x % 10;
    putchar('0' + x);
}

int a[maxn], cnt[maxn];
lolo c2(int n) {
    if (n <= 1) {
        return 0;
    }
    return 1LL*n*(n-1)/2;
}
int main() {
//    freopen("../in.txt", "r", stdin);
    int n;
    read(n);
    for (int i = 0; i < n; ++i) {
        read(a[i]);
        ++cnt[a[i]];
    }
    lolo ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += c2(cnt[i+1]);
    }
    for (int i = 0; i < n; ++i) {
        lolo tmp = ans - c2(cnt[a[i]]) + c2(cnt[a[i]]-1);
        printf("%lld\n", tmp);
    }
    return 0;
}


Measured memory_bytes: 3712
#include <stdio.h>
#include <string.h>
int main(void)
{
    char s[100005];
    int n=0,p=0,ans;
    scanf("%s", s);
    while(strncmp(&s[n], "\0", 1)!=0)
    {
        if(strncmp(&s[n], "p", 1)==0) p++;
        n++;
    }
    if(n%2==0) ans=(n/2)-p;
    else ans=((n-1)/2)-p;
    printf("%d", ans);
    return 0;
}

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

struct state{
  ll a,b,bit,cost;
  bool operator < (const state &p) const {
    return cost > p.cost;
  }
};

int n,m;
int d[50],e[50];
int G[50][50];
map<ll,ll> dist[50][50];

void f(ll a,ll b,ll bit){
  if(dist[a][b].count(bit)==0){
    dist[a][b][bit]=1e8;
  }
}

int solve(){
  priority_queue< state > Q;
  dist[0][0][0]=0;
  Q.push( (state){0,0,0,0} );
  
  while(!Q.empty()){
    state s=Q.top();Q.pop();
    if(s.a==n-1&&s.b==n-1){
      return s.cost;
    }
    

    for(int na=0;na<n;na++){
      if(e[s.a]>e[na])continue;
        
      ll ncost=s.cost+G[s.a][na]+d[na];
      if(s.bit>>na&1)ncost-=d[na];
        
      ll nbit=s.bit;
      if(e[na]>e[s.b])nbit=(1LL<<na);
      else if(e[na]==e[s.b])nbit=s.bit|(1LL<<na);
        
      f(na,s.b,nbit);
      if(dist[na][s.b][nbit] > ncost ){
        dist[na][s.b][nbit]=ncost;
        Q.push( (state){na,s.b,nbit,ncost} );
      }
    }

    for(int nb=0;nb<n;nb++){
      if(e[s.b]>e[nb])continue;
      ll ncost=s.cost+G[nb][s.b]+d[nb];
      if(s.bit>>nb&1)ncost-=d[nb];
        
      ll nbit=s.bit;
      if(e[nb]>e[s.a])nbit=(1LL<<nb);
      else if(e[nb]==e[s.a])nbit=s.bit|(1LL<<nb);
        
      f(s.a,nb,nbit);
      if(dist[s.a][nb][nbit] > ncost ){
        dist[s.a][nb][nbit]=ncost;
        Q.push( (state){s.a,nb,nbit,ncost} );
      }

    }
  }
  
  return -1;
}

int main(){
  while(1){
    cin>>n>>m;
    if(n==0&&m==0)break;

    for(int i=0;i<50;i++){
      d[i]=e[i]=0;      
      for(int j=0;j<50;j++){
        dist[i][j].clear();
        G[i][j]=1e8;
      }
    }
    
    for(int i=1;i<n-1;i++)cin>>d[i]>>e[i];
    e[n-1]=1000;
    
    for(int i=0;i<m;i++){
      int a,b,c;
      cin>>a>>b>>c;
      a--,b--;
      G[a][b]=min(G[a][b],c);
    }
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 10724
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
	int n, i, j;
	int dp[40];

	memset(dp, 0, sizeof(dp));
	
	dp[0] = 1;
	
	for( i = 0; i <= 30; i++)
	{
			for( j = 1; j <= 3; j++)
				dp[i+j] += dp[i];
	}
	
	while( cin >> n , n)
	{
		cout << ((dp[n] + 9)/10 + 364)/365 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1e9;
const ll INF= 1e18;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

ll Sum(int n) {
    ll ret = 0;
    for(int i = 1;i <= n;i++) {
        ret += i;
    }
    return ret;
}

int main() {
    string S;
    cin >> S;
    vector<int> vec(26);
    for(int i = 0;i < S.size();i++) {
        vec.at(S.at(i) - 'a')++;
    }
    ll ret = 0;
    for(int i = 0;i < 26;i++) {
        ret += Sum(vec.at(i));
    }
    cout << Sum(S.size()) + 1 - ret << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int a[3][3];
     for(int i=0;i<3;i++){
         for(int j=0;j<3;j++){
             cin>>a[i][j];
         }
     }
     int n;cin>>n;
     int b[n];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<n;k++){
                if(b[k]==a[i][j])a[i][j]=1;
            }
        }
    }
    int s=1;
    if(a[0][0]==a[0][1]&&a[0][1]==a[0][2])s=0;
    if(a[1][0]==a[1][1]&&a[1][1]==a[1][2])s=0;
    if(a[2][0]==a[2][1]&&a[2][1]==a[2][2])s=0;
    if(a[0][0]==a[1][0]&&a[1][0]==a[2][0])s=0;
    if(a[0][1]==a[1][1]&&a[1][1]==a[2][1])s=0;
    if(a[0][2]==a[1][2]&&a[1][2]==a[2][2])s=0;
    if(a[0][0]==a[1][1]&&a[1][1]==a[2][2])s=0;
    if(a[0][2]==a[1][1]&&a[1][1]==a[2][0])s=0;
    if(s==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main(int argc, char* argv[]) {
  int X, A;
  cin >> X >> A;
  if (X < A) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (){
	int a,b,c,min,sec,t,temp;
	scanf ("%d %d %d",&a,&b,&c);
	if (a<b){
		min = a;
		sec = b;
		t = c;	
	}
	else{
		min = b;
		sec = a;
		t = c;
	}
	if (c<sec){
		if (c<min){
			temp = c;
			t = sec;
			sec = temp;
			
			temp = min;
			min = sec;
			sec = temp;
		}
		else{
			temp = sec;
			sec = c;
			t = temp;
		}
	}
	printf("%d %d %d\n",min,sec,t);
}


Measured memory_bytes: 2084
N, X = map(int, input().split())
L_list = list(map(int, input().split()))

cnt = 0
ichi = 0
for l in L_list:
    #print(l,'l')
    if ichi > X:
        break
    cnt += 1
    ichi += l

if ichi <= X:
    cnt +=1

print(cnt)

Measured memory_bytes: 3060
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

const double PI = 3.1415926535;

int main() {
	// 小数点以下12ケタを表示させるためのおまじない
	cout << fixed << setprecision(12);

	int n;
	cin >> n;

	int x[1000], y[1000];
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> y[i];
	}

	double man = 0.0, euc = 0.0, san = 0.0, che = 0.0;
	for (int i = 0; i < n; i++) {
		double diff = abs(x[i] - y[i]);
		man += diff;
		euc += pow(diff, 2);
		san += pow(diff, 3);
		che = (che < diff) ? diff : che;
	}
	euc = sqrt(euc);
	san = cbrt(san);

	cout << man << endl;
	cout << euc << endl;
	cout << san << endl;
	cout << che << endl;
	return 0;
}



Measured memory_bytes: 3408
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

const int MAX = 50;
int n, m;
int a[MAX], b[MAX];

bool graph[MAX][MAX];
bool visited[MAX];

void dfs(int v) {
    visited[v] = true;
    for (int v2 = 0; v2 < n; v2++) {
        if (graph[v][v2] == false) continue;
        if (visited[v2] == true) continue;
        dfs(v2);
    }
}


int main() {

    cin >> n >> m;
    
    for(int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    int ans = 0;

    for(int i = 0; i < m; i++) {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
        for(int j = 0; j < n; j++) {
            visited[j] = false;
        }

        dfs(0);

        bool bridge = false;
        for (int j = 0; j < n; j++) {
            if (visited[j] == false)
                bridge = true;
        }
        if (bridge)
            ans++;
        
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

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

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <queue>
using namespace std;
int n;
int a[50][26];
string s;
int main(){
  cin >> n;
  int len;
  for(int i=0;i<n;i++){
    cin >> s;
    for(int j=0;j<s.length();j++){
      char x=s[j]-97;
      a[i][x]++;
    }
  }

  for(int i=0;i<26;i++){
    int Min=1000;
    for(int j=0;j<n;j++){
      Min=min(Min,a[j][i]);
    }
    for(int k=0;k<Min;k++){
      printf("%c",i+97);
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define oo 2000000000
#define inf 1000000000000000000
#define P1 31
#define P2 37
#define M  1000000007
#define M2 1000000009
#define pii pair<ll,ll>
typedef long long ll;
using namespace std;
const int N = 255001;
const int SQRTN = 320;
const int LOGN = 20;
const long double PI = acos(-1);
const long double TAU = 2*PI;

ll n,freq[2],a[N];

signed main(){
    cin >> n;
    for(int i = 0 ; i < n ; i++){
        scanf("%lld",&a[i]);
        freq[a[i]%2]++;
    }
    if(freq[1]%2==0)puts("YES");
    else cout << "NO" << endl;


}



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

using namespace std;

typedef long long LL;

const int nmax = 100010; const LL mod = 1000000007;

int N,M,nr[nmax],a[nmax],x,y,sol[nmax];
vector<int>G[nmax];
bool viz[nmax],ok,mark[nmax];

void DFS(int nod){
   if(ok)return;
   viz[nod] = true;
   a[++a[0]] = nod;
   if(nod==y&&!ok){
         for(int i = 1; i <= a[0]; ++i)
            sol[i] = a[i];
         sol[0] = a[0];
      ok=true;
      return;
   }
   for(auto it: G[nod])
      if(!viz[it])
         DFS(it);
   a[0]--;
}

bool gasit;

void DFS2(int nod){
   if(ok)return;
   viz[nod] = true;
   a[++a[0]] = nod;
   mark[nod] = true;

   if(!ok&&nod!=x){
      gasit = true;
      for(auto it: G[nod])
         if(!mark[it])
            gasit = false;
      if(gasit){
         for(int i = 1; i <= a[0]; ++i)
            sol[i] = a[i];
         sol[0] = a[0];

         ok = true;
         return;
      }
   }
//   cout << nod << ' ';
   for(auto it: G[nod])
      if(!viz[it])
         DFS2(it);
   mark[a[a[0]]] = false;
   a[0]--;
}

bool uz[nmax];

void DFS3(int nod,int tata){
   if(ok)return;
   viz[nod] = true;
   a[++a[0]] = nod;
   for(auto it: G[nod]){
         if(it == tata)continue;
      if(!viz[it])
         DFS3(it,nod);
      else{
         ok = true;

//         for(int i = 1; i <= a[0]; ++i)
//            cout << a[i] <<' ';
//         cout << '\n';
//         cout << it <<' ' << nod << '\n';
//         while(a[a[0]] != it){
//            cout << a[a[0]]<<' ';
//            a[0]--;
//         }
      }
   }
   a[0]--;
}

inline void Solve(){
   int i,j,l,r,u;
   cin >> N >> M;
   for(i = 1; i <= M; ++i){
      cin >> x >> y;
      G[x].push_back(y);
      G[y].push_back(x);
      nr[x]++;
      nr[y]++;
   }
   x=y=0;
   for(i = 1; i <= N; ++i){
      if(nr[i] == 1&&!x)x=i;
     else if(nr[i] == 1 && x){
         y=i;
         break;
      }
   }
   if(y){
      DFS(x);
       cout << sol[0] << '\n';
      for(i = 1; i <= sol[0]; ++i)
         cout << sol[i] << ' ';
      cout << '\n';
      return;
   }
   if(x){
         DFS2(x);
          cout << sol[0] << '\n';
         for(i = 1; i <= sol[0]; ++i)
            cout << sol[i] << ' ';
         cout << '\n';
      return;
   }

   bool k;
   for(i = 1; i <= min(N,1000); ++i){
      DFS2(i);
      k=true;
      for(j = 1; j <= N; ++j)
         mark[j] = false;
      for(j = 1; j <= sol[0]; ++j)
         mark[sol[j]]=true;

      for(auto it: G[i]){
         if(!mark[it])
            k=false;
      }
      if(k)break;
      a[0]=0;
      ok=false;
      for(j = 1; j <= N; ++j)
         viz[j]=mark[j] = false;
   }

         cout << sol[0] << '\n';
         for(i = 1; i <= sol[0]; ++i)
            cout << sol[i] << ' ';
         cout << '\n';
}

inline void Reset(){

}

int main(void){
   int tests;
////   freopen("txt.in","r",stdin);
////   freopen("txt.out","w",stdout);
   ios::sync_with_stdio(false);

   tests=1;
  for(int j = 1; j <= tests; ++j){
      Solve();
      Reset();
  }
    return 0;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define loop(i,a,b) for(i=a;i<b;i++)
#define ms(a,b) memset(a,b,sizeof(a))
#define INF 1000000010
using namespace std;

typedef vector<int> vi;
typedef long long large;
int DX[]= {-2,-2,-1,-1,1,1,2,2};
int DY[]= {-1,1,2,-2,2,-2,-1,1};

//int A[200][200];
large arr[100010];
//vi AdjList[100010];
//vi path;
//int vis[100010];

int main(){
    int N,cont=0,k,l,i;
    scanf("%d",&N);
    loop(i,0,N){
        scanf("%lld",&arr[i]);
    }
    arr[N] = INF;
    int ban =1;  // 2 es mayor 3 es menor 1 es nuetro
    loop(i,0,N){
        if(ban== 1 && arr[i]>arr[i+1])ban = 2;
        //else if(ban==2 && arr[i]>arr[i+1])continue;
        else if(ban==1 && arr[i]<arr[i+1])ban = 3;
        //else if(ban==3 && arr[i]<arr[i+1]) continue;
        else if(ban==2 && arr[i]<arr[i+1] && arr[i+1]!=INF) cont++,ban=1;
        else if(ban==3 && arr[i]>arr[i+1] && arr[i+1]!=INF) cont++,ban=1;
        if(arr[i+1]==INF) cont++;
    }
    printf("%d\n",cont);
    return 0;
}


Measured memory_bytes: 1024
def insert(A,n,g):
    global cnt
    for i in range(g,n):
        v = a[i]
        j = i-g
        while(j>=0 and A[j]>v):
            A[j+g] = A[j]
            j = j-g
            cnt+= 1
        A[j+g] = v
        
def shell(A,n):
    global cnt
    cnt = 0
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = 3*h+1
    G.reverse()
    m = len(G)
    print(m)
    print(" ".join(map(str,G)))
    for i in G:
        insert(A,n,i)
    return cnt
        
n = int(input())
a = []
for i in range(n):
    ai = int(input())
    a.append(ai)
    
shell(a,n)
print(cnt)

for i in range(n):
    print(a[i])


Measured memory_bytes: 45516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    for(ll i=1;i<=5;i++){
        ll x;cin>>x;
        if(x==0)return cout<<i, 0;
    }
}



Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>
int main(){
  for(;;){
    int i;
    float n;
    float S[1000],SUM=0;
    float m,bunsan,bbunsan,SSUM=0;
    scanf("%f",&n);
    if(n==0){
      return 0;
    }
    for(i=0;i<n;i++){
      scanf("%f",&S[i]);
      SUM+=S[i];
    }
    m=SUM/n;
    for(i=0;i<n;i++){
      SSUM+=(S[i]-m)*(S[i]-m);
    }
    bbunsan=SSUM/n;
    bunsan=sqrt(bbunsan);
    printf("%f\n",bunsan);
  }
}

Measured memory_bytes: 2656
z,*s=gets.split(/
|T/,-1).map &:size;Y=Z=1<<8000;X=Y<<z;s.each_slice(2){|t,u|Y=Y>>t|Y<<t;u&&X=X>>u|X<<u};eval"puts X>>%d&Y>>%d&Z>0?:Yes: :No"%gets.split

Measured memory_bytes: 10748
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

type Array with
    static member private _BinarySearch<'T when 'T: comparison>
        (comp, array: 'T [], first: Int32, last: Int32, value: 'T) =
        let rec loop left right =
            if left > right then
                left
            else
                let mid = left + ((right - left) >>> 1)
                if comp array.[mid] value then
                    loop (mid + 1) right
                else
                    loop left (mid - 1)
        loop first (last - 1)

    static member LowerBound<'T when 'T: comparison>
        (array: 'T [], first: Int32, last: Int32, value: 'T) =
        Array._BinarySearch((<), array, first, last, value)

    static member UpperBound<'T when 'T: comparison>
        (array: 'T [], first: Int32, last: Int32, value: 'T) =
        Array._BinarySearch((<=), array, first, last, value)

[<EntryPoint>]
let main _ =
    let N = read int
    let LS = reada int |> Array.sort

    let mutable ans = 0
    for i in [N-1 .. -1 .. 2] do
        for j in [i-1 .. -1 .. 1] do
            let high = LS.[i]
            let mid = LS.[j]
            let bound = Array.UpperBound(LS, 0, LS.Length, (high - mid))
            let lows = max 0 (j - bound)
            ans <- ans + lows

    printfn "%i" ans
    0

Measured memory_bytes: 35008
#include <stdio.h>
int main(){
int a;
int b;
scanf("%d",&a);
scanf("%d",&b);
if (a < b) {
printf("a < b\n");
} else if (a > b) {
printf("a > b\n");
} else if (a == b) {
printf("a == b\n");
} return 0;
}

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

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

int main(){
    int x, n;
    scanf("%d%d", &x, &n);
    bool ng[110];
    memset(ng, false, sizeof(ng));
    rep(i, n){
        int p;
        scanf("%d", &p);
        ng[p] = true;
    }
    int ans = 0, M = MAX;
    rep(i, 110)if(!ng[i] && chmin(M, abs(i - x))) ans = i;
    printf("%d\n", ans);
}

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

typedef long long LL;

const int N = 5005;
const LL INF = 0x3f3f3f3f3f3f3f3f;

int n, k, p[N], loop[N];
LL cost[N], dp[N][N];

int main(){
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) scanf("%d", &p[i]), p[i]--;
    for (int i = 0; i < n; i++) scanf("%lld", &cost[i]);

    for (int i = 0; i < n; i++){
        int id = i;
        for (int j = 1; j <= n; j++){
            id = p[id];
            dp[i][j] = dp[i][j - 1] + cost[id];
            if (id == i){
                loop[i] = j;
                break;
            }
        }
    }

    LL ans = -INF;
    
    for (int i = 0; i < n; i++)
        for (int j = 1; j <= min(loop[i], k); j++)
            if (dp[i][loop[i]] > 0) ans = max(ans, dp[i][j] + (k - j) / loop[i] * dp[i][loop[i]]);
            else ans = max(ans, dp[i][j]);

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

    return 0;
}

Measured memory_bytes: 199324
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline LL ri() {LL x; scanf("%lld", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/


int c[4];
int main() {
  rep(i, 6) {
    int x;
    cin >> x;
    c[x] ++;
    if (c[x] >= 3) {
      cout << "NO"  << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}


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

using namespace std;

int n;
int a[200100];
vector<int> cons;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    int val = 1;
    for (int i = 0; i < n; i++) {
        if (a[i] == val) {
            cons.push_back(a[i]);
            val++;
        }
    }
    if (cons.empty()) cout << "-1\n";
    else cout << n - (int) cons.size() << '\n';
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(a,b) for(ll i=a;i<=b;i++)
#define show(x) cout<<x<<"\n"
#define vr vector<ll> 
ll fact(ll n); 
  
ll nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
// Returns factorial of n 
ll fact(ll n) 
{ 
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
int main()
{
	ll  n;
	cin>>n;
	vr nos(n);
	unordered_map<ll,ll> map;
	f(0,n-1)
	{
		cin>>nos[i];
		map[nos[i]]++;
	}
	vr ans;
	ll answer=0;
		for(auto j=map.begin();j!=map.end();j++)
		{
			ll t=j->second;
			if(t<2)
			{
				continue;
			}
			answer+=t*(t-1)/2;
		}

	f(0,n-1)
	{
		ll freq=map[nos[i]];
		ll speanswer=answer-(freq-1);
		ans.push_back(speanswer);
		}
	f(0,n-1)
	{
		show(ans[i]);
	}

}

Measured memory_bytes: 11716
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_binaric_easy(void) {
	string s;
	cin >> s;
	char ans[20]={' '};
	int ptr = 0;
	for (int i = 0; i < s.size(); i++) {
		if ((s[i] == '0') || (s[i] == '1')) {
			ans[ptr++]=s[i];
		}
		else {
			if (ptr != 0) {
				ans[--ptr] = ' ';
			}
		}
	}
	cout << ans << endl;
}

int main()
{
	b_binaric_easy();
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <algorithm>

using namespace std;

int x , y;
void work () {
	int i;
	scanf ( "%d" , &x );
	for ( i = 1 ; i <= 100000 ; i++ ) {
		y += i;
		if ( y >= x ) break;
	}
	printf ( "%d\n" , i );
}
int main () {
	work ();
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const ll mod = 1000000007;
int go[200005][61];
ll len[200005][61],k;
int n,a[200005];
vector<int>pos[200005];

int main(){
	cin >> n >> k; 
	rep(i,n){
		cin >> a[i];
		pos[a[i]].pb(i);
		pos[a[i]].pb(i+n);
	}
	rep(i,200005) SORT(pos[i]);
	rep(i,n){
		int x = POSL(pos[a[i]],i);
		go[i][0] = (1+pos[a[i]][x+1])%n;
		len[i][0] = 1+pos[a[i]][x+1]-pos[a[i]][x];
	}
	rep(j,60){
		rep(i,n){
			go[i][j+1] = go[go[i][j]][j];
			len[i][j+1] = len[i][j] + len[go[i][j]][j];
			if(len[i][j+1] > 1e18) len[i][j+1] = 1e18;
		}
	}
	ll goal = 1LL*n*k-1;
	ll cur = 0;
	{
		for(int j=59;j>=0;j--){
			if(len[cur][j] <= goal){
				goal -= len[cur][j];
				cur = go[cur][j];
			}
		}
	}
	stack<int>st;
	set<int>S;
	
	for(ll ii=0;ii<=goal;ii++){
		int i = ((n-1-goal+ii)%n+n)%n;
		if(S.find(a[i]) == S.end()){
			S.insert(a[i]);
			st.push(a[i]);
		}
		else{
			while(st.top() != a[i]){
              S.erase(S.find(st.top()));
              st.pop();
            }
			st.pop();
			S.erase(S.find(a[i]));
		}
	}
	
	vector<int>ans;
	while(st.size()){ ans.pb(st.top()); st.pop(); }
	reverse(ans.begin(),ans.end());
	rep(i,ans.size()) cout << ans[i] << " " ;
	cout << endl;
}


Measured memory_bytes: 167284
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


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

	sort(d.begin(), d.end());

	cout << d[N / 2] - d[N / 2 - 1] << endl;

	return 0;
}

Measured memory_bytes: 640
double x[100],y[100],A,h,X,Y,C,S;i,j,k,s,m,M;main(n){for(;scanf("%d",&n),n;printf("%d\n",M+2)){M=-1;for(i=n;i--;)scanf("%lf,%lf",x+i,y+i);for(i=n;--i;)for(j=i;j--;)if(A=hypot(x[i]-x[j],y[i]-y[j])/2,A<=1)for(S=atan2(y[i]-y[j],x[i]-x[j]),C=cos(S),S=sin(S),h=sqrt(1-A*A),s=2;s--;h=-h)for(m=0,k=n;k--;M=m>M?m:M)m+=k-i&&k-j&&hypot(x[j]+A*C-h*S-x[k],y[j]+A*S+h*C-y[k])<=1;}exit(0);}

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

int main() {
    const int MAX = 32770;
    bool isPrime[MAX];
    fill_n(isPrime, MAX, true);
    for (int i = 4; i < MAX; i += 2) {
        isPrime[i] = false;
    }
    for (int i = 3; i * i <= MAX; i += 2) {
        if (isPrime[i]) {
            for (int j = i * 2; j < MAX; j += i) {
                isPrime[j] = false;
            }
        }
    }
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        int res = 0;
        if (n == 4) {
            res++;
        } else {
            for (int i = 3; i * 2 <= n; i += 2) {
                if (isPrime[i] && isPrime[n - i]) {
                    res++;
                }
            }
        }
        cout << res << endl;
    }
}

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

#define ll long long
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)

//library----------------------------------------------


int main(){
    int a,b,c; cin >>a>>b>>c;
    int max = a;
    if(max<b) max=b;
    if(max<c) max=c;
    int ans = max*10+(a+b+c-max);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		for (int i = 0; i < 3; i++) {
			String line = stdin.next();
			System.out.print(line.charAt(i));
		}
	}

}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    int c;
    int x = n;
    int ans = 0;
    int l = 0;
    while(x){
        c = x % 10;
        x /= 10;
        l++;
        ans += c;
    }
    ans = max(ans, c - 1 + (l - 1) * 9);
    cout << ans;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        /*
        long n = long.Parse(Console.ReadLine());
        long[] input = new long[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=long.Parse(Console.ReadLine());
        }
        */
        int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        Console.WriteLine((double)input[0]/input[1]);


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

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

int main () {
	ll int k=0,x,ans=0,i=0;

	cin >> x;
	if(x<0){
		x = x*(-1);
	}

	while(1){
		i++;
		ans++;
		k += i;
		if(k>=x){
			break;
		}
	}

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

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

int main() {
    int l,r,d;
    cin >> l >> r >> d;
    int count = 0;
    for(int i=l;i<=r;i++)
    {
        if(i%d == 0)
        {
            count++;
        }
    }
    cout << count << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
int dp[1001][1001];
int price[1001];
int n ,k;
int OO=1e6+1;
int solve(int i , int taken)
{
    if(i==n)
    {
        if(taken==k)
            return 0;
        return OO;
    }
    int &ret=dp[i][taken];
    if(ret!=-1)
        return ret;
    ret=OO;
    ret=min(solve(i+1 , taken+1)+price[i] , solve(i+1,taken) );
    return ret;
}
int main()
{

    cin >> n>>k;
    memset(dp , -1 , sizeof dp);
    for(int i = 0 ; i < n ; i++)
    {
        cin >> price[i];
    }
    cout << solve(0,0);
    return 0;
}


Measured memory_bytes: 7600
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    bool judge = true;
    vector<int> t(n+1);
    int x[n+1];
    int y[n+1];
    t[0] = 0;
    x[0] = y[0] = 0;
    for(int i = 1;i < n+1;i++){
        cin >> t[i] >> x[i] >> y[i];
        if(t[i] < abs(x[i])+abs(y[i])){
            judge = false;
            break;
        } 
        else{
            if(t[i]% 2 != (abs(x[i])+abs(y[i]))%2){
                judge = false;
                break;
            }
        }
    }
    if(judge == true)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <string>
using namespace std;

int main(){
	int N, K;
	string S;
	cin >> N >> K >> S;
	int ans = 0;
	int kdash = K;
	int check = 0;
	int count = 0;
	vector<int> left1;
	left1.push_back(0);
	for(int i=0;i<N;i++){
		if(S[i] == '0' && !check){
			check = 1;
			count++;
		}
		if(S[i] == '1' && check){
			check = 0;
			left1.push_back(i);
		}
		if(count > K){
			count--;
			ans = max(ans, i - left1[0]);
			left1.erase(left1.begin());
		}
		if(i == N - 1) {
			ans = max(ans, i - left1[0] + 1);
		}
	}
	cout << ans << endl;
}

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

#define endl '\n'

using namespace std;

long long dp[101][100001];

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  memset(dp,0x3f3f3f,sizeof(dp));

  dp[0][0]=0;

  int N,W;

  cin>>N>>W;

  long long w[101],v[101];
  
  for(int i=0;i<N;i++){

    cin>>w[i]>>v[i];

  }
    
  for(int i=0;i<N;i++){

    for(int j=0;j<=100*1000;j++){

      //dp[i+1][j]:i番目までの品物から価値の総和がjとなるように選んだときの、重さの総和の最小値
      
      if(j<v[i]){
	dp[i+1][j]=dp[i][j];
      }else{
	dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
      }

    }
  }

  int res=0;

  for(int i=0;i<=100*1000;i++){
    if(dp[N][i]<=W){
      res=i;
    }
  }

  cout<<res<<endl;

  
  return 0;

}


Measured memory_bytes: 79740
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
class Main{


	static final int MOD = 1000000007;


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		long a = sc.nextLong();
		long b = sc.nextLong();



		ArrayList<Long> aa = new ArrayList<Long>();
		ArrayList<Long> bb = new ArrayList<Long>();


		
		for(long i = 2;i*i <= a;i++){
			if(a%i == 0){
				aa.add((long) i);

				a /= i;
				while(a != 1 && a%i == 0){
					a /= i;
				}
				if( a == 1){
					break;
				}
			}
		}
		if(a > 1){
			aa.add(a);
		}
		for(long i = 2;i*i <= b;i++){
			if(b%i == 0){

				bb.add((long) i);

				b /= i;
				while(b != 1 && b%i == 0){
					b /= i;
				}				
				if( b == 1){
					break;
				}
			}
		}
		if(b > 1){
			bb.add(b);
		}
		long ans = 0;
		HashSet<Long> set = new HashSet<Long>();
		for(int i = 0;i < aa.size();i++){
			set.add(aa.get(i));
		}
		for(int i = 0;i < bb.size();i++){
			if(set.contains(bb.get(i))){
				ans++;
			}
		}

		System.out.println(ans+1);




	}

	static void sieve(ArrayList<Long> list){
		int n = 50000000;
		boolean[] is_prime = new boolean[n+1];
		int[] prime = new int[n];
		for(int i= 0;i <=n;i++){
			is_prime[i] = true;
		}
		list.add((long) 1);
		for(int i = 2;i <= n;i++){
			if(is_prime[i]){
				list.add((long)i);
				for(int j = 2*i;j <= n;j+=i){
					is_prime[j] = false;
				}
			}
		}



	}




	static int upperbond(int k,int min,int[] data){		//kより小さい最大の値をdataの中から探し、返す二分探索
		int max = data.length;
		//		if(min == data.length-1){
		//			if(data[min] > k){
		//				return min;
		//			}
		//		}

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}

		return max;
	}

	static int lowerbond(int k,int min,int[] data){		//kより大きい最小の値をdataの中から探し、返す二分探索
		int max = data.length;

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}
		return min;
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}


class Edge extends ArrayList<P>{

}

class P{
	int to;
	long cost;
	P(int to,long cost){
		this.to = to;
		this.cost = cost;
	}
}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   from- otherpair.from;
	}








}






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

int main() {
  int X;
  cin >> X;
  
  int fx;
  for (int i = X; i > 0;) {
    fx += i % 10;
    i /= 10;
  }
  
  if (X % fx == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;

void main() {
    string t = readln.chomp;
    string p = readln.chomp;
    int i = 0;
    while (true) {
        i = indexOf(t, p, i).to!int;
        if (i == - 1) break;
        i.writeln;
        ++i;
    }
}


Measured memory_bytes: 2508
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b;
    cin>>a>>b;
    b+=a*3;
    cout<<b/2<<endl;

    return 0;
}


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

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

     if(S == "Sunny") cout << "Cloudy" << endl;
     else if(S == "Cloudy") cout << "Rainy" << endl;
     else if(S == "Rainy") cout << "Sunny" << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll ff(ll m){
  if(m<0||m%2==1)return 0;
  m--;
  ll res=1;
  for(ll i=m;i>0;i-=2)(res*=i)%=mod;
  return res;
}

ll f[601];
ll n,m;
ll dp[601][601];
ll c[601];

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

  rep(i,601)f[i]=ff(i);

  cin>>n>>m;
  memset(c,-1,sizeof(c));
  rep(i,m){
    ll a,b;
    cin>>a>>b;
    a--; b--;
    c[a]=b; c[b]=a;
  }

  ll res=0;
  repl(len,2,2*n+1)rep(l,2*n+1){
    int r=l+len;
    if(r>2*n)continue;
    if((r-l)%2==1)continue;
    bool ok=true;
    repl(i,l,r){
      if(c[i]!=-1){
        if(c[i]<l||c[i]>=r)ok=false;
      }
    }
    if(!ok)continue;
    int cnt=0;
    repl(i,l,r){
      if(c[i]!=-1){
        cnt++;
      }
    }
    dp[l][r]=f[len-cnt];
    repl(i,l,r-1){
      if(c[i]!=-1)cnt--;
      dp[l][r]=(dp[l][r]-(dp[l][i+1]*f[r-(i+1)-cnt]%mod)+mod)%mod;
    }
    ll s1=0,s2=0;
    rep(i,l){
      if(c[i]!=-1)s1++;
    }
    repl(i,r,2*n){
      if(c[i]!=-1)s2++;
    }
    res+=dp[l][r]*f[2*n-len-s1-s2]%mod;
    res%=mod;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 3072
#include<stdio.h>

int main(void)
{
	int a,b,c,d;

	scanf("%d %d %d",&a,&b,&c);
	
	d=b/a;

	if(d>=c){
	printf("%d\n",c);

	}else{
		printf("%d\n",d);
	}

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int x,y;
    cin >> x >> y;
    int ans = x + y/2;
    cout << ans << endl;
}

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

using namespace std;
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;
typedef pair<double,double> PD;

#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())

#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 2000000011
#define MOD 1000000007
//2000000014
#define MAXSIZE 10010

int d;
string k;
LL wyn=0;
LL dp[MAXSIZE][11][110];

void u(LL &t1,LL &t2){
	t1+=t2;
	while(t1>=MOD)
		t1-=MOD;
}

int main(){
	
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>k>>d;
	//if(d==2&&SIZE(k)<=9){
	//	dp[INF][INF][INF]++;		
	//}
	int n=SIZE(k);
	
	dp[n][0][0]=1;
	
	FORD(i,n-1,0){
		REP(j,10){
			REP(m,10){
				REP(p,d){
					u(dp[i][j][(p+j)%d],dp[i+1][m][p]);
				}
			}
		}
	}
	
	LL temp=0;
	REP(i,n){
		int cat=k[i]-'0';
		if(cat==0)
			continue;
			
		REP(j,cat)
			u(wyn,dp[i][j][(d-temp)%d]);
		temp+=cat;
		temp%=d;
	}
	
	if(temp%d==0)
		wyn++;
	
	cout<<(wyn-1+MOD)%MOD;
	return 0;
}

//1000000001 1


Measured memory_bytes: 94848