akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define MAX_N 103
#define MAX_V 10
#define MAX_M 101
#define min(a,b) (a>b?b:a)
#define max(a,b) (a>b?a:b)
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")
#define pro "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○○するために生まれてきた男"

signed main(){
	int count = 0, x, y;
	
	cin>>x>>y;
	
	while(x <= y){
		x*=2;
		count++;
	}
	
	cout<<count<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  	int n,k;
  	cin>>n>>k;
  	int h[n],dp[n];
  	for(int i=0;i<n;i++){
      	cin>>h[i];
      	dp[i]=INT_MAX;
    }  	
  	dp[0]=0;
	for(int i=0;i<n;i++){
      for(int j=1;j<=k;j++){
        if(i+j<n)
        	dp[i+j]=min(dp[i+j],abs(h[i]-h[i+j])+dp[i]);
      }
    }
  	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<vector>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
#define rep(i, n) for (i32 i = 0; i < (i32)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;
using i64 = int_fast64_t;
constexpr i64 MAX = 10000000;
constexpr i64 MOD = 1000000007;
i64 fac[MAX], finv[MAX], inv[MAX];
template <i64 modulus>
class modcal
{

public:
  i64 a;

  constexpr modcal(const i64 x = 0) noexcept : a(x % modulus) {}
  constexpr i64 &value() noexcept { return a; }
  constexpr const i64 &value() const noexcept { return a; }
  constexpr modcal operator+(const modcal rhs) const noexcept
  {
    return modcal(*this) += rhs;
  }
  constexpr modcal operator-(const modcal rhs) const noexcept
  {
    return modcal(*this) -= rhs;
  }
  constexpr modcal operator*(const modcal rhs) const noexcept
  {
    return modcal(*this) *= rhs;
  }
  constexpr modcal operator/(const modcal rhs) noexcept
  {
    return modcal(*this) /= rhs;
  }
  constexpr modcal &operator+=(const modcal rhs) noexcept
  {
    a += rhs.a;
    if (a >= modulus)
    {
      a -= modulus;
    }
    return *this;
  }
  constexpr modcal &operator-=(const modcal rhs) noexcept
  {
    if (a < rhs.a)
    {
      a += modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modcal &operator*=(const modcal rhs) noexcept
  {
    a = a * rhs.a % modulus;
    return *this;
  }
  constexpr modcal &operator/=(modcal rhs) noexcept
  {
    i64 exp = modulus - 2;
    while (exp)
    {
      if (exp % 2)
      {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }

  void COMninit()
  {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
      fac[i] = fac[i - 1] * i % modulus;
      inv[i] = MOD - inv[modulus % i] * (modulus / i) % modulus;
      finv[i] = finv[i - 1] * inv[i] % modulus;
    }
  }
  i64 COMn(i64 n, i64 k)
  {
    if (n < k)
      return 0;
    if (n < 0 || k < 0)
      return 0;
    return fac[n] * (finv[k] * finv[n - k] % modulus) % modulus;
  }
  constexpr modcal<1000000007> modpow(const modcal<1000000007> &a, i64 n)
  {
    if (n == 0)
      return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1)
      t = t * a;
    return t;
  }
};
using modc = modcal<1000000007>;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i64 n;
cin >> n;
vector<i64> a(n);
vector<modc> sum(n + 1);
rep(i,n){
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
}
modc ans = 0;
for(i32 i = 1; i <n; i++){
    ans += (sum[n] - sum[i]) * a[i - 1];
}
cout << ans.a << endl;
}

Measured memory_bytes: 6364
#B

N = int(input())
D = []
counter = []

for i in range(N):
  D.append(list(map(int,input().split())))

for i in range(N):
  if D[i][0] == D[i][1]:
    counter.append(1)
    if (i >= 2 and counter[i-1]==1 and counter[i-2]==1):
      print('Yes')
      break
  else:
    counter.append(0)
  if i == N-1:
    print('No')



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

#define Gene template< class
#define Rics printer& operator,
Gene c> struct rge{c b, e;};
Gene c> rge<c> range(c i, c j){ return {i, j};}
struct printer{
    ~printer(){cerr<<endl;}
    Gene c >Rics(c x){ cerr<<boolalpha<<x; return *this;}
    Rics(string x){cerr<<x;return *this;}
    Gene c, class d >Rics(pair<c, d> x){ return *this,"(",x.first,", ",x.second,")";}
    Gene ... d, Gene ...> class c >Rics(c<d...> x){ return *this, range(begin(x), end(x));}
    Gene c >Rics(rge<c> x){
        *this,"["; for(auto it = x.b; it != x.e; ++it)
            *this,(it==x.b?"":", "),*it; return *this,"]";}
};
#define debug() cerr<<"LINE "<<__LINE__<<" >> ", printer()
#define dbg(x) "[",#x,": ",(x),"] "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int my_rand(int l, int r) {
    return uniform_int_distribution<int>(l, r) (rng);
}


int main() {
//    freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, K;
    cin >> n >> K;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    long long ans = 0;
    vector<long long> cum(n), pos(n), neg(n);
    for(int i = 0; i < n; i++) {
        cum[i] = (i > 0 ? cum[i-1] : 0) + a[i];
        pos[i] = (i > 0 ? pos[i-1] : 0) + max(a[i], 0);
        neg[i] = (i > 0 ? neg[i-1] : 0) + (a[i] < 0 ? -a[i] : 0);
    }
    for(int i = 0; i+K-1 < n; i++) {
        long long block_sum = cum[i+K-1] - (i > 0 ? cum[i-1] : 0);
        long long cur = (i > 0 ? pos[i-1] : 0) + (pos[n-1]-pos[i+K-1]) + max(block_sum, 0LL);
        ans = max(ans, cur);
    }
    cout << ans << endl;
}





Measured memory_bytes: 6124
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
#include<bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll

ll mod=1e9+7;
ll mod1=1e9+5;
 
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}
 
