akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

bool ContainsSameChar(const string &S)
{
    for (const char ch : S)
    {
        if (ch != S.front()) return false;
    }
    return true;
}

int main()
{
    string S; int K; cin >> S >> K;
    if (ContainsSameChar(S))
    {
        cout << S.length() * K / 2 << endl;
    }
    else
    {
        // S内部で必要な書き換え回数を数える
        LLONG inside = 0;
        for (int i = 0; i < S.length() - 1; ++i)
        {
            if (S[i] == S[i + 1])
            {
                ++inside;
                ++i;
            }
        }
        // つなぎ目で必要な書き換え数を数える
        LLONG ans = inside * K;
        if (S.front() == S.back())
        {
            LLONG frontNum = 1, backNum = 1;
            for (int i = 1; i < S.length(); ++i)
            {
                if (S[i] == S.front()) ++frontNum;
                else break;
            }
            for (int i = 1; i < S.length(); ++i)
            {
                if (S[S.length() - i - 1] == S.back()) ++backNum;
                else break;
            }
            ans -= (frontNum / 2 + backNum / 2 - (frontNum + backNum) / 2) * (K - 1);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	char a[105];
	char b[105];
	scanf("%s",a);
	//getchar();
	scanf("%s",b);
	int len_a = strlen(a);
	int len_b = strlen(b);
	//printf("%d %d\n",len_a,len_b);
	if(len_a > len_b) printf("GREATER\n");
	else if(len_a < len_b) printf("LESS\n");
	else 
	{
		if(strcmp(a,b)>0) printf("GREATER\n");
		else  if(strcmp(a,b)<0) printf("LESS\n");
		else printf("EQUAL\n");
	}
	return 0;
}

Measured memory_bytes: 256
// vim: set fdm=marker:
// {{{
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <utility>

using namespace std ;

typedef long long ll ;

// }}}

int main()
{
    int N, M;
    cin >> N >> M;
    string s, t;
    cin >> s >> t;
    ll x = N*1LL*M / __gcd(N, M);
    ll g = __gcd(N, M);
    for (int i = 0 ; i*(N/g) < N ; i++) {
        if (s[i*(N/g)] != t[i*(M/g)])
            return puts("-1")*0;
    }
    cout << x << endl;
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
bool ex[200005];
int deg[200005],a[200005];
vector<int> v[200005],inv[200005];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		v[a].push_back(i);
		inv[i].push_back(a);
		deg[a]++;
	}
	set<int> d;
	set<pair<int,int> > s;
	for (int i=1;i<=n;i++)
	s.insert({deg[i],i});
	bool st=0,odd=0;
	memset(a,-1,sizeof(a));
	while (!s.empty())
	{
		auto p=*s.begin();
		s.erase(s.begin());
		if (p.first)
		st=1;
		odd^=st;
		for (int i:v[p.second])
		{
			if (a[i]!=-1)
			ex[a[i]]=1;
		}
		int m=0;
		while (ex[m])
		m++;
		if (st)
		d.insert(m);
		else
		a[p.second]=m;
		for (int i:v[p.second])
		{
			if (a[i]!=-1)
			ex[a[i]]=0;
		}
		for (int i:inv[p.second])
		{
			if (s.find({deg[i],i})!=s.end())
			{
				s.erase({deg[i],i});
				deg[i]--;
				s.insert({deg[i],i});
			}
		}
	}
	if (d.size()==1 && odd)
	printf("IMPOSSIBLE");
	else
	printf("POSSIBLE");
}

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

int main(){
  int N,L;
  cin >> N >> L;
  int sum = L*N + N*(N-1)/2;
  vector<int> p(210,310),n(210,310);
  for(int i=0; i<N; i++){
    if(L+i >= 0){
      p[i] = L+i;
    }
    else{
      n[i] = -i-L;
    }
  }
  sort(p.begin(),p.end());
  sort(n.begin(),n.end());
  if(p[0] < n[0]){
    cout << sum - p[0] << endl;
  }
  else{
    cout << sum + n[0] << endl;
  }
}

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

int main() {
  int N, M, ans = 0, K;
  cin >> N >> M;
  vector<vector<int>> S;
  for (int i = 0; i < M; ++i) {
    vector<int> s;
    s.clear();
    cin >> K;
    int l;
    for (int j = 0; j < K; ++j) {
      cin >> l;
      s.push_back(l);
    }
    S.push_back(s);
  }

  vector<int> P;
  int l;
  for (int i = 0; i < M; i++) {
    cin >> l;
    P.push_back(l);
  }


  for (int bit = 0; bit < (1 << N); bit++) {
    int onLights = 0;
    for (int k = 0; k < M; k++) {
      int count = 0;
      for (int s = 0; s < S.at(k).size(); s++) {
        if (bit & (1 << (S.at(k).at(s)-1) ) ) count++;
      }
      if (count % 2 == P.at(k)) onLights++;
    }
    if (onLights == M) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int>H(N);
  for(int i=0;i<N;i++){
    cin >> H[i];
  }
  H.push_back(1e10);
  int ans=0;
  int num=0;
  for(int i=0;i<N;i++){
    if(H[i]>=H[i+1]){
      num++;
    }
    else{
      ans=max(ans,num);
      num=0;
    }
  }
  cout << ans << endl;
         
}
      
    
      


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquestring;
typedef priority_queue<int> priqueint;
typedef priority_queue<ll> priquell;
typedef priority_queue<char> priquechar;
typedef priority_queue<string,vector<string>,greater<string>> rpriquestring;
typedef priority_queue<int,vector<int>,greater<int>> rpriqueint;
typedef priority_queue<ll,vector<ll>,greater<ll>> rpriquell;
typedef priority_queue<char,vector<char>,greater<char>> rpriquechar;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
int exp(int x,int y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%big;
    int t=exp(x,y/2);
    return (t*t)%big;
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}

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


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
    
    ll s;cin >> s;
    /*
    一つを原点に移動して(a,b),(c,d)となったとする
    |ad-bc|==s
    ad>sなるa,dは明らかに制約内に存在
    その時b,cを与えて終わりか。
    b=1,cはそのまま、にしたいので、ad-s<=1e9になってほしい
    いや、一番平方根に近い値をとるのが無難そう。
    a,d=ceil(sqrt(s))にとる。
    */
    ll a,b,d;
    if(s==pow(10,18)){a=pow(10,9);d=pow(10,9);b=0;}
    else{
    a=ceil(sqrt(s));
    d=a;
    b=a*d-s;
    }
    printf("%d %d %lld %lld %d %lld\n",0,0,a,b,1,d);
}

Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))
 
