akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,0,n-1){cin >> a[i];a[i]--;}
    vector<int> mp(n,0);
    rep(i,0,n-1)mp[a[i]]++;
    ll ans = 0L;
    rep(i,0,n-1)ans += (ll)mp[i] * (mp[i]-1) /2;
    // cout << ans << endl;
    rep(i,0,n-1){
        cout << ans - (mp[a[i]] - 1) << endl;
    }

    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;


}

Measured memory_bytes: 4096
#include <iostream>
#include <cstdio>
#define NMAX (1000)
using namespace std;
int main(void){
    
    int N = 0;
    int a=0;
    int b=0;
    int c=0;

    //N??°?????\???
    scanf("%d",&N);
    
    //N?????°???????????????a,b,c???????????????
    for(int Ncount = 0; Ncount < N; Ncount++){
        scanf("%d %d %d",&a,&b,&c);
        if( ((a*a) + (b*b))  == (c*c) ){ 
            printf("YES\n"); 
        }else if( (b*b) + (c*c)  == (a*a) ){
            printf("YES\n"); 
        }else if( (c*c) + (a*a)  == (b*b) ){ 
            printf("YES\n"); 
        }else{ 
            printf("NO\n"); 
        }
    }
}

Measured memory_bytes: 1168
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

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

    int l_black[n+1], r_white[n+1];

    int b=0;
    l_black[0]=0;
    for(int i=1; i<=n; i++){
        if(s[i-1]=='#')b+=1;
        l_black[i]=b;
    }

    int w=0;
    r_white[n]=0;
    for(int i=n-1; 0<=i; i--){
        if(s[i]=='.') w++;
        r_white[i]=w;
    }

    int mi=1e9;
    for(int i=0; i<=n; i++)
        mi = min(mi, l_black[i]+r_white[i]);
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 2172
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
half = -int(-N/2)

query = [[0]*N for _ in range(N-1)]
for i in range(N-1):
    for j in range(i+1, N):
        for k in range(10):
            if ((i^j)>>k)&1:
                query[i][j] = k+1
                break

for i in range(N-1):
    print(*[x for x in  query[i] if x!=0])

Measured memory_bytes: 76548
#include <cstdio>

int main()
{
  int n;
  scanf("%d",&n);
  char s[101], t[101];
  scanf("%s%s",s,t);
  int c=n;
  while(c>0){
    int i;
    for(i=0;i<c&&s[n-c+i]==t[i];i++);
    if(i==c){
      break;
    }
    c--;
  }
  printf("%d\n",2*n-c);
  return 0;
}


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

ll a[50];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

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

	int minid = min_element(a, a + N) - a;
	ll mina = a[minid];
	int maxid = max_element(a, a + N) - a;
	ll maxa = a[maxid];

	vector<pair<int, int>> ans;
	if (mina >= 0 && maxa >= 0 || mina < 0 && maxa >= 0 && abs(mina) < maxa) {
		for (int i = 0; i < N; i++) {
			a[i] += maxa;
			ans.push_back({ maxid, i });
		}
		for (int i = 0; i < N; i++) {
			assert(a[i] >= 0);
		}
		for (int i = 0; i < N - 1; i++) {
			a[i + 1] += a[i];
			ans.push_back({ i, i + 1 });
		}
	}
	else {
		for (int i = 0; i < N; i++) {
			a[i] += mina;
			ans.push_back({ minid, i });
		}
		for (int i = 0; i < N; i++) {
			assert(a[i] <= 0);
		}
		for (int i = N - 1; i >= 1; i--) {
			a[i - 1] += a[i];
			ans.push_back({ i, i - 1 });
		}
	}

	for (int i = 0; i < N - 1; i++) {
		assert(a[i] <= a[i + 1]);
	}

	cout << ans.size() << endl;
	for (auto p : ans) {
		cout << p.first + 1 << " " << p.second + 1 << endl;
	}
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

int dp[52][52][2501];