// using namespace __gnu_pbds;
// #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solutions

int32_t main()
{
    IOS


 	int a,b,m;
 	cin>>a>>b>>m;
 	int x[a+1];
 	int y[b+1];
 	for(int i=1;i<=a;i++)
 		cin>>x[i];
 	for(int j=1;j<=b;j++)
 		cin>>y[j];
 	int ans=*min_element(x+1,x+a+1)+*min_element(y+1,y+b+1);
 	while(m--)
 	{
 		int p,q,r;
 		cin>>p>>q>>r;
 		ans=min(ans,x[p]+y[q]-r);
 	}
 	cout<<ans;

}       

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		int tmp, remainder;
		int[] next = {0, 0};
		Scanner in = new Scanner(System.in);
		next[0] = Integer.parseInt(in.next());
		next[1] = Integer.parseInt(in.next());
		
		if(next[0] < next[1]){
			tmp = next[1];
			next[1] = next[0];
			next[0] = tmp;
		}
		int i = 1;
		while(i == 1){
			remainder = gcd(next[0], next[1]);
			if(remainder == 0){
				System.out.println(next[1]);
				System.exit(0);
			}
			next[0] = remainder;
			remainder = gcd(next[1], next[0]);
			if(remainder == 0){
				System.out.println(next[0]);
				System.exit(0);
			}
			next[1] = remainder;			
		}
	}	
			
	public static int gcd(int big, int small){
		int remainder = big % small;
		return remainder;	
	}
	
}
		

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
using ll = long long;
using ull = unsigned long long;

int main() {
  int n; cin>>n;
  int ma = 0;
  int mi = 1001;
  rep(i, n) {
    int t; cin>>t;
    ma = max(ma, t);
    mi = min(mi, t);
  }
  cout << ma - mi;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=200005;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
#define lowbit(x) (x&(-x))
int g[N][26];
int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    while(cin>>n)
    {
        string s;
        memset(g,0,sizeof(g));
        for(int i=1;i<=n;i++)
        {
            cin>>s;
            int l=s.length();
            for(int j=0;j<l;j++)
            {
                g[i][s[j]-'a']++;
            }
        }
        int flag=0;
        for(int i=0;i<26;i++)
        {
            int mn=inf;
            for(int j=1;j<=n;j++)
            {
                mn=min(mn,g[j][i]);
            }
            for(int j=0;j<mn;j++)
            {
                flag=1;
                cout<<char(i+'a');
            }
        }
    //    if(!flag)
      //      cout<<"The answer is an empty string.";
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 20608
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		if(N==1) {
			System.out.println("Hello World");
		}else {
			System.out.println(scn.nextInt() + scn.nextInt());
		}
	}

}


Measured memory_bytes: 21716
#!/usr/bin/env python3

def factorization(n):
    arr = []
    temp = n
    i = 2
    cnt=0
    if temp%i==0:
        while temp%i==0:
            cnt+=1
            temp //= i
    return cnt



N = int(input())
A = list(map(int, input().split()))

ret = 0
for a in A:
    ret += factorization(a)

print(ret)


Measured memory_bytes: 10160
#include<iostream>


using namespace std;

