akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    sort(v.begin(), v.end());
    if(v[n-1] -v[0] >= 2) {
        puts("No");
        return 0;
    }
    if(v[0] == v[n-1]){
        puts((2*v[0] <= n || v[0] == n-1) ? "Yes" : "No");
        return 0;
    }
    int a = 0, b = 0;
    for (int i = 0; i < n; ++i) {
        (v[i] == v[0] ? a : b)++;
    }
    puts((a+1 <= v[n-1] && v[n-1] <= a+b/2) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(begin(v), end(v))
#define REV(v) reverse(begin(v), end(v))
#define VI vector<int>
#define PB(x) push_back(x)
#define SZ(x) end(x) - begin(x)
#define DEBUG(x) cerr << __LINE__ << ":" << #x << ": " << x << "\n";
//#define int long long
using namespace std;
using lint = long long;
struct Fast{Fast(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};} fast;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
inline void CO(auto &a) {REP(i, SZ(a)) cout << i << ": " << a[i] << "\n";}
//if (IO > 1e5){lint a;	scanf(%lld, &a);	printf("%lld\n", a);}

signed main(){
	string s;	cin >> s;
	int ans = INF;
	REP(i,s.length()-2){
		ans = min(ans, abs(753-stoi(s.substr(i,3))));
	}
	cout << ans;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=100010;
int a[maxn],c[maxn],b[maxn],A[maxn],ans[maxn];
int AA[maxn];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&AA[i]);
/**/	if(i!=1)a[i]=AA[i]-AA[i-1];
		else a[i]=AA[i];
		c[i]=i;
	}
	int m;LL k;
	scanf("%d%lld",&m,&k);
	for(int i=1;i<=m;++i){
		int x;
		scanf("%d",&x);
		swap(c[x],c[x+1]);
	}
//	cout<<a[3]<<endl;
	for(int i=1;i<=n;++i){
		if(!b[i]){
			int cnt=0;
			for(int j=i;!b[j];j=c[j]){
	//			cout<<j<<endl;
				b[j]=1;
				A[++cnt]=j;
			}
			for(int j=1;j<=cnt;++j){
				ans[A[j]]=a[A[((LL)(j+k-1))%cnt+1]];
		//		cout<<ans[A[j]]<<endl;
//				cout<<A[(j+k-1)%cnt+1]<<endl;
			}
		}
	}
	LL sum=0;
	for(int i=1;i<=n;++i){
		//cout<<ans[i]<<endl;
		sum+=ans[i];
		printf("%lld.0\n",sum);
	}
	return 0;
}

Measured memory_bytes: 3840
n = gets.chomp
if n.to_i >= 100
  s = n.split("")
  num = s[2].to_i
elsif n.to_i >= 10
  s = n.split("")
  num = s[1].to_i
else
  num = n.to_i
end

h = "hon"
p = "pon"
b = "bon"
re = [p, p, h, b, h, h, p, h, p, h]
for i in 0..9
  if i == num
    puts re[i]
  end
end

Measured memory_bytes: 14380
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<vector<P> > v(N);
  FOR(i,0,N) {
    int A;
    cin >> A;
    FOR(j,0,A) {
      int x, y;
      cin >> x >> y;
      x--;
      v[i].push_back(P(x, y));
    }
  }
  int ans = 0;
  FOR(i,0,1<<N) {
    bool ok = true;
    int cnt = 0;
    FOR(j,0,N) {
      // jの証言、jが正直者なら証言が矛盾しないかチェック
      if (i & (1 << j)) {
        cnt++;
        for (P p : v[j]) {
          int x = p.first;
          int y = p.second;
          if (y == 1) {
            if (!(i & (1 << x))) {
              ok = false;
            }
          }
          if (y == 0) {
            if (i & (1 << x)) {
              ok = false;
            }
          }
        }
      }
    }
    if (ok) {
      //cout << "ok => " << std::bitset<8>(i) << endl;
      ans = max(ans, cnt);
    }
  }
  cout << ans << endl;
}


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

