akhauriyash/Code-Regression huggingface dataset:
"""
Atcoder Beginner Contest 118 Problem A(https://atcoder.jp/contests/abc118/tasks/abc118_a)
my code: https://atcoder.jp/contests/abc118/submissions/4279133
"""

A, B = map(int, input().split())
if B % A == 0:
  print(A+B)
else:
  print(B-A)

Measured memory_bytes: 2940
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;
ll black[100100];
ll white[100100];

void dfs(int now, vector<vector<int> > &G, int p) {
    black[now]=1;
    white[now]=1;
    for(int to:G[now]){
        if(to==p) continue;
        dfs(to,G,now);
        white[now]*=white[to]+black[to];
        black[now]*=white[to];
        white[now]%=MOD;
        black[now]%=MOD;
    }
}

int main(){
    int n;
    cin>>n;
    vector<vector<int> > G(n);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0,G,-1);
    ll ans=white[0]+black[0];
    ans%=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 15436
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
using namespace std; const int N=3000010;
inline int read()
{
	int s=0, w=1; ri char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar(); return s*w;
}
void print(int x) {if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
int k,ans[N],cnt;
inline void Init()
{
	queue<int> Q;
	for(ri int i=1;i<=9;i++) Q.push(i);
	while(!Q.empty())
	{
		int X=Q.front(); Q.pop();
		if(X>1e10) return;
		ans[++cnt]=X; int p=X%10; Q.push(X*10+p);
		if(p) Q.push(X*10+p-1);
		if(p^9) Q.push(X*10+p+1);
	}
}
signed main()
{
	k=read(); Init();
	sort(ans+1,ans+cnt+1);
	printf("%lld\n",ans[k]);
	return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <string>
using namespace std;
int main() {
char p[10000];
string ret;
for(int i = 0; i < 3; i++) {
scanf("%s", p);
ret += (p[0] - 'a' + 'A');
}
printf("%s\n", ret.c_str());
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define RREP(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector
#define dump(x)  cerr << #x << " = " << (x) << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int from, to; int cost; };
ostream& operator << (ostream& s, const edge& e) {
   s << "(" << e.from << "->" << e.to << ": " << e.cost << ")";
   return s;
}
bool operator< (const edge &edge1, const edge &edge2){
   return edge1.cost < edge2.cost;
};

const int INF = 1e18;
const int MOD = 1e18;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const map<T1,T2>& m) {
   s << "{";
   for (auto i = m.begin(); i != m.end(); ++i) {
      s << i->first << ":" << i->second;
      if (next(i) != m.end()) s << ", ";
   }
   s << "}";
   return s;
}

vector<bool> isprime;
void init_isprime(int N)
{
   isprime.resize(N+1, true);
   isprime[0] = isprime[1] = false;
   for(int i = 2; i <= N; i++) {
      if (isprime[i]) {
         for (int j = 2; i*j <= N; j++) {
            isprime[i*j] = false;
         }
      }
   }
}

void factorize(map<int,int>& fact_n, int M)
{
   int tmpM = M;
   for(int i = 2; i < isprime.size(); i++) {
      if (!isprime[i]) continue;
      while (tmpM % i == 0) {
         fact_n[i]++;
         tmpM /= i;
      }
   }
   if (tmpM != 1) fact_n[tmpM]++;
}

int powM(int x, int n) {
   int res = 1;
   while (n > 0) {
      if ((n & 1) == 1) {
         res = mod(res * x);
      }
      x = mod(x * x);
      n >>= 1;
   }
   return res;
}

signed main()
{
   int N, P; cin >> N >> P;

   init_isprime((int)sqrt(P)+1);
   map<int, int> fact_n;
   factorize(fact_n, P);

   int ans = 1;
   EACH(i, fact_n) {
      ans *= powM(i->first, (i->second / N));
   }

   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

LL comb2(LL val);

int main(){
    int N;
    cin >> N;
    vector<string> si(N);
    REP(i,N){
        cin >> si[i];
    }

    REP(i,N){
        string s = si[i];
        sort(s.begin(), s.end());
        si[i] = s; 
    }

    sort(si.begin(), si.end());
    LL count=0;

    string pre = si[0];
    LL tmp_count = 1;
    FOR(i,1,N){
        if(pre==si[i]){
            tmp_count++;
        }else{
            count += comb2(tmp_count);
            tmp_count = 1;
        }
        pre = si[i];
    }
    count += comb2(tmp_count);

    cout << count << endl;
    return 0;
}

LL comb2(LL val){
    return val*(val-1)/(2*1);
}

Measured memory_bytes: 6432
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
		String S = scan.next();
		
		if (S.substring(0, N /2).equals(S.substring(N /2))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <cstdint>

using namespace std;

static void inputArray(uint32_t A[], int num) {
  for (int i = 0; i < num; i++) {
    cin >> A[i]; 
  }
}

static void printArray(uint32_t A[], int num) {
  for (int i = 0; i < num; i++) {
    cout << (i != 0 ? " " : "") << A[i];
  }
  cout << endl; 
}

static int compared = 0;

static vector<uint32_t> L(250000);
static vector<uint32_t> R(250000);

static inline void merge(uint32_t A[], uint32_t left, uint32_t mid, uint32_t right) {
  uint32_t n1 = mid - left;
  uint32_t n2 = right - mid;

  L.assign(&A[left], &A[left + n1]);
  R.assign(&A[mid], &A[mid + n2]);
/*
  for (int i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (int i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
*/
  L[n1] = R[n2] = UINT32_MAX;

  for (uint32_t i = 0, j = 0, k = left; k < right; k++) {
    compared++;
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  } 
}

static inline void mergeSort(uint32_t A[], uint32_t left, uint32_t right) {
  if (left + 1 < right) {
    uint32_t mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  } 
}

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

  vector<uint32_t> A(n);
  inputArray(&A[0], n);
  
  mergeSort(&A[0], 0, n);
  
  printArray(&A[0], n);
  
  cout << compared << endl;
  
  return 0;
}



Measured memory_bytes: 6764
N=int(input())

xlist=[1]
for d in range(1,10**9):
  if 6**d>100000:
    break
  xlist.append(6**d)
for d in range(1,10**9):
  if 9**d>100000:
    break
  xlist.append(9**d)
xlist.sort()
#print(xlist)

dp=[0,1]+[0]*(N-1)
for i in range(2,N+1):
  min_dp=10**9
  for x in xlist:
    if i-x>=0:
      min_dp=min(min_dp,dp[i-x])
  dp[i]=min_dp+1
  
#print(dp)
print(dp[-1])

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/
constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,k;
	cin>>a>>b>>k;
	int c=0,ans=1;
	rrep(i,101){
		if(a%i==0 and b%i==0){
			c++;
			ans=i;
			if(c==k){
				puta(i);
				return 0;
			}
		}
	}
	return 0;
}

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

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

  string S;
  cin >> S;

  int result = 0;
  for (int i = 1; i < N; i++) {
    if (S.at(i - 1) == S.at(i)) result++;
  }
  result += 2 * K;

  if (result > N - 1) {
    cout << N - 1 << endl;
  } else {
    cout << result << endl;
  }

  return 0;
}

Measured memory_bytes: 512
import math
import collections
import sys

input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]

n=I()
info=[]
for i in range(1,n+1):
    if i%10!=0:
        info.append(str(i)[0]+str(i)[-1])
#print(info)
c=collections.Counter(info)
#print(c)
ans=0
for i in range(1,10):
    for j in range(1,10):
        if i==j:
            ans+=(c[str(i)+str(j)])**2
            #print(i,j,end=" ")
            #print((c[str(i)+str(j)])**2)
        else:
            ans+=(c[str(i)+str(j)])*(c[str(j)+str(i)])
            #print(i,j,end=" ")
            #print((c[str(i)+str(j)])*(c[str(j)+str(i)]))
print(ans)

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

#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define pfis(a) printf("%d ",a);
#define pfls(a) printf("%lld ",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(int i=a;i<b;i++)
#define mem(dp,a) memset(dp,a,sizeof dp);
#define pb(a) push_back(a);
#define mp(a,b) make_pair(a,b)
#define ll long long

const ll mod=1e9+7;

int main()
{
    int n;
    sfi(n)

    int arr[n][3];
    f(i,0,n)
    {
        f(j,0,3)
            sfi(arr[i][j])
    }

    int dp[n][3];
    f(j,0,3)
        dp[0][j]=arr[0][j];

    f(i,1,n)
    {
        f(j,0,3)
        {
            dp[i][j]=max((dp[i-1][(j+1)%3]+arr[i][j]),(dp[i-1][(j+2)%3]+arr[i][j]));
        }
    }
    
    int ans=0;

    f(i,0,3)
        ans=max(ans,dp[n-1][i]);
        
    pfin(ans)

    return 0;
}

Measured memory_bytes: 2560
function Main(input){
    const arr = input.split(' ').map(Number);
    let K = arr[3];
    let total=0;
 
    if(K>=arr[0]){
        total += arr[0];
        K -= arr[0];
    } else {
        total += K;
        console.log(total);
        return;
    }
    K -= arr[1];    
    console.log(K>0 ? total-K:total)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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


int main(){
  int dis = 0;
  int n;

  cin >> n;
  int *a = new int[n+2];
  a[0] = 0;
  a[n+1] = 0;
  for(int i=1;i<n+1;++i) cin >> a[i];
  
  int counter = 0,i=0;
  while(i<n+2){
    if(a[i] == 1){
      ++counter;
    }else{
      if(dis < counter + 1) dis = counter + 1;
      counter = 0;
    }
    ++i;
  }

  cout << dis << endl;

  delete[] a;

  return 0;
}



Measured memory_bytes: 3100
#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>;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    int total = 0;
    rep(i, n) total += a.at(i);

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    if(a.at(m-1) >= (double) total/(4*m)) cout << "Yes" <<endl;
    else cout << "No" <<endl;

    return 0;
}

Measured memory_bytes: 256
import sys
import math
sys.setrecursionlimit(int(1e6))

A = [[0]*3]*3
A[0] = list(map(int, input().split()))
A[1] = list(map(int, input().split()))
A[2] = list(map(int, input().split()))

N = int(input())
b = [0] * N
for i in range(N):
    b[i] = int(input())

c = [[0]*3 for i in range(3)]
for bn in b:
    for m in range(3*3):
        i = m % 3
        j = m // 3
        if (A[i][j] == bn):
            c[i][j] = 1
            break

ans = 'No'
for i in range(3):
    if sum(c[i]) == 3:
        ans = 'Yes'
        break
    if sum([c[0][i], c[1][i], c[2][i]]) == 3:
        ans = 'Yes'
        break
else:
    if sum([c[0][0], c[1][1], c[2][2]]) == 3:
        ans = 'Yes'
    elif sum([c[2][0], c[1][1], c[0][2]]) == 3:
        ans = 'Yes'

print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int n,m,k,kk[1000],kkk[1000],i,j,a,c;
	scanf("%d%d",&n,&m);
	for(i=0;i<2*n+1;i++){
		kk[i]=i;
	}
	for(i=0;i<m;i++){
		scanf("%d",&k);
		if(k!=0){
			for(j=0;j<k;j++){
				for(a=1;a<2*n+1;a++){
					kk[a-1]=kk[a];
				}
				kk[2*n]=kk[0];
			}}
		else{
			c=1;
			for(a=1;a<2*n+1;a++){
				if(a%2==1){
					kkk[a]=kk[c];
				}
				else{
					kkk[a]=kk[n+c];
					++c;
				}}
			for(a=1;a<2*n+1;a++){
				kk[a]=kkk[a];
			}}}
	for(i=1;i<2*n+1;i++){
		printf("%d\n",kk[i]);
	}
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	int ans = 0;
	rep(i, 1, n)
	{
		int x = i;
		int d = 0;
		while (x > 0)
		{
			++d;
			x /= 10;
		}
		if (d % 2)++ans;
	}
	cout << ans << endl;
}

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


