akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict

S = tuple(input())
T = tuple(input())

# S->T と T->S の変換表
s_to_t = defaultdict(set)
t_to_s = defaultdict(set)
for s,t in zip(S,T):
    s_to_t[s].add(t)
    t_to_s[t].add(s)


# 1対1対応しているか
flag = True
for v in s_to_t.values():
    if len(v) > 1:
        flag = False
for v in t_to_s.values():
    if len(v) > 1:
        flag = False

# print
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 6960
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a+b>=c) co("Yes");
  else co("No");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,k;
    cin>>n>>k;
    double arr[n+1];
    for(int i=1;i<=n;i++)
    cin>>arr[i];
    double dp[n+1][n+1];
    for(int i=0;i<=n;i++)
    for(int j=0;j<=n;j++)
    dp[i][j]=0;
    dp[1][0]=1.0-arr[1];
    for(int i=2;i<=n;i++)
    dp[i][0]=dp[i-1][0]*(1.0-arr[i]);
    dp[1][1]=arr[1];
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
        {
            dp[i][j]=dp[i-1][j]*(1.0-arr[i])+dp[i-1][j-1]*arr[i];
        }
    }
    double ans=0;
    for(int i=n/2+1;i<=n;i++)
    ans+=dp[n][i];
    printf("%0.10lf",ans);
}

Measured memory_bytes: 70528
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {
    int n; cin >> n;
    int l[n];
    REP(0, i, n) {
        cin >> l[i];
    }

    sort(l, l + n);

    long ans = 0;
    REP(0, i, n) {
        REP(i + 1, j, n) {
            REP (j + 1, k, n) {
                if (l[k] < l[i] + l[j]) {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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


int main() {
	int N,K;
	cin>>N>>K;
	int count=1;
	while(1){
		if(N/K==0){
			break;
		}
		else{
			++count;
			N=N/K;
		}
	}

	cout<<count;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define endl "\n" 
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    int n; cin >> n;
    int a = n % 10;
    if(a == 3) cout << "bon" << endl;
    else if(a == 0 || a == 1 || a == 6 || a == 8) cout << "pon" << endl;
    else cout << "hon" << endl;

    return 0;
}


Measured memory_bytes: 3636
char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(G=g,c=*G++,i=0;G[-1];)c=c-d[i]?putchar(c),*G++:r[i++];exit(0);}

Measured memory_bytes: 524
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key) {
    int left = 0;
    int right = n;  // 右端は入力した数列の数n
    int mid;
    while(left < right) {  // 左端が右端より小さい間繰り返し（左端と右端が同じになっても終了する）
        mid = (right + left) / 2;  // 左端と右端の真ん中を取る
        if (key == A[mid]) return 1;
        if (key > A[mid]) left = mid + 1;  // 左端をずらす
        else if (key <= A[mid]) right = mid;  // 右端をずらす
    }
    return 0;  // whileループを抜けた → 求めるkeyは存在しないので0を返す
}

int main() {
    int i, q, k, sum = 0;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &k);  // k: key
        if (binarySearch(k)) sum++;  // binarySearchの返り値が1ならsumをカウントアップ
    }
    printf("%d\n", sum);

    return 0;
}


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

a, b, c, d = map(int, input().split())

if c >= a and d >= b and b >= c:
    print(b - c)
elif c >= a and d <= b:
    print(d - c)
elif a >= c and b <= d:
    print(b - a)
elif a >= c and b >= d and d >= a:
    print(d - a)
else:
    print(0)


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

const lint MOD = (lint)1e9 + 7;
lint dp[2005][2005], S[2005], T[2005];

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N, M;
    cin>>N>>M;
    for(int i=0;i<N;i++)cin>>S[i];
    for(int i=0;i<M;i++)cin>>T[i];

    for(int i=0;i<=N;i++)dp[i][0] = 1;
    for(int i=0;i<=M;i++)dp[0][i] = 1;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=M;j++){
            dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1];
            if(S[i-1]==T[j-1]) dp[i][j] += dp[i-1][j-1];
            dp[i][j] = (dp[i][j]%MOD+MOD) % MOD;
        }
    }

    cout<<dp[N][M]<<endl;
    return 0;
}

Measured memory_bytes: 31616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    string s;   cin >> s;
    int c = 0;
    char key = 'A';
    rep(i, s.size()){
        if(key != s[i]){
            c++;
            key = s[i];
        }
    }
    cout << c-1 << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>

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

    int n, m;
    std::cin >> n >> m;

    std::vector<std::vector<bool>> table( n );

    int k, kind_num;
    for( auto& vec : table ){
        std::cin >> k;
        vec = std::vector<bool>( m, false );
        for( int i = 0; i < k; ++i ){
            std::cin >> kind_num;
            vec[kind_num-1] = true;
        }
    }

    int count = 0;
    bool prod;
    for( int i = 0; i < m; ++i ){
        prod = true;
        int j = 0;
        for( ; j < n; ++j ){
            prod &= table[j][i];
        }
        count += static_cast<int>( prod );
    }

    std::cout << count << std::endl;
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long ;