int main(){
        int n;
        cin>>n;
        int r[9]={0};
        for(int i=0; i<n; i++){
                int a;
                cin>>a;
                a/=400;
                if(a>=8) r[8]++;
                else r[a]++;
        }
        int mx=0, mn=0;
        for(int i=0; i<=7; i++) if(r[i]>0) mn++;
        if(mn==0){
                if(r[8]>0){
                        mn=1;
                        mx=r[8];
                }
        }
        else{
                mx=mn+r[8];
        }
        cout<<mn<<" "<<mx<<endl;
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
const int MOD = 1e9 + 7;
typedef long long ll; 
map<ll, ll> m; 
ll f(ll n) 
{
  return m[n] > 0 ? m[n]: (m[n] = (f(n / 2) + f((n - 1) / 2) % MOD + f((n - 2) / 2)) %MOD);
} 
int main() 
{
  ll n;
  cin>>n;
  m[0] = 1;
  m[1] = 2;
  cout<<f(n);
  return 0;
}

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

int main() {
  int A , B , C;
  cin >> A >> B >> C;
  
  if(A == B && A != C) {
    cout << " Yes" << endl;
  }
  
  else if(A == C && A != B) {
    cout << "Yes" << endl;
  }
  
  else if(B == C && B != A) {
    cout << "Yes" << endl;
  }
  
  else { cout << "No" << endl;}
  
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

/* ダブルハッシュ法を使うのでハッシュテーブルのサイズは素数である必要がある */
#define HASH_TABLE_LEN 1046527

/* Hash_tableash Table */
/* グローバル宣言:ゼロクリアされているため初期化は不要 */
static char Hash_table[HASH_TABLE_LEN][13];

/* 文字列から数値に変換 */
int getChar(char ch)
{
    if (ch == 'A')
        return 1;
    else if (ch == 'C')
        return 2;
    else if (ch == 'G')
        return 3;
    else if (ch == 'T')
        return 4;

    return 0;
}

/* convert a string into an integer value */
int getKey(char str[])
{
    int str_convert = 0;
    int p = 1;
    int str_len = (int)strlen(str);

    for (int i = 0; i < str_len; i++)
    {
        str_convert += p * (getChar(str[i]));
        /* ここで5を乗算しているのは、文字を1から4の数値に置き換えているため */
        p *= 5;
    }
    return str_convert;
}

int hash_func1(int key)
{
    return key % HASH_TABLE_LEN;
}

int hash_func2(int key)
{
    /* HASH_TABLE_LENと,HASH_TABLE_LEN - 1は「互いに素」 */
    return (1 + (key % (HASH_TABLE_LEN - 1)));
}

int hash_func(int key, int i)
{
    return ((hash_func1(key) + i * hash_func2(key)) % HASH_TABLE_LEN);
}

int find(char str[])
{
    int key, hash_index;
    key = getKey(str);
    for (int i = 0;; i++)
    {
        hash_index = hash_func(key, i);

        /* 文字列が一致すれば1,値が格納されていなければ0 */
        if (strcmp(Hash_table[hash_index], str) == 0)
            return 1;
        else if (Hash_table[hash_index][0] == '\0')
            return 0;
    }
}

int insert(char str[])
{
    int key;
    int i;
    int hash_index;

    key = getKey(str);

    for (i = 0;; i++)
    {
        hash_index = (hash_func1(key) + i * hash_func2(key)) % HASH_TABLE_LEN;
        if (strcmp(Hash_table[hash_index], str) == 0)
            return 1;
        else if (strlen(Hash_table[hash_index]) == 0)
        {
            strcpy(Hash_table[hash_index], str);
            return 0;
        }
    }

    for (i = 0;; i++)
    {
        hash_index = (hash_func1(key) + i * hash_func2(key)) % HASH_TABLE_LEN;
        if (strcmp(Hash_table[hash_index], str) == 0)
            return 1;
        else if (strlen(Hash_table[hash_index]) == 0)
        {
            strcpy(Hash_table[hash_index], str);
            return 0;
        }
    }
    return 0;
}

int main()
{
    int i, N;
    char str[12];
    char order[7];

    scanf("%d", &N);
    for (i = 0; i < N; i++)
    {
        scanf("%s %s", order, str);
        if (order[0] == 'i')
            insert(str);
        else
        {
            if (find(str))
                printf("yes\n");
            else
                printf("no\n");
        }
    }
    return 0;
}


Measured memory_bytes: 14952
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    strings = []
    prevdic = None
    for _ in range(N):
        ch = S()
        curdic = collections.Counter()
        for c in ch:
            curdic[c] += 1
        if prevdic:
            for k, v in prevdic.items():
                prevdic[k] = min(v, curdic[k])
        else:
            prevdic = curdic
    diclist = []
    for k, v in prevdic.items():
        diclist.append((k, v))
    diclist = sorted(diclist, key=lambda x: x[0])
    ans = ''
    for item in diclist:
        k, v = item[0], item[1]
        ans += k * v
    print(ans)
main()



Measured memory_bytes: 6220
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n,ans=0;
    cin>>n;
    map<string,int> f;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if(f[s]==0) ans++;
        f[s]++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 19140
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
  stack<int> S;
  S.push(r);
  color[r] = c;
  while ( !S.empty() ) {
    int u = S.top(); S.pop();
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if (color[v] == NIL) {
        color[v] = c;
        S.push(v);
      }
    }
  }
}