signed main() {
	int n, a, ans = 0;
	int x[51];
	cin >> n >> a;
	rep(i, n) {
		cin >> x[i];
	}
	rep(j, n + 1) {
		dp[0][j][0] = 1;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 0; k <= 2500; k++) {
				if (k < x[j - 1]) {
					dp[i][j][k] = dp[i][j - 1][k];
				}
				else {
					dp[i][j][k] = dp[i - 1][j - 1][k - x[j - 1]] + dp[i][j - 1][k];
				}
				//cout << dp[i][j][k] << " ";
			}
			//cout << endl;
		}
		//cout << endl;
	}
	for (int i = 1; i <= n; i++) {
		ans += dp[i][n][a * i];
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
    
int main()
{
    int X, Y, Z;
    cin >> X >> Y >> Z;

    int A, B, C;
    A = Z;
    B = X;
    C = Y;

    cout << A << " " << B << " " << C;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace CTypicalStairs
{
    class Program
    {
        const int LAW = 1000000007;

        static void Main(string[] args)
        {
            // 入力の取得
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = inputs[0];
            var m = inputs[1];

            // 壊れている床の一覧を取得
            var brokenStairs = new int[m];
            for (var i = 0; i < m; i++)
            {
                brokenStairs[i] = int.Parse(Console.ReadLine());
            }

            // 連続する壊れていない床の距離を計算
            var distances = new int[m + 1];
            for (var i = 0; i <= m; i++)
            {
                var current = i != m ? brokenStairs[i] : n + 1;
                var prev = i != 0 ? brokenStairs[i - 1] : -1;

                // 壊れた階段が連続していたら、0を出力して終了
                if (current - prev == 1)
                {
                    Console.WriteLine(0);
                    return;
                }

                distances[i] = (current - 1) - (prev + 1);
            }

            // 0 ~ a1 - 1 まで P1 通り、a1 + 1 ~ a2 - 1 まで P2 通り… am + 1 ~ N まで Pm+1 通り
            // 総数は P1 * P2 * … * Pm+1 通り
            var maxDistance = distances.Max();
            var patternMap = CalcPatternMap(Math.Max(maxDistance, 1));

            var patternCount = 1;
            foreach (var distance in distances)
            {
                patternCount = (int)(Math.BigMul(patternCount, patternMap[distance]) % LAW);
            }

            // 解答の出力
            Console.WriteLine(patternCount);
        }

        /// <summary>
        /// 各距離までの経路数 % 1000000007 の一覧を返す
        /// </summary>
        /// <param name="maxDistance"></param>
        /// <returns></returns>
        static int[] CalcPatternMap(int maxDistance)
        {
            var patternMap = new int[maxDistance + 1];

            patternMap[0] = 1;
            patternMap[1] = 1;
            for (var i = 2; i <= maxDistance; i++)
            {
                patternMap[i] = (patternMap[i - 2] + patternMap[i - 1]) % LAW;
            }

            return patternMap;
        }
    }
}


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


int main()
{
	string a, b;
	cin >> a >> b;
	int x = stoi(a + b);
	string ans = "No";
	for (int i = 1; i <=1000; i++)
	{
		if (x == i * i)
		{
			ans = "Yes";
			break;
		}
	}
	cout << ans << endl;
}




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

class Cube{
public:
	int f[6];
	Cube(){}
	void roll_z(){ roll(1,2,4,3);}
	void roll_y(){ roll(0,2,5,3);}
	void roll_x(){ roll(0,1,5,4);}
	void roll(int i,int j,int k,int l){
		int t = f[i]; f[i]= f[j]; f[j]=f[k]; f[k]=f[l]; f[l] = t; 
	}
	void move(char ch){
		if(ch == 'E')for(int i = 0; i< 3; i++ )roll_y();
		if(ch == 'W')roll_y();
		if(ch == 'N')roll_x();
		if(ch == 'S')for(int i = 0; i< 3; i++ )roll_x();
	}
};

int main(){
	Cube c;
	string com;

	for( int i = 0; i < 6; i++) cin >> c.f[i];
		cin >> com;

	for( int i = 0; i < com.size(); i++ )c.move(com[i]);

	cout << c.f[0] << endl;

	return 0;

}

Measured memory_bytes: 3168
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String o=sc.next();
        String e=sc.next();
        for(int i=0;i<o.length()+e.length();i++) {
        	if(i%2==0)	System.out.print(o.charAt(i/2));
        	else		System.out.print(e.charAt(i/2));
        }

    }
}

Measured memory_bytes: 21716
// #define _GLIBCXX_DEBUG

#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <vector>
#include <chrono>
#include <cmath>

#define int long long

using namespace std;

int n, m;
vector<int> h;
vector<int> G[100001];
vector<bool> visit;

signed main() {
  cin >> n >> m;
  h.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    bool flag = true;
    for (auto u : G[i]) {
      if (h[u] >= h[i]) {
        flag = false;
        break;
      }
    }

    if (flag) {
      ans++;
    }
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 9776
s = input()
ans = [0,0,0]
for i in range(3):
    if s[i:i+1] =="a":
        ans[0] += 1
    elif s[i:i+1] == "b":
        ans[1] += 1
    elif s[i:i+1] == "c":
        ans[2] += 1
if min(ans) == 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

  /*
     input: 1 3 8
     output: Yes
  */
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt(), b = scan.nextInt(), c = scan.nextInt();
    if (a < b && b < c) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}



Measured memory_bytes: 26300
fun main(){
    val s = readLine()!!.split(" ")[0].toCharArray()
    val t = readLine()!!.split(" ")[0].toCharArray()
    val size = s.size
    var flag = 0
    for (i in 0 until size){
        if (s[i] != t[i]) flag = 1
    }
    if (flag == 1) println("No")
    else println("Yes")
}

Measured memory_bytes: 36448
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <unordered_map>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ll long long int

using namespace std;

int to_int(string s)
{
  return atoi(s.c_str());
}

int main()
{
  string s;
  cin >> s;
  int min = 100000;
  for (int i = 0; i < s.length() - 2; i++)
  {
    string sub = s.substr(i, 3);
    int tmp = abs(to_int(sub) - 753);
    if (tmp < min)
    {
      min = tmp;
    }
  }
  cout << min << endl;
}


Measured memory_bytes: 256
n = int(input())

d, x = map(int, input().split())
a = []
for i in range(n):
    a.append(int(input()))