result = 0
mini = [P[0]]
 
for i in range(N-1):
    if mini[i]>P[i+1]:
        mini.append(P[i+1])
    else:
        mini.append(mini[i])
 
for i in range(N):
    if P[i]==mini[i]:
        result += 1
 
print(result)

Measured memory_bytes: 24744
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            int iX = int.Parse(Console.ReadLine().Trim());

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            String sOut = "ARC";
            if (iX < 1200) { sOut = "ABC"; }

            //出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 11220
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
N = int(input())
a = list(map(int, input().split()))

C = [0 for _ in range(9)]

for i in range(N) :
  if a[i] < 3200 :
    C[a[i]//400] += 1
  else :
    C[8] += 1

minN = 0
maxN = 0
for j in range(8) :
  if C[j] > 0 :
    minN += 1
  
#maxN = min(minN + C[8], 8)
maxN = minN + C[8]

if minN == 0 :
  minN = 1
  
print (str(minN) + " " + str(maxN))
  




Measured memory_bytes: 3436
#include <iostream>
#include <vector>
#include <cstdint>
#include <cmath>

std::vector<uint32_t> getPrimeFact(uint32_t);

int main() {
	uint32_t n;
	std::cin >> n;
	std::vector<uint32_t>&& fact = getPrimeFact(n);
	std::cout << n << ": ";
	for (uint32_t i=0; i<fact.size(); i++) {
		if (i<fact.size()-1) {
			std::cout << fact[i] << " ";
		} else {
			std::cout << fact[i] << std::endl;
		}
	}
}

std::vector<uint32_t> getPrimeFact(uint32_t n) {
	std::vector<uint32_t> fact;
	uint32_t n_sq = sqrt(n);
	while (n > 1) {
		for (uint32_t i=2; i<=n_sq; i++) {
			if (n%i == 0) {
				fact.push_back(i);
				n /= i;
				break;
			}
			if ( i == n_sq ) {
				fact.push_back(n);
				n = 1;
			}
		}
	}
	return fact;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long 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;
}

int main()
{
    char b;
    cin >> b;

    if (b == 'A')
    {
        b = 'T';
    }
    else if (b == 'T')
    {
        b = 'A';
    }
    else if (b == 'C')
    {
        b = 'G';
    }
    else
    {
        b = 'C';
    }

    cout << b << endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin

def main():
    h = int(input())
    kyu = 8
    if 600 <= h and h < 800:
        kyu = 7
    if 800 <= h and h < 1000:
        kyu = 6
    if 1000 <= h and h < 1200:
        kyu = 5
    if 1200 <= h and h < 1400:
        kyu = 4
    if 1400 <= h and h < 1600:
        kyu = 3
    if 1600 <= h and h < 1800:
        kyu = 2
    if 1800 <= h and h < 2000:
        kyu = 1
    print(kyu)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9196
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}

int main(){
    ll A,B,C;
    ll K;
    cin>>A>>B>>C>>K;
    ll t=0;
    while(A>=B){
        B*=2;
        t++;
    }
    while(B>=C){
        C*=2;
        t++;
    }
    YN(t<=K);
    return 0;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<algorithm>
using namespace std;
int N,ptr,res;
int A[100000];

int main(){
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  sort(A,A+N);
  while(ptr<N){
    int cc=A[ptr],f=0;
    {while(ptr<N&&A[ptr]==cc)f++,ptr++;}
    res+=f%2;
  }
  printf("%d",res);
  return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  if (S.at(K - 1) == 'A') {
    S.at(K - 1) = 'a';
    cout << S << endl;
  }
  else if (S.at(K - 1) == 'B') {
    S.at(K - 1) = 'b';
    cout << S << endl;
  }
  else {
    S.at(K - 1) = 'c';
    cout << S << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a[4][13],b,n, i,j;
	char c;
	scanf("%d", &n);
	for (i = 0;i < 4;i++)
	{
		for (j = 0;j < 13;j++)
		{
			a[i][j] = 0;
		}
	}
	for (i = 0;i < n;i++)
	{
		scanf(" %c %d", &c,&b);
		if (c == 'S') a[0][b-1] = 1;
		else if (c == 'H') a[1][b-1] = 1;
		else if (c == 'C') a[2][b-1] = 1;
		else if (c == 'D') a[3][b-1] = 1;
	}
	for (i = 0;i < 4;i++)
	{
		for (j = 0;j < 13;j++)
		{
			if (a[i][j] == 0)
			{
			if (i == 0) printf("S %d\n", j + 1);
			else if (i == 1) printf("H %d\n", j + 1);
			else if (i == 2) printf("C %d\n", j + 1);
			else if (i == 3) printf("D %d\n", j + 1);
			}
		}
	}

	return 0;
}


Measured memory_bytes: 596
//-----------------------------B-I-Y------------------------------------------------
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const ll M = 1000000007;

void solve(){
	ll r;
	cin >> r;
	ld pi = 22/(7*1.0);
	ld ans = 2*pi*r;
	cout << fixed << setprecision(9) << ans << endl;

}

signed main(){
    fast;
    ll t=1;
    // cin >> t;
    while( t-- )
        solve();
    return 0;
}
//-----------------------------B-I-Y------------------------------------------------

Measured memory_bytes: 3800
#include<cstdio>
int main(){
	long int a,b;
	char o;
	scanf("%ld %c %ld",&a,&o,&b);
	if(o == '+'){
		printf("%ld\n",a+b);
		}
		else{
			printf("%ld\n",a-b);
			}
	return 0;
	}

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

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

  if(n<10){
    cout << r + (100 * (10 - n));
  }
  else
  {
    cout << r;
  }

}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){
    Int A, B;
    cin >> A >> B;
    cout << A * B << endl;


}

Measured memory_bytes: 3596
merge xs [] = xs
merge [] xs = xs
merge (x:xs) (y:ys)
  | x < y     = x : merge xs (y:ys)
  | otherwise = y : merge (x:xs) ys

msort [] = []
msort [x] = [x]
msort xs = merge (msort $ take h xs) (msort $ drop h xs)
  where h = length xs `div` 2

judge [] = True
judge (x:xs)
  | even $ length $ filter (== x) (x:xs)  = judge xs'
  | otherwise                             = False
  where xs' = snd $ break (/= x) (x:xs)


main = do
  ans <- judge . msort <$> getLine
  putStrLn (if ans then "Yes" else "No")
  
  
  


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

#define mod 1000000007

using namespace std;
 
int main(void){
	
	char S[4];
	
	cin >> S[0] >> S[1] >> S[2] >> S[3];
	
	if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3]){
		cout << "Bad";
		return 0;
	}
	
	cout << "Good";
	
	return 0;
}