void assignColor() {
  int id = 1;
  for (int i = 0; i < n; i++) color[i] = NIL;
  for (int u = 0; u < n; u++) {
    if (color[u] == NIL) dfs(u, id++);
  }
}

int main() {
  int s, t, m, q;

  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();

  cin >> q;

  for (int i = 0; i < q; i++) {
    cin >> s >> t;
    if (color[s] == color[t]) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 8944
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 2e6 + 7;
const int maxm = 1e6 + 7;
const int ALP = 26;
const long long mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-8;

long long gcd(long long a,long long b)
{
	return b==0?a:gcd(b,a%b);
}

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

long long a,b;

int main()
{
	scanf("%lld%lld",&a,&b);
	printf("%lld\n",lcm(a,b));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    
    for(int i=1;i<=n-k;i++){
        if(a[i-1] < a[i+k-1]){
            cout<<"Yes\n";
        }
        else{
            cout<<"No\n";
        }
    }
}


Measured memory_bytes: 5196
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
from collections import Counter
from math import factorial

def main():
    n = int(input().strip())
    s = input().strip()
    s += 'E'
    ans = 0
    for i in range(1000):
        a = i // 100
        b = (i % 100) // 10
        c = i % 10
        k = s.find(str(a))
        l = s.find(str(b), k+1)
        m = s.find(str(c), l+1)
        if k != -1 and l != -1 and m != -1:
            # print(a, b, c)
            ans += 1
    print(ans)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc  = new Scanner(System.in);

    public static void main(String[] args){
        int N = nextInt();
        int M = nextInt();

        String[] S = next().split("");
        String[] T = next().split("");

        long L = lcm(N, M);

        HashMap<Long, String> map = new HashMap<>();
        for(int i=0; i<N; i++){
            long indexS  = i==0 ? 0 : i*L/N + 1;
            map.put(indexS, S[i]);
        }

        for(int i=0; i<M; i++){
            long indexT = i==0 ? 0 : i*L/M + 1;

            if(!(!map.containsKey(indexT) || map.get(indexT).equals(T[i]))){
                L = -1;
                break;
            }
        }

        println(L);
    }

    //最大公約数gcd
    static long gcd (long a, long b) {
        long temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
    //最小公倍数lcm
    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (c/b);
    }
    static int nextInt(){
        return Integer.parseInt(next());
    }
    static Long nextLong(){
        return Long.parseLong(next());
    }
    static String next(){
        return sc.next();
    }
    static void println(Object o){
        PrintWriter out = new PrintWriter(System.out);
        out.println(o);
        out.flush();
    }
   static void print(Object o){
       PrintWriter out = new PrintWriter(System.out);
       out.print(o);
       out.flush();
    }
}


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

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

    if(n%2==0)
        cout<<"-1\n";
    else
    {

        int rem = 0,m;
        for(int i=1;i<=1e6;i++)
        {
            long long int k = rem*10+7;

            rem = k%n;
            if(rem==0)
            {
                m = i;
                break;
            }

        }

        if(rem!=0)
            cout<<"-1\n";
        else
            cout<<m<<endl;
    }
}


Measured memory_bytes: 3556
n,k = gets.split.map(&:to_i)
ans = 0.0
1.upto(n) do |i|
  t = Math.log2((k/i.to_f).ceil)
  t = 0 if !t.finite?
  ans += 1.0 * 2**(-(t.ceil))/n
  #p [i,t] if i < 50
end
p ans


Measured memory_bytes: 1916
X, K, D = map(int, input().split())

X = abs(X)

low = X // D

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

Measured memory_bytes: 9184
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
int n;
char s[15]=" aaaaaaaaaa";
void dfs(int i,char maxc){
	if(i==n+1) return;
	for(char c='a';c<=maxc+1;c++){
		s[i]=c;
		if(i==n) printf("%s\n",s+1);
		dfs(i+1,max(maxc,c));
	}
}
int main(){
	scanf("%d",&n);
	if(n==1){
		puts("a");
		return 0;
	}
	s[n+1]='\0';
	dfs(2,'a');
	return 0;
}

Measured memory_bytes: 1536
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    String out = "";
    boolean keyBreak = false;
    List<String> scores = new ArrayList<String>();
    List<String> ranks = new ArrayList<String>();
    while (scanner.hasNext()) {
      String line = scanner.nextLine();
      if (line.equals("0,0")) {
        keyBreak = true;
        Collections.sort(scores);
        Collections.reverse(scores);
        int rank = 0;
        int preScore = Integer.MAX_VALUE;
        for (String el : scores) {
          String[] works = el.split(",");
          int score = Integer.parseInt(works[0]);
          if (preScore > score) {
            rank++;
          }
          ranks.add(works[1] + "," + rank);
          preScore = score;
        }
        continue;
      }
      if (keyBreak) {
        for (String el : ranks) {
          String[] works = el.split(",");
          if (!line.equals(works[0])) {
            continue;
          }
          out += works[1] + "\n";
        }
      } else {
        String[] works = line.split(",");
        if (works[1].length() == 1) {
          works[1] = "0" + works[1];
        }
        scores.add(works[1] + "," + works[0]);
      }
    }
    System.out.print(out);
  }
}