cnt = 0
for v in a:
    cnt = cnt + 1
    n = 1
    while True:
        if v * n + 1 <= d:
            cnt = cnt + 1
            n = n + 1
        else:
            break

print(cnt + x)


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

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define ll long long
#define OK puts("OK")
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int inf = 1e9+7;
double mx = inf ,ans;
int main()
{
    double n , a ,b ,c ,d ,e ,f ,su , o;
    cin >> a >> b >> c >>d >> e >> f;
    o = 100/e;
    a = a * 100;
    b = b * 100;
    for (int i = 0 ;i <= 30 ; i ++)
    {
        for (int j = 0 ;j <= 30; j++)
        {
            for (int k = 0 ;k <=300 ;k++)
            {
                for (int z = 0 ; z <=300 ;z++)
                {
                    if (i*a+j*b+k*c+d*z <= f && i*a+j*b+k*c+d*z > 0)
                    {

                           if ( o* (k*c+z*d) <= i*a+j*b && ( i*a+j*b ) - o*(k*c+z*d) < mx)
                           {
                               mx = ( i*a+j*b ) - o * (k*c+z*d);
                               ans = i*a+j*b+k*c+d*z;
                               su = k*c+z*d;
                           }
                    }
                }
            }
        }
    }
    cout << ans << ' ' << su;

}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  vec n = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  int k;
  cin >> k;
  k--;
  cout << n[k] << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N;
    cin >> N;
    vector<int> a(N);
    for (auto &&i : a) {
        cin >> i;
        i--;
    }
    int ans = 0;
    REP(i, N) {
        if (a[a[i]] == i)
            ans++;
    }
    print(ans / 2);

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int disabled_route[16][16];

int main(void){
	int dataset;
	scanf("%d", &dataset);

	while(dataset--){
		int gx, gy, matatabi;
		int x1, y1, x2, y2;
		int foo;
		for(x1=0;x1<16;x1++)
		for(y1=0;y1<16;y1++)
		disabled_route[x1][y1] = 0;

		scanf("%d", &gx);
		scanf("%d", &gy);
		scanf("%d", &matatabi);

		while(matatabi--){
			scanf("%d", &x1);
			scanf("%d", &y1);
			scanf("%d", &x2);
			scanf("%d", &y2);
			if(x1 > x2) {
				foo = x1;
				x1 = x2;
				x2 = foo;
			}else if(y1 >y2) {
				foo = y1;
				y1 = y2;
				y2 = foo;
			}
			disabled_route[x2][y2] += ( x1==x2 ? 1 : 2 );
		}

		if(foo = count(gx, gy)) printf("%d\n", foo);
		else printf("Miserable Hokusai!\n");
	}

	return 0;
}

int count(x, y){
	if(x==0 && y==0) return 1;
	switch(disabled_route[x][y]){
	  case 3:
		return 0;
	  case 2:
		return y ? count(x, y-1) : 0;
	  case 1:
		return x ? count(x-1, y) : 0;
	  case 0:
		return (y ? count(x, y-1) : 0) + (x ? count(x-1, y) : 0);
	}
}

/* note
1	vertical
2	horizontal
*/