int main(){
    int n , m ;
    cin >> n >> m ;
    char grid[n][m] ;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> grid[i][j] ;
        }
    }
    int right[n][m] ;
    int left[n][m] ;
    int up[n][m] ;
    int down[n][m] ;
    // right
    for(int i=0;i<n;i++){
        int cnt = 0 ;
        for(int j=m-1;j>=0;j--){
            if ( grid[i][j] == '#' ) cnt = 0, right[i][j] = 0 ;
            else if ( j == m-1 ) right[i][j] = 1 ;
            else right[i][j] = right[i][j+1] + 1 ;
        }
    }
    // left
    for(int i=0;i<n;i++){
        int cnt = 0 ;
        for(int j=0;j<m;j++){
            if ( grid[i][j] == '#' ) cnt = 0 , left[i][j] = 0 ;
            else if ( j == 0 ) left[i][j] = 1 ;
            else left[i][j] = left[i][j-1] + 1 ;
        }
    }
    // up
    for(int j=0;j<m;j++){
        int cnt = 0 ;
        for(int i=0;i<n;i++){
            if ( grid[i][j] == '#' ) cnt = 0 , up[i][j] = 0 ;
            else if ( i == 0 ) up[i][j] = 1 ;
            else up[i][j] = up[i-1][j]+1 ;
        }
    }
    // down
    for(int j=0;j<m;j++){
        int cnt = 0 ;
        for(int i=n-1;i>=0;i--){
            if ( grid[i][j] == '#' ) cnt = 0 , down[i][j] = 0 ;
            else if ( i == n-1 ) down[i][j] = 1 ;
            else down[i][j] = down[i+1][j] + 1 ;
        }
    }
    int ans = 0 ;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if ( grid[i][j] == '.' ){
                ans = max(ans, right[i][j] + left[i][j] + up[i][j] + down[i][j] - 3);
            }
        }
    }
    cout << ans << endl;
    return 0 ;
}


Measured memory_bytes: 66688
H,W=map(int,input().split())
S=[input() for _ in range(H)]
for i in range(H):
  T=''
  for j in range(W):
    if S[i][j] == '#':
      T+='#'
    else:
      T+=str(sum([x[max(0,j-1):min(j+2,W)].count('#') for x in S[max(0,i-1):min(i+2,H)]]))
    
  print(T)   

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=3010;
ll ksm(ll x,ll y,ll mod) {
	ll res=1;
	while (y) {
		if (y&1) res=res*x%mod;
		x=x*x%mod; y>>=1;
	} return res;
}
int n,c[maxn][maxn],s[maxn][maxn];
ll mod,tmp,ans,cnt,mi[maxn];
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(mod);
	mi[0]=1;
	for (int i=1;i<=n;i++) mi[i]=mi[i-1]*2%mod;
	s[0][0]=c[0][0]=1;
	for (int i=1;i<=n+1;i++) {
		c[i][0]=1;
		for (int j=1;j<=i;j++)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod,
			s[i][j]=((ll)s[i-1][j]*j+s[i-1][j-1])%mod;
	}
	for (int i=0;i<=n;i++) {
		tmp=c[n][i]*ksm(2,ksm(2,n-i,mod-1),mod)%mod;
		cnt=0;
		for (int j=0;j<=i;j++) {
			cnt=(cnt+(ll)s[i+1][j+1]*ksm(mi[n-i],j,mod))%mod;
		}
		tmp=tmp*cnt%mod;
		if (i&1) ans=ans+mod-tmp;
		else ans+=tmp;
		if (ans>=mod) ans-=mod;
	}
	printf("%lld\n",ans);
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 69632
#include <stdio.h>
#include <string.h>
#include <math.h>
int toint(char a) {return a-'0';}
int main() {
	char a[11];
	int l,i,n,min=1000,minx;
	scanf("%s",a);
	l=strlen(a);
	for (i=0;i<l-2;i++) {
		n = toint(a[i])*100 + 
		toint(a[i+1])*10 + 
		toint(a[i+2]);
		if (min>abs(n-753)) {minx=n;min=abs(n-753);}
	}
	printf("%d\n",min);
	return 0;
}


Measured memory_bytes: 128
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


s = "Sunny"
c = "Cloudy"
r = "Rainy"
d = {
    s: c, c: r, r: s
}

ans = d[input()]
print(ans)


Measured memory_bytes: 2940
package main

import (
    "fmt"
    "math"
)

func main(){
    var H int
    fmt.Scan(&H)

    bit := fmt.Sprintf("%b", H)
    digit := len(bit)-1
    
    sum := 0.0
    
    for i:=0; i<=digit; i++{
        sum += math.Pow(2, float64(i))
    }

    fmt.Println(int(sum))
    
}


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