Measured memory_bytes: 18236
N = int(input())
a_list = []
b_list = []
c_list = []
a_append = a_list.append
b_append = b_list.append
c_append = c_list.append
for i in range(N):
    a, b, c = map(int, input().split())
    a_append(a)
    b_append(b)
    c_append(c)

dp = [[-1 for _ in range(3)] for _ in range(N + 1)]

for i in range(1, N + 1):

    if i == 1:
        dp[i][0] = a_list[i - 1]
        dp[i][1] = b_list[i - 1]
        dp[i][2] = c_list[i - 1]
    else:
        dp[i][0] = max(dp[i][0], dp[i - 1][1] + a_list[i - 1])
        dp[i][0] = max(dp[i][0], dp[i - 1][2] + a_list[i - 1])
        dp[i][1] = max(dp[i][1], dp[i - 1][0] + b_list[i - 1])
        dp[i][1] = max(dp[i][1], dp[i - 1][2] + b_list[i - 1])
        dp[i][2] = max(dp[i][2], dp[i - 1][0] + c_list[i - 1])
        dp[i][2] = max(dp[i][2], dp[i - 1][1] + c_list[i - 1])

print(max(dp[N]))

Measured memory_bytes: 36176
k,a,b = map(int,input().split())
ans0 = 1+k
#a<bの時のみ交換を行う。1>>aになるまで加算し、そのあとはa-bを繰り返す。

if a+2>=b:
    print(1+k)
else:
    q=(k-a+1)//2
    if q==0:
        print(1+k)
    else:
        print(1+(k-2*q)+q*(b-a))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 222222;
int n,a[N],b[N];
int dis(int x, int y){return x-y>0?x-y:y-x;}
bool ck(){//a[1..2*n-1]
	bool flag=1;
	rep(i,1,2*n-2)flag&=a[i]!=a[i+1];
	if(flag){
		return (n-1+a[n])&1;
	}
	int v[2];rep(i,0,1)v[i]=1e9;
	rep(i,1,2*n-2)if(a[i]==a[i+1])
		umin(v[a[i]],min(dis(i,n),dis(i+1,n)));
	return v[1]<v[0];
}
int main() {
	read(n);rep(i,1,n*2-1)read(b[i]);
	int l=1,r=2*n-1;
	while(l<r){
		int mid=(l+r)>>1;
		rep(i,1,n*2-1)a[i]=b[i]>mid;
		if(ck())l=mid+1;else r=mid;
	}
	printf("%d",l);
	return 0;
}


Measured memory_bytes: 1792
n,m,x=map(int,input().split())
l=[]
for _ in range(n):
    l.append(list(map(int,input().split())))
sum=100000000
for i in range(2**n):
    a=[0]*m
    buf=0
    for j in range(n):
        if (i>>j)&1:
            for k in range(m):
                a[k]+=l[j][k+1]
            buf+=l[j][0]
    flag=0
    for _ in a:
        if _<x:
            flag-=1
    if flag==0:
        sum=min(sum,buf)
if sum==100000000:
    print(-1)
else:
    print(sum)


Measured memory_bytes: 68352
#include <stdio.h>

int main(void){
    int a,b,i,j,k;
    int div[1000];
    j = 0;
    scanf("%d %d %d",&a,&b,&k);
    for (i=100;i>0;i--){
        if (a%i==0){
            if (b%i==0){
                div[j] = i;
                j++;
            }
        }
    }
    printf("%d",div[k-1]);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int k,len;
	char s[105];
	cin>>k;
	cin>>s;
	len=strlen(s);
	if(len>k)
	{
		for(int i=0;i<k;i++)
		    cout<<s[i];
		cout<<"..."<<endl;
	}
	else
		cout<<s<<endl;	   
	return 0;
}

Measured memory_bytes: 3072
def solve():
    N = int(input())
    H = list(map(int, input().split()))

    for i in range(N-2, -1, -1):
        if H[i] - 1 == H[i+1]:
            H[i] -= 1
        elif H[i] - 1 > H[i+1]:
            print('No')
            exit(0)
    
    else:
        print('Yes')

if __name__ == '__main__':
    solve()


Measured memory_bytes: 63856
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cassert>
using namespace std;