int main(){
	int n,sum,MN=1e9;
	string s,s2;
	cin >> n;
	for(int i=1;i<n;i++){
		s=to_string(i);
		s2=to_string(n-i);
		
		sum=0;
		for(int j=0;j<s.size();j++){
			sum+=s[j]-'0';
		}
		for(int j=0;j<s2.size();j++){
			sum+=s2[j]-'0';
		}
		
		MN=min(MN,sum);
	}
	
	cout << MN << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string S, T, B = "~";
bool isOK(string A1, string A2) {
	for (int i = 0; i < A1.size(); i++) {
		if (A1[i] != '?' && A1[i] != A2[i])return false;
	}
	return true;
}
int main() {
	cin >> S >> T;
	for (int i = 0; i <= (int)S.size() - (int)T.size(); i++) {
		string U = S.substr(i, T.size());
		if (isOK(U, T) == true) {
			string V = S;
			for (int j = i; j < i + T.size(); j++)V[j] = T[j - i];
			for (int j = 0; j < i; j++) { if (V[j] == '?')V[j] = 'a'; }
			for (int j = i + T.size(); j < V.size(); j++) { if (V[j] == '?')V[j] = 'a'; }
			B = min(B, V);
		}
	}
	if (B == "~")cout << "UNRESTORABLE" << endl;
	else cout << B << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;

bool isPalindrome(string s){
    string t = s;
    reverse(t.begin(), t.end());
    // cout << "s: " << s << endl;
    // cout << "t: " << t << endl;
    return t == s;
}

void Main() {
    // input
    string S;
    cin >> S;
    int N = S.size();

    if (!isPalindrome(S)) {
        cout << "No" << endl;
        return;
    }

    int len = (N-1)/2 - 1 + 1;
    if(!isPalindrome(S.substr(1-1, len))) {
        cout << "No" << endl;
        return;
    }

    len = N - (N + 3) / 2 + 1;
    if(!isPalindrome(S.substr((N+3)/2-1, len))) {
        cout << "No" << endl;
        return;
    }

    cout << "Yes" << endl;

    // translate


    // output

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main(){
  int N; cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++)
    cin>>a.at(i);
  
  if(N%2==0){
    for(int i=N-1;i>=0;i-=2)
      cout<<a.at(i)<<" ";
    for(int i=0;i<N-1;i+=2)
      cout<<a.at(i)<<" ";
  }
  
  else{
    for(int i=N-1;i>=0;i-=2)
      cout<<a.at(i)<<" ";
    for(int i=1;i<N-1;i+=2)
      cout<<a.at(i)<<" ";
  }
    
}  

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1 << 30;
template <typename Functor>
struct fix_type
{
    Functor functor;
    template <typename... Args>
    decltype(auto) operator()(Args&&... args) const& { return functor(functor, std::forward<Args>(args)...); }
};
template <typename Functor>
fix_type<typename std::decay<Functor>::type> fix(Functor&& functor) { return {std::forward<Functor>(functor)}; }
class Flow
{
public:
    struct Edge
    {
        int from, to, revind, capacity, flow;
        bool reversed;
    };
    Flow(const int v) : V{v}, edge(v) {}
    void addEdge(const int from, const int to, const int capacity) { edge[from].push_back(Edge{from, to, (int)edge[to].size(), capacity, 0, false}), edge[to].push_back(Edge{to, from, (int)edge[from].size() - 1, capacity, capacity, true}); }
    int FordFulkerson(const int s, const int t)
    {
        vector<bool> checked(V);
        auto dfs = fix([&](auto&& self, const int pos, const int& flow) -> int {
            if (pos == t) { return flow; }
            checked[pos] = true;
            for (auto& e : edge[pos]) {
                if (not checked[e.to]) {
                    const int res = e.capacity - e.flow;
                    if (res > 0) {
                        const int d = self(self, e.to, min(flow, res));
                        if (d > 0) {
                            e.flow += min(d, res), edge[e.to][e.revind].flow -= min(d, res);
                            return d;
                        }
                    }
                }
            }
            return 0;
        });
        int flow = 0;
        while (true) {
            for (int i = 0; i < V; i++) { checked[i] = false; }
            const int f = dfs(s, INF);
            if (f == 0) { break; }
            flow += f;
        }
        return flow;
    }
    const int V;
    vector<vector<Edge>> edge;
};
int main()
{
    for (int N, M;;) {
        cin >> N >> M;
        if (N == 0 and M == 0) { break; }
        Flow flow(N + M + 2);
        const int S = N + M, T = N + M + 1;
        for (int i = 0, u, v; i < M; i++) { cin >> u >> v, u--, v--, flow.addEdge(u, i + N, 1), flow.addEdge(v, i + N, 1); }
        for (int i = N; i < N + M; i++) { flow.addEdge(i, T, 1); }
        int inf = M / N;
        for (; inf >= 0; inf--) {
            auto f = flow;
            for (int i = 0; i < N; i++) { f.addEdge(S, i, inf); }
            const int F = f.FordFulkerson(S, T);
            if (F >= inf * N) { break; }
        }
        int sup = inf;
        for (;; sup++) {
            auto f = flow;
            for (int i = 0; i < N; i++) { f.addEdge(S, i, sup); }
            const int F = f.FordFulkerson(S, T);
            if (F >= M) { break; }
        }
        cout << inf << " " << sup << endl;
    }
    return 0;
}



Measured memory_bytes: 4592
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

int findSumOfDigits(int n) {
    int sum = 0;
    while (n > 0) { // n が 0 になるまで
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(){
    int N;
    cin >> N;
    int sum;
    sum = findSumOfDigits(N);

    if(N % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  ll f=0;
  rep(i,n){
    ll a;cin>>a;
    if(a%2)f=1;
  }
  if(f)cout<<"first"<<endl;
  else cout<<"second"<<endl;

  return 0;

}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
use std::cmp::{max, min, Ordering};
use std::collections;
use std::io::{stdin, BufRead};
use std::fmt;

macro_rules! get
{
  ($rd:ident; V; $t:ty) => {
    scanl($rd, b'\n')
      .split_whitespace()
      .map(|w| get_inner!{w; $t})
      .collect::<Vec<_>>()
  };
  ($rd:ident; T; $($t:ty),+) => {
    {
      let s = scanl($rd, b'\n');
      let mut i = s.split_whitespace();
      ( $( get_inner!{i.next().unwrap(); $t}),+ )
    }
  };
  ($rd:ident; $t:ty) => (get_inner!{scanl($rd, b'\n'); $t});
}

macro_rules! get_inner
{
  ($src:expr; $t:ty) => {
    $src.parse::<$t>().expect("Parse Error")
  };
}

macro_rules! gets
{
  ($rd:ident; $n:expr; $($tok:tt)*) => {
    (0..)
      .take($n)
      .map(|_| get!{$rd; $($tok)*})
      .collect::<Vec<_>>()
  };
}

fn solve(rd: &mut BufRead)
{
  let mut x = get!(rd; usize);
  
  loop {
    if is_prime(x) {
      break;
    }
    
    x += 1;
  }
  
  println!("{}", x);
}

fn is_prime(n: usize) -> bool {
  !(n < 2 || (2..((n as f64).sqrt() as usize)).any(|i| n % i == 0))
}

fn scanl(rd: &mut BufRead, delim: u8) -> String
{
  let mut buf = Vec::new();
  let _ = rd.read_until(delim, &mut buf).expect("Read Failed");
  String::from_utf8(buf)
    .expect("Invalid UTF-8 String")
    .trim_right()
    .to_string()
}

fn main()
{
  let rd = stdin();
  let mut rd = rd.lock(); // std::io::StdinLock
  solve(&mut rd);
}


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

ll n, dp[1000009], vet[1000009], k;

ll solve(int i) {
    if(dp[i] != INF)
        return dp[i];
    if(i == n-1)
        return 0;
    if(i > n-1)
        return INF;

    for(int j = 1; j <= k; j++)
        dp[i] = min(dp[i], solve(i+j)+abs(vet[j+i]-vet[i]));
    return dp[i];
}
int main() {
    cin >> n >> k;
    for(int i = 0; i < n;i++) cin >> vet[i];
    for(int i = 0; i <= 1000000; i++)
        dp[i] = INF;

    solve(0);
    cout << dp[0] << endl;
}


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

int N;
string s;

string res;

char notC( char c ){
  if( c=='S' ) return 'W';
  return 'S';
}

bool check( int st ){
  if( st == 0 ) res = "SS";
  else if( st == 1 ) res = "SW";
  else if( st == 2 ) res = "WS";
  else res = "WW";
  for(int i=1;i<N;i++){
    char cl = res[i-1];
    if( res[i] == 'S' ){
      if( s[i] == 'o' ){
        res += cl;
      } else {
        res += notC(cl); 
      }
    } else {
      if( s[i] == 'o' ){
        res += notC(cl);
      } else {
        res += cl;
      }    
    }
  }

  
  if( res[N] == res[0] ){
    if( res[0] == 'S' ){
      if( s[0] == 'o' )
        return res[1] == res[N-1];
      else
        return res[1] != res[N-1];
    } else {
      if( s[0] == 'o' )
        return res[1] != res[N-1];
      else
        return res[1] == res[N-1];
    }
  }
  return false;
}

int main(){
  cin >> N >> s;
  for(int i=0;i<4;i++){
    if( check(i) ) {
      cout << res.substr(0,N) << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


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

int main(){
  long N, Y;
  cin >> N >> Y;
  Y /= 1000;
  for(int i=0; i<=N; i++){
    if(10*i>Y) break;
    for(int j=0; j<=N-i; j++){
      if(10*i+5*j>Y) break;
      if(10*i+5*j+(N-i-j)==Y){
        cout << i << ' ' << j << ' ' << N-i-j << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 256
from math import sqrt

size = 123456
primes = [x for x in range(2, 2*size+1) if x == 2 or x % 2 == 1]
for i in range(2, int(sqrt(2*size))):
    primes = [x for x in primes if x % i != 0 or x == i]

while True:
    n = int(input())
    if n == 0: break
    nums = [x for x in primes if x > n and x <= 2*n]
    print(len(nums))

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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

char arr[52][52];

void cn(int i,int j){
    int count=0;
    if(arr[i][j]=='#')
        cout<<'#';
    else{
        if(arr[i][j+1]=='#'){
            count+=1;
        }
        if(arr[i][j-1]=='#'){
            count+=1;
        }
        if(arr[i+1][j+1]=='#'){
            count+=1;
        }
        if(arr[i+1][j-1]=='#'){
            count+=1;
        }
        if(arr[i-1][j+1]=='#'){
            count+=1;
        }
        if(arr[i-1][j-1]=='#'){
            count+=1;
        }
        if(arr[i+1][j]=='#'){
            count+=1;
        }
        if(arr[i-1][j]=='#'){
            count+=1;
        }
        cout<<count;
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int h,w;
    cin>>h>>w;
    for(int i=1;i<=h;i++){
        string s;
        cin>>s;
        for(int j=1;j<=w;j++){
            arr[i][j]=s[j-1];
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cn(i,j);
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=305;
const int M=2*N;
const int mod=1e9+7;
int pow(int x, int k)
{
	int ret=1;
	for(;k;k>>=1,x=(ll)x*x%mod) if(k&1) ret=(ll)ret*x%mod;
	return ret;
}
int dp[M][M],g[M],inv[M],n,m,a[N],b[N];
bool was[M][M],f[M];
bool in(int x, int l, int r){ return x>=l && x<=r;}
int DP(int l, int r)
{
	if(was[l][r]) return dp[l][r];
    if(l>r) return 0;
    was[l][r]=1;
	int x=0,y=0,z=0,i;
	for(i=1;i<=m;i++) if(in(a[i],l,r)!=in(b[i],l,r)) return 0;
	for(i=1;i<l;i++) y+=f[i];
	for(i=l;i<=r;i++) x+=f[i];
	for(i=r+1;i<=n;i++) y+=f[i];
	dp[l][r]=(ll)g[x]*g[y]%mod;
	z+=f[r];
	for(i=r-1;i>=l;i--)
	{
        int tmp=DP(l,i);
        dp[l][r]-=(ll)tmp*inv[y+z]%mod*g[z]%mod*g[y]%mod;
        if(dp[l][r]<0) dp[l][r]+=mod;
		z+=f[i];
	}
	return dp[l][r];
}
int main()
{
	int i,j;
	scanf("%i %i",&n,&m);n*=2;
	for(i=1;i<=n;i++) f[i]=1;
	for(i=1;i<=m;i++) scanf("%i %i",&a[i],&b[i]),f[a[i]]=0,f[b[i]]=0;
	g[0]=1;for(i=2;i<=n;i+=2) g[i]=(ll)g[i-2]*(i-1)%mod;
	for(i=0;i<=n;i++) inv[i]=pow(g[i],mod-2);
	int ans=0;
	for(i=1;i<=n;i++) for(j=i;j<=n;j++) ans+=DP(i,j),ans=ans>=mod?ans-mod:ans;
	printf("%i\n",ans);
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>

using namespace std;
 
int main(void) {
  string s;
  cin >> s;
  if (s == "Sunny") {
    cout << "Cloudy";
  } else if (s == "Cloudy") {
    cout << "Rainy";
  } else {
    cout << "Sunny";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 760
// AOJ 1027
#include<cstdio>

int main()
{
	int K, c;
	while( scanf( "%d", &K ), K )
	{
		int sum = 0;
		for( int i = 0; i != K*(K-1)/2; ++i )
		{
			scanf( "%d", &c );
			sum += c;
		}

		printf( "%d\n", sum / (K-1) );
	}

	return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 9223372036854775807
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0;
string s;
bool flag;
#pragma endregion
#define MAX 111111


int main(void) {
  vll a, b;
  cin >> n;
  FOR(i, 0, n) {
	cin >> tmp;
	a.pb(tmp);
	cin >> tmp;
	b.pb(tmp);
  }
  RFOR(i, 0, n) {
	a[i] += ans;
	if (a[i] <= b[i]) {
	  if (a[i] == 0) continue;
	  ans += b[i] - a[i];
	}
	else {
	  if (a[i] % b[i] != 0) ans += b[i]- (a[i]%b[i]);
	}
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2036
def main():
  t = input().split(" ")
  A, B, C, X ,Y = int(t[0]), int(t[1]), int(t[2]), int(t[3]), int(t[4])
  a_p = min(A, 2*C)
  b_p = min(B, 2*C)
  set_p = min(A+B, 2*C)
  set_n = min(X, Y)
  a_n = X - set_n
  b_n = Y - set_n
  r = a_p * a_n + b_p * b_n + set_p * set_n
  print(r)
main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

int main() {
	fastio; int x; cin >> x; cout << 1-x;
}


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

int main() {
	int n;
	cin >> n;
	int ans = 10000000;
	for(int i =0;i<=n;i++)
	{
		int c=0,t=i;
		while(t>0)
		{
			c+=t%6;
			t/=6;
		}
		t = n - i;
		while(t>0)
		{
			c+=t%9;
			t/=9;
		}
		if(ans>c)
		{
			ans = c;
		}
	}
    cout << ans << endl;
	return 0;
}


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

using namespace std;
using LL = long long;

constexpr int MAXN = 2e5 + 5;
constexpr LL Mod = 998244353;

LL n, m, k, ans, fac[MAXN];

inline void Init() {
    fac[0] = 1;
    for (LL i = 1; i < MAXN; i++) fac[i] = fac[i - 1] * i % Mod;
}

inline LL qpow(LL a, LL b) {  // a^b
    LL res = 1;
    while (b) {
        if (b & 1) res = res * a % Mod;
        a = a * a % Mod;
        b >>= 1;
    }
    return res;
}

inline LL C(LL N, LL M) {
    if (M > N || M < 0) return 0;
    return fac[N] * qpow(fac[M], Mod - 2) % Mod * qpow(fac[N - M], Mod - 2) % Mod;
}

int main() {
    // freopen("test.out", "w", stdout);
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> m >> k;
    Init();
    ans = 0;
    for (LL i = 0 ; i <= k; i++)
        ans = (ans + C(n - 1, i) * m % Mod * qpow(m - 1, n - i - 1) % Mod) % Mod;
    cout << ans << endl;
    return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define ul unsigned long long

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



int main() {
        int H,W,K;
        cin >>H >> W >> K;
        ll result=0;
        char masu[H][W];
        bool hcheck[H];
        bool wcheck[H];
        rep(i,H)
                rep(j,W)
                cin >> masu[i][j];
        int h=1;
        int w=1;
        rep(i,H) h=h*2;
        rep(i,W) w=w*2;

        rep(i,h)
                rep(j,w){
                //cout << "i:"<<i << ", j:"<<j <<endl;
                int black=0;
                rep(k,H){
                        if((i>>k)&1) hcheck[k]=false;
                        else hcheck[k]=true;
                }
                rep(k,W){
                        if((j>>k)&1) wcheck[k]=false;
                        else wcheck[k]=true;
                }
                rep(k,H)rep(l,W) if(hcheck[k]&&wcheck[l]&&masu[k][l]=='#') black++;
                //cout << "  black:" << black << endl;
                if(black==K) result++;
        }

        cout << result << endl;
}

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

using namespace std;

#define ll long long
#define sf scanf
#define pf printf 
#define nl printf("\n")
#define pi acos(-1)

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

    double r,res;
    sf("%lf",&r);
    res = 2*pi*r;
    pf("%lf\n",res);
    return 0;
}

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

using namespace std;

int main(){
  int a;
  bool flag=false;
  cin >> a;
  for(int i=a;i<100004;i++){
    flag=false;
    for(int j=2;j<i;j++){
      if(i%j==0){
        flag=true;
        break;
      }
    }
    if(flag==false){
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int main() {
    string s;
    cin >> s;
 
    VI a(4);
    REP(i,4) a[i] = (s[i] - '0');
 
    string t;
    if (a[0] + a[1] + a[2] + a[3] == 7){
        t = "+++";
    }
    if (a[0] + a[1] + a[2] - a[3] == 7){
        t = "++-";
    }
    if (a[0] + a[1] - a[2] + a[3] == 7){
        t = "+-+";
    }
    if (a[0] + a[1] - a[2] - a[3] == 7){
        t = "+--";
    }
    if (a[0] - a[1] + a[2] + a[3] == 7){
        t = "-++";
    }
    if (a[0] - a[1] + a[2] - a[3] == 7){
        t = "-+-";
    }
    if (a[0] - a[1] - a[2] + a[3] == 7){
        t = "--+";
    }
    if (a[0] - a[1] - a[2] - a[3] == 7){
        t = "---";
    }
 
    REP(i,3) cout << s[i] << t[i];
    cout << s[3] << "=7" << endl;
 
    return 0;
}

Measured memory_bytes: 256
x,y,a,b,c = map(int, input().split())
p = sorted(map(int, input().split()), reverse=True)
q = sorted(map(int, input().split()), reverse=True)
r = sorted(map(int, input().split()), reverse=True)
p = p[:x]
r.extend(p)
q = q[:y]
r.extend(q)
r = sorted(r, reverse=True)
print(sum(r[0:x+y]))

Measured memory_bytes: 23328
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;

void solve();

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

void solve() {
    int h,w;
    cin >> h >> w;
    string s[h][w];
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> s[i][j];
        }
    }
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(s[i][j] == "snuke") {
                cout << (char)('A' + (char)j) << (i+1) << endl;
            }
        }
    }


}

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int n , m , x;
multiset<int> S;

int main(){
    scanf("%d",&n);
    rep(i,0,n){
        scanf("%d",&x);
        S.insert(x);
    }
    scanf("%d",&m);
    rep(i,0,m){
        scanf("%d",&x);
        if(!S.count(x)) return puts("NO") , 0;
        S.erase(S.find(x));
    }
    puts("YES");
    return 0;
}


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

int main(){
    int Anttenas[5];
    for(int i = 0; i < 5; ++i){
        cin >> Anttenas[i];
    }
    int distance; cin >> distance;
    if((Anttenas[4] - Anttenas[0]) <= distance){
        cout << "Yay!";
    }else{
        cout << ":(";
    }
    return 0;
}


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

int main(){
    ll K;
    cin>>K;
    ll x = 7 % K;
    for(int i = 1;i<=K;i++){
        if(x==0){
            cout << i;
            return 0;
        }
        x=(x*10+7)%K;
    }
    cout<<-1;
}

Measured memory_bytes: 3592
"""



"""

import sys
sys.setrecursionlimit(10**6)


N = int(input())
C = list(map(int, input().split()))
C.sort()
MOD = 10**9 + 7


ans = 0
# どうも公式ドキュメントによると、組み込み関数のpowの第三引数に値渡すとMODとってくれるらしいので、完全に無駄
def pow_mod(x, n, mod):
    if n == 0:
        return 1 % mod
    elif n % 2 == 0:
        y = pow_mod(x, n//2, mod)
        return y * y % MOD
    else:
        return x * pow_mod(x, n-1, mod) % mod

for i in range(N):
    # 詳細は開設動画の通りだが、i桁目の右にr個の数字、左にlこの数字がある
    l = i
    r = N - i - 1
    # i桁目の寄与が C[i] * 2**l * (2**r + r * 2**(r-1))で、最後に2**Nをかける（Tのとり方が2**Nこあるので）
    # -> C[i] * 2**l * (2**(N+r) + r * 2**(r+N-1))
    ans += ((C[i] * pow(2, l, MOD)) % MOD * (pow(2, N+r, MOD) + r * pow(2, N+r-1, MOD))) % MOD
    ans %= MOD

print(ans)

Measured memory_bytes: 26024
#include <cstdio>
typedef long long ll; 
int pos[300005]; 
int main()
{
	// freopen("AGC022-D.in", "r", stdin); 
	int n, len, l = 0, r = 0, arb = 0; 
	scanf("%d%d", &n, &len); 
	for (int i = 0; i < n; i++)
		scanf("%d", pos + i); 
	ll ans = 1; 
	for (int i = 0; i < n; i++)
	{
		int t; 
		scanf("%d", &t); 
		ans += t / (2 * len); 
		t %= 2 * len; 
		if (!t)
			continue; 
		ans++; 
		bool f = t <= len - pos[i] << 1, g = t <= pos[i] << 1; 
		if (i == n - 1)
			ans -= f; 
		else if (g)
		{
			l++; 
			if (f)
				arb++;
		}
		else if (f)
			r++; 
		while (l - arb < r + arb)
			(arb ? arb : r)--;
	}
	ans -= r + arb; 
	printf("%lld\n", ans * len * 2);
	return 0; 
}


Measured memory_bytes: 1280
S = list(input())
s1 = list("keyence")

x = [1]
y = [1]
for i in range(7):
  if S[i] == s1[i]:
    x.append(x[len(x)-1])
  else:
    x.append(0)
  if S[len(S)-1-i] == s1[6-i]:
    y.append(y[len(y)-1])
  else:
    y.append(0)

if sum(x) + sum(y) >= 9:
  print("YES")  
else:
  print("NO")

Measured memory_bytes: 3064
#include<stdio.h>
#include <math.h>
#define PI 3.141592653589793//double radian = degree * PI / 180.0;
int main()
{

   int a,b,h,m;
   scanf("%d %d %d %d",&a,&b,&h,&m);
   double a_x,a_y,b_x,b_y;
    a_x=a*cos((h*-30.0f+ m*-0.5f) *PI/180.0f);
    a_y=a*sin((h*-30.0f+ m*-0.5f) *PI/180.0f);
    
    b_x=b*cos(m*-6.0f *PI/180.0f);
    b_y=b*sin(m*-6.0f *PI/180.0f);
    //printf("%f %f %f %f",a_x,a_y,b_x,b_y);
    double length;
    length=sqrt((a_x-b_x)*(a_x-b_x)+(a_y-b_y)*(a_y-b_y));
    printf("%.9lf",length);
}

Measured memory_bytes: 2532
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int N =sc.nextInt();
    int M=sc.nextInt();
    int m[] =new int[M+1];
    m[0]=0;
    for(int i=1;i<M+1;i++){
      m[i]=m[i-1]+sc.nextInt();}
    if(N>=m[M]){System.out.println(N-m[M]);}
    else{System.out.println(-1);}
  }
}

Measured memory_bytes: 46184
/*
AizuOnline A2199
Title Differential Pulse Code Modulation
@kankichi573
*/
#include <stdio.h>
#include <string.h>
#include <limits.h>
#define min(x,y) (((x)<(y))?(x):(y))

int N,M;
int C[16];
int x[20001];
int old_sum_sqr_dif[256];
int new_sum_sqr_dif[256];
//
int find_min(int array[])
{
        int i,min_;
        min_=INT_MAX;
        for(i=0;i<=255;i++)
                if(array[i]!=-1 && array[i]<min_)
                {
                        //printf("Ia=%d %d",i,array[i]);
                        min_=array[i];
                }
        return(min_);
}
solve()
{
        int i,j,k,s,idx,newval;
        for(i=1;i<=N;i++)
        {
                for(j=0;j<=255;j++)
                {
                        s=old_sum_sqr_dif[j];
                        //printf("IJS=%d:%d:%d\n",i,j,s);

                        if(s!=-1)
                        {
                                for(k=0;k<M;k++)
                                {
                                        idx=j+C[k];
                                        if(idx>255)
                                                idx=255;
                                        else if(idx<0)
                                                idx=0;
                                        //printf("Idx=%d\n",idx);

                                                                                newval=s+(idx-x[i])*(idx-x[i]);
                                        if(new_sum_sqr_dif[idx]==-1)
                                                new_sum_sqr_dif[idx]=newval;
                                        else
                                                new_sum_sqr_dif[idx]=min(newval,new_sum_sqr_dif[idx]);

                                        //printf("%d::%d:%d\n",i,idx,newval);

                                }
                        }

                }
                memcpy(old_sum_sqr_dif,new_sum_sqr_dif,256*4);
                memset(new_sum_sqr_dif,-1,256*4);
        }
        return(find_min(old_sum_sqr_dif));
}

main()
{
        int i,ret;

        while(EOF!=scanf("%d %d",&N,&M) && (N||M))
        {

                for(i=0;i<M;i++)
                        scanf("%d",&C[i]);
                for(i=1;i<=N;i++)
                        scanf("%d",&x[i]);

                memset(old_sum_sqr_dif,-1,256*4);
                memset(new_sum_sqr_dif,-1,256*4);
                old_sum_sqr_dif[128]=0;  //開始点

                ret=solve();

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

        }
        return(0);
}

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

int main(){
	int w, h, n, i, j, sx, sy, nx, ny, count;
	cin >> w >> h >> n;
	cin >> sx >> sy;
	count = 0;
	for(i = 1; i < n; i++){
		cin >> nx >> ny;
		if((sx < nx && sy < ny) || (sx > nx && sy > ny)){
			count += max(abs(sx-nx), abs(sy-ny));
		} else {
			count += abs(sx-nx) + abs(sy-ny);
		}
		sx = nx;
		sy = ny;
	}
	cout << count << endl;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

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

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (N % 2 != 0){
    ll lowest = a[(N - 1) / 2];
    ll largest = b[(N - 1) / 2];
    cout << largest - lowest + 1 << endl;
  }
  else {
    ll lowest = a[(N - 1) / 2] + a[(N - 1) / 2 + 1];
    ll largest = b[(N - 1) / 2] + b[(N - 1) / 2 + 1];
    cout << largest - lowest + 1 << endl;
  }
}


Measured memory_bytes: 6420
while True:
    n = int(input())
    if n == 0:
        break
        
    ta = [0] * 86400
    for _ in range(n):
        a,b = input().split()
        c,cc,ccc = int(a[0:2]),int(a[3:5]),int(a[6:8])
        d,dd,ddd = int(b[0:2]),int(b[3:5]),int(b[6:8])
        ta[c*3600+cc*60+ccc] += 1
        ta[d*3600+dd*60+ddd] -= 1

    for i in range(86400):
        if 0 < i:
            ta[i] += ta[i-1]

    ans = 0
    for i in range(86400):
        if ans < ta[i]:
            ans = ta[i]

    print(ans)


Measured memory_bytes: 9592
#include<stdio.h>
int main()
{
  int a,b,d;
  char op;
  while(1){
    scanf("%d %c %d",&a,&op,&b);
  if(op == '+'){
    d=a+b;
      }
  else if(op == '-'){
    d=a-b;
      }
  else if(op == '*'){
    d=a*b;
      }
  else if(op == '/'){
    d=a/b;
  }
  else if(op == '?'){
    break ;
  }
  printf("%d\n",d);
  }
  return 0;
}

Measured memory_bytes: 2656