akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        ll K, A, B;
        cin >> K >> A >> B;

        if (B - A <= 1) {
            cout << K + 1 << endl;
            return;
        }

//        if (K == 1 && A == 1) {
//            cout << B << endl;
//            return;
//        }

        ll rest = K;
        ll ans = 0ll;

        if (rest >= A + 1) {
            ans += B;
            rest -= (A + 1);

            ans += rest / 2 * (B - A);
            rest -= rest / 2 * 2;
            ans += rest;

            cout << ans << endl;
        } else {
            cout << K + 1 << endl;
        }


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
S = input()
if len(S)<26:
    for c in map(chr, range(97,123)):
        if c not in S:
            print(S+c)
            exit()
for i in range(26):
    for c in map(chr, range(ord(S[25-i])+1,ord('z')+1)):
            if c not in S[0:25-i]:
                print(S[0:25-i]+c)
                exit()
print(-1)


Measured memory_bytes: 62060
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

void solve(char str[128]);

int main(void){
  char str[128];
  while(scanf("%s%*c",str)!=EOF){
    solve(str);
  }
  return 0;
}

void solve(char str[128]){
  int i,j,len;
  len=strlen(str);
  for(i=0;i<len;i++){
    if(str[i] != '@'){
      putchar(str[i]);
    }else{
      j=str[i+1]-'0';
      j--;
      while(j--){
        putchar(str[i+2]);
      }
      i++;
    }
  }
  putchar('\n');
}

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

int main() {
  string s;
  cin >> s;
  int c[3];
  memset(c, 0, sizeof(c));
  for (int i = 0; i < s.length(); ++i) {
    ++c[s[i] - 'a'];
  }
  sort(c, c + 3);
  cout << (c[2] <= c[0] + 1 ? "YES" : "NO") << endl;
}

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

int N, k, h[100005], dp[100005];

int main() {
    scanf("%d %d", &N, &k);

    for (int i = 0; i < N; ++i) {
        scanf("%d", &h[i]);
    }

    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
        dp[i] = INT_MAX;
        for (int j = 1; i - j >= 0 && j <= k; j++)
            dp[i] = min(dp[i-j] + abs(h[i] - h[i-j]), dp[i]);
    }

    printf("%d\n", dp[N-1]);
}

Measured memory_bytes: 1024
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))
ans = [0,0,0]
for i in p:
    if i<=a:
        ans[0] +=1
    elif i<= b:
        ans[1] += 1
    else:
        ans[2] += 1
print(min(ans))

Measured memory_bytes: 38256
#include <stdio.h>
int main(){

	int a,b,c,x,y,z;

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

	if(a>b){
		x = a;
		a = b;
		b = x;
	}
	if(b>c){
		y = b;
		b = c;
		c = y;
	}
	if(a>b){
		z = a;
		a = b;
		b = z;
	}

	printf("%d %d %d\n",a,b,c);

	return 0;

}

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

n, X = map(int, input().split())
x = list(map(int, input().split()))

if len(x) == 1:
    print(abs(X - x[0]))
    exit()


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

ans = 0
for i in range(n):
    ans = gcd(ans, abs(X - x[i]))
print(ans)


Measured memory_bytes: 14168
#include<bits/stdc++.h>
using namespace std;
long long dis[500010],len[500010],err[500010];
int main()
{
	int n;scanf("%d%lld",&n,&dis[0]);
	for (int i=1;i<=n;i++)
	{
		scanf("%lld",&len[i]);
		dis[i]=min(dis[i-1],abs(dis[i-1]-len[i]));
	}
	err[n+1]=1;
	for (int i=n;i>=1;i--)
	{
		if (err[i+1]<=len[i]/2) err[i]=err[i+1];
		else err[i]=err[i+1]+len[i];
	}
	int q;scanf("%d",&q);
	while (q--)
	{
		int x;scanf("%d",&x);
		puts((dis[x-1]>=err[x+1])?"YES":"NO");
	}
}

Measured memory_bytes: 13696
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		String[] s = sc.nextLine().split(" ");
		if (Arrays.stream(s).filter(e -> e.equals("Y")).count() > 0L) {
			System.out.println("Four");
		} else {
			System.out.println("Three");
		}

		sc.close();
	}
}

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

using namespace std;

int n;
string s;