Measured memory_bytes: 416
/*
解説AC
一方を固定して、計算量を落とす問題？
K>=a[i]+b[j]から
b[j]<=K-a[i]を導き、それを用いて、iとjの最大化を図る。
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)

int main(){
    ll n,m,k,ans=0;
    cin>>n>>m>>k;
    vector<ll> a(n+1,0),b(m+1,0);
    rep(i,n){
        ll x;
        cin>>x;
        a[i+1]=a[i]+x;
    }
    rep(i,m){
        ll x;
        cin>>x;
        b[i+1]=b[i]+x;
    }
    int j=m;
    rep(i,n+1){
        if(a[i]>k)break;
        while(b[j]>k-a[i]){
            j--;
        }
        ans=max(ans,i+j);
    }
    cout<<ans<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 6384
package main

import (
	"fmt"
	"math"
)

var factorialMemo [400000]int

func factorial(n, m int) int {
	if n <= 1 {
		return 1
	}
	if factorialMemo[n] != 0 {
		return factorialMemo[n]
	}
	ret := n * factorial(n-1, m) % m
	factorialMemo[n] = ret
	return ret
}

func repeatedSquaring(n, p, m int) int {
	if p == 0 {
		return 1
	}
	if p%2 == 0 {
		t := repeatedSquaring(n, p/2, m)
		return t * t % m
	}
	return n * repeatedSquaring(n, p-1, m) % m
}

func choose(n, k, m int) int {
	x := factorial(n, m) % m
	y := factorial(k, m) % m
	y *= factorial(n-k, m) % m
	y %= m
	return x * repeatedSquaring(y, m-2, m) % m
}

func multiChoose(n, k, m int) int {
	return choose(n+k-1, n-1, m)
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	divisor := int(math.Pow10(9) + 7)
	ret := 0
	for i := 0; i < n; i++ {
		if i > k {
			break
		}
		ret += choose(n, i, divisor) * multiChoose(n-i, i, divisor) % divisor
	}
	ret %= divisor
	fmt.Println(ret)
}


Measured memory_bytes: 17536
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,ar[N],br[N];
string s,s1;
//Variables End

int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		cin>>n>>k;
		vi in(n,0),dp(k+1,1);
		rep(i,0,n)cin>>in[i];
		dp[0]=0;
		rep(i,1,k+1)
		{
			rep(j,0,n)
			{
				if(in[j]>i)break;
				dp[i]=dp[i]&dp[i-in[j]];
			}
			dp[i]=1-dp[i];
		}        

		if(dp[k])cout<<"First";
		else cout<<"Second";
    }
    return 0;
        
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll a,b,c,d,mod=998244353,dp[3005][3005];
int main(){
	a=read(),b=read(),c=read(),d=read();
    dp[a][b]=1;
    for(int i=a;i<=c;i++)
        for(int j=b;j<=d;j++){
        	if(i+1<=c)dp[i+1][j]=(dp[i+1][j]+dp[i][j]*j)%mod;
        	if(j+1<=d)dp[i][j+1]=(dp[i][j+1]+dp[i][j]*i)%mod;
        	if(i+1<=c and j+1<=d)dp[i+1][j+1]=(dp[i+1][j+1]+mod-dp[i][j]*i*j%mod)%mod;
        }
    cout << dp[c][d];
	return 0;
}

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

int main() {
  int k;
  string s;
  cin >> k >> s;

  if (s.size() > k) {
    cout << s.substr(0, k) + "..." << endl;
  }
  else {
    cout << s << endl;
  }

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); 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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  vector<int> c(3, 0);
  rep(i, n) {
    if (a[i] & 1) c[0]++;
    else if (a[i] % 4 == 0) c[1]++;
    else c[2]++;
  }
  if (c[2] > 0) cout << (c[0] <= c[1] ? "Yes" : "No") << endl;
  else cout << (c[0] <= c[1] + 1 ? "Yes" : "No") << endl;

  
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cmath>
#include <stack>
typedef long long ll;
#define INF 0x3f3f3f3f

using namespace std;
int N;

int sum( int n ) {
	int s = 0;
	while( n ) {
		s += n % 10;
		n /= 10;
	}
	return s;
}
void solve() {
	scanf("%d", &N);
	int ans = N;
	for(int i = 1; i < N; i++) {
		ans = min(ans, sum(i) + sum(N - i));
	}
	printf("%d\n", ans);
}
int main(int argc, char *argv[]) {
	solve();
}

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

using namespace std;

const int maxV = 1e5+10;
const long long  INF = 1e14;
long long dp[maxV];

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

	fill(dp, dp+maxV-1, INF);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		int w, v;
		cin >> w >> v;
		
		for(int j = maxV-1; j >= 0; j--) {
			if(dp[j] != INF && j+v < maxV) {
				dp[j+v] = min(dp[j+v], dp[j]+w);
			}
		}
	}

	for(int i = maxV-5; i >= 0; --i) {
		if(dp[i] <= W) {
			cout << i;
			return 0;
		}
	}
}

Measured memory_bytes: 4412
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	vector<int> t(in());
	int A = in(), B = in(), C = in();
	for (int &x: t)
		x = in();
	sort(t.rbegin(), t.rend());
	double c = (double) C / A;
	for (int x: t) {
		double n = (double) (C + x) / (A + B);
		if (n > c) {
			c = n;
			A += B;
			C += x;
		} else
			break;
	}
	outl((int) c);
}


Measured memory_bytes: 2548
def readQuestion():
    import sys
    h, w = map(int, sys.stdin.readline().split(' '))
    p = [[] for i in range(h)]
    for (i, line) in enumerate(sys.stdin):
        p[i] = list(map(lambda x:line[x] == '#', range(w)))
    return h, w, p

def mkNbr(s):
    nb = [[i-1,i+1] for i in range(s)]
    nb[0] = [1] if s > 1 else []
    nb[s-1] = [s-2] if s > 1 else []
    return nb

def solve(h, w, p):
    def hasNbr(i, j):
        return any((p[y][j] for y in nbH[i])) or \
               any((p[i][x] for x in nbW[j]))

    nbH = mkNbr(h)
    nbW = mkNbr(w)
    return 'Yes' if all((not p[i][j] or hasNbr(i,j)
                         for i in range(h) for j in range(w))) \
                 else 'No'

def main():
    h, w, p = readQuestion()
    print(solve(h, w, p))

if __name__ == '__main__':
    main()


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll N;
ll dist[310][310];
bool is[310][310]{};

int main(int argc, char **argv)
{
	cin >> N;
	REP(h, N)REP(w, N) cin >> dist[h][w];

	memset(is, 0, sizeof is);
	REP(s, N)REP(t, N)
	{
		ll d = dist[s][t];
		REP(vi, N)
		{
			if (s == vi) continue;
			if (t == vi) continue;
			if (d > dist[s][vi] + dist[vi][t])
			{
				std::cout << -1 << std::endl;
				return 0;
			}

			if (d == dist[s][vi] + dist[vi][t])
			{
				is[s][t] = true;
			}
		}
	}

	ll res{0};
	REP(h, N)REP(w, N)
	{
		if (!is[h][w])
			res += dist[h][w];
	}

	std::cout << res/2 << std::endl;
}


Measured memory_bytes: 1024
<?php

// ITP1_11 Dice IV

// read data
$n = trim(fgets(STDIN));
$data = [];
for ($i = 0; $i < $n; $i++) {
  $input = trim(fgets(STDIN));
  $labels = explode(" ", $input);
  $data[] = $labels;
}

// usort($data, 'compare');

// check
$cmp = false;
for ($i = 0; $i < $n-1 and !$cmp; $i++) {
  $dice1 = new Dice($data[$i]);
  // $a = $data[$i];
  // sort($a);
  for ($j = $i + 1; $j < $n and !$cmp; $j++) {
    // $b = $data[$j];
    // sort($b);
    //if (!array_diff_assoc($a, $b)) {
      $dice2 = new Dice($data[$j]);
      $cmp = compare_dice($dice1, $dice2);
      // var_dump($cmp);
    //}
  }
}

// answer
if ($cmp) {
  echo "No" . PHP_EOL;
} else {
  echo "Yes" . PHP_EOL;
}

//========================================

function print_labels(array $data) {
  foreach ($data as $labels) {
    echo implode(",", $labels) . PHP_EOL;
  }
}

function compare($arr_a, $arr_b)
{
  $sum_a = array_sum($arr_a);
  $sum_b = array_sum($arr_b);

  if ($sum_a == $sum_b) {
    return 0;
  } else {
    return ($sum_a < $sum_b) ? -1 : 1;
  }
}

function compare_dice($dice1, $dice2)
{
  $dice1_top = $dice1->getLabel("T");

  $check_dirs = "NWSSSW";
  foreach (str_split($check_dirs) as $dir)
  {
    $dice2->roll($dir);
    $dice2_top = $dice2->getLabel("T");
    if ($dice1_top == $dice2_top) {
      for ($i = 0; $i < 4; $i++) {
        if ($dice1->isEqual($dice2)) {
          return true;
        }
        $dice2->roll("R");
      }
    }
  }
  return false;
}


//========================================

class Dice
{
  private $labels;
  private $TBL_ROLL = array(
    array(4, 0, 2, 3, 5, 1),  // -> S
    array(3, 1, 0, 5, 4, 2),  // -> E
    array(2, 1, 5, 0, 4, 3),  // -> W
    array(1, 5, 2, 3, 0, 4),  // -> N
    array(0, 3, 1, 4, 2, 5),  // -> sidespin : right
    array(0, 2, 4, 1, 3, 5)   // -> sidespin : left
  );

  public function __construct($labels)
  {
    $this->labels = $labels;
  }

  public function roll($dirs)
  {
    foreach (str_split($dirs) as $dir) {
      $idx = strpos("SEWNRL", $dir);
      if ($idx === false) {
        continue;
      }

      $old = $this->labels;
      for ($i = 0; $i < 6; $i++) {
        $this->labels[$i] = $old[$this->TBL_ROLL[$idx][$i]];
      }
    }
  }

  public function isEqual($dice) {
    return ($this->labels == $dice->getLabels());
  }

  public function getLabel($dir) {
    $idx = strpos("TSEWNB", $dir);
    if ($idx !== false) {
      return $this->labels[$idx];
    }
    return false;
  }

  public function getLabels() {
    return $this->labels;
  }

  public function getDirection($number) {
    $idx = array_search($number, $this->labels);
    if ($idx !== false) {
      return "TSEWNB"[$idx];
    }
    return false;
  }
}

Measured memory_bytes: 15548
import java.io.*;
import java.util.*;

public class Main{
    
    public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	String s[]=br.readLine().split(" ");

	int num[]=new int[2];

	for(int i=0;i<2;i++){
	    switch(s[i]){
	    case "A":
		num[i]=10;
		break;
	    case "B":
		num[i]=11;
		break;
	    case "C":
		num[i]=12;
		break;
	    case "D":
		num[i]=13;
		break;
	    case "E":
		num[i]=14;
		break;
	    case "F":
		num[i]=15;
		break;
	    }
	}
	if(num[0]>num[1]){
	    System.out.println(">");
	    
	}else if(num[0]<num[1]){
	    System.out.println("<");
	}else{
	    System.out.println("=");
	}
	
    }
    public static void permutation(String q, String ans){
        // Base Case
        if(q.length() <= 1) {
	    //   comb.add(ans + q);
        }
        // General Case
        else {
            for (int i = 0; i < q.length(); i++) {
                permutation(q.substring(0, i) + q.substring(i + 1),
                        ans + q.charAt(i));
            }
        }
    }
}


Measured memory_bytes: 21204
import java.util.Arrays;
import java.util.Scanner;

class Main{

    public static void main(String[] args) {
        class UnionFind {
            private int parents[];		//parents[x] == ノードxの親

            //コンストラクタ
            public UnionFind(int capacity) {
                parents = new int[capacity];
                Arrays.fill(parents, -1);
            }

            //xの根を返す
            public int findRoot(int x) {
                if(parents[x] < 0) return x;
                return parents[x] = findRoot(parents[x]);
            }

            public void unite(int x, int y) {
                x = findRoot(x);
                y = findRoot(y);
                if (x == y) return;

                if (parents[x] > parents[y])
                    swap(parents, x, y);
                parents[x] += parents[y];
                parents[y] = x;
            }

            public boolean same(int x, int y) {
                return findRoot(x) == findRoot(y);
            }

            public int getSize(int x) {
                return -parents[findRoot(x)];
            }

            private void swap(int[] a, int idx1, int idx2) {
                int tmp = a[idx1];
                a[idx1] = a[idx2]; a[idx2] = tmp;
            }
        }


        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        UnionFind uf = new UnionFind(N);
        for(int i = 0; i < M; i++)
        	uf.unite(sc.nextInt() - 1, sc.nextInt() - 1);
        
        int ans = 0;
        for(int i = 0; i < N; i++)
        	ans = Math.max(ans, uf.getSize(i));
        
        System.out.println(ans);
    }

}

Measured memory_bytes: 59936
#include<bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof a) ;
typedef pair<int,int> pii ;
#define vi vector<int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
void solve()
{
int n,m; cin>>n>>m;
vi sig(n+1);
sig[1]=0;
vector < vi > v(n+1);
rep(i,0,n+1)
sig[i]=-1;
rep(i,0,m)
{
int x,y; cin>>x>>y;
v[x].pb(y); v[y].pb(x);
}
queue<int>q;
q.push(1);
int ct=1; sig[1]=0;
while(!q.empty())
{
int p=q.front();
q.pop();
rep(i,0,v[p].size())
{
if(sig[v[p][i]]==-1)
{
ct++;
sig[v[p][i]]=p;
q.push(v[p][i]);
}
}
}
if(ct==n)
{
	cout<<"Yes\n";
	rep(i,2,n+1)
	cout<<sig[i]<<"\n";
}
else
cout<<"No\n";
return;
}
int main()
{
ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
//	cin>>t;
while(t--)
{
solve();
}
return 0;
}

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

int main()
{
	int n,k;
	cin>>n>>k;
	bool a[10]={};
	for(int i=0;i<k;i++)
	{
		int x;
		cin>>x;
		a[x]=true;
	}
	string s;
	bool t;
	char c[10];
	for(int i=0;i<10;i++)
		c[i]='0'+i;
	for(int i=n;i<n*100;i++)
	{
		stringstream ss;
		ss<<i;
		s=ss.str();
		t=true;
		for(int j=0;j<10;j++)
		{
			if(a[j]&&s.find(c[j])!=-1)
			{
				t=false;
				break;
			}
		}
		if(t)
		{
			cout<<i;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let r: usize = it.next().unwrap().parse().unwrap();
    let g: usize = it.next().unwrap().parse().unwrap();
    let b: usize = it.next().unwrap().parse().unwrap();
    let n: usize = it.next().unwrap().parse().unwrap();
    let mut ans = 0;
    for i in (0..).filter(|&x| x % r == 0).take_while(|&x| x <= n) {
        for j in (0..).filter(|&x| x % g == 0).take_while(|&x| x <= n - i) {
            let k = n - i - j;
            if k % b == 0 {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int N;
	char S[101];
	scanf("%d", &N);
	scanf("%s", S);

	int i, x = 0, max = 0;
	for (i = 0; i < N; i++) {
		if (S[i] == 'I') {
			x++;
			if (x > max) max = x;
		} else x--;
	}
	
	printf("%d\n", max);
	fflush(stdout);
	return 0;
}

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

int a[1405][1405];
int dp[1405][1405]; 
//int Maxdp = 0; 


int main()
{
	int n = 0,m = 0;
	
	cin>>n>>m;
	
	for(int i = 0 ;i < n ;i++ )
	{
		for(int j = 0 ;j < m ;j++ )
		{
			cin>>a[i][j];
	
			if(a[i][j] == 1)
			{
				dp[i][j] = 0;
			}
			else
			{
				dp[i][j] = 1;
			}
		}
	}

	for(int i = 1 ;i < n ;i++ )
	{
		for(int j = 1 ;j < m ;j++ )
		{
			if(a[i][j] == 0)
			{
				dp[i][j] = min(dp[i - 1][j - 1],min(dp[i - 1][j],dp[i][j - 1])) + 1;
	
//				if(dp[i][j] > Maxdp)
//				{
//					Maxdp = dp[i][j];
//				}
			}
		}
	}
	
	int Maxdp=dp[0][0];
	for(int i=0; i<=n; i++) {
		for(int j=0; j<=m; j++) {
			if(dp[i][j]>Maxdp) {
				Maxdp=dp[i][j];
			}
		}
	}
	
	cout<<Maxdp*Maxdp<<endl;
	return 0;
}


Measured memory_bytes: 18480
def solve(s):
    sums = 0
    sumt = 0
    ans = 0
    for i in s:
        if i == 'S':
            sums += 1
        else:
            if sums > 0:
                sums -= 1
                ans += 2
    return len(s)-ans

if __name__ == '__main__':
    s = input()
    print(solve(s))


Measured memory_bytes: 3500
#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
ll max(ll a,ll b){
	if(a>b) return a;
	else return b;
}
ll min(ll a,ll b){
	if(a<=b) return a;
	else return b;
}
int n,a,b,c,d;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    string t;
    cin>>s>>t;
    string m="";
    for(int i=0; i<t.size()-1;i++) m+=t[i];
    if(s==m)cout<<"Yes";
    else cout<<"No";
    
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <vector>
#define N 15
using namespace std;

int n, m, k, c, ans, p[N];
vector<int> s[N];
int main()
{
	int i, j, x, t;
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		scanf("%d", &k);
		for (j = 0; j < k; j++) {
			scanf("%d", &t);
			s[i].push_back(t - 1);
		}
	}
	for (i = 0; i < m; i++) scanf("%d", &p[i]);
	for (x = 0; x < 1 << n; x++) {
		for (i = 0; i < m; i++) {
			c = 0;
			for (j = 0; j < s[i].size(); j++) {
				if (x & (1 << s[i][j])) c++;
			}
			if (c % 2 != p[i]) break;
		}
		if (i == m) ans++;
	}
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,x,y) for(int i=(x);i<=(y);i++)
#define drep(i,x,y) for(int i=(x);i>=(y);i--)
using namespace std;
const int sz=2007;
const int mod=1e9+7;
int f[sz][sz],sum[sz][sz];
int qpow(int x,int y){
	int ret=1;
	for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) ret=1ll*x*ret%mod;
	return ret;
}
int main(){
	int n,k,ans=0;
	scanf("%d%d",&n,&k);
	rep(i,2,n+1) sum[0][i]=1;
	rep(i,1,k-1) drep(j,n-i+1,2){
		if(j<=n-i+1) (f[i][j]+=sum[i-1][j])%=mod;
		sum[i][j]=(sum[i][j+1]+f[i][j])%mod;
	}
	rep(i,2,n-k+2) (ans+=1ll*f[k-1][i])%=mod;
	if(k==1) ans=1;
	if(k!=n) ans=1ll*ans*qpow(2,n-k-1)%mod;
	printf("%d\n",ans); 
}

Measured memory_bytes: 31360
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n;
	cin>>n;
	if( n % 2 == 1 ){
		cout<<0<<endl;
		return 0;
	}
	else{
		int ans = 0;
		n = n/10;
		while( n > 0 ){
			ans += n;
			n = n/5;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
/**
 * @author yuichirw
 *
 */