int main(){

    int A,B; cin >> A >>B ;

    if(A == B)
        cout <<"Draw"<<endl;
    else if((A > B && B != 1) || A == 1)
        cout << "Alice"  << endl;
    else
        cout << "Bob" << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
s = ['']*3
s[0] = raw_input()
s[1] = raw_input()
s[2] = raw_input()

pos = [0]*3
turn = 0
while(pos[turn]<len(s[turn])):
    pos[turn] += 1
    turn = ord(s[turn][pos[turn]-1])-97
print(chr(turn+65))

Measured memory_bytes: 2568
#include <iostream>

uint32_t dfs(uint32_t N, uint32_t exist, uint32_t current) {
  uint32_t count = 0;
  if (current > N) return 0;
  if (current <= N && exist == 3 * 5 * 7) count++;

  count += dfs(N, (exist % 3) ? exist * 3 : exist, current * 10 + 3);
  count += dfs(N, (exist % 5) ? exist * 5 : exist, current * 10 + 5);
  count += dfs(N, (exist % 7) ? exist * 7 : exist, current * 10 + 7);
  return count;
}

int main() {
  uint32_t N = 0;
  std::cin >> N;

  std::cout << dfs(N, 1, 0) << std::endl;

  return 0;
}

Measured memory_bytes: 256
X, K, D = map(int, input().split())
a = int(X/D)

if -K <= a <= K:
    if a%2 == K%2:
        print(abs(X-a*D))
    else:
        print(min(abs(X-(a-1)*D), abs(X-(a+1)*D)))
else:
    print(min(abs(X-K*D), abs(X+K*D)))

Measured memory_bytes: 61868
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<((int)n);i++)
#define REP(i,n)	for(int i=0;i<=((int)n);i++)
#define srep(i,a,n)	for(int i=a;i<((int)n);i++)
#define SREP(i,a,n)	for(int i=a;i<=((int)n);i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll sqrtll(ll x) {
	ll left = 0, right = x;
	rep(i, 100) {
		ll mid = (left + right) >> 1;
		if (mid*mid <= x)	left = mid;
		else	right = mid;
	}
	return left;
}
ll gcd(ll a, ll b) {
	return a % b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	printf("Case #%d: ", x)
#define DEBUG 0
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

int main() {
	int n;	cin >> n;
	vint a(n);
	rep(i, n)	cin >> a[i];
	int r = 0;
	ll ret = 0;
	int base = 0;
	rep(l, n) {
		while (r < n&&(base&a[r]) == 0) {
			base |= a[r++];
		}
		ret += r - l;
		base ^= a[l];
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1024
//10
#include<iostream>

using namespace std;

int main(){
  int n;
  cin>>n;
  while(n--){
    int y,m,d;
    cin>>y>>m>>d;
    int e=0;
    while(y!=1000||m!=1||d!=1){
      e++;
      d++;
      if(d>((y%3==0||m%2==1)?20:19)){
	d=1;
	m++;
	if(m>10){
	  m=1;
	  y++;
	}
      }
    }
    cout<<e<<endl;
  }
  return 0;
}
      

Measured memory_bytes: 1164
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
 
n, c = na()
stc = []
for i in range(n):
    stc.append(na())
stc.sort(key=lambda x: (x[2], x[0]))

nstc=[]
for i in range(n):
    if(len(nstc)>0 and nstc[-1][2]==stc[i][2] and nstc[-1][1]==stc[i][0]):
        nstc[-1][1]=stc[i][1]
    else:
        nstc.append(stc[i])
n=len(nstc)
h=[0]*200005
for i in range(n):
    h[2*nstc[i][0]-1]+=1
    h[2*nstc[i][1]]+=-1
for i in range(len(h)-1):
    h[i]+=h[i-1]
print(max(h))
    


Measured memory_bytes: 36820
import math
import numpy as np

N, D = map(int, input().split())
p = [[int(i) for i in input().split()] for i in range(N)]
X = np.array(p)
count = 0
for i in range(N):
    j = i + 1
    while(j < N):
        test = X[i] - X[j]
        dist = math.sqrt(sum(test * test))
        if(dist.is_integer()):
            count += 1
        j += 1
print(count)


Measured memory_bytes: 12496
from collections import deque
q=deque();K=int(input());a=q.append;a((1,1));m={}
while len(q):
 n,s=q.popleft()
 if not n in m:m[n]=s;q.appendleft((n*10%K,s));a(((n+1)%K,s+1))
print(m[0])

Measured memory_bytes: 24300
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
#include<math.h>
using namespace std;
int main() {
	long long int a, b, c, d, lcm, sm, um, cnt = 0, sc, uc;
	cin >> a >> b >> c >> d;
	a = a - 1;
	long long int cc = c, dd = d;
	while (1) {
		cc = cc % dd;
		if (cc == 0)break;
		dd = dd % cc;
		if (dd == 0)break;
	}
	lcm = c * d / (max(cc, dd));

	sm = a / lcm;
	um = b / lcm;

	cnt = lcm - (lcm / c) - (lcm / d) + 1;

	sc = sm * cnt;
	uc = um * cnt;
	cnt = 0;
	cnt = (a - (sm*lcm))-(((a - (sm*lcm)) / c) + ((a - (sm*lcm)) / d));

	sc = sc + cnt;
	cnt = 0;
	cnt = (b - (um*lcm))-(((b - (um*lcm)) / c) + ((b - (um*lcm)) / d));
	uc = uc + cnt;

	cout << uc - sc << endl;

}
	


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# 解説pdf https://img.atcoder.jp/agc026/editorial.pdf を見た



import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys


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



def solve(A, B, C, D):
    if B > A:
        return "No"
    if B > D:
        return "No"
    if B <= C:
        return "Yes"

    g = gcd(B, D)
    if B - g + (A % g) > C:
        return "No"
    else:
        return "Yes"


T = int(input())
for t in range(T):
    A, B, C, D = map(int, input().split())
    print(solve(A, B, C, D))
    



Measured memory_bytes: 6440
import sys

if __name__=="__main__":
    ab=[]
    cd=[]
    [n,m]=map(int,raw_input().split(" "))
    for i in range(n):
        ab.append( map(int,raw_input().split(" ")) )
    for j in range(m):
        cd.append( map(int,raw_input().split(" ")) )
    for i in range(n):
        min=sys.maxint
        index=0
        for j in range(m):
            distance = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
            if min > distance :
                min=distance 
                index=j
        print(index+1)


Measured memory_bytes: 32364
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,a[100100],ans;
int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n;i++)
		scanf("%d",&a[i]);
	if(a[1] == 1)ans++;
	for(int i = 2;i <= n;i++)
	{
		if(a[i] == i && a[i - 1] ==  i - 1)a[i] = n + i;
		if(a[i] == i)ans++;
	}
	printf("%d\n",ans);
}

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

def solve():
    W, a, b = list(map(int, input().split()))
    
    if a+W <= b:
        ans = b - (a+W)
    elif b+W <= a:
        ans = a- (b+W)
    else:
        ans = 0
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    bool ans = true;
    if(s.size()%2 != 0) ans = false;
    rep(i, s.size()){
        if(i%2 == 0){
            if(s[i] != 'h') ans = false;
        }
        else{
            if(s[i] != 'i') ans = false;
        }
    }
    ans ? Yes() : No();
}

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