Measured memory_bytes: 256
// Last Change: 05/11/2019 22:07:15.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

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

  ll ans = 0;
  ll tar = sqrt(N) + 1;
  for (ll i = 1; i <= tar; ++i) {
    if (N % i == 0) {
      ll q = N / i;

      ll m = i - 1;
      if (m > q) {
        ans += m;
      }

      if (N != i * i) {
        if (q - 1 > i) {
          ans += q - 1;
        }
      }
    }
  }

  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
#include <cstdio>

int n, x;

int main(){

	scanf("%d", &n);
	for(int i = 1; i <= 9; i++)
		if(n % i == 0){
			x = n / i;
			if(x >= 1 && x <= 9){
				puts("Yes");
				return 0;
			}
		}
	puts("No"); 
	
	return 0;
}

Measured memory_bytes: 128
n = int(input())
t = list(map(int, input().split()))
m = int(input())
pl = []
for i in range(m):
    pl.append(list(map(int, input().split())))


for i in pl:
    tt = t.copy()
    tt[i[0]-1] = i[1]
    print(sum(tt))


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	long long int g[1001],s[1001],d[1001],f[1001];
	int j,i,k,a,h[1001];
	while(1){
		scanf("%d",&a);
		if(a==0) break;
		for(i=0;i<a;i++){
			h[i]=0;
			g[i]=0;
		}
		for(i=0;i<a;i++){
			scanf("%lld %lld %lld",&s[i],&d[i],&f[i]);
			if(d[i]*f[i]>=1000000) h[i]=1;
			if(d[i]==1000000&&f[i]>=1) h[i]=1;
			if(f[i]==100000&&d[i]>=10) h[i]=1;
			if(h[i]==0) g[i]=d[i]*f[i];
			else g[i]=0;
		}
		for(i=0;i<a;i++){
			for(j=i+1;j<a;j++){
				if(g[i]>=1000000&&h[i]==0){
					h[i]=1;
				}
				if(s[i]==s[j]){
					if(h[i]==0){
						g[i]+=g[j];
						g[j]=0;
					}
					else g[j]=0;
				}
				if(g[i]>=1000000&&h[i]==0){
					h[i]=1;
				}
			}
		}
		k=0;
		for(i=0;i<a;i++){
			if(h[i]==1){
				printf("%lld\n",s[i]);
				k=1;
			}
		}
		if(k==0) printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 2592
#辞書順で最も小さいものが答えだから、後ろから文字列の後ろから処理していく。
#後ろから考えるのは面倒くさいので、逆順にソートする。

s = str(input())
t = str(input())

sr = ''.join(list(reversed(s)))
tr = ''.join(list(reversed(t)))

slen = len(sr)
tlen = len(tr)

for i in range(slen-tlen+1):
    flg = i
    for j in range(tlen):
        if sr[i+j] == tr[j] or sr[i+j] == "?":
            continue
        else:
            flg = -1
            break
    else:
        #breakせずに正常にループが終了したら、Tが入る適切な場所が見つかったということなのでbreakする。
        #ここでbreakできなかったら、"UNRESTORABLE"が出力され終了する。
        break
else:
    flg = -1
    print("UNRESTORABLE")
    exit()


#before_resultではまだ"?"が残っている。
before_result_reversed = sr[:flg] + tr + sr[flg+tlen:]
before_result = ''.join(list(reversed(before_result_reversed)))


print(before_result.replace("?","a"))

Measured memory_bytes: 3064
while True:
    try:
        n = int(input())
        num = 0
        for a in range(10):
            for b in range(10):
                for c in range(10):
                    for d in range(10):
                        if (a + b + c + d == n):
                            num += 1
        print(num)
    except EOFError:
        break



Measured memory_bytes: 5592
use std::io::*;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = AtRead::from(i);
    let s = i.read_line().as_bytes();

    let r = is_win_first(&s);
    let r = if r { "First" } else { "Second" };

    writeln!(o, "{}", r).unwrap();
}