import java.util.*;
import static java.lang.Math.*;

public class Main {
	static String c;
	static Scanner sc = new Scanner(System.in);
	static String[] color_str = {
		"black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white"
	};
	static int[][] color = {
		{0, 0, 0},
		{0, 0, 255},
		{0, 255, 0},
		{0, 255, 255},
		{255, 0, 0},
		{255, 0, 255},
		{255, 255, 0},
		{255, 255, 255}
	};
	
	static boolean read() {
		c = sc.next();
		return (c.equals("0")) ? false : true;
	}
	
	static String solve() {
		int[] clr = new int[3];
		clr[0] = Integer.parseInt(c.substring(1, 1 + 2), 16);
		clr[1] = Integer.parseInt(c.substring(3, 3 + 2), 16);
		clr[2] = Integer.parseInt(c.substring(5, 5 + 2), 16);
		
		String ans; int d, a;
		ans = ""; d = 195075;
		
		for(int i = 0; i < color.length; i++) {
			a = (int)(pow(color[i][0] - clr[0], 2) + pow(color[i][1] - clr[1], 2) + pow(color[i][2] - clr[2], 2));
			if(a < d) {
				d = a;
				ans = color_str[i];
			}
		}
		return ans;
	}
	
	public static void main(String[] args) {
		while(read()) {
			System.out.println(solve());
		}
	}

}