long long H, W, K, A, B, C, mod = 1000000007; string S[1009]; bool a1 = false, a2 = false;
map<long long, long long>M;

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 63; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}
long long Div(long long a, long long b, long long m) {
	return (a*modpow(b, m - 2, m)) % m;
}
long long modpowsum(long long a, long long b, long long m) {
	if (b == 1) return 1;
	if (M[b] >= 1) return M[b] - 1;
	long long E = b / 2;
	long long R1 = modpowsum(a, E, m);
	long long R2 = modpowsum(a, b - E, m)*modpow(a, E, m); R2 %= m;
	long long S = (R1 + R2) % m;
	M[b] = S + 1;
	return S;
}

int main() {
	cin >> H >> W >> K; assert(K != 0);
	for (int i = 0; i < H; i++) {
		cin >> S[i];
		for (int j = 0; j < W; j++) { if (S[i][j] == '#') C++; }
	}
	if (K == 0) {
		cout << "1" << endl;
		return 0;
	}
	if (K == 1) {
		cout << "1" << endl;
		return 0;
	}
	for (int i = 0; i < H; i++) {
		if (S[i][0] == '#' && S[i][W - 1] == '#') a1 = true;
	}
	for (int i = 0; i < W; i++) {
		if (S[0][i] == '#' && S[H - 1][i] == '#') a2 = true;
	}
	if (a1 == false && a2 == false) {
		cout << modpow(C, K - 1, mod) << endl;
		return 0;
	}
	if (a1 == false && a2 == true) {
		vector<string>I(W, "");
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) I[j] += S[i][j];
		}
		swap(H, W);
		for (int i = 0; i < H; i++) S[i] = I[i];
	}
	if (a1 == true && a2 == true) {
		cout << "1" << endl;
		return 0;
	}
	for (int i = 0; i < H; i++) {
		if (S[i][0] == '#' && S[i][W - 1] == '#') B++;
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W - 1; j++) {
			if (S[i][j] == '#' && S[i][j + 1] == '#') A++;
		}
	}
	long long I1 = modpow(B, K - 2, mod); I1 *= A; I1 %= mod;
	long long J = Div(C, B, mod);
	long long I2 = modpowsum(J, K - 1, mod);
	long long I = modpow(C, K - 1, mod);
	long long II = I1*I2; II %= mod;
	cout << (I - II + mod) % mod << endl;
	return 0;
}

Measured memory_bytes: 2432
import java.util.*;
import java.io.*;
public class Main{
public static int getMin(int N,int[]height,int k){
    int[]dp=new int[N+1];
    dp[2]=Math.abs(height[0]-height[1]);
    for(int i=3;i<=N;i++){
      dp[i]=Integer.MAX_VALUE;
      for(int j=1;j<=k&&i>j;j++){
          dp[i]=Math.min(dp[i-j]+Math.abs(height[i-1-j]-height[i-1]),dp[i]);
      }
    }
    return dp[N];
  }
public static void main(String[] args){
    int N,k;
    Scanner in=new Scanner(System.in);
    N=in.nextInt();
    k=in.nextInt();
    int[] height=new int[N];
    for(int i=0;i<N;i++)height[i]=in.nextInt();
    if(N<=k+1)System.out.println(Math.abs(height[0]-height[N-1]));
    else System.out.println(getMin(N,height,k));
    }
}

Measured memory_bytes: 50512
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const ll inf=1e9;
const int MAX = 510000;
const ll MOD = 998244353;

int main(){
  ll n,x,t;cin>>n>>x>>t;
  if(n%x==0)cout<<t*(n/x)<<endl;
  else cout<<t*(n/x+1)<<endl;
}


Measured memory_bytes: 3628
#include<iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	}
	if (n == 2) {
		int a, b;
		cin >> a;
		cin >> b;
		cout << a + b << endl;
	}
    return 0;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int numCntst, winNum, dedRate, pool, total;
		List<Integer> voteList = new ArrayList<Integer>();

		for(;;){
			pool = total = 0;

			numCntst = sc.nextInt();
			winNum = sc.nextInt();
			dedRate = sc.nextInt();
			if(numCntst == 0) break;

			for(int i = 0; i < numCntst; i++){
				voteList.add(sc.nextInt());
			}

			for(int i = 0; i < numCntst; i++){
				pool += 100 * voteList.get(i);
			}
			total = pool * (100 - dedRate)/ 100;

			if(voteList.get(winNum - 1) == 0) System.out.println(0);
			else System.out.println(total / voteList.get(winNum - 1));

			voteList.clear();
		}
	}

}

Measured memory_bytes: 13000
S = input()
K = int(input())
s = list(map(int,S))