int main()
{
    cin >> n >> s;
    if (n%2 == 0 && s.substr(0, n/2) == s.substr(n/2)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100

int main( ){
  int n,i,j,v[MAX+1][MAX+1],u,k,a;

  scanf("%d",&n);


for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      v[i][j] = 0;
    }
 }  
  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&a);
      v[u][a] = 1;
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j != 1)printf(" ");
      	printf("%d",v[i][j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
  int r,g,b;
  cin >> r >> g >> b;
  int N = 100*r+10*g+b;
  if(N%4==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define PI (acos(-1))
#define _GLIBCXX_DEBUG

int main(){
  
  int h, w;
  cin >> h >> w;
  
  rep(i, h){
    vector<char> v(w);
    rep(j, w){
      cin >> v[j];
      cout << v[j];
      if(j == w-1){
        cout << endl;
        rep(k, w){
          cout << v[k];
          if(k == w-1) cout << endl;
        }
      }
    }
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i, j, k;
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		sc.close();
		int cnt = 0;
		for(i=0;i<=a;i++) {
			for(j=0;j<=b;j++) {
				for(k=0;k<=c;k++) {
					if(x==i*500+j*100+k*50) {
						cnt++;
					}
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int n;
string a[100050];

//inputします
void input() {
	cin >> n;
    ff(i, 0, n) {
        string s;
        cin >> s;
        srt(s);
        a[i] = s;
    }
    sort(a, a + 100050);
    reverse(a, a + 100050);
}

i64 nCk(i64 aa32, i64 bb32) {//aaCbb 
    if (aa32 < bb32)return 0;
    if (2 * bb32 > aa32)bb32 = aa32 - bb32;
    i64 ans32 = 1;
    ff(ii32, 0, bb32) {
        ans32 *= aa32 - ii32;
    }
    ff(ii32, 1, bb32 + 1) {
        ans32 /= ii32;
    }
    return ans32;
}


int main() {
	input();
    i64 ans = 0;
    int t = 1;
    ff(i, 1, n) {
        if (a[i] == a[i - 1]) {
            t++;
        }
        else {
            if (t == 1)continue;
            else {
                ans += nCk(t, 2);
                t = 1;
            }
        }
    }
    ans += nCk(t, 2);
    cout << ans << endl;
	return 0;
}

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

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

    map<long, int> mp;
    long num;
    while(cin >> num) {
        if (mp.find(num) == mp.end()) {
            mp.insert(make_pair(num, 1));
        } else {
            mp.erase(num);
        }
    }
    cout << mp.size();
}


Measured memory_bytes: 6528
D, G = map(int, input().split())
G //= 100
P = [0] * D
S = [0] * D
for i in range(D):
    p, c = map(int, input().split())
    P[i] = p
    S[i] = (i + 1) * p + c // 100
ans = 10**9
for i in range(2**D):
    tmp = G
    res = 0
    idx = -1
    bi = bin(i)[2:].zfill(D)
    for j, b in enumerate(bi):
        if b == '1':
            tmp -= S[j]
            res += P[j]
        else:
            idx = j
    if tmp > 0 and tmp - (P[idx] - 1) * (idx + 1) <= 0:
        k = (tmp + idx) // (idx + 1)
        tmp -= (idx + 1) * k
        res += k
    if tmp <= 0:
        ans = min(ans, res)

print(ans)

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

bool next_choice(int ixh[], int h, int N) {
  for(int i = h-1, n = N; i >= 0; --i, --n) {
    if(ixh[i]+1 < n) {
      int v = ixh[i]+1;
      for(int j = i; j < h; ++j) ixh[j] = v++;
      return true;
    }
  }
  return false;
}

int calc(int ix[], int N) {
  int res = 0;
  for(int i = 0; i < N-1; ++i) for(int j = i+1; j < N; ++j) {
    if(ix[i] > ix[j]) ++res;
  }
  return res;
}

uint64_t getZ() {
  uint64_t v = 0; int c;
  while((c = getchar_unlocked()) >= '0') v=v*10+c-'0';
  return v;
}

int main() {
  int N = getZ(), H = (N+1)/2;
  int ab[2][18];
  for(int i = 0; i < N; ++i) std::cin >> ab[i%2][i];
  for(int i = 0; i < N; ++i) std::cin >> ab[(i+1)%2][i];
  int ix[18], ixh[9], ixe[9], ixo[9];
  bool used[18];
  std::iota(ixh, ixh+H, 0);
  
  int ans = 10000;
  // check all possibility; MAX: comb(18,9) < 50000
  for(;;) {
    // prepare even
    std::copy_n(ixh, H, ixe);
    std::sort(ixe, ixe+H, [&](int l, int r){ return ab[0][l] < ab[0][r]; });
    
    // prepare odd
    std::fill_n(used, N, false);
    for(int i = 0; i < H; ++i) used[ixh[i]] = true;
    int ix_o = 0;
    for(int i = 0; i < N; ++i) if(!used[i]) ixo[ix_o++] = i;
    std::sort(ixo, ixo + N-H, [&](int l, int r){ return ab[1][l] < ab[1][r]; });
    
    // check if sorted
    bool sorted = true;
    for(int i = 0; i < N-H; ++i) {
      if(ab[0][ixe[i]] > ab[1][ixo[i]]) { sorted = false; break; }
      if(i+1 < H &&  ab[1][ixo[i]] > ab[0][ixe[i+1]]) { sorted = false; break; }
    }
    if(sorted) {
      // merge
      for(int i = 0; i < H; ++i) ix[i*2] = ixe[i];
      for(int i = 0; i < N-H; ++i) ix[i*2+1] = ixo[i];
      ans = std::min(ans, calc(ix, N));
    }
    
    if(!next_choice(ixh, H, N)) break;
  }
  if(ans > 9999) ans = -1;
  fin(ans);
  return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  string S; cin >> S;
  int N = S.length();

  for (int i = 1; i < N; i++){
    if (S[i-1] == S[i]){
      cout << i << " " << i+1 << endl;
      return 0;
    }
  }

  for (int i = 2; i < N; i++){
    if (S[i-2] == S[i]){
      cout << i-1 << " " << i+1 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;

  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
//#include <unordered_map>
#define M ((ll)1e9+7)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
typedef long long ll;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t,n,c=0;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<n-1;i++){
	    if(s[i]!=s[i+1]) c++;
	}
	cout<<c+1;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	unsigned int width;
	scanf("%u", &width);
	//cin >> width;
	vector <unsigned int> up(width), mid(width), down(width);
	for (unsigned int i = 0; i < width; ++i) {
		//cin >> up[i];
		scanf("%u", &up[i]);
	}
	for (unsigned int i = 0; i < width; ++i) {
		//cin >> mid[i];
		scanf("%u", &mid[i]);
	}
	for (unsigned int i = 0; i < width; ++i) {
		//cin >> down[i];
		scanf("%u", &down[i]);
	}
	sort(up.begin(), up.end());
	sort(mid.begin(), mid.end());
	sort(down.begin(), down.end());
	// ---
	vector <unsigned int> mid_down_counter(width);
	for (long long i = 0; i < width; ++i) {
		mid_down_counter[i] = distance(upper_bound(down.begin(), down.end(), mid[i]), down.end());
	}
	unsigned long long count = 0, count_temp = 0;
	auto accu_start = mid_down_counter.end();
	for (long long i = width - 1; i >= 0; --i) {
		size_t index = distance(mid.begin(), upper_bound(mid.begin(), mid.end(), up[i]));
		if (mid_down_counter.begin() + index != accu_start) {
			count_temp += accumulate(mid_down_counter.begin() + index, accu_start, 0LL);
			accu_start = mid_down_counter.begin() + index;
		}
		count += count_temp;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <unordered_map>
#include <map>
#include <set>
#include <unordered_set>
#include <sstream>
typedef long long ll;
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    //for writing to files
    //freopen('input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    map<char, int> dict;
    string seq;
    cin >> seq;
    for (char x : seq) {
        if (dict.count(x)) {
            dict[x]++;
        } else {
            dict[x] = 1;
        }
    }
    for (char x : "abcdefghijklmnopqrstuvwxyz") {
        if (dict[x] % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
/** Author: Nicklaus **/
 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
 
int main(){
	int n, k;
	string s;
	cin>>n>>k>>s;
	s[k-1]=s[k-1]+32;
	cout<<s<<endl;
	return 0;
}

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

int main() {
  int N, k = 0;
  cin >> N;
  vector<int> A(N);

  for(int i=0; i<N; i++) {
    cin >> A.at(i);
  }
  
  for(int i=0; i<N; i++) {
    if(i==1) break;
    k++;
    if(k==N) {
      k=-1;
      break;
    }
    i = A.at(i)-2;

  }
  cout << k << endl;
  
}

Measured memory_bytes: 3756
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>

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

int main()
{
	int h, w;
	cin>>h>>w;
	int a[500][500];
	P prev[500][500];
	P p=P(-1, -1);
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin>>a[i][j]; a[i][j]%=2;
    }
  }
	for(int i=0; i<h; i++){
		if(i%2==0){
			for(int j=0; j<w; j++){
				prev[i][j]=p;
				p=P(i, j);
			}
		}else{
			for(int j=w-1; j>=0; j--){
				prev[i][j]=p;
				p=P(i, j);
			}
		}
	}
	P pr=P(-1, -1);
	vector<P> ans1, ans2;
	for(int i=0; i<h; i++){
		if(i%2==0){
			for(int j=0; j<w; j++){
				if(a[i][j]==1){
					if(pr==P(-1, -1)){
						pr=P(i, j);
					}else{
						P q=P(i, j);
						while(q!=pr){
							ans1.push_back(q);
							ans2.push_back(prev[q.first][q.second]);
							q=prev[q.first][q.second];
						}
						pr=P(-1, -1);
					}
				}
			}
		}else{
			for(int j=w-1; j>=0; j--){
				if(a[i][j]==1){
					if(pr==P(-1, -1)){
						pr=P(i, j);
					}else{
						P q=P(i, j);
						while(q!=pr){
							ans1.push_back(q);
							ans2.push_back(prev[q.first][q.second]);
							q=prev[q.first][q.second];
						}
						pr=P(-1, -1);
					}
				}
			}
		}
	}
	cout<<ans1.size()<<endl;
	for(int i=0; i<ans1.size(); i++){
		cout<<ans1[i].first+1<<" "<<ans1[i].second+1<<" "<<ans2[i].first+1<<" "<<ans2[i].second+1<<endl;
	}
	return 0;
}

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

typedef long long ll;

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

	ll a, b, c, a2, b2, c2;
	cin>>a>>b>>c;
	// cout<<a<<" "<<b<<" "<<c<<endl;

	if(a == b && b == c && (a%2)+(b%2)+(c%2) == 0) {
		cout<<-1<<endl;
		return 0;
	}

	ll ans = 0;

	while((a%2)+(b%2)+(c%2) == 0) {
		a2 = b/2 + c/2;
		b2 = a/2 + c/2;
		c2 = a/2 + b/2;
		a = a2;
		b = b2;
		c = c2;
		// cout<<a<<" "<<b<<" "<<c<<endl;
		ans++;
	}

	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

void rotate(string str, int* dice)
{
	if(str == "north")
	{
		int temp = dice[0];
		dice[0] = dice[4];
		dice[4] = dice[5];
		dice[5] = dice[1];
		dice[1] = temp;
	}
	else if(str == "east")
	{
		int temp = dice[0];
		dice[0] = dice[2];
		dice[2] = dice[5];
		dice[5] = dice[3];
		dice[3] = temp;
	}
	else if(str == "south")
	{
		int temp = dice[0];
		dice[0] = dice[1];
		dice[1] = dice[5];
		dice[5] = dice[4];
		dice[4] = temp;
	}
	else if(str == "west")
	{
		int temp = dice[0];
		dice[0] = dice[3];
		dice[3] = dice[5];
		dice[5] = dice[2];
		dice[2] = temp;
	}
}

void solve()
{
	int N;
	while(cin >> N, N)
	{
		string str;
		int dice[6] ={1, 2, 3, 4, 5, 6};
		for(int i = 0; i < N; ++i)
		{
			cin >> str;
			rotate(str, dice);
		}
		cout << dice[0] << endl;
	}
}

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

Measured memory_bytes: 0
#include <iostream>

using namespace std;

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

    cout << ((a==5 && b==5 && c==7) || (a==5 && b==7 && c==5) || (a==7 && b==5 && c==5) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
int main(){

	int a,b;
	cin >> a >> b;
	if(a*b % 2 == 0){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
  int i;
  char str[1001];
  scanf("%s",str);
  for(i=0;i<strlen(str);i++){
    if(str[i]=='A'){printf("X");}
else    if(str[i]=='B'){printf("Y");}
else    if(str[i]=='C'){printf("Z");}
 else{ printf("%c",str[i]-3);}
    if(i==strlen(str)-1){ printf("\n");
    }
  }
  return 0;
  }

Measured memory_bytes: 524
N, M = map(int, input().split())
A = [''] * N
for i in range(N):
    A[i] = list(map(int, input().split()))
    
for i in range(len(A)):
    del A[i][0]

ans = 0
Alist = [flatten for inner in A for flatten in inner]
for i in set(Alist):
    if Alist.count(i) == N:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
void solve(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a<b){
    cout<<"No"<<"\n";
    return ;
  }
  if(d<b){
    cout<<"No"<<"\n";
    return;
  }
  if(c>=b){
    cout<<"Yes"<<"\n";
    return ;
  }
  ll g=GCD(b,d);
  ll ch=(a%g-c%g>0?a%g-c%g:a%g-c%g+g)+c;
   if(0<=ch-b)cout<<"Yes"<<"\n";
   else cout<<"No"<<"\n";
}
int main(){
  int t;
  cin>>t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
 public static void main(String[]args){
Scanner scan = new Scanner(System.in);
  int A = scan.nextInt();
  int B = scan.nextInt();
  int C = scan.nextInt(); 
  int D = scan.nextInt();
  while ((A>0) && (C>0)){
   C=C-B;
   if (C<=0){
    System.out.println("Yes");}
   A=A-D;
   if ((A<=0) && (C>0)){
    System.out.println("No");}
  }
 }
}

Measured memory_bytes: 35760
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int n,a,mini,ans=-(1<<30);
  scanf("%d %d",&n,&mini);
  for(int i=0;i<n-1;i++){
    scanf("%d",&a);
    if(a-mini>ans)ans=a-mini;
    if(mini>a)mini=a;
  }
  cout<<ans<<endl;
  return 0;
}



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

int main(){
  int swcut=0,flag=1;
  int n,*a,i,stock;
  
  scanf("%d",&n);
  a=(int *)malloc(n*sizeof(int));
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  while(flag){
    flag=0;
    for(i=n-1;0<i;i--){
      if(a[i]<a[i-1]){
	stock=a[i];
	a[i]=a[i-1];
	a[i-1]=stock;
	swcut++;
	flag=1;
      }
    }
 
  }

  for(i=0;i<n;i++){
  printf("%d",a[i]);
  if(i!=n-1) printf(" ");
  }
  printf("\n%d\n",swcut);
  
  return 0;
}



Measured memory_bytes: 2760
N, K = map(int, input().split())
# bが1-Nまでの場合を考えて、余りがK以上の物を足していく
res = 0

for b in range(1,N+1):
    if b <= K: continue
    res += (N//b) * (b-K)
    if K == 0:
        res += N%b
    else:
        res += max(0, N%b-K+1)
print(res)

Measured memory_bytes: 65008
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class Test_153_d
{

#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            var H = long.Parse(Console.ReadLine());
            long l = Solve(H);
            Console.WriteLine(l.ToString());
        }

        private static long Solve(long h)
        {
            if (h == 1) return 1;
            long next = h / 2;

            long a = Solve(next) * 2 + 1;

            return a;
        }
#if TEST
#else
    }
}
#endif


Measured memory_bytes: 13140
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			for (long a = 1; a <= 3500; a++) {
				for (long b = 1; b <= 3500; b++) {
					long u = a * b * n;
					long v = 4 * a * b - a * n - b * n;
					if (v != 0 && u % v == 0) {
						long c = u / v;
						if (c >= 1 && c <= 3500) {
							out.println(a + " " + b + " " + c);
							return;
						}
					}
				}
			}
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



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

int main() {
	int r,c;cin>>r>>c;
	int a[101][101]={};
	for(int i=0;i<r;i++)for(int j=0;j<c;j++)cin>>a[i][j];
	for(int i=0;i<r;i++)for(int j=0;j<c;j++)a[i][c]+=a[i][j];
	for(int i=0;i<c;i++)for(int j=0;j<r;j++)a[r][i]+=a[j][i];
	for(int i=0;i<r;i++)a[r][c]+=a[i][c];
	for(int i=0;i<=r;i++)
	{
		for(int j=0;j<=c;j++)
		{
			if(j)cout<<" ";
			cout<<a[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

int n;
vi a, b, c[2];
int clt(int idx, int val){
  int l = -1, r = sz(c[idx]), mid;
  while(r - l > 1){
    mid = (l + r) / 2;
    if(c[idx][mid] <= val){
      l = mid;
    }else{
      r = mid;
    }
  }
  return r;
}

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    int t;
    cin >> t;
    a.pb(t);
  }
  FOR(i, 0, n){
    int t;
    cin >> t;
    b.pb(t);
  }
  ll ans = 0;
  FOR(i, 0, 29){
    c[0].clear();
    c[1].clear();
    int k = 1 << i;
    FOR(j, 0, n) c[a[j] / k % 2].pb(a[j] % k);
    sort(rng(c[0]));
    sort(rng(c[1]));
    int cc = 0;
    for(int j: b){
      int bb = k - j % k - 1;
      if(j / k % 2){
        cc += clt(0, bb);
        cc += sz(c[1]) - clt(1, bb);
      }else{
        cc += sz(c[0]) - clt(0, bb);
        cc += clt(1, bb);
      }
    }
    if(cc%2) ans += 1<<i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4212
#include<cstdio>
#include<algorithm>
using namespace std;

int n,a[100005][4],dp[100005][4];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d%d",&a[i][1],&a[i][2],&a[i][3]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=3;j++)
			for(int k=1;k<=3;k++)
				if(j!=k)
					dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
	printf("%d",*max_element(dp[n]+1,dp[n]+4));
	return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>
int partition(int *,int,int,int);
int main(){
  int i,n,q;
  int A[100000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  q=partition(A,n,0,n-1);
  for(i=0;i<n;i++){
    if(i>0){
      printf(" ");
    }
    if(i==q){
      printf("[");
    }
    printf("%d",A[i]);
    if(i==q){
      printf("]");
    }
  }
  printf("\n");
  return 0;
}

int partition(int A[],int n, int p,int r){
  int i,j,k,a,temp;
  a=A[r];
  j=p-1;
  for(i=p;i<r;i++){
    if(A[i]<=a){
      j++;
      temp=A[j];
      A[j]=A[i];
      A[i]=temp;
    }
  }
  temp=A[j+1];
  A[j+1]=A[r];
  A[r]=temp;
  return j+1;
}



Measured memory_bytes: 2176
#!/usr/bin/env python3
import sys


def solve(a: int, b: int, c: int, d: int, e: int, k: int):
    print('Yay!' if e - a <= k else ':(')



# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    e = int(next(tokens))  # type: int
    k = int(next(tokens))  # type: int
    solve(a, b, c, d, e, k)

if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){
  
  int n;
  cin >> n;
  cout << 3*n*n << endl;



  return 0;
}


Measured memory_bytes: 256
/*****************Bismillahir Rahmanir Rahim***********************/

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

/************************Start Of Template*************************/

/******** Mahin Shefat - GhOstMan *************/


#define     pb              push_back
#define     popb            pop_back
#define     ll              long long int
#define     ull             unsigned long long int
#define     max3(a,b,c)     max(a,max(b,c))
#define     max4(a,b,c,d)   max(max3(a,b,c),d)
#define     min3(a,b,c)     min(a,min(b,c))
#define     min4(a,b,c,d)   min(a,min3(b,c,d))
#define     MOD             1000000007
#define     f               first
#define     s               second
#define     mem(a,v)        memset(a,v,sizeof(a))
#define     mp              make_pair
#define     check           printf("check")
#define     sqr(x)          (x)*(x)
#define     all(v)          v.begin(),v.end()
#define     fast            ios_base::sync_with_stdio(0);cin.tie(0)
#define     pii             pair<int,int>
#define     Pair            pair<ll,ll>
#define     MAX             1000000000000014
#define     MIN             -1000000000000014
#define     endl            '\n'
#define     Fread           freopen("inputdur.txt","r",stdin)
#define     Fwrite          freopen("output.txt","w",stdout)

/************************End Of Template*************************/
ll a[300005] , b[300005] , c[300005];
ll dp[300005][5];
int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i] >> b[i] >> c[i];
	}	
	for(int i = 1; i <= n; i++){
		dp[i][1] = a[i] + max(dp[i - 1][2] , dp[i - 1][3]);
		dp[i][2] = b[i] + max(dp[i - 1][1] , dp[i - 1][3]);
		dp[i][3] = c[i] + max(dp[i - 1][1] , dp[i - 1][2]);
	}
	cout << max3(dp[n][1] , dp[n][2] , dp[n][3]) << endl;
	return 0;
}


Measured memory_bytes: 12544
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(c >= a) {
			System.out.println(c <= b ? "Yes" :"No");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
//#define int long long

void solve() {
	string s; cin >> s;
    int n = (int)s.size();
    int k = n;
    rep1(i, n - 1) {
        if(s[i - 1] != s[i]) {
            chmin(k, max(i, n - i));
        }
    }
    cout << k << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    int x, y, tmp;
    
    while(1){
        cin >> x >> y;
        
        if (x == 0 && y == 0)
            break;
        else{
            if (x < y)
                cout << x << " " << y << endl;
            else
                cout << y << " " << x << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3044
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
   
   
public class Main {
	static int INF = 2 << 27;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Node[] node = new Node[n];
		Node[] Tmp  = new Node[n];
		for(int i = 0; i < n; i++) {
			node[i] = new Node();
			Tmp[i] = new Node();
			Tmp[i].id = node[i].id;
			Node.ID--;
		}
		int m = sc.nextInt();
		for(int i = 0; i < m; i++) {
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			
			node[a].out.add(node[b]);
			node[b].in.add(node[a]);
			Tmp[a].out.add(Tmp[b]);
			Tmp[b].in.add(Tmp[a]);
		}
		
		ArrayList<Node> L = new ArrayList<Node>();
		ArrayList<Node> S = new ArrayList<Node>();
		for(int i = 0; i < n; i++) {
			if(node[i].in.isEmpty()) S.add(node[i]);
		}
		while(!S.isEmpty()) {
			Node tmp = S.get(0);
			S.remove(0);
			L.add(tmp);
			while(!tmp.out.isEmpty()) {
				Node to = tmp.out.get(0);
				tmp.out.remove(0);
				to.in.remove(tmp);
				if(to.in.isEmpty()) {
					S.add(to);
				}
			}
		}
		int[] color = new int[n];
		for(int i = 0; i < L.size(); i++) {
			System.out.println(L.get(i).id);
			for(int j = 0; j < Tmp[L.get(i).id-1].out.size(); j++) {
				color[Tmp[L.get(i).id-1].out.get(j).id-1] = Math.max(color[Tmp[L.get(i).id-1].out.get(j).id-1], color[L.get(i).id-1]+1);
			}
		}
		
		int[] count = new int[n];
		
		for(int i = 0; i < n; i++) {
			//System.out.println(color[i]);
			count[color[i]]++;
		}
		Arrays.sort(count);
		
		System.out.println(((count[n-1] >= 2)?1:0));
		
		
		
		
		
		
		
		
		
	}
	
	static class Node {
		static int ID = 1;
		int id = ID++;
		ArrayList<Node> out = new ArrayList<Node>();
		ArrayList<Node> in  = new ArrayList<Node>();
	}

	
}

Measured memory_bytes: 106440
#include <iostream>
#include <string>
#include <vector>
#define rep(i, j) for (long long i = 0; i < j; i++)

using namespace std;

signed main()
{
    vector<string> arr = {"Sunny", "Cloudy", "Rainy", "Sunny"};
    string str;
    cin >> str;
    rep(i, arr.size() - 1)
    {
        if (str == arr[i])
            cout << arr[i + 1] << endl;
    }
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B=[0]*N
    for i in range(N):
        if A[i]%2==0:
            B[i]=2
            if A[i]%3==0 or A[i]%5==0:
                B[i]=1

    for i in range(N):
        if B[i]==2:
            print("DENIED")
            return
    print("APPROVED")
    return
    
    
main()

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

long long int a, b, c;

int main(){
  cin >> a >> b >> c;
  long long int high, mid, low;
  high = max(a, max(b, c));
  low = min(a, min(b, c));
  mid = a + b + c - high - low;
  if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
    cout << 0 << endl;
  }else{
    cout << mid * low << endl;
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);

		String s=sc.next();
		int[] a=new int[26];
		Arrays.fill(a, 0);
		for(int i=0; i<4;i++) {
			a[s.charAt(i)-'A']++;
		}
		boolean a1=false;
		boolean a2=false;
		for(int i=0; i<26; i++) {
			if(!a1 && a[i]==2) {
				a1=true;
			}
			else if(a1&& a[i]==2) {
				a2=true;
			}
		}
		if(a1 && a2) {
			pl("Yes");
		}
		else {
			pl("No");
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

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

using namespace std;



int main(){
    string S;
    cin >> S;
    
    if(S[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }
    
    int num, cnt = 0;
    for(int i = 2; i < S.length() - 1; ++i){
        if(S[i] == 'C'){
            num = i;
            cnt++;
        }
    }
    
    if(cnt != 1){
        cout << "WA" << endl;
        return 0;
    }
    
    for(int i = 1; i < S.length(); ++i){
        if(('a' - S[i]) > 6){
            if(i != num){
                cout << "WA" << endl;
                return 0;
            }
        }
    }
    
    cout << "AC" << endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int x[5];
	for (int i = 0; i < 5; i++) cin >> x[i];
	for (int i = 0; i < 5; i++) {
		if (x[i] == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
}

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

bool win[101010];

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

	int n, k;
	cin >> n >> k;

	vector<int> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];

	for (int i = 0; i <= k; ++i) {
		bool b = 0;
		for (auto c : v) {
			if (i - c < 0) continue;
			if (!win[i-c]) b = 1;
		}
		win[i] = b;
	}
	if (win[k]) cout << "First\n";
	else cout << "Second\n";
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)
const ll mod = 1e9+7;

class mint {
public:
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

class combination {
public:
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) const {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
	mint p(ll n,ll k) const{
		if (k < 0 || k > n ) return 0;
		return fact[n]*ifact[n-k];
	}
	mint h(ll n,ll k) const {
		if (k < 0 || k > n) return 0;
		return fact[n+k-1]*ifact[n-1]*ifact[k];
	}
	mint choose(ll n ,ll a) const{// k <= 1e5 n <= 1e9
	    if (a < 0 || a > n) return 0;
		mint x=1,y=1;
		for(ll i=0;i < a; i++){
			x*=n-i;
			y*=i+1;
		}
		return x / y; 
	}
	mint perm(ll n, ll a) const { // k <= 1e5
	if (a < 0 || a > n) return 0;
	   mint x=1,y=1;
	   for (ll i=0;i < a;i++){
		   x*=n-i;
	   }
	   return x;
	}
}comb(100000);// plsese mint control!


int main(){
  ll n,m;
  cin >> n >> m;
  map<ll,int> mp;
  for (int i = 2; i*i <= m;i++){
    while(m%i==0){
      m/=i;
      mp[i]++;
    }
  }
  if (m != 1) mp[m]++;
  mint ans = 1LL;
  for (auto q:mp){
    ans *= comb.choose(q.second + n-1, q.second);
  }
  
  cout << ans.x << endl;
  

   
  return 0; 
}



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

    //long long
    using ll = long long;

    // pair<int, int>
    using PII = pair<int, int>;

    //最大値、mod
    const int MOD = 1000000007;
    const int INF = 1000000000;
    const long long LINF = 1e18;

    //出力系
    #define print(x) cout << x << endl
    #define prints(x) cout << fixed << setprecision(10) << x << endl
    #define printc(x) cout << setw(2) << setfill('0') << x << endl;
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

    //for
    #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

    //最大公約数 
    unsigned gcd(unsigned a, unsigned b) {
      if(a < b) return gcd(b, a);
      unsigned r;
      while ((r=a%b)) {
        a = b;
        b = r;
      }
      return b;
    }

    // 最小公倍数
    unsigned lcm(unsigned a, unsigned b){
        return a / gcd(a, b) * b; 
    }

    // a = max(a, b), a = min(a, b)
    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 dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};









int main(){
  int N;
  cin >> N;
  int cnt = 0;
  vector<ll> x(N), y(N);
  REP(i, N) cin >> x.at(i) >> y.at(i);
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      int tmp = 0;
      int a = x.at(i) - x.at(j);
      int b = y.at(i) - y.at(j);
      for(int i1 = 0; i1 < N; i1++)
        for(int j1 = 0; j1 < N; j1++){
          if(a == x.at(i1) - x.at(j1) && b == y.at(i1) - y.at(j1) && i1 != j1) tmp++;
        }
        chmax(cnt, tmp);
    }
  }
  int ans = N - cnt;
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int MOD = (int) 1e9 + 7;
void sadd(int &a, int b)
{
    a += b;
    if (a >= MOD) a -= MOD;
}
void ssub(int &a, int b)
{
    a -= b;
    if (a < 0) a += MOD;
}
int add(int a, int b)
{
    sadd(a, b);
    return a;
}
int mul(int a, int b)
{
    return (a * 1LL * b) % MOD;
}

const int K = (int) 5000; 
int dp[2][K];
const int N = 105;
int cnt[N];

int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    int n, k;
    scanf("%d%d", &n, &k);

    memset(dp, 0, sizeof dp);
    int t = 0, nt = 1;
    dp[t][0] = 1;

    int sum = 0;
    for (int i = 1; i <= k; i++)
        sadd(sum, i);

    cnt[0] = 1;
    
    for (int i = 0; i < n; i++)
        cnt[i + 1] = mul(cnt[i], k + 1);
    int ans = mul(cnt[n - 1], mul(sum, n) );
    eprintf("ans = %d\n", ans);

    for (int i = n; i >= 1; i--)
    {
        memset(dp[nt], 0, sizeof dp[nt] );

        for (int j = 0; j < K; j++)
        {
            int cur = dp[t][j];
            if (cur == 0) continue;
            int big = max(0, k - i);
            sadd(dp[nt][j], mul(cur, big) );
            for (int val = 0; val <= min(k, i); val++)
            {
                int nx = j + (val + j) / i;
                if (nx >= K)
                {
                    eprintf("i = %d, nx = %d\n", i, nx);
                    throw;
                }
                sadd(dp[nt][nx], cur);
            }
        }

        swap(t, nt);
//        for (int it = 0; it < 10; it++)
//            eprintf("%d ", dp[t][it] );
//        eprintf("\n");
    }


    for (int i = 0; i < K; i++)
        ssub(ans, mul(dp[t][i], i) );

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


	return 0;
}



Measured memory_bytes: 256
(defun App ()
    (let* ((k (read))
        (a (read))
        (b (read))
        (ans "NG"))
        (loop for i from a to b
            do(if (zerop (rem i k))
                (progn
                    (setq ans "OK")
                    (return)
                )
            )
        )
    (format t "~A~%" ans)
    )
)

(App)

Measured memory_bytes: 23488
import math
A,B,H,M=map(int,input().split())
a=360*H/12+360*M/60/12
b=360*M/60
c=abs(a-b)
if c>180:
    c=360-c
C=(A**2+B**2-(2*A*B*math.cos(math.radians(c))))**0.5
print(C)

Measured memory_bytes: 9528
package main

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

func main() {
	A1 := nextInt()
	A2 := nextInt()
	A3 := nextInt()

	if A1+A2+A3 >= 22 {
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void) {
	int n, i, s, c, k;
	i = 0;
	c = 0;
	n = 0;
	scanf("%d", &n);
	while (i <= n) {
		s = i;
		k = 0;
		while (s != 0) {
			s = s / 10;
			k++;
		}
		if (k % 2 != 0) {
			c++;
		}
		i++;
	}
	printf("%d", c);
	return 0;
}

Measured memory_bytes: 128