Measured memory_bytes: 12000
import itertools

N,T = list(map(int,input().split(" ")))
As = list(map(int,input().split(" ")))
ans = 1
ma = -1
l = 0
for r,a in enumerate(As):
    if a < As[l]:
        l = r

    if a - As[l] >0:
        if a - As[l] > ma:
            ma = a - As[l]
            ans = 1
        elif a - As[l] == ma:
            ans += 1

print(ans)





Measured memory_bytes: 58576
O = input()
E = input()

password = O[0] + E[0]

if len(O)-len(E)==1:
    for i in range(1, len(O)-1):
        password = password + O[i] + E[i]
    password = password + O[-1]
else:
    for i in range(1, len(O)):
        password = password + O[i] + E[i]

print(password)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, p;
    string s;
    cin >> n >> p >> s;
    if (p == 2) {
        ll ans = 0;
        rep(i, n) {
            int x = s[i] - '0';
            if (x % 2 == 0) {
                ans += i+1;
            }
        }
        cout << ans << endl;
    } else if (p == 5) {
        ll ans = 0;
        rep(i, n) {
            int x = s[i] - '0';
            if (x % 5 == 0) {
                ans += i+1;
            }
        }
        cout << ans << endl;
    } else {
        reverse(s.begin(), s.end());
        vi modsum(n+1, 0);
        int now = 1;
        rep(i, n) {
            modsum[i+1] = (modsum[i] + (s[i] - '0') * now) % p;
            now = (now * 10) % p;
        }
        map<int, int> mp;
        rep(i, n+1) mp[modsum[i]]++;
        ll ans = 0;
        for (auto&& p : mp) ans += (ll)p.se * (p.se - 1) / 2;
        cout << ans << endl;
    }
    
}

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