fn is_win_first(s: &[u8]) -> bool {
    (s[0] == s[s.len() - 1]) ^ (s.len() % 2 != 0)
}

mod utils {
    use super::*;

    pub struct AtRead<R: BufRead> {
        r: R,
        s: String,
    }

    impl<R: BufRead> AtRead<R> {
        pub fn from(r: R) -> Self {
            AtRead {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }
    }
}

Measured memory_bytes: 4352
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<unordered_set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<stack>
#include <cstring>
#include <climits>
using namespace std;
#define rep(i,n) for(int (i)=0;(i) < (n); (i)++)
#define FIND(v, k) find((v).begin(), (v).end(), k)
#define MAX 101
#define MAX_V 15
#define mset(a,x) memset(a,x,sizeof(a))
long long a[100000];
long long b[100000];
int main() {
	long long n, m;
	cin >> n >> m;
	if (m >= n * 2) {
		cout << n + ((m - n * 2) / 4) << endl;
	}
	else {
		cout << m / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int m,k,s=0,i;string st;char last=' ';
int main(){
	cin>>m>>k>>st;
	for(i=0;i<m;i++){
		if(last!=st[i]){
			last=st[i];
			s++;
		}
	}
	s=max(1,s-k*2);
	cout<<m-s<<endl;
	return 0;
}

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


int main(){
  
  int y,c[1000],a[1000],n[1000],p[1000];
  cin>>y;
  
  for(int i=0;i<y;i++){

   cin>>c[i]>>a[i]>>n[i];
   int cd,ad,nd;
   nd=min(c[i],a[i]);
   nd=min(nd,n[i]);
   ad=min(c[i]/2,a[i]);
   cd=c[i]/3;
   p[i]=cd;
   
   for(int t=0;t<=cd;t++){
     for(int h=0;h<=ad;h++){
       for(int j=0;j<=nd;j++){
	 if(t*3+h*2+j<=c[i] && h+j<=a[i] && j<=n[i]){p[i]=max(p[i],t+h+j);}
	 else{break;}
       }
     }
   }


  }

  for(int i=0;i<y;i++){
    cout<<p[i]<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 3104
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	int t;
	while(cin>>t,t){
		int n;
		cin>>n;
		int sum = 0;
		for(int i =0;i < n;i++){
			int x,y;
			cin>>x>>y;
			int z =y-x;
			sum +=z;
		}
		if(sum>=t){
			cout <<"OK"<<endl;
		}else{
			cout <<t-sum<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]

dp = [[0] * w for i in range(h)]

if maze[0][0] == "#":
    dp[0][0] = 1
    
for i in range(h):
    for j in range(w):
        if i == j == 0:
            continue
                
        if i == 0:
            if maze[0][j] != maze[0][j - 1]:
                dp[0][j] = dp[0][j - 1] + 1
            else:
                dp[0][j] = dp[0][j - 1]
        
        if j == 0:
            if maze[i][0] != maze[i - 1][0]:
                dp[i][0] = dp[i - 1][0] + 1
            else:
                dp[i][0] = dp[i - 1][0]
        
        if i != 0 and j != 0:
            tmp1 = 0
            tmp2 = 0
            if maze[i][j] != maze[i - 1][j]:
                tmp1 = 1
            if maze[i][j] != maze[i][j - 1]:
                tmp2 = 1
        
            dp[i][j] = min(dp[i - 1][j] + tmp1, dp[i][j - 1] + tmp2)

if maze[h - 1][w - 1] == "#":
    dp[h - 1][w - 1] += 1

ans = dp[h - 1][w - 1] // 2

print(ans)

Measured memory_bytes: 42352
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);
	static final int[] weights = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };

	public static void main(String[] args){

		while(scan.hasNext()){
			int w = scan.nextInt();
			StringBuffer sb = new StringBuffer();
			for(int i = 0; i < 10; i++){
				if((w & weights[i]) > 0){
					sb.append(weights[i]).append(' ');
				}
			}
			sb.deleteCharAt(sb.length() -1);
			String s = sb.toString();
			System.out.printf("%s\n", s);
		}
	}
}

Measured memory_bytes: 25992
# n = int(input())
# s = input()
n, m = map(int,input().split())
# da = list(map(int,input().split()))
# a = [int(input()) for i in range(n)]
da = [list(map(int,input().split())) for i in range(m)]

def ch(x):
    k = len(x)
    if n!=k: return False
    for i in range(m):
        if k < da[i][0]:
            return False
        if x[da[i][0]-1] != str(da[i][1]):
            return False
    return True

def solve():
    for i in range(10**n):
        if(ch(str(i))):
            print(i)
            return
    print(-1)
    return

solve()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
map <string,int> mp;
string s;
long long ans=0;
int main(){
	int n;cin>>n;
	while (cin >> s, n--){
		sort (s.begin(),s.end());
		ans+=mp[s]++;
	}
	cout<<ans;
}

Measured memory_bytes: 11136
n=int(input())
s=input()
cnt=0
for i in range(1000):
  flag=0
  pin=str(i).zfill(3)
  if s.find(pin[0])==-1:
    continue
  s1=s[s.find(pin[0])+1:]
  if s1.find(pin[1])==-1:
    continue
  s2=s1[s1.find(pin[1])+1:]
  if s2.find(pin[2])==-1:
    continue
  cnt+=1
print(cnt)

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {

        static Int64 Clac(List<Int64> currentData, ref int inputData)
        {
            List<Int64> tmpDataList = new List<Int64>();
            foreach (Int64 current in currentData)
            {

                string tmp = current.ToString();
                int minDigit = int.Parse(tmp.Last().ToString());
                Int64 newData = Int64.Parse(tmp + minDigit);

                //マイナス
                if (minDigit != 0)
                {
                    tmpDataList.Add(newData - 1);
                    inputData--;
                    if (inputData == 0)
                    {
                        return newData - 1;
                    }
                }
                tmpDataList.Add(newData);
                inputData--;
                if (inputData == 0)
                {
                    return newData;
                }

                if (minDigit != 9)
                {
                    tmpDataList.Add(newData + 1);
                    inputData--;
                    if (inputData == 0)
                    {
                        return newData + 1;
                    }
                }
            }
            return Clac(tmpDataList, ref inputData);
        }
        static void Main(string[] args)
        {
            //string[] inputData = Console.ReadLine().Split(' ');
            Int32 inputData = Int32.Parse(Console.ReadLine());

            List<Int64> startDataList = new List<Int64>() { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            List<Int64> allData = new List<Int64>();

            if (inputData < 10)
            {
                Console.WriteLine(startDataList[inputData - 1]);
            } else
            {
                inputData = inputData - 9;
                allData.AddRange(startDataList);
                Console.WriteLine(Clac(startDataList, ref inputData));
            }
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 17244
// Starting with the name of Allah

#include <bits/stdc++.h>
#define ll long long
#define nl endl
#define Nayon ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b


using namespace std;



int main()
{
	Nayon;
	int a,b;
	cin>>a>>b;
	if(a>9 || b>9){
		cout<<-1;
	}
	else{
		cout<<a*b;
	}
	return 0;
}

//Happy Coding.........

Measured memory_bytes: 3568
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    print(min(N%K, K - N%K));
    

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 305
const int mod=998244353;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int dp[N][N][N],n,ans;
bool ok[N][N][N];
char s[N];
#define ck(x) (x>=mod?x-mod:x)
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=0;i<n;++i){
		ok[i][0][0]=true;
		for(int j=0;j<=i;++j){
			for(int k=0;k+j<=i;++k){
				if(!ok[i][j][k])continue;
				if(s[i+1]=='0'||s[i+2]=='0')ok[i+2][j+1][k]=true;
				if(s[i+1]=='1'||s[i+2]=='1')ok[i+2][j][k+1]=true;
				if(j|k)ok[i+1][j][k]=true;
				if(s[i+1]=='0'&&k)ok[i+1][j+1][k-1]=true;
				if(s[i+1]=='1'&&j)ok[i+1][j-1][k+1]=true;
			}
		}
	}
	dp[n][0][0]=1;
	for(int i=n;i>=1;--i){
		for(int j=0;j<=i;++j){
			for(int k=0;k+j<=i;++k){
				const int t=dp[i][j][k];
				if(!t)continue;
				dp[i-1][j][k]=ck(dp[i-1][j][k]+t);
				if(s[i]=='0')dp[i][j][k+1]=ck(dp[i][j][k+1]+t);
				else dp[i][j+1][k]=ck(dp[i][j+1][k]+t);
			}
		}
	}
	for(int i=0;i<=n;++i){
		for(int j=0;j<=i;++j){
			for(int k=0;k+j<=i;++k){
				if(ok[i][j][k])ans=ck(ans+dp[i][j][k]);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 66804
/*
Author : N_o_o_B
Created : April 12 2020 17:32:20 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n;
    cin >> n;
    ll ans = 0;
    rep(i,1,n){
        if(i%3 != 0 and i%5 != 0) ans += i;
    }
    cout << ans << endl;


    time_taken();
    return 0;
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define lli long long int
#define llu long long unsigned int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(i,s,e) for(i=s; i<e; i++)
#define mod 1000000007
#define F first
#define S second
#define plli pair<lli,lli>
#define pqlli priority_queue<lli>
#define test(t) cin>>t; while(t--)
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s == "SUN")
	cout<<7<<endl;
	if(s == "MON")
	cout<<6<<endl;
	if(s == "TUE")
	cout<<5<<endl;
	if(s == "WED")
	cout<<4<<endl;
	if(s == "THU")
	cout<<3<<endl;
	if(s == "FRI")
	cout<<2<<endl;
	if(s == "SAT")
	cout<<1<<endl;
	

}



Measured memory_bytes: 256
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
void solve()
{
	ll x;
	cin>>x;
	cout<<x/500*1000+(x%500)/5*5;
}
signed main()
{
	
		/***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);
    /***********************************/
 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
		
	}
	TIME
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <list>
#include <cstdlib>
#include <cmath>
#define _USE_MATH_DEFINES

using namespace std;

bool isPrime(int n) {

	int i = 3;

	if (n == 2)
		return true;
	if (n <= 1 || n %2 == 0)
		return false;

	while (i <= sqrt(n)) {
		if (n % i == 0) 
			return false;
		i = i + 2;
	}
	return true;
}

int main() {

	int n, cnt=0,x;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
		if (isPrime(x))
			cnt++;
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool> vecbool;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<vecint> vec2int;
typedef vector<vecbool> vec2bool;
int dx[4]{-1, +1, 0, 0};
int dy[4]{0, 0, -1, +1};
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main() {
  init();
  ll n, m;
  cin >> n >> m;
  vecll a(m);
  ll sum = 0;
  for (auto &e : a) {
    cin >> e;
    sum += e;
  }
  cout << max(-1LL, n - sum) << endl;
}


Measured memory_bytes: 3696
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll safe_mod(ll x,ll m){
    x %= m;
    if (x < 0) x += m;
    return x;
}
pair<long long, long long> inv_gcd(long long a, long long b) {
    a = safe_mod(a,b);
    if (a == 0) return {b, 0};
    long long s = b, t = a;
    long long m0 = 0, m1 = 1;

    while (t) {
        long long u = s / t;
        s -= t * u;
        m0 -= m1 * u; 
        auto tmp = s;
        s = t;
        t = tmp;
        tmp = m0;
        m0 = m1;
        m1 = tmp;
    }
    if (m0 < 0) m0 += b / s;
    return {s, m0};
}
pair<long long, long long> crt(const vector<long long>& r,
                                    const vector<long long>& m) {
    int n = int(r.size());
    long long r0 = 0, m0 = 1;
    for (int i = 0; i < n; i++) {
        long long r1=safe_mod(r[i], m[i]), m1 = m[i];
        if (m0 < m1) {
            swap(r0, r1);
            swap(m0, m1);
        }
        if (m0 % m1 == 0) {
            if (r0 % m1 != r1) return {0, 0};
            continue;
        }
        long long g, im;
        P p= inv_gcd(m0, m1);
        g=p.fi;im=p.se;
        long long u1 = (m1 / g);
        if ((r1 - r0) % g) return {0, 0};
        long long x = (r1 - r0) / g % u1 * im % u1;
        r0 += x * m0;
        m0 *= u1; 
        if (r0 < 0) r0 += m0;
    }
    return {r0, m0};
}
vector<ll> divisor(ll n){
	vector<ll> ret;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			ret.push_back(i);
            if(i*i!=n)ret.push_back(n/i);
		}
	}
	sort(ret.begin(),ret.end());
	return(ret);
}
int main(){
    ll n;
    cin>>n;
    n*=2;
    V<ll> d=divisor(n);
    ll ans=inf;
    for(ll v:d){
        V<ll> b={0,n/v-1},m={v,n/v};
         P res=crt(b,m);
          if(res.fi!=0){
            chmin(ans,res.fi);
          }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 3748
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;
int main()
{
	string s;
	
	while(cin>>s)
	{
		bool ok=false;
		for(int i=0;i<s.size();i++)
		if(s[i]=='9')
			ok=true;
		if(ok)
			puts("Yes");
		else
			puts("No");
	}
	return 0;
}

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

ll A[100005];

ll gcd(ll a, ll b) {
	return b ? gcd(b, a%b) : a;
}
void noans() {
	puts("0");
	exit(EXIT_SUCCESS);
}
int main() {
	ll N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		ll tmp; cin >> tmp;
		A[i] = tmp / 2;
		//if (A[i] % 2 == 0) noans();
	}
	ll lcm = 1LL;
	for (int i = 0; i < N; i++) {
		//모든 수의 최소공배수를 구한다.
		lcm = lcm * A[i] / gcd(lcm, A[i]);
		if (lcm > M) noans();
	}
	for (int i = 0; i < N; i++) {
		if (((lcm / A[i]) % 2) == 0) noans();
	}
	ll ans = (M / lcm + 1) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int n,z,w,a[2000],memo[2000][2];

int dfs(int k,int turn){
    if(memo[k][turn]!=-1){
        return memo[k][turn];
    }
    int res;
    if(turn==0){
        res=abs(a[n-1]-(k==0?w:a[k-1]));
        for(int i=k;i<n-1;i++){
            res=max(res,dfs(i+1,1));
        }
    }
    else{
        res=abs(a[n-1]-a[k-1]);
        for(int i=k;i<n-1;i++){
            res=min(res,dfs(i+1,0));
        }
    }
    return memo[k][turn]=res;
}

int main(){
    cin>>n>>z>>w;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        memo[i][0]=memo[i][1]=-1;
    }
    cout<<dfs(0,0)<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
#define scd second
#define fst first
#define pb push_back
#define mkp make_pair
#define all(x) x.begin(), x.end()
#define VT(T) vector<T>
 
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;
typedef list<int> lint;
typedef list<ll> llong;
typedef list<pii> lpii;
typedef list<pll> lpll;
typedef list<lint> llint;
typedef list<llong> lllong;
typedef pair<double,double> pdd;

ll const LINF=numeric_limits<long long int>::max();
int const INF=numeric_limits<int>::max();
 
ll gcd(ll a, ll b){
	return b ? gcd(b,a%b) : a;
}
 
ll pow_mod(ll a, ll e, ll m){
	ll res=1;
	while(e){
		if(e&1) res=res*a%m;
		a=a*a%m;
		e>>=1;
	}
	return res;
}
 
ll inv_mod(ll b, ll m){
	b%=m;
	ll x=0, y=1, r, q, a=m;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=m;
	return x%m;
}

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

	char ch;
	cin>>ch;
	cout<<(char)(ch+1)<<endl;
}

Measured memory_bytes: 256
A,B=map(int,input().split())
import math
a=[]
for i in range(13,1010):
    if math.floor(i*0.08)==A and math.floor(i*0.10)==B:
        a.append(i)
if len(a)>=1:
    print(a[0])
else:
    print('-1')

Measured memory_bytes: 3060
while True:
    n = input()
    if not n: break 
    time = [0]*86400
    for i in range(n):
        s, t = raw_input().split()
        ssec = int(s[0:2])*3600 + int(s[3:5])*60 + int(s[6:8])
        tsec = int(t[0:2])*3600 + int(t[3:5])*60 + int(t[6:8])
        time[ssec] += 1
        time[tsec] -= 1
    ans = time[0]
    for i in range(86400-1):
        time[i+1] += time[i]
        ans = max(ans, time[i+1])
    print ans

        

Measured memory_bytes: 9592
A = [list(map(int,input().split())) for i in range(3)]
n = int(input())
ans = [[False]*3 for i in range(3)]
for i in range(n):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if b == A[j][k]:
        ans[j][k] = True
if ans[0][0] and ans[0][1] and ans[0][2]:
  print("Yes")
elif ans[1][0] and ans[1][1] and ans[1][2]:
  print("Yes")
elif ans[2][0] and ans[2][1] and ans[2][2]:
  print("Yes")
elif ans[0][0] and ans[1][0] and ans[2][0]:
  print("Yes")
elif ans[0][1] and ans[1][1] and ans[2][1]:
  print("Yes")
elif ans[0][2] and ans[1][2] and ans[2][2]:
  print("Yes")
elif ans[0][0] and ans[1][1] and ans[2][2]:
  print("Yes")
elif ans[0][2] and ans[1][1] and ans[2][0]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
/*
g++ -std=c++11 -o2 -Wall AISing2019B0.cpp -o .\out\AISing2019B0.out
.\out\AISing2019B0.out
*/

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

typedef long long ll;

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

  string s;
  cin >> s;
  int n = s.size();

  const string keyence = "keyence";
  int m = keyence.size();

  if (n == m) {
    if (s != keyence) cout << "NO\n";
    else cout << "YES\n";
  } else if (n < m) {
    cout << "NO\n";
  } else {
    for (int i = 0; i < n; ++i) {
      string ss = s;
      if ((i + (n -m) -1) < n && ss.erase(i, n - m) == keyence) {
        cout << "YES\n";
        return 0;
      }
    }
    cout << "NO\n";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    string a, b;
    cin >> a >> b;
    vrev(b);
    if (a == b) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



int H, W;
char maze[30][30];

int bfs(pair<int, int> s) {
  queue<pair<int, int>> que;
  que.push(s);
  int dist[30][30];
  rep(i, H) {
    rep(j, W) {
      dist[i][j] = -1;
    }
  }
  dist[s.first][s.second] = 0;

  while (!que.empty()) {
    pair<int, int> p = que.front();
    que.pop();
    int c = dist[p.first][p.second];
    c++;

    Rep(i, 4) {
      if (maze[p.first + dy[i]][p.second + dx[i]] == '.') {
        if (dist[p.first + dy[i]][p.second + dx[i]] != -1) continue;

        dist[p.first + dy[i]][p.second + dx[i]] = c;
        que.emplace(p.first + dy[i], p.second + dx[i]);
      }
    }
  }

  int ans = 0;
  rep(i, H) {
    rep(j, W) {
      ans = max(ans, dist[i][j]);
    }
  }

  return ans;
}

int main () {
  cin >> H >> W;

  rep(i, H) {
    string tmp;
    cin >> tmp;
    rep(j, W) {
      maze[i][j] = tmp[j-1];
    }
  }

//  rep(i, H) {
//    rep(j, W) {
//      cout << maze[i][j] << "\n";
//    }
//  }

  int ans = 0; 

  rep(i, H) {
    rep(j, W) {
      if (maze[i][j] == '#') continue;

      int tmp = bfs(make_pair(i, j));
      // cout << i << " " << j << "\n";
      // cout << tmp << "\n";
      ans = max(ans, tmp);
    }
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
n,y=map(int,input().split())
y//=1000
a=y%5
for i in range(n+1):
    if a==i%5:
        b=(y-i)//5
        c=n-i
        if c<=b<=2*c:
            print(b-c,2*c-b,i)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int N;

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

	int A,B;

	cin >> A >> B;


	if(B % A == 0){
		

		cout << A + B << endl;
	}else{
		cout << B - A << endl;
	}

}

Measured memory_bytes: 256
a,c = map(int,input().split())
ax = []
ay = []
cx = []
cy = []
mindistance = 10 ** 10
point = 0
for hogehoge in range(a):
         axx,ayy = input().split()
         ax.append(int(axx))
         ay.append(int(ayy))
for hogehoge in range(c):
         cxx,cyy = input().split()
         cx.append(int(cxx))
         cy.append(int(cyy))
for i in range(a):
         for j in range(c):
                  temp = (abs(ax[i] - cx[j]) + abs(ay[i] - cy[j]))
                  if mindistance > temp:
                           mindistance = temp
                           point = j
         else:
                  print(point+1)
                  mindistance = 10 ** 10
                  point = 0
                           
                  


Measured memory_bytes: 3064
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
int G[101][101];
int tim[101];
const int INF=100000000;
int dist[101];
bool used[101];
int n;
int dp[1<<17];

int main(){
while(cin>>n,n){
rep(i,n){
	rep(j,n+1){
		if(j==0)cin>>tim[i];
		else cin>>G[i][j-1];
	}
}
rep(i,1<<n)dp[i]=INF;
dp[0]=0;

for(int i=0;i<(1<<n);i++){//状態

	if(dp[i]!=INF){
	for(int j=0;j<n;j++){//次追加するやつ
		if(i&(1<<j))continue;
		int c=tim[j];
		for(int k=0;k<n;k++){
			if(i&(1<<k))c=min(c,G[j][k]);
		}	
		int next=i+(1<<j);
		dp[next]=min(dp[next],dp[i]+c);
	}
	}
}

cout<<dp[(1<<n)-1]<<endl;

rep(i,n)tim[i]=0;
rep(i,n)rep(j,n)G[i][j]=0;
}
	return 0;
}


Measured memory_bytes: 3368
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int sum_digit(const int n) {
	return (n == 0) ? 0 : n % 10 + sum_digit(n / 10);
}
int main() {
	int n, a, b; std::cin >> n >> a >> b;
	int sum = 0;
	for (auto i = 1; i <= n; ++i) {
		if (a <= sum_digit(i) && sum_digit(i) <= b) sum += i;
	}
	std::cout << sum << std::endl;
}



Measured memory_bytes: 256