using namespace std;

int main()
{
	string S;

	int C = 0, ptr = 0;

	cin >> S;

	while (true)
	{
		if (ptr < S.size())
		{
			while (S[ptr] != 'A')
			{
				ptr++;

				if (ptr >= S.size())
				{
					goto Exit;
				}
			}
		}
		else
		{
			goto Exit;
		}

		ptr++;

		if (ptr < S.size())
		{
			while (S[ptr] != 'Z')
			{
				ptr++;

				if (ptr >= S.size())
				{
					goto Exit;
				}
			}

			C++;
		}
		else
		{
			goto Exit;
		}
	}

Exit:;

	if (C == 0)
	{
		cout << -1 << endl;
	}
	else
	{
		for (int i = 0; i < C; i++)
		{
			cout << "AZ";
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3220
#include <cstdio>
#include <algorithm>

using namespace std;

#define m_MAX (int)1e5
int n, m;
int L[m_MAX + 1];
int R[m_MAX + 1];

int main(){
    scanf("%d %d", &n, &m);
    for(int i = 0; i < m; i++){
        scanf("%d %d", &L[i], &R[i]);
    }

    int L_max = L[0];
    int R_min = R[0];
    for(int i = 0; i < m; i++){
        L_max = max(L_max, L[i]);
        R_min = min(R_min, R[i]);
    }

    int ans;
    ans = R_min - L_max + 1;
    if(ans < 0){
        ans = 0;
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans;
    vector<ll> val(3);
    val[0] = max(a*c, b*d);
    val[1] = max(a*d, b*c);
    ans = max(val[0], val[1]);
    if ((a<0 && b>0) || (c<0 && d>0))ans = max(ans, (ll)0);
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3624
H,W=map(int,input().split())
A=[input() for i in range(H)]

B=[]
D=[]

for i in range(H):
  if A[i]!="."*W:
    B.append(list(A[i]))
    
C=[["0" for j in range(len(B))] for i in range(W)]

for i in range(len(B)):
  for j in range(W):
    C[j][i]=B[i][j]

for i in range(W):
  if C[i]!=["."]*len(B):
    D.append(C[i])
   
E=[["0" for j in range(len(D))] for i in range(len(B))]

for i in range(len(D)):
  for j in range(len(B)):
    E[j][i]=D[i][j]
    
for i in range(len(B)):
  print("".join(E[i]))



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

int main() {
    int n;
    cin >> n;
    vector<int> vec(n), num(1e5+1);

    for(int i=0; i<n; i++) {
        cin >> vec.at(i);

        if(vec.at(i) != 0) num.at(vec.at(i)-1)++;
        num.at(vec.at(i))++;
        num.at(vec.at(i)+1)++;
    }
    sort(num.begin(), num.end());
    reverse(num.begin(), num.end());
    cout << num.at(0) << endl;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  string s;
  cin >> s;
  
  cout << (s=="KIHBR"||s=="KIHBRA"||s=="KIHBAR"||s=="KIHBARA"||
         s=="KIHABR"|| s=="KIHABRA"||s=="KIHABAR"||s=="KIHABARA"||
         s=="AKIHBR"||s=="AKIHBRA"||s=="AKIHBAR"||s=="AKIHBARA"||
         s=="AKIHABR"|| s=="AKIHABRA"||s=="AKIHABAR"||s=="AKIHABARA"?"YES":"NO" ) << endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main
{
	public static void main(String[] args)throws Exception
	{
		Scanner scan=new Scanner(System.in);
		
		int i;
		int sum=0;
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		
		for(i=a;i<=b;i++)
		{
			if(c%i==0)
			{
				sum++;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 26328
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

int main() {

	int a, b, c, d, e, f, g, h, i;
	cin >> a >> b >> c >> d >> e >> f >> g >> h >> i;

	if (a - b == d - e&&d - e == g - h&&b - c == e - f&&e - f == h - i&&a - d == b - e&&b - e == c - f&&d - g == e - h&&e - h == f - i)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import copy
import collections
def f(s):
    h = {('R','G'): 'B', ('B','G'): 'R', ('R','B'): 'G',('R','G')[::-1]: 'B', ('B','G')[::-1]: 'R', ('R','B')[::-1]: 'G', }
    c = collections.Counter()
    cc = [None] * (len(s)+1)
    cc[-1] = copy.deepcopy(c)
    for jj in range(len(s)-1,-1,-1):
        c[s[jj]]+=1
        cc[jj] = copy.deepcopy(c)


    res = 0
    for i in range(len(s)):
        for j in range(i + 1, len(s)):
            if s[j] != s[i]:
                res += cc[j+1][h[(s[i],s[j])]] 
                
                k = j + (j - i)
                if k < len(s) and s[k] == h[(s[i],s[j])]:
                    res -=1
    return res
raw_input()
print f(raw_input())


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

int main() {
    int N; cin >> N;
    vector<string> W(N); for(int i = 0; i < N; ++i) cin >> W[i];
    vector<string> W_copy(N);
    W_copy = W;

    bool flag = false;
    sort(W_copy.begin(), W_copy.end());
    for(int i = 1; i < W_copy.size(); ++i) {
        if(W_copy[i - 1] == W_copy[i]) {
            cout << "No" << endl;
            flag = true;
        }
    }

    if(flag != true) {
        for(int i = 1; i < N; ++i) {
            if(W[i - 1].at(W[i - 1].size() - 1) != W[i].at(0)) {
                cout << "No" << endl;
                break;
            }

            if(i == N - 1) {
                cout << "Yes" << endl;
            }
        }
    }
}

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

long long mod = 1000000007;

int h, w;
bool map[1005][1005];
long long dp[1005][1005];
int main()
{
	std::cin >> h >> w;
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j) {
			char a;
			std::cin >> a;
			map[i][j] = a == '.';
		}

	dp[0][0] = 1;
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j) {
			if (i + 1 < h&&map[i + 1][j])
				dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod;
			if (j + 1 < w&&map[i][j + 1])
				dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % mod;
		}

	std::cout << dp[h - 1][w - 1] << std::endl;
	return 0;
}


Measured memory_bytes: 9088
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()
    var a = Array<Int>(n,{0})
    var b = Array<Int>(n,{0})
    var c = Array<Int>(n,{0})
    var dp = Array(3){IntArray(n){0}}


    for(i in 0 until n){
        val (ai,bi,ci) = readLine()!!.split(" ").map{it.toInt()}
        a[i] = ai
        b[i] = bi
        c[i] = ci

    }
    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];

    for(i in 1 until n){

        dp[0][i] = Math.max(dp[1][i-1],dp[2][i-1])+a[i]
        dp[1][i] = Math.max(dp[0][i-1],dp[2][i-1])+b[i]
        dp[2][i] = Math.max(dp[0][i-1],dp[1][i-1])+c[i]
    }



    println(Math.max(dp[0][n-1],Math.max(dp[1][n-1],dp[2][n-1])))

}


Measured memory_bytes: 74444
def selection_sort(a,n):
    m=0
    for i in range(0,n):
        minj=i
        for j in range(i,n):
            if(a[minj] > a[j]):
                minj=j
        if(minj!=i):
            m+=1
            #print("swap(%d<->%d)"%(a[ninj],a[i]))
            a[minj],a[i] = a[i],a[minj]
        
    b=list(map(str,a))
    print(" ".join(b))
    print(m)

a=[]
n=int(input())
s=input()
a=list(map(int,s.split()))
selection_sort(a,n)

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

#define rep(i, n) for (int i = 0; i < n; i++)
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(){
  int n; cin >> n;
  bool ans = false;
  for (int i = 1; i <= 9; ++i){
    for (int j = 1; j <= 9; ++j){
      if (n == i*j) ans = true;
    }
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main() {
  int W,H,N;
  cin >> W >> H >> N;
  
  vector<vector<char>> data(W, vector<char>(H,'-'));
  for(int k = 0; k < N; k++){
    int x,y,a;
    cin >> x >> y >> a;
    if(a == 1){
      for(int i = 0; i <= x-1; i++){
        for(int j = 0; j < H; j++){
          data.at(i).at(j) = '#';
        }
      }
    }
    if(a == 2){
      for(int i = x; i < W; i++){
        for(int j = 0; j < H; j++){
          data.at(i).at(j) = '#';
        }
      }
    }
        if(a == 3){
      for(int i = 0; i < W; i++){
        for(int j = 0; j <= y-1; j++){
          data.at(i).at(j) = '#';
        }
      }
    }
     if(a == 4){
      for(int i = 0; i < W; i++){
        for(int j = y; j < H; j++){
          data.at(i).at(j) = '#';
        }
      }
    }
  }

  int c = 0;
  for(int i = 0; i < W; i++){
         for(int j = 0; j < H; j++){
           if(data.at(i).at(j) == '-') c++;
         }
        }
  cout << c << endl;
}
          
      

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

N = int(input())

T, A = map(int, input().split())

H = list(map(int, input().split()))

answer = 0

for i in range(1, N):
	if abs(A - (T - H[answer]*0.006)) > abs(A - (T-H[i]*0.006)):
		answer = i

answer += 1
print(answer)

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

using namespace std;

using ll = unsigned long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    ll cnt = n / (a + b);
    ll rest = n - (a + b) * cnt;
    ll ans = cnt * a + min(a, rest);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
INFTY = 1 << 21
WHITE = 0
GRAY = 1
BLACK = 2

n = int(input())
M = [list(map(int, input().split())) for i in range(n)]

d = [INFTY for i in range(n)]
p = [-1 for i in range(n)]
color = [WHITE for i in range(n)]

for i in range(n):
    for j in range(n):
        if (M[i][j] == -1):
            M[i][j] = INFTY

def prim():
    global M, d, p, color
    d[0] = 0
    while(1):
        minv = INFTY
        u = -1
        for i in range(n):
            if (minv > d[i] and color[i] != BLACK):
                u = i
                minv = d[i]
        if (u == -1):
            break
        color[u] = BLACK
        for v in range(n):
            if (color[v] != BLACK and M[u][v] != INFTY):
                if (d[v] > M[u][v]):
                    d[v] = M[u][v]
                    p[v] = u
                    color[v] = GRAY
    
    return sum([M[i][p[i]] for i in range(n) if p[i] != -1])

print(prim())

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

int main()
{
    int n;
    int i, cou2 = 0, cou4 = 0;
    
    cin >> n;
    
    int a[n];
    
    for(i = 0; i < n; i++) {
        cin >> a[i];
        
        if((a[i] % 4) == 0) {
            cou4++;
        } else if((a[i] % 2) == 0) {
            cou2++;
        }
    }
    
    if(((cou2 == 0) && (n / 2 <= cou4)) || (cou4 * 2 + cou2 >= n)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int y, m, d;
	int a;
	
	while (scanf("%d %d %d", &y, &m, &d) != EOF){
		a = y * 365 + 30 * m + d;
		y++;
		if (a < 1868 * 365 + 9 * 30 + 8){
			printf("pre-meiji\n");
		}
		else if (1868 * 365 + 9 * 30 + 8 <= a && a <= 1912 * 365 + 7 * 30 + 29){
			printf("meiji %d %d %d\n", y - 1868, m, d);
		}
		else if (1912 * 365 + 7 * 30 + 30 <= a && a <= 1926 * 365 + 12 * 30 + 24){
			printf("taisho %d %d %d\n", y - 1912, m, d);
		}
		else if (1926 * 365 + 12 * 30 + 25 <= a && a <= 1989 * 365 + 1 * 30 + 7){
			printf("showa %d %d %d\n", y - 1926, m, d);
		}
		else {
			printf("heisei %d %d %d\n", y - 1989, m, d);
		}
	}
	
	return (0);
}

Measured memory_bytes: 608
import math
def gcd(a,b,c):
    a = math.gcd(a, b)
    a = math.gcd(a, c)
    return a

ans=0
K=int(input())
for i in range(1,K+1): 
    for j in range(1,K+1):
        for k in range(1, K+1):
            ans+=gcd(i,j,k)

print(ans)

Measured memory_bytes: 68260
#include<bits/stdc++.h>
using namespace std;
const int N=200010;
int hd[N],nxt[N],to[N],h[N];
int tot,ans,n,m;
void add(int x,int y){
	to[++tot]=y;
	nxt[tot]=hd[x];
	hd[x]=tot;
}
bool judge(int x){
	for(int i=hd[x];i;i=nxt[i]){
		if(h[x]<=h[to[i]]) return false;
	}
	return true;
}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%d",&h[i]);
	for(int i=1,x,y;i<=m;++i){
		scanf("%d %d",&x,&y);
		add(x,y);
		add(y,x);
	}
	for(int i=1;i<=n;++i){
		if(judge(i)) ++ans;
	}
	printf("%d\n",ans);
}

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

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

    int h = 0, w = 0;
    int c[H][W];
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < a[i]; j++)
        {
            if(h % 2 == 0){
                c[h][w] = i + 1;
                w++;
            }
            else {
                c[h][w] = i + 1;
                w--;
            }
            if(w == -1){
                w = 0;
                h++;
            }
            else if(w == W){
                w = W - 1;
                h++;
            }
        }
    }

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cout << c[i][j];
            if(j == W - 1) cout << endl;
            else cout << " ";
        }
    }

}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;

const int MAX_N = 112345;

const ll INF = LONG_LONG_MAX;

bool isnot_primed[MAX_N]={0};

vector<int> prime2017(){
    vector<int> ans;
    isnot_primed[0] = isnot_primed[1] = true;
    repeat(i, MAX_N){
        if(isnot_primed[i]) continue;
        if(!isnot_primed[(i+1)/2]){
            ans.push_back(i);
        }
        for(int j=2*i;j<MAX_N;j+=i){
            isnot_primed[j] = true;
        }
    }
    return ans;
}

int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    vint similar2017 = prime2017();
    int Q;
    cin >> Q;
    vint ans;
    repeat(i, Q){
        int l,r;
        cin >> l >> r;
        int numx = upper_bound(similar2017.begin(), similar2017.end(), r)
                    -lower_bound(similar2017.begin(), similar2017.end(), l);
        ans.push_back(numx);
    }
    repeat(i, Q){
        cout << ans[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 1280
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>

using namespace std;

int n, m;
int l[505], r[505];
int dif[1005], sum[1005];

int main(void)
{
  cin >> n >> m;
  for(int i = 1; i <= m; i++) cin >> l[i] >> r[i];

  for(int i = 1; i <= m; i++){
    dif[l[i]]++, dif[r[i]]--;
  }
  for(int i = 1; i <= n+1; i++) sum[i] = sum[i-1] + dif[i];
  
  int ans = 0, cnt = 0;
  for(int i = 1; i <= n+1; i++){
    if(sum[i] > 0) cnt++;
    else{
      ans += cnt;
      cnt = 0;
    }
  }
  ans *= 2, ans += n+1;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3132
process.stdin.resume();
process.stdin.setEncoding('utf8');
var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
 var input = lines[0].split(' ');
 var N = parseInt(input[0]);
 var M = parseInt(input[1]);
 var arr = new Array(M).fill(0);
//console.log(arr)
 for (var i = N ; i > 0 ; i--) {
   var prefer = lines[i].split(' ');
   for (var turn = 1 ; turn <= parseInt(prefer[0]) ; turn++) {
     //console.log(prefer[turn])
     arr[parseInt(prefer[turn]) - 1] += 1;
   }
   //console.log(arr);
}
  var count = 0;
  for (var j = 0 ; j < M ; j++) {
    if (arr[j] === N) {
      count += 1;
    }
  }
console.log(count);
});

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define int long long
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = 3.141592653589793;

int d,n;
int t[205];
vector<pair<int ,pair<int,int>>> cab;
vector<vector<int>> cl(65);
int dp[205][205];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin  >> d >> n;
    rep(i,d) cin >> t[i];
    rep(i,n){
        int a,b,c;
        cin >> a >> b >> c;
        cab.pb(make_pair(c,make_pair(a,b)));
    }
    rep(i,d)rep(j,n){
        int l=cab[j].se.fi;
        int r=cab[j].se.se;
        if (l<=t[i] && t[i]<=r) cl[t[i]].pb(j);
    }
    rep(i,d+1)rep(j,n) dp[i][j]=-INT_MAX;
    for (auto i: cl[t[0]]){
        for (auto j: cl[t[1]]){
            dp[2][j]=max(dp[2][j],abs(cab[i].fi-cab[j].fi));
        }
    }
    rep2(i,2,d)rep(j,n){
        for (auto k: cl[t[i]]){
            dp[i+1][k]=max(dp[i+1][k],dp[i][j]+abs(cab[j].fi-cab[k].fi));
        }
    }
    int ans=0;
    rep(j,n) ans=max(ans,dp[d][j]);
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
    
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
  int n, k;
  cin >> n >> k;
  vector<int> l(k), r(k);
  for(int i=0; i<k; i++) cin >> l[i] >> r[i];
  vector<mint> dp(n+1);
  vector<mint> dpsum(n+1);
  dp[1] = 1;
  dpsum[1] = 1;
  for (int i = 2; i <= n; ++i) {
    for(int j=0; j<k; j++) {
      // [l[i], r[i]]
      int li = i-r[j];
      int ri = i-l[j];
      if (ri < 0) continue;
      li = max(li,1);
      dp[i] += dpsum[ri]-dpsum[li-1]; //dp[li]~dp[ri];
    }
    dpsum[i] = dpsum[i-1]+dp[i];
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 6408
# 2020/02/09
# AtCoder Beginner Contest 154 - C

# Input
n = int(input())
a = list(map(int,input().split()))

a.sort()

# Calc
ans = "YES"
for i in range(1, n):
    if a[i-1] == a[i]:
        ans = "NO"
        break

# Output
print(ans)


Measured memory_bytes: 25936
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set> 
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>
using namespace std;
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define ld long double
#define ii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<ii>
#define rep(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define sz(a) (int)(a).size()
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
int x[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
int y[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
const int MOD = 1e9 + 7, N = 2e5 + 5;
const double pi = acos(-1);

ll n, arr[N], dp[N][3];

ll solve(int id, int taken, int skipped)
{
	if (id >= n) return (taken == n / 2) ? 0 : -1e18;
	if (dp[id][skipped] != -1) return dp[id][skipped];
	ll ans = -1e18;
	if (skipped < 2) ans = max(ans, solve(id + 1, taken, skipped + 1));
	ans = max(ans, solve(id + 2, taken + 1, skipped) + arr[id]);
	return dp[id][skipped] = ans;
}

int main()
{ 
	assem99;
	memset(dp, -1, sizeof(dp));
	cin >> n;
	rep(i, 0, n) cin >> arr[i];
	cout << solve(0, 0, 0);

	return 0;
}


Measured memory_bytes: 17656
import java.math.*

fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    val aList = readInputLine().split(" ").map { it.toInt() }.sorted()
    
    val num = aList.last()
    
    val choose = aList.dropLast(1).sortedBy { Math.abs(it * 2 - num) }.first() 

    println("$num $choose")
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 58628
S = str(input())
list_S = []

for i in range(len(S)):

    list_S.append(S[i:i+1])



alf = 'abcdefghijklmnopqrstuvwxyz'
list_alf = []
for i in range(len(alf)):
    list_alf.append(alf[i:i+1])

count = 0
conti = 0

for i in range(len(alf)):
    count = list_S.count(list_alf[i])
    if count == 0:
        print (list_alf[i])
        break
    conti += 1


if conti >= 26:
    print ('None')

Measured memory_bytes: 4084
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    cnt=0
    for i in l:
        if i%2==1:
            cnt+=1
    if cnt%2==1:
        print('NO')
    else:
        print('YES')
resolve()

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    int res = 0;
    cin >> n;
    ll sumA = 0, sumB = 0;
    ll lack = 0;
    vector<ll> a(n), b(n), surp;
    rep (i, n) {
        cin >> a[i];
        sumA += a[i];
    }
    rep (i, n) {
        cin >> b[i];
        sumB += b[i];
    }
    if (sumA < sumB) {
        cout << -1 << endl;
        return 0;
    }
    rep (i, n) {
        if (a[i] >= b[i]) surp.push_back(a[i] - b[i]);
        else {
            lack += b[i] - a[i];
            res++;
        }
    }
    sort(surp.begin(), surp.end(), greater<ll>());
    ll sum = 0;
    rep (i, surp.size()) {
        if (sum >= lack) break;
        sum += surp[i];
        res++;
    }
    cout << res << endl;
    
    return 0;
}



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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int a,b,t;cin>>a>>b>>t;

	int ans =0;

	for(int i=a; i<=t; i +=a){
		ans +=b;
	}

	writeln(ans);



}



Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll digitcal(ll x){
  ll n=0;
  while(x>0){
    x/=10;
    n++;
  }
  return n;
}

int main() {
  int n,q;
  cin>>n>>q;
  dsu d(n);
  for(int i=0;i<q;i++){
    int t,u,v;
    cin>>t>>u>>v;
    if(t==0){
      d.merge(u,v);
    }
    else{
      cout<<d.same(u,v)<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4076
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int x; cin >> x;
    int a;
    x--;
    while(a != 2){
        x++;
        VI b = getDivisor(x);
        a = b.size();
    }
    OUT(x);

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var s string
	fmt.Scan(&s)

	ca, cb, cc := 0, 0, 0
	for _, r := range s {
		switch r {
		case 'a':
			ca++
		case 'b':
			cb++
		case 'c':
			cc++
		}
	}
	if len(s) == 1 {
		fmt.Println("YES")
		return
	}

	if h := len(s) / 2; ca > h || cb > h || cc > h || abs(ca-cb) > 1 || abs(cb-cc) > 1 || abs(cc-ca) > 1 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}


Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ABC_103
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            for (int i = 0; i <= s.Length; i++)
            {
                if (s.Equals(t))
                {
                    Console.WriteLine("Yes");
                    return;
                }

                string sub = s.Substring(0, s.Length - 1);
                s = s.Substring(s.Length - 1);
                s += sub;
                //Console.WriteLine(s);
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
    #define int ll
    #define M 1000000007
    #define hell 998244353
    #define inf 1e18
    #define pb push_back
    #define pi 3.1415926536
    #define mp make_pair
    #define ub upper_bound
    #define lb lower_bound
    #define all(a) a.begin(),a.end()
    #define ll long long
    #define vec vector <int>
    #define pii pair<int,int>
    #define endl "\n"
    #define gcd __gcd
    using namespace std;
    int power(int x, unsigned int y, unsigned int m) 
    { 
        if (y == 0) 
            return 1; 
        int p = power(x, y/2, m) % m; 
        p = (p * p) % m; 
  
        return (y%2 == 0)? p : (x * p) % m; 
    } 
    int modInverse(int a, int m) 
    {   
        return power(a, m-2, m);
    }
    int nCrModPFermat(int n, int r, int p) 
    { 
           if (r==0) 
              return 1; 
  
        int fac[n+1]; 
        fac[0] = 1; 
        for (int i=1 ; i<=n; i++) 
            fac[i] = fac[i-1]*i%p; 
  
        return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
    } 
    signed main()
    {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        ll t=1;
        // cin >> t;
        /*SAARE INPUTS LENA*/
        /*VARIABLES KI RANGE DEKHLENA*/
        /*EXPONENT RANGE OF OUTPUT KA DHYAN RAKHNA*/
        while(t-->0)
        {
            ll n=0,s=0,ans=0;
            cin>>n;
            vector <int> v(n),su(n);
            for (int i = 0; i < n; ++i)
            {
                cin>>v[i];
                s+=v[i];
                if(i==0)
                    su[0]=v[i];
                else
                    su[i]=su[i-1]+v[i];
            }
            for (int i = 0; i < n; ++i)
            {
                int k=(v[i]*((s-su[i])%M))%M;
                ans+=k;
                ans%=M;
            }
            cout<<ans;

        }
        return 0;
    }


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

int main(void) {
	while(1) {
		//入力
		char str1[201], str2[201];// 問題文ではs1,s2となっています。
		scanf("%s", str1);
		if(str1[0] == '.' && str1[1] == '\0') break;
		scanf("%s", str2);

		//処理
		if(strcmp(str1, str2) == 0){
			printf("IDENTICAL\n"); //2つの文字列は完全に一致したなら、IDENTICALを出力。
			continue;
		}

		bool inQuotes = false; //二重引用府(")の中ならtrue,外ならfalse
		int i=0, j=0;
		int diffCount=0;//文字列定数(奇数番目の二重引用符とその次の二重引用符の間の文字の並び)がstr1とstr2とで異なってる数。
		while(str1[i] != '\0' || str2[j] != '\0') {
			if(str1[i] != str2[j]) {
				if(inQuotes == false) {
					diffCount = 2;//二重引用符の外で異なっている場合は、その時点でDIFFERENT。
					break;
				} else{
					diffCount++;
					if(diffCount == 2) break;
					//str1,str2共に、二重引用符(")のところまで、進める。
					while(str1[i] != '"') i++;
					while(str2[j] != '"') j++;
					inQuotes = false;
				}
			} else if(str1[i] == '"' && str2[j] == '"') {
				inQuotes = !inQuotes;//trueならfalseに、falseならtureにする。
			}
			i++; j++;
		}

		//出力
		if(diffCount == 1){
			printf("CLOSE\n");
		} else{
			printf("DIFFERENT\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2604
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {
		for(;;){
			String buf = sc.nextLine();
			if(".".equals(buf)){
				break;
			}
			System.out.println(solve(buf)?"yes":"no");
		}
	}
	
	
	boolean solve(String s){
		String left = "[(";
		String right = "])";
		
		Stack<Integer> open = new Stack<Integer>(); 
		for(char ch: s.toCharArray()){
			int l = left.indexOf(ch);
			int r = right.indexOf(ch);

			if(l >= 0) open.push(l);
			if(r >= 0 && open.isEmpty()) return false;
			if(r >= 0 && open.pop() != r) return false;
		}
		return open.isEmpty();
	}	
	
	boolean solve2(String s){
		s = s.replaceAll("[a-zA-Z\\.]", "").replace(" ","");
		int length = s.length();
		for(;;){
			s = s.replaceAll("\\(\\)", "").replace(" ","");
			s = s.replaceAll("\\[\\]", "").replace(" ","");
			if(s.length() == 0){
				return true;
			}
			
			if(s.length() < length){
				length = s.length();
			}else{
				return false;
			}
		}
	}
}



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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

struct Edge {
    int id, next;
    Edge(int id, int next) : id(id), next(next) {}
};

using Graph = vector<vector<Edge>>;

void dfs(const Graph& G, vb& seen, vi& ans, int node, int exception) {
    seen[node] = true;

    int color = 0;
    for (const Edge& e : G[node]) {
        if (seen[e.next]) { continue; }

        if (color == exception) { ++color; }
        ans[e.id] = color + 1;

        dfs(G, seen, ans, e.next, color++);
    }
}

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

    int n;
    cin >> n;

    Graph G(n);

    rep(i, 0, n - 1) {
        int a, b;
        cin >> a >> b;
        G[a - 1].emplace_back(i, b - 1);
        G[b - 1].emplace_back(i, a - 1);
    }

    vb seen(n, false);
    vi ans(n - 1, 0);
    dfs(G, seen, ans, 0, -1);

    int maxv = 0;
    rep(i, 0, n - 1) { maxv = max(maxv, ans[i]); }

    cout << maxv << endl;
    rep(i, 0, n - 1) { cout << ans[i] << endl; }

    return 0;
}

Measured memory_bytes: 8320
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let S = rl();

    let t = match S.as_str() {
        "Sunny" => "Cloudy",
        "Cloudy" => "Rainy",
        "Rainy" => "Sunny",
        _ => unreachable!(),
    };

    println!("{}", t)
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N, K;
	in >> N >> K;
	out << (N - K + 1) << std::endl;
}


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

int main(){

  std::vector<unsigned int> heights;

  char buf[100];
  for (int i=0; i<10 ; i++){
    std::cin >> buf;
    heights.push_back(atoi(buf));
  }

  std::sort(heights.begin(),heights.end(),std::greater<int>());

  for (int i=0; i<3;i++){
    std::cout << heights[i] << std::endl;
  }

  return 0;
}

Measured memory_bytes: 1200