int main()
{
	string N;
	cin >> N;
	if (N[0] == N[1] && N[1] == N[2] )cout << "Yes" << endl;
	else if (N[1] == N[2] && N[2] == N[3])cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

const int mod = 1000000007;

ll modPow(ll x, ll y, ll mod) {

    x %= mod;
    ll res = 1;

    while (y > 0) {

        if (y & 1 == 1) res = res * x % mod;

        x = x * x % mod;
        y >>= 1;
    }
    return res;
}

ll solve()
{
    ll N, K;

    std::cin >> N >> K;


    vector<ll> minSum(N + 1, 0);
    for (int i = 1; i <= N; ++i)
        minSum[i] = (minSum[i-1] + i) % mod;

    ll maxSum = (N * (N + 1) % mod) * modPow(2, mod - 2, mod) % mod;
    ll ans = 0;

    for (int i = K; i <= N; ++i) {
        ans = (ans + (maxSum - minSum[N - i] - minSum[i-1] + 1 + mod)) % mod;
    }

    return ans + 1;
}

int main()
{
    std::cout << solve() << std::endl;
    //solve();

    return 0;
}

Measured memory_bytes: 4820
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
int p=1000000007;
int p_MAX = 1000;
vector<int> prime;
typedef long long ll;
int calc_prime()
{
  bool notPrime[p_MAX];
  int n = sqrt(p_MAX)+1;
  fill(notPrime,notPrime+p_MAX,0);
  notPrime[0]=1;
  notPrime[1]=1;
  for(int i=0;i<=n;i++){
    if(notPrime[i])
      continue;
    int m = p_MAX/i;
    for(int j=2;j<=m;j++)
      notPrime[j*i]=1;
  }
  prime.clear();
  for(int i=0;i<p_MAX;i++)
    if(!notPrime[i])
      prime.push_back(i);
  return 0;
}
int main()
{
  int n,t,x,i;
  ll res=1;
  cin >> n;
  calc_prime();
  for(i=0;i<prime.size();i++){
    if(prime[i]>n)
      break;
    t=n;
    x=0;
    while(t>0){
      t/=prime[i];
      x+=t;
    }
    res*=x+1;
    res%=p;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

ll N, A;
void dfs(ll now, ll sum, ll num_used, vector<ll>& x, map<ll, ll>& num) {
  if (x.size() == 0) {
    num[0] = 1;
    return;
  }
  if (now == x.size() - 1) {
    num[A * num_used - sum] += 1;
    num[A * (num_used + 1) - (sum + x.at(x.size() - 1))] += 1;
  }
  else {
    dfs(now + 1, sum, num_used, x, num);
    dfs(now + 1, sum + x.at(now), num_used + 1, x, num);
  }
}

int main() {
  cin >> N >> A;
  vector<ll> x1(N / 2), x2(N - N / 2);
  for (ll i = 0; i < N / 2; ++i) {
    cin >> x1.at(i);
  }
  for (ll i = 0; i < (N - N / 2); ++i) {
    cin >> x2.at(i);
  }
  map<ll, ll> num1, num2;
  dfs(0, 0, 0, x1, num1);
  dfs(0, 0, 0, x2, num2);
  // for (ll i = 0; i < num1.size(); ++i) {
  //   cout << num1.at(i) << " ";
  // }
  // cout << "\n";
  // for (ll i = 0; i < num2.size(); ++i) {
  //   cout << num2.at(i) << " ";
  // }
  // cout << "\n";
  ll ans = 0;
  for (const auto& [key, value] : num1) {
    ans += value * num2[-key];
  }

  ans -= 1;
  cout << ans << "\n";
}


Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
using ll = long long;
using namespace std;

ll solve(ll n, ll k) {
    vector<ll> f(k);
    REP3 (i, 1, n + 1) {
        f[i % k] += 1;
    }
    ll cnt = 0;
    REP (a, k) {
        int b = (- a + k) % k;
        int c = a;
        if ((a + c) % k == 0) {
            cnt += f[a] * f[b] * f[c];
        }
    }
    return cnt;
}

int main() {
    int n, k; cin >> n >> k;
    cout << solve(n, k) << endl;
    return 0;
}


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

signed main() {
    while(true){
        int n,x;
        cin >> n >> x;

        if(n == 0 && x == 0) break;
        int ans = 0;
        for(int i = 1; i <= n; i++){
            for(int j = i + 1; j <= n; j++){
                for(int k = j + 1; k <= n; k++){
                    if(i + j + k == x) ans++;
                }
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3084
#include<iostream>
using namespace std;
int main()
{
    int m = 0;
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++)
    {
        int k = 0, j;
        j = i;
        while(s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T')
        {
            k++;
            j++;
        }
        if(m < k)
            m = k;
    }
    cout << m;
    return 0;
}


Measured memory_bytes: 3552