num = 1
one_cnt = 0
for i in s:
    if i != 1:
        num = i
        break
    else:
        one_cnt += 1
if (one_cnt >= K):
    print(1)
else:
    print(num)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    int n, W;
    cin >> n >> W;
    
    int w[n+1], v[n+1];
    forn(i, 1, n+1) {
        cin >> w[i] >> v[i];
    }
    
    ll dp[n+1][W+1] = {};
    forn(i, 1, n+1) {
        forn(j, 1, W+1) {
            ll a = dp[i-1][j];
            ll b = (j-w[i] >= 0) ? b = dp[i-1][ j-w[i] ] + v[i] : 0;
            dp[i][j] = max(a, b);
        }
    }
    
    cout << dp[n][W] << endl;
}


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

int main(){
  string s;
  cin >> s;
  int n1, n2;
  n1 = stoi(s.substr(0, 2));
  n2 = stoi(s.substr(2, 2));
  if (1 <= n1 && n1 <= 12){
    if (1 <= n2 && n2 <= 12) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  }
  else{
    if (1 <= n2 && n2 <= 12) cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]pub mod pcl{}
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    if s.trim().as_bytes().windows(2).any(|s| s[0] != s[1]) {
        println!("Yes");
    } else {
        println!("No");
    }
}



Measured memory_bytes: 4352
#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++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;

int  main()
{ 
	ll a; string b; cin >> a >> b;
	int ib = ((b[0]-48) *100)+ ((b[2]-48)*10) + ((b[3]-48)*1);
	// printf("%lld", (ll)(a*b / 100));
	printf("%lld", (ll)a*ib/100);
	return (0);
}

Measured memory_bytes: 3720
#include<cstdio>
int main()
{
	int a=0,b=0,c=0;
	scanf("%d %d %d",&a,&b,&c);
	if((a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5))printf("YES\n");
	else printf("NO\n");
	return 0;
	}


Measured memory_bytes: 128
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                String S = scan.next();
                String T = scan.next();
               
                int nagasa = T.length();
                
                int ans = 10000;
                
                for(int i=0; i<=S.length()-nagasa; i++){
                    int kotonaru = 0;
                    int cnt=0;
                    while(cnt<T.length()){
                        if(S.charAt(i+cnt)!=T.charAt(cnt)){
                            kotonaru++;
                        }
                        cnt++;
                    }
                
                    ans = Math.min(kotonaru, ans);
                }
                
                System.out.println(ans);
        }
}

Measured memory_bytes: 35764
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    const long long MOD = 1000000000 + 7;

    int N;
    int K;
    cin >> N >> K;

    vector <long long> posVal;
    vector <long long> negVal;
    long long res = 1;

    for (int i = 0; i < N; ++i) {
        long long val;
        cin >> val;

        if (val < 0) {
            negVal.push_back(val);
        } else {
            posVal.push_back(val);
        }
    }

    int RK = K - min(K/2*2, ((int)negVal.size()/2) * 2);

    // must be negative
    if (RK > posVal.size()) {
        int idx[2] = {0, 0};
        sort(posVal.begin(), posVal.end());
        sort(negVal.begin(), negVal.end(), greater<int>());

        while (K > 0) {
            if (idx[0] < posVal.size() && idx[1] < negVal.size()) {
                if (abs(posVal[idx[0]]) < abs(negVal[idx[1]])) {
                    res *= posVal[idx[0]++];
                    res %= MOD;
                } else {
                    res *= negVal[idx[1]++];
                    res %= MOD;
                }
            } else if (idx[0] < posVal.size()) {
                res *= posVal[idx[0]++];
                res %= MOD;
            } else {
                res *= negVal[idx[1]++];
                res %= MOD;
            }
            --K;
        }
    } else { // can be positive
        int idx[2] = {0, 0};
        sort(posVal.begin(), posVal.end(), greater<int>());
        sort(negVal.begin(), negVal.end());

        if (K%2) {
            res *= posVal[idx[0]++];
            res %= MOD;
            --K;
        }

        while (K >= 2 && idx[1]+2 <= negVal.size()) {
            long long mul[2] = {0, negVal[idx[1]] * negVal[idx[1]+1]};
            int plus = 0;

            if (idx[0]+2 <= posVal.size()) {
                mul[0] = posVal[idx[0]] * posVal[idx[0]+1];
                plus = 2;
            } else if (idx[0]+1 <= posVal.size()) {
                mul[0] = posVal[idx[0]];
                plus = 1;
            }

            if (mul[0] > mul[1]) {
                mul[0] %= MOD;
                res *= mul[0];
                res %= MOD;
                idx[0] += plus;
                K -= plus;
            } else {
                mul[1] %= MOD;
                res *= mul[1];
                res %= MOD;
                idx[1] += 2;
                K -= 2;
            }
        }

        while (K > 0 && idx[0] < posVal.size()) {
            res *= posVal[idx[0]++];
            res %= MOD;
            --K;
        }
    }

    cout << ((res + MOD) % MOD) << endl;

    return 0;
}

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