int main() {
  int K;
  string S;
  cin>>K>>S;
  int size = S.size(); //intで設定しないとKと比較できない
 
 //型を合わせたから出力できた 
  if(size<=K){
    cout<<S<<endl;
  }
  
  //ので本番はここから
  //たぶんSの文字0からどんどん足してく
  else{
    string nico;
    for(int i=0;i<K;i++){
    string tasu;
    tasu = S[i];//[]だねありがとう
    nico +=tasu;//文字列をどんどん足していけば良いんだよな
    }
    cout<<nico<<"..."<<endl;    
  
  //やったのでは!!!
  }
}
  


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    string a, b;
    cin >> a >> b;
    string ans ="";
    if(a.size() < b.size()){
        ans = "LESS";
    } else if(a.size() > b.size()){
        ans = "GREATER";
    } else {
        bool flag = true;
        for(int i = 0; i < a.size(); i++){
            if(a[i] == b[i]){
                continue;
            } else {
                if(a[i] < b[i]){
                    ans = "LESS";
                } else {
                    ans = "GREATER";
                }
                flag = false;
                break;
            }
        }
        if(flag){
            ans = "EQUAL";
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  cin >> A;
  cout << max(-1, N - accumulate(all(A), 0)) << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <memory>
#include <initializer_list>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int n; cin >>n;
	vector<ll> a(n);
	cinf(n,a);
	vector<ll > s(n+1,0);
	for(int i=0;i<n;i++){
		s[i+1]=s[i]+a[i];
	}
	map<ll,ll> mp;
	for(int i=0;i<=n;i++){
		mp[s[i]]++;
	}
	ll cnt=0;
	for(auto p:mp){
		cnt+=p.second*(p.second-1)/2;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;



int main()
{
	ll a, b, k;
	cin >> a >> b >> k;

	if (a + b < k) {
		a = b = 0;
	} else {
		if (a < k) {
			b = b - k + a;
			a = 0;
		} else {
			a -= k;
		}
	}

	printf("%lld %lld", a, b);

	return 0;
}



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

typedef long long ll;

 
int main(){
  string s;
  cin >> s;
  for(int i=s.length()-1; i>0; i--){
    bool ok = true;
    string tmp = s.substr(0,i);
    int l = tmp.length();
    if(i%2==1) continue;
    for(int j=0; j<l/2; j++){
      if(tmp[j]!=tmp[j+i/2]) ok = false;
    }
    if(ok){
      cout << l << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const ll MOD = 998244353;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int x, k; cin >> x >> k;
	vi r(k+1);
	REP(i, k) cin >> r[i + 1];
	vi lit(k+1), much(k+1), els(k+1);
	vi conlit(k+1), conmuch(k+1);
	lit[0] = 0; much[0] = x;
	conlit[0] = 0; conmuch[0] = x;
	REP(i, k)
	{
		int dif = r[i + 1] - r[i];
		if (i % 2 == 0)
		{
			els[i + 1] = els[i] - dif;
			if (lit[i] - dif < 0)
			{
				lit[i+1] = 0;
			}
			else
			{
				lit[i + 1] = lit[i] - dif;
			}
			conlit[i + 1] = max(conlit[i], -els[i + 1]);
			much[i + 1] = max(0, much[i] - dif);
			conmuch[i + 1] = conmuch[i];
		}
		else
		{
			els[i + 1] = els[i] + dif;
			if (much[i] + dif > x)
			{
				much[i + 1] = x;
			}
			else
			{
				much[i + 1] = much[i] + dif;
			}
			conmuch[i + 1] = min(conmuch[i], x - els[i + 1]);
			lit[i + 1] = min(x, lit[i] + dif);
			conlit[i + 1] = conlit[i];
		}
	}
	int q; cin >> q;
	REP(i, q)
	{
		int t, a; cin >> t >> a;
		if (t >= r[k])
		{
			int ans;
			if (k % 2 == 0)
			{
				//minus
				if (conlit[k] > a) ans = lit[k] - (t - r[k]);
				else if (conmuch[k] < a) ans = much[k] - (t - r[k]);
				else ans = a + els[k] - (t - r[k]);
				cout << max(0, ans) << endl;
			}
			else
			{
				//plus
				if (conlit[k] > a) ans = lit[k] + (t - r[k]);
				else if (conmuch[k] < a) ans = much[k] + (t - r[k]);
				else ans = a + els[k] + (t - r[k]);
				cout << min(x, ans) << endl;
			}
			continue;
		}
		int lb = 0, ub = k;
		while (ub - lb > 1)
		{
			int mid = (ub + lb) / 2;
			if (r[mid] > t) ub = mid;
			else lb = mid;
		}
		int ans;
		if (lb % 2 == 0)
		{
			//minus
			if (conlit[lb] > a) ans = lit[lb] - (t - r[lb]);
			else if (conmuch[lb] < a) ans = much[lb] - (t - r[lb]);
			else ans = a + els[lb] - (t - r[lb]);
			cout << max(0, ans) << endl;
		}
		else
		{
			//plus
			if (conlit[lb] > a) ans = lit[lb] + (t - r[lb]);
			else if (conmuch[lb] < a) ans = much[lb] + (t - r[lb]);
			else ans = a + els[lb] + (t - r[lb]);
			cout << min(x, ans) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3584
///Combination + Bit mask

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9;
#define Fast    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sz      15

int arr[sz][sz];
vector < int > cost;

int main(){
    Fast;
    int n,m,x,i,j,val;

    cin>>n>>m>>x;
    for(i=1; i<=n; i++){
        cin>>val;
        cost.push_back(val);
        for(j=1; j<=m; j++){
            cin>>arr[i][j];
        }
    }

    int ans=inf;
    int all=(1<<n);
    for(int mask=0; mask<all; mask++){
        int c=0;
        vector < int > level(m+1);
        for(i=1; i<=n; i++){
            if(mask&(1<<(i-1))){
                c+=cost[i-1];
                for(j=1; j<=m; j++){
                    level[j]+=arr[i][j];
                }
            }
        }
        bool ok=true;
        for(i=1; i<=m; i++){
            if(level[i]<x)ok=false;
        }
        if(ok)ans=min(ans,c);
    }
    if(ans==inf)cout<<-1<<endl;
    else    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>
int main(void){
    int a,b,i,sign,c=0;
    for(;sign=1,scanf("%d %d",&a,&b),b;c++){
        if(c)
            puts("");
        for(i=a;i<=b;i++)
            if(!(i%400) || (i%100!=0 && i%4==0)){
                sign=0;
                printf("%d\n",i);
            }
        if(sign)
            puts("NA");
    }
    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    int tmp = 0;
    int ind;
    for (int i = 1; i <= N; i++) {
        tmp += i;
        if(tmp >= N){
            ind = i;
            break;
        }
    }
    for (int i = 1; i <= ind; i++) {
        if(i == tmp - N) continue;
        printf("%d\n", i);
    }
}

Measured memory_bytes: 3776
// Problem : A - Multiplication 1
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	ll a,b;
	cin >> a >> b;
	cout << a*b << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


Measured memory_bytes: 3648
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#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 <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << “\t:“;for(const auto& xxx : v){std::cerr << xxx << ” “;}std::cerr << “\n”;}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << ” ” << xxx.second << “\n”;}}

using LL = long long;

constexpr LL INF = 1e12;

int main() {

    int N;
    cin >> N;

    vector<LL> h(N);
    for (int i = 0; i < N; i++)cin >> h[i];

    vector<LL> dp(N, INF);
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= 2; j++) {
            int from = max(0, i - j);
            dp[i] = min(dp[i], dp[from] + abs(h[from] - h[i]));
        }
    }

    cout << dp.back() << endl;

    return 0;
}































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

using namespace std;
typedef long long int ll;
int main() {
    
    ll n, k, a[200001], i, j;
    cin>>n>>k;
    for(i=1;i<=n;i++)
    scanf("%lld", &a[i]);
    
    for(i=k+1;i<=n;i++)
    {
        
        if(a[i]>a[i-k])
        printf("Yes\n");
        else
        printf("No\n");
    }
    
    
    return 0;
}

Measured memory_bytes: 5324
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
    double a, b, x;
    cin >> a >> b >> x;

    double h = x / (a * a);

    if (h * 2 >= b) {
        cout << setprecision(15) << atan((b - h) * 2 / a) / M_PI * 180 << endl;
    }
    else {
        double h2 = x / (a * b);
        cout << setprecision(15) << atan(b / (h2 * 2)) / M_PI * 180 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

char buf[1001];

void func(){

	scanf("%s",buf);

	int length;
	for(length = 0; buf[length] != '\0'; length++);

	stack<int> S;

	for(int i = length-1; i >= 0; i--){
		S.push(buf[i]-'0');
	}

	int count = 0;

	while(S.size() > 1){

		int num1 = S.top();
		S.pop();
		int num2 = S.top();
		S.pop();

		int next = num1+num2;
		count++;

		while(next >= 10){
			num1 = next/10;
			num2 = next%10;

			next = num1+num2;
			count++;
		}
		S.push(next);
	}


	if(count%2 == 0){
		printf("Audrey wins.\n");
	}else{
		printf("Fabre wins.\n");
	}
}

int main(){

	int N;
	scanf("%d",&N);

	for(int i = 0; i < N; i++)func();

}

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

int main()
{
    string s, t;
    cin>>s>>t;
    int dp[s.length()+1][t.length()+1];
    for(int i=0; i<=s.length(); i++)
    {
        for(int j=0; j<=t.length(); j++)
        {
            if(i == 0 || j == 0)
                dp[i][j] = 0;
            else if(s[i-1] == t[j-1])
                dp[i][j] = 1 + dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    int len = dp[s.length()][t.length()];
    //cout<<dp[s.length()][t.length()]<<endl;
    int i = s.length(), j = t.length();
    string temp = "";
    while(i >=0 && j >=0 && len!=0)
    {
        if(s[i-1] == t[j-1])
        {
            temp.push_back(s[i-1]);
            i--, j--, len--;
        }
        else if(dp[i-1][j] > dp[i][j-1])
            i--;
        else
            j--;
    }
    reverse(temp.begin(), temp.end());
    cout<<temp;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

const int MAX_N = 3000001;

int prime[MAX_N];
bool is_prime[MAX_N + 1];

void eratos(int n) {
    int p = 0;
    for (int i = 0; i <= n; ++i) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    is_prime[6] = true;
    for (int i = 2; i <= n; ++i) {
        if (is_prime[i] and (i%7==1 or i%7==6)) {
            prime[p++] = i;
            for (int j = 2*i; j <= n; j += i) is_prime[j] = false;
        }
        else {
            is_prime[i] = false;
        }
    }
}

// 素因数分解
map<int, int> prime_factor(int n) {
    map<int, int> res;
    for (int i=2;i<n;++i) {
        if (n%i==0 and is_prime[i]) {
            ++res[i];
            //n /= i;
        }
    }

    if (is_prime[n] and (n%7 == 1 or n%7 == 6)) res[n] = 1;
    //if (n != 1) res[n] = 1;
    return res;
}

int main() {
    eratos(MAX_N);
    int n;
    while (cin >> n) {
        if (n == 1) break;
        map<int, int> tmp = prime_factor(n);
        cout << n << ": ";
        int sz = 0;
        for (auto t : tmp) {
            cout << t.first;
            if (sz+1 < tmp.size()) cout << " ";
            sz++;
        }
        cout << endl;
    }
    return 0;
}



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

using namespace std;

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

#define X 13

void print_answer(char mark, int cards[X]) {
    REP(i, X) {
        if(cards[i] != 0)
            printf("%c %d\n", mark, cards[i]);
    }
}

int main() {

    int s_cards[X] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
    int h_cards[X] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
    int c_cards[X] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
    int d_cards[X] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};

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

    int num;
    char mark;

    REP(i, n) {
        // scanf(" %c %d ", &mark, &num);
        cin >> mark >> num;
        if(mark == 'S') {
            s_cards[num-1] = 0;
        } else if(mark == 'H') {
            h_cards[num-1] = 0;
        } else if(mark == 'C') {
            c_cards[num-1] = 0;
        } else if(mark == 'D') {
            d_cards[num-1] = 0;
        }
    }

    print_answer('S', s_cards);
    print_answer('H', h_cards);
    print_answer('C', c_cards);
    print_answer('D', d_cards);

    return 0;
}



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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b;
    cin>>a>>b;
    string s = "", s1="";
    for(int i=0;i<a;++i)
    {
        s+= to_string(b);
    }
    for(int i=0;i<b;++i)
    {
        s1+= to_string(a);
    }
    cout<<min(s1,s);
}


Measured memory_bytes: 256
from itertools import permutations
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int, input().split()))
lp = list(permutations(p, n))
lq = list(permutations(q, n))
lp.sort()
lq.sort()
a=lp.index(p)
b=lq.index(q)
print(abs(a-b))

Measured memory_bytes: 12788
def station_bus?(str)
  return false unless str.length == 3

  valid = false
  str.each_char.with_index do |s, i|
    return false unless ['A', 'B'].include?(s)
    next if i.zero?
    valid = true if s != str[i-1]
  end
  valid
end

str = gets.chomp!
puts station_bus?(str) ? 'Yes' : 'No'

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <math.h>
#include <cstdint>
#include <cstring>

using namespace std;

//#define DEBUG

//2019-08-18 B
int main()
{
	long long int n;

	cin >> n;

#ifdef DEBUG
	cout << n << endl;
#endif

	long long int *a;
	a = new long long int[n];

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

#ifdef DEBUG
	for (int i = 0; i < n; i++){
		cout << a[i] << endl;
	}
#endif

	double tmp = 0;

	for (int i = 0; i < n; i++){
		tmp += (1 / (float)a[i]);
	}

	double ans = 1 / tmp;

	cout << ans << endl;
#ifdef DEBUG
	system("pause");
#endif
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

void main() {
    string s, t;
    while (true) {
        s = readln.chomp;
        if (s == "") break;
        t = readln.chomp;
        static int f(string s, string t) {
            int ans = 0;
            foreach (i; 0 .. s.length) {
                int c = 0;
                for (auto j = 0; j < t.length && i + j < s.length; j++) {
                    if (s[i + j] == t[j]) {
                        c++;
                    } else {
                        c = 0;
                    }
                    ans = max(ans, c);
                }
            }
            return ans;
        }
        writeln(max(f(s, t), f(t, s)));
    }
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin>>s;
  
  bool isA = false;
  bool isC = false;
  
  int ccount = 0;
  int isupperc = 0;
    
  string ans="WA";
  
  
  if (s[0]=='A') {
    isA = true;
  }
  
  
  for (int i = 2; i < s.length() - 1; ++i) {
    if(s[i]=='C') {
      isC = true;
      ++ccount;
    }
  }
  
  rep(i, s.length()) {
    if(isupper(s[i])) {
      ++isupperc;
    }
  }
  
  if(isA and isC and ccount==1 and isupperc==2) {
    ans="AC";
  }
  
  cout<<ans;
  
  return 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
signed main(){
  int a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  if(v-w<=0) cout<<"NO\n";
  else{
    if(a<0||b<0){
      int l=min(a,b);
      l=0-l;
      a+=l;
      b+=l;
    }
    if(v*t-w*t>=abs(a-b)) cout<<"YES\n";
    else cout<<"NO\n";
  }
}

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

int main(){
  int n;
  int tmp = 2;
  queue<int> que;

  cin >> n;
  int ans = n;

  while(n > 1 && tmp*tmp <= n){
    if(n % tmp == 0){
      que.push(tmp);
      n /= tmp;
    }else{
      tmp++;
    }
  }

  if(n > 1){
    que.push(n);
  }

  cout << ans << ":";
  while(!que.empty()){
    cout << " " << que.front();
    que.pop();
  }

  cout << endl;
  return 0;

}





Measured memory_bytes: 3144
import std.stdio, std.string, std.array, std.conv, std.algorithm;

void main() {
    foreach (i; 0 .. 3000) {
        int[] x = readln.chomp.split.to!(int[]);
        if (x[0] == 0 && x[1] == 0) break;
        writeln(min(x[0], x[1]), " ", max(x[0], x[1]));
    }
}


Measured memory_bytes: 2600
#include<bits/stdc++.h>
using namespace std;
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t;
	char gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			return s==t?EOF:*s++;
		}
		return *s++;
	}
	char c;
	template<class IT>inline void gi(IT &x){
		x=0;c=gc();while(c<'0'||c>'9')c=gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^'0');c=gc();}
	}
};
using io::gi;
#define ll long long
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
const int N=5005;const ll inf=1000000000000ll,INF=10000000000000000ll;
int a[N],b[N],c[N];
ll d[N],e[N];
int main(){
	int n,m,p,t,i;
	scanf("%d%d%d",&n,&m,&p);
	for(i=1;i<=m;++i){scanf("%d%d%d",&a[i],&b[i],&c[i]);c[i]=p-c[i];}
	
	for(i=2;i<=n;++i)d[i]=INF;t=n;
	while(t--)for(i=1;i<=m;++i)cmin(d[b[i]],d[a[i]]+c[i]);
	
	for(i=1;i< n;++i)e[i]=INF;t=n;
	while(t--)for(i=1;i<=m;++i)cmin(e[a[i]],e[b[i]]+c[i]);
	
//	for(i=1;i<=n;++i)printf("%lld ",d[i]);printf("\n");
//	for(i=1;i<=n;++i)printf("%lld ",e[i]);printf("\n");
	for(i=1;i<=m;++i)if(d[a[i]]<inf&&e[a[i]]<inf&&d[b[i]]<inf&&e[b[i]]<inf&&d[b[i]]>d[a[i]]+c[i]){printf("-1");return 0;}
	if(d[n]<0ll)printf("%lld",-d[n]);else printf("0");
	return 0;
}


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

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

//#define debug(x) ;
#define debug(x) cerr << #x << " = " << x << "\n";

ostream& operator<<(ostream& cerr, vector<ll> aux) {
    cerr << "[";
    for (auto e : aux) cerr << e << ' ';
    cerr << "]";
    return cerr;
}

const int maxN = 200011;
const int maxLen = 2;

int n;
char s[maxN];
int dp[maxN][maxLen];

bool same(int i, int l1, int j, int l2) {
    //cerr << i << ' ' << l1 << ' ' << j << ' ' << l2 << '\n';
    if (l1 != l2) return false;

    for (int k = 0; k <= l1; k++)
        if (s[i - k] != s[j - k])
            return false;

    return true;
}

int main()
{
    //freopen("test.in","r",stdin);

    scanf("%s", s + 1);
    n = strlen(s + 1);
    s[0] = '@';

    for (int i = 1; i <= n; i++) {
        for (int len = 0; len < maxLen; len++) {
            dp[i][len] = -1;

            int j = i - len - 1;
            if (j < 0) break;

            for (int prv = 0; prv < maxLen; prv++) {
                int bg = j - prv;

                if (bg < 0) break;
                if (dp[j][prv] < 0) continue;

                if (!same(j, prv, i, len)) 
                    dp[i][len] = max(dp[i][len], dp[j][prv] + 1);
            }
        }
    }

    int answer = dp[n][0];
    for (int i = 1; i < maxLen; i++)
        answer = max(answer, dp[n][i]);
    cout << answer;


    return 0;
}


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

int main(){
  ll H,W,ans,x,y;
  cin>>W>>H>>x>>y;
  if(H%2==1&&W%2==1){
    ans=H*W/2;
    cout<<ans;
    cout<<".500000000000";
  }
  else{
    ans=H*W/2;
    cout<<ans;
    cout<<".00000000000";
  }
  cout<<" ";
  if(W==x*2&&H==y*2)
    cout<<1<<endl;
  else
    cout<<0<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline()

N = int(input())
A1 = [int(i) for i in input().split()]
A2 = [int(i) for i in input().split()]

ans = 0
for i in range(N):
	ans = max(sum(A1[:i+1]) + sum(A2[i:]), ans)
	
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return (a / g) * b;
}

int main() {
	ll a, b, c, d; cin >> a >> b >> c >> d;
	ll LCM = lcm(c, d);

	cout << b-a+1-((b / c - (a-1) / c) + (b / d - (a-1) / d) - (b / LCM - (a-1) / LCM)) << endl;

	return 0;
}

Measured memory_bytes: 256
import fractions
from functools import reduce
import math

MOD = 10**9 + 7


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0


def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m


# def pathes(x, y):
#     xf = None
#     yf = None
#     xyf = None
#     temp = 1
#     for i in range(1, x + y + 1):
#         temp *= i % MOD
#         if i == x:
#             xf = temp
#         if i == y:
#             yf = temp
#         if i == x + y:
#             xyf = temp
#     # xf = math.factorial(x) % MOD
#     # yf = math.factorial(y) % MOD
#     # xyf = math.factorial(x + y) % MOD

#     return xyf * modinv(xf * yf % MOD, MOD)


def pathes(rf, cf, rcf):
    return rcf * modinv((rf * cf) % MOD, MOD)


def main():
    r1, c1, r2, c2 = map(int, input().split())

    f = [1 for _ in range(r2 + c2 + 2 + 1 + 1)]

    for i in range(1, r2 + c2 + 2 + 1):
        f[i] = f[i - 1] * i % MOD

    a = (pathes(f[r1], f[c1], f[r1 + c1]) - 1) % MOD
    b = (pathes(f[r1], f[c2 + 1], f[r1 + c2 + 1]) - 1) % MOD
    c = (pathes(f[r2 + 1], f[c1], f[r2 + 1 + c1]) - 1) % MOD
    d = (pathes(f[r2 + 1], f[c2 + 1], f[r2 + c2 + 2]) - 1) % MOD

    print((d - c - b + a) % MOD)


main()


Measured memory_bytes: 84404