int main() {

  int N;
  cin >> N;

  vector<char> color(N);
  vector<char> color_copy(N);

  for(int i = 0; i < N; i++){
    cin >> color[i];
    color_copy[i] = color[i];
  }

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

  int cnt = 0;
  for(int i= 0; i < N; i++){
    if(color[i] == 'W'){
      break;
    }else if(color_copy[i] == 'W'){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3780
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
int main() {
    string s;
    cin >> s;
    for(int i = 0; i < s.size();i++) {
        if(s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3624
#include "iostream"
#include "algorithm"
#include "string"
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	int target[105];
	for (int i = 0; i < m; i++) {
		cin >> target[i];
	}
	int prediction[105][105], score[105] = {};
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n; j++) {
			cin >> prediction[i][j];
			//i回目のゲームのfriends[j]の予想
			if (prediction[i][j] == target[i])score[j]++;
			else score[target[i] - 1]++;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << score[i] << endl;
	}
}


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

using namespace std;
int a[105];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]%2==0&&a[i]%3!=0&&a[i]%5!=0){
			cout<<"DENIED";
			return 0;
		}
	}
	cout<<"APPROVED";
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    string s;
    cin>>s;

    ll n = s.length();
    Vec x(s.length());
    rep(i,n){
        x[i] = s[i]=='p'?1:0;
    }
    ll ans = 0;

    rep(i,n){
        ll a = i%2;
        ans += a-x[i];
    }

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


Measured memory_bytes: 1232
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int main()
{
	LL N, h, n, w;
	scanf("%lld", &N);
	for (LL h = 1; h <= 3500; h++) {
		for (LL w = 1; w <= 3500; w++) {
			LL hor = N * h * w;
			LL lob = 4 * h * w - N * w - N * h;
			if (lob == 0) continue;
			if (hor % lob) continue;
			LL n = hor / lob;
			if (!IN(n, 1, 3500)) continue;
			printf("%lld %lld %lld\n", h, n, w);
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node
{
	int l,r;
}a[100003];
int n,minn=2e9+3,x,l,ans,ans1,maxx=-2e9;
int cmp(node nx,node ny)
{
	return nx.r<ny.r;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&x,&l);
		a[i].l=x-l,a[i].r=x+l;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
		if(a[i].l>=maxx)
			ans++,maxx=max(a[i].r,maxx);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {

	int H, R;
	cin >> H >> R;

	if (H >= 0)
	{
		cout <<"1" << endl;
	}
	else if (H == -R)
	{
		cout << "0" << endl;
	}
	else
	{
		cout << "-1" << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a>0 && b>0){
    cout<<"Positive"<<'\n';
  }
  else if(a<0 && b>0){
    cout<<"Zero"<<'\n';
  }
  else{
    int x=a%2,y=b%2;
    if((x+y)%2==0){
      cout<<"Negative"<<'\n';
    }
    else{
      cout<<"Positive"<<'\n';
    }
  }
  return(0);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	sort(a.begin(), a.end());
	vector<ll> f(n);
	rep(i,n) cin >> f[i];
	sort(f.rbegin(), f.rend());
	ll ok = 1e18, ng = -1;
	while(ok - ng > 1){
		ll mid = (ok + ng) / 2;
		ll cost = 0;
		rep(i,n){
			if(a[i]*f[i] > mid) cost += a[i] - mid / f[i];
		}
		if(cost <= k) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
	return 0;
}

Measured memory_bytes: 6372
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    string s;
    cin >> s;
    if(s=="ABC"){
        cout<<"ARC"<<endl;
    }
    else if(s=="ARC"){
        cout<<"ABC"<<endl;
    }
    else{
        cout<<"why?????????????????????????????"<<endl;
    }
}
    



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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amin(T& a,T2 b){ if(a > b) a = b;}



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n;
	cin >>n;
	
	auto f=[](ll a) ->ll{
		ll rt=0;
		for(; a>0; a/=10) rt++;
		return rt;
	};
	ll ans = 1LL<<55;
	for(ll i=1; i*i <= n; i++){
		if(n%i == 0){
			ans = min(ans, max(f(i), f(n/i)));
		}
	}
	cout <<ans <<"\n";
	return 0;
}


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

using namespace std;
int main()
{
  int N;
  cin>>N;
  if(N>=1800){
      cout<<1;
      return 0;
  }
  for(int i=0;i<8;i++){
    if(N<i*200+400){
      cout<<8-i+1;
      break;
    }
  }
  return 0;
}





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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
    void rereset(int n){ 
        for(int i=0;i<n;i++)par[i] = i;
    }
    void reset(int n){ 
        for(int i=0;i<n;i++)par[i] = root(par[i]);
    }
    bool solve(int n) {
        int num=0; 
        for(int i=0;i<n;i++)if(par[i]==par[0])num++;
        return num==n;
    }
};

int main() {
    int n,m;
    cin >> n >> m;
    int a,b;
    pair<int,int> p[m];
    for(int i=0;i<m;i++){
        cin >> a >> b;
        a--; b--;
        p[i]=make_pair(a,b);
    }
    UnionFind tree(n);   
    int ans=0;
    for(int i=0;i<m;i++){
        tree.rereset(n);
        for(int j=0;j<m;j++)if(j!=i)tree.unite(p[j].first,p[j].second);
        tree.reset(n);
        ans += (1-tree.solve(n));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3596
//#pragma GCC optimize("trapv")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include<bits/stdc++.h>
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define pb push_back
#include <x86intrin.h>
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 2e5 + 55, mod = 1e9 + 7 , i2 = (mod+1)/2;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int a[3][3];
set<int> x;
bool check(int a) {return x.count(a);}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	for(int i = 0; i < 9; i++) cin >> a[i/3][i%3];
	int n;
	cin >> n;
	for(int t; n--;)
		cin >> t, x.insert(t);
	for(int i = 0; i < 3; i++) {
		if(check(a[i][0])&&check(a[i][1])&&check(a[i][2])) return cout << "Yes", 0;
		if(check(a[0][i])&&check(a[1][i])&&check(a[2][i])) return cout << "Yes", 0;
	}
		if(check(a[0][0])&&check(a[1][1])&&check(a[2][2])) return cout << "Yes", 0;
		if(check(a[2][0])&&check(a[1][1])&&check(a[0][2])) return cout << "Yes", 0;
	cout << "No";
}



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

int main() {
    int N;
    int a[200];

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

    sort(a, a + N, greater<int>());

    int Alice = 0;
    int Bob = 0;

    for(int i = 0; i < N; i++) {
        if(i % 2 == 0) {
            Alice += a[i];
        }
        else {
            Bob += a[i];
        }
    }

    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
bool d[55556] ;
int main(){
 int n ;cin>> n ;
 rep(i,55556) d[i] =0 ;
 vector<int> A(55) ;
 int x= 0 ;
 rep2(i,2,55555){
  if(d[i]) continue ;
  if(i%5==1){
     A[x]=i ;
     x++ ;
  }
  for(int j=1;i*j<=55555;j++){
    if(d[i*j]==0) d[i*j]=1 ;
  }
 }
  rep(i,n) cout<<A[i]<<endl ;
  return 0;
  }

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define f(i,l,h) for(ll i=l;i<h;i++)
#define fr(i,h,l) for(ll i=h;i>=l;i--)
#define PI 3.141592653589793
using namespace std;

typedef pair<ll,ll> pll;
const ll INF=(ll)(1e9+7);
typedef vector<ll> vll;
map<pll,pll>mp;

ll power(ll a, ll b){
    ll res=1;
    while(b){
        if(b&1) res=(res*a)%INF;
        a=(a*a)%INF;
        b>>=1;
    }
    return res;
}

int main()
{
    //cout << "Hello world!" << endl;
    cout<<fixed<<setprecision(14);
    ll n;
    cin>>n;
    ll a[n],b[n];
    ll a0=0,b0=0,ab0=0;
    f(i,0,n){
        cin>>a[i];
        cin>>b[i];
        if(a[i]==0 && b[i]==0){
            ab0++;
            continue;
        }
        if(a[i]==0){
            a0++;
            continue;
        }

        if(b[i]==0){
            b0++;
            continue;
        }
        ll x=__gcd(a[i],b[i]);
        a[i]/=x;b[i]/=x;

        if(b[i]<0){
            a[i]*=-1;
            b[i]*=-1;
        }

        if(a[i]>0){
            mp[{a[i],b[i]}].first++;
        }else{
            mp[{b[i],-a[i]}].second++;
        }
    }

    ll ans=power(2,a0);
    ans=(ans+power(2,b0));
    ans=(ans-1+INF)%INF;

    for(auto u:mp){
        ll curr=power(2,u.second.first);
        curr=(curr+power(2,u.second.second))%INF;
        curr=(curr-1+INF)%INF;
        ans=(ans*curr)%INF;
    }

    ans=(ans-1+INF)%INF;
    ans=(ans+ab0)%INF;
    cout<<ans<<endl;



}


Measured memory_bytes: 22264