akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import static java.lang.System.*;

public class Main {
 	public static void main(String[] args) {
     	Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      	boolean isJust = false;
		for(int i = 0; i <= 25; i++) {
        	for(int j = 0; j <= 14; j++) {
            	int total = i * 4 + j * 7;
              	if(total == N) isJust = true;
            }
        }
      	if(isJust)   out.println("Yes");
      	if(! isJust) out.println("No");
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <queue>
#include <utility>
#include <algorithm>
#include <vector>

using namespace std;

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

	int nJobs, nDays;
	cin >> nJobs >> nDays;

	pair<int, int> jobs[nJobs];
	for(int i = 0 ; i < nJobs ; ++i) {
		cin >> jobs[i].first >> jobs[i].second;
	}
	sort(jobs, jobs+nJobs);

	int jobCounter = 0;
	long long result = 0;

	priority_queue<pair<int, int> > PQ;
	for(int i = 1 ; i <= nDays ; ++i) {
		while(jobCounter < nJobs && jobs[jobCounter].first <= i) {
			PQ.push({jobs[jobCounter].second, jobs[jobCounter].first});
			jobCounter++;
		}
		if(PQ.size() >= 1) {
			result += PQ.top().first;
			PQ.pop();
		}
	}

	cout << result << '\n';
}

Measured memory_bytes: 2168
/*
  AtCoder Beginner Contest 099
  B - Stone Monument
*/

#include<iostream>
#include<vector>
using namespace std;

int a, b;
int t[999];

int main() {
  scanf("%d%d", &a, &b);

  t[0] = 1;
  for (int i = 2; i < 1000; ++i) t[i-1] = t[i-2] + i;
 
  printf("%d\n", t[b-a-1] - b);
  return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappop, heappush

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)


N, M, S, T = map(int, input().split())
PATH = [[] for _ in range(N+1)]


for _ in range(M):
    u, v, a, b = map(int, input().split())
    PATH[u].append((v, a, b))
    PATH[v].append((u, a, b))


def dijkstra(s, mode):
    INF = 10 ** 15
    dist = [INF] * (N+1)
    dist[s] = 0
    que = [(0, s)]

    while que:
        d, v = heappop(que)
        if dist[v] < d:
            continue

        for u, *a in PATH[v]:
            dv = d + a[mode]

            if dv < dist[u]:
                dist[u] = dv
                heappush(que, (dv, u))

    return dist


da = dijkstra(S, 0)
db = dijkstra(T, 1)

score = [10**15 - (da[i]+db[i]) for i in range(1, N+1)]

ans = [10**15] * N
ans[-1] = score[-1]

for i in range(N-2, -1, -1):
    ans[i] = max(ans[i+1], score[i])

for i in range(N):
    print(ans[i])


Measured memory_bytes: 67048
parseInt(x) = parse(BigInt,x)

function main()
  N = parseInt(readline())
  P = Int[]
  for i = 2:N
    tmp = 0
    j = 2
    while j < i
      if rem(i,j) == 0 
        tmp = 1
      end
      j += 1
    end
    tmp == 0 ? push!(P,i) : k = 0 
  end
  l = length(P)
  r = zeros(BigInt,l) 
  M = factorial(N)
  for i = 1:l
    while M % P[i] == 0
      M = div(M,P[i])
      r[i] += 1
    end
  end
  c = rem(prod(r.+1), 10^9+7)
  println(c)
end

main()

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

int main(){
  int N, Y;
  cin >> N >> Y;
  int sum;
  for (int i = 0; i <= N; i++){
    for (int j = 0; j <= N - i; j++){
      sum = i*10000 + j*5000 + (N-i-j)*1000;
      if (sum == Y){
        cout << i << " "<< j << " "<< N-i-j << endl;
        return 0;
      }
    }
  }
  cout << -1 << " "<< -1 << " "<< -1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <list>
#include <map>
#include <array>
#include <memory>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <stdexcept>


using std::string;
using std::vector;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// util
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

std::vector<std::string> split(const std::string& input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// user func
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void printList(const vector<int>& list) {
    // print
    for(int i = 0; i < list.size(); i++){
        printf(" %d", list[i]);
    }
    printf("\n");
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// logic
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
vector<int> memo(45, -1);
int fib(int n){
    if(memo[n] != -1) return memo[n];

    if(n == 0) return 1;
    if(n == 1) return 1;
    int res = fib(n-1) + fib(n-2);
    memo[n] = res;
    return res;
}
void solve() {
    int n;
    scanf("%d", &n);
    printf("%d\n", fib(n));
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// main
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3188
h,w=map(int,input().split())

grid=[]
for i in range(h):
    grid.append(list(map(int,input().replace("#","1").replace(".","0"))))

ans="Yes"

for row in range(1,h-1):
    for col in range(1,w-1):
        if not(grid[row-1][col] or grid[row+1][col] or grid[row][col-1] or grid[row][col+1]) and grid[row][col]:
            ans="No"
            break

print(ans)



Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String C =sc.nextLine();
		String alpha[]= {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
		for(int i=0;i<alpha.length;i++) {
			if(C.contentEquals(alpha[i])) {
				i ++;
				System.out.println(alpha[i]);
			}
		}
	}

}

Measured memory_bytes: 23124
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

pll operator + (pll a, pll b) {
	return pll(a.first + b.first, a.second + b.second);
}
pll bit[140000];
void update(int p, pll v) {
	for (; p <= IT_MAX; p += p & (-p)) bit[p] = bit[p] + v;
}
pll getsum(int p) {
	pll rv = pll(0, 0);
	for (; p; p -= p & (-p)) rv = rv + bit[p];
	return rv;
}

ll in[100050];
ll val[100050];
int u[100050];
ll sum[100050];
ll ans[100050];
int main() {
	int N, i;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%lld", &in[i]);
	for (i = 1; i <= N; i++) u[i] = i;
	sort(u + 1, u + N + 1, [](int a, int b) {
		if(in[a] != in[b]) return in[a] < in[b];
		else return a < b;
	});
	for (i = 1; i <= N; i++) sum[i] = sum[i - 1] + in[u[i]];
	for (i = N; i >= 1; i--) val[u[i]] = (sum[N] - sum[i]) - (N - i) * in[u[i]];
	for (i = 2; i <= N; i++) val[i] = min(val[i], val[i - 1]);

	ll c = 0;
	val[0] = sum[N];
	for (i = N; i >= 1; i--) {
		ans[i] = val[i - 1] - c;
		c = val[i - 1];
	}
	for (i = 1; i <= N; i++) printf("%lld\n", ans[i]);
	return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    long long x,k,d;
    cin>>x>>k>>d;
    if(max(x/d, -x/d) >= k){
        if(x<0) x += k*d;
        else x-= k*d;
    }
    else{
        if(max(x/d, -x/d)%2==k%2) x -= (x/d)*d;
        else{
            if(x>=0) x-= (x/d+1)*(d);
            else x-= (x/d-1)*(d);
        }
    }
    cout<<max(x,-x);
    return 0;
}


Measured memory_bytes: 3684
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int N,K;
  cin>>N>>K;
  
  if(2*K>(N-1)*(N-2)){
    co(-1);
    return 0;
  }
  
  cout<<(N-1)*N/2-K<<endl;
  RREP(i,N-1) cout<<1<<" "<<i+1<<endl;
  int cnt=(N-1)*(N-2)/2-K;
  for(int i=2; i<=N-1; ++i){
    for(int j=i+1; j<=N; ++j){
      if(cnt==0) return 0;
      cout<<i<<" "<<j<<endl;
      cnt--;
    }
  }
}

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

int main()
{
    int n;
    cin >> n;
    vector<int64_t> a(n+1);
    vector<int64_t> b(n);

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

    int64_t killedMonstersCnt = 0;
    int64_t remainingCapacity = 0;
    for (int i = 0; i < n; ++i)
    {
        if (a[i] <= remainingCapacity)
        {
            killedMonstersCnt += a[i];
            // a[i] = 0;
            remainingCapacity = b[i];
            // continue;
        }
        else
        {
            killedMonstersCnt += remainingCapacity;
            a[i] -= remainingCapacity;
            if (a[i] <= b[i])
            {
                killedMonstersCnt += a[i];
                // a[i] = 0;
                remainingCapacity = b[i] - a[i];
                // continue;
            }
            else
            {
                killedMonstersCnt += b[i];
                // a[i] -= b[i]
                remainingCapacity = 0;
                // continue;
            } 
        }
    }
    if (a[n] <= remainingCapacity)
    {
        killedMonstersCnt += a[n];
    }
    else
    {
        killedMonstersCnt += remainingCapacity;
    }
    
    cout << killedMonstersCnt << endl;

    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
namespace Collections
{
	class program
	{
		static void Main(string[] args)
		{
			// 入力
			int N = Int32.Parse(Console.ReadLine());

			// 仕事を読み込む
			// 締め切り-仕事量の辞書を作る
			Dictionary<int, long> deadline = new Dictionary<int, long>();
			List<int> keys = new List<int>();
			for(int i=0; i<N; i++)
			{
				string[] input = Console.ReadLine().Split(' ');
				int a = Int32.Parse(input[0]);
				int b = Int32.Parse(input[1]);
				if(deadline.ContainsKey(b))
				{
					deadline[b] = deadline[b] + a;
				}
				else
				{
					deadline.Add(b, (long)a);
					keys.Add(b);
				}
			}

			// 締め切りの近い順に仕事をこなしていく
			long time = 0;
			keys.Sort();
			for(int i=0; i<keys.Count; i++)
			{
				time += deadline[keys[i]];
				if(time > keys[i])
				{
					Console.WriteLine("No");
					return;
				}
			}
			Console.WriteLine("Yes");
    }
	}
}


Measured memory_bytes: 32308
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
cnt = [0] * (n+1)
for i in range(1, n):
    for j in range(i, n, i):
        cnt[j] += 1

ans = sum(cnt[:-1])
print(ans)

Measured memory_bytes: 89608
class Main{
	
public static void main (String[] args) {
	
	java.util.Scanner sc = new java.util.Scanner(System.in);
	
	int N = sc.nextInt();
	boolean flag = true;
	
	while (flag) {
		N-=1000;
		if (N<=0) {
			flag=false;
			N*=-1;
		}
	}
	
	System.out.println(N);
	
	sc.close();;
	
}
	
	
}



Measured memory_bytes: 35776
#include <stdio.h>

void sum(int n);

int main(void){
	int n;
	scanf("%d",&n);
	
	if(n==1 || n==0){
		printf("%d\n",1);
	}
	
	else if(n>=2){
		sum(n);
	}
	else{
	}
	return 0;
}


void sum(int n){
	
	int i;
	int fib[n];
	
	fib[0]=1;
	fib[1]=1;
	
	for(i=2;i<=n;i++){
	fib[i]=fib[i-1]+fib[i-2];
	}
	
	printf("%d\n",fib[n]);
}



Measured memory_bytes: 2048
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long int i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


/*
 *  a,b,c
 *  1 --> b+c, a+c, b+a; ---> x = b+c - a-c = b-a;
 *  2 --> 2a+b+c, 2b +c+a, ... ---> x = 2a+b+c -2b-c-a = a-b;  
 */
int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    i64 a,b,c;
    i64 k;
    cin>>a>>b>>c>>k;
    if(k%2==1) cout<<b-a<<endl;
    else       cout<<a-b<<endl;
    return 0;
}



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

int main(void){
    int Ain;
    int Asum = 0;

    for(int i=0; i<3; i++){
        cin >> Ain;
        Asum += Ain;
    }

    if(Asum < 22){
        cout << "win" << endl;
    }else{
        cout << "bust" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}

int log(int x) {
    int i;
    for(i=0;(1ll<<i)<=x;i++);
    return i;
}
 
int32_t main() {
    fio
    
    cout << fixed << setprecision(15);
    int n;
    cin >> n;
    
    int c=LLONG_MAX;
    fff(i,n) {
        int x;cin >> x;
        
        int f=0;
        while(x%2==0) {
            f++;
            x/=2;
        }
        c=min(c,f);
    }
    
    cout << c;
        
    
    
	return 0;
    
}

Measured memory_bytes: 8832
s = input()
n = len(s)
k = int(input())

A = []
for i in range(n):
    A.append(s[i:])

A.sort()
# print(A)

B = []

for i in range(min(k, len(A))):
    for j in range(1, len(A[i])+1):
        B.append(A[i][:j])

B.sort()

# print(B)
co = 1
i = 1
mae = B[0]
while co < k:
    #print(i)
    if mae != B[i]:
        co += 1
        mae = B[i]
    i += 1
print(mae) 

Measured memory_bytes: 53620
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 0
flag = True
if N % 2 == 1:
  # 奇数個の場合、0,2,2,4,4,～みたいに並んでるはず
  if A[0] == 0:
    for i in range(1, N, 2):
      if A[i] != i+1 or A[i+1] != i+1:
        flag = False
        break
    if flag:
      ans = 2**(N//2) % (10**9+7)
else:  
  # 偶数個の場合、1,1,3,3,5,5,～のように並んでるはず
  if A[0] != 0:
    for i in range(0, N, 2):
      if A[i] != i+1 or A[i+1] != i+1:
        flag = False
        break
    if flag:
      ans = 2**(N//2) % (10**9+7)
print(ans)      

Measured memory_bytes: 14008
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
// #define ll long long
typedef long long ll;
typedef pair<int, int> P;

unsigned int len(unsigned int n)
{
    return n ? len(n/10)+1 : 0;
}

int main(int argc, const char * argv[]) {

  int a;
  string s;
  cin >> a;
  cin >> s;
  if (a >= 3200){
    cout << s << endl;
  }else{
    cout << "red" << endl;
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define MAX 5000000000000000000LL
#define MIN -5000000000000000000LL

ll n, x, m, xx;
map<ll, ll> chk;
ll cou;
ll hap;
ll ans;

int main(void)
{
	scanf("%lld %lld %lld", &n, &x, &m);
	
	xx = x;
	
	chk[x] = 1;
	
	while(1)
	{
		x = (x * x) % m;
		
		if(chk[x])
			break;
		
		chk[x] = 1;
	}
	
	while(n > 0 && xx != x)
	{
		ans += xx;
		xx = (xx * xx) % m;
		n--;
	}
	
	xx = x;
	
	hap += x;
	cou++;
	x = (x * x) % m;
	
	while(x != xx)
	{
		hap += x;
		cou++;
		x = (x * x) % m;
	}
	
	ans += (n / cou) * hap;
	
	n %= cou;
	
	for(ll i = 0 ; i < n ; i++)
	{
		ans += x;
		x = (x * x) % m;
	}
	
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 6872
#include<iostream>

using namespace std;

int main() {
	int N;
	bool flag=false;

	cin >> N;

	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < 15; j++) {
			if (i * 4 + j * 7 == N) {
				flag = true;
			}
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,sum=0;
    long double a[10000];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n-1;i++)
    {
        a[i+1] = (a[i]+a[i+1])/2;
    }
    cout<<fixed<<setprecision(6)<<a[n-1];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  string s ;
  cin >> s ;
  int n = SZ(s) ;
  int cnt = 0 ;
  REP(i,n){
    if(s.at(i)=='o'){
      cnt++ ;
    }
  }
  if(n<=cnt+7){
    cout <<"YES"<<endl ;
  }
  else{
    cout <<"NO"<<endl ;
  }
    


  return 0 ;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;
int a,b,c,maxx,minn,mid;
int main()
{
	cin>>a>>b>>c;
	maxx=max(a,max(b,c));
	minn=min(a,min(b,c));
	mid=a+b+c-maxx-minn;
	cout<<maxx*10+mid+minn;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) v.erase(unique(ALL(v)), v.end())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int r,D,x2000;
  while(cin >> r >> D >> x2000){
    int x = x2000;
    FORE(i,1,10){
      x = r*x-D;
      cout << x << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main() {
    int n, f=0;
    while (cin>>n) {
        if (!n) break;
        if (f) cout<<endl;
        else f=1;
        vector<int> m;
        map<int, vector<string> > f;
        for (int i=0; i<n; i++) {
            string name; cin>>name;
            int a,b,c; cin>>a>>b>>c;
            int p=-(a*3+c);
            if (count(m.begin(), m.end(), p)==0) m.push_back(p);
            f[p].push_back(name);
        }
        sort(m.begin(),m.end());
        for (int i=0; i<m.size(); i++) {
            for (int j=0; j<f[m[i]].size(); j++) {
                cout<<f[m[i]][j]<<","<<-m[i]<<endl;
            }
        }
    }
}

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

    val nums = arrayOf(0, 2, 5, 5, 4, 5, 6, 3, 7, 6)

    val (n, m) = readLine()!!.split(' ').map { it.toInt() }

    val map = mutableMapOf<Int, Int>()

    readLine()!!.split(' ')
            .map { it.toInt() }
            .forEach {
                val num = nums[it]
                map[num] = Math.max(map.getOrPut(num) { 0 }, it)
            }

    val dp = IntArray(n + 1) { -1 }

    dp[0] = 0

    for (i in (1..n)) {
        dp[i] = map.keys.map {
            if (it > i) {
                return@map -1
            }

            if (dp[i - it] == -1) {
                return@map -1
            }

            dp[i - it] + 1
        }.max()!!
    }

    val vs = map.values.sortedDescending()

    var res = ""
    var n1 = n

    repeat(dp[n]) {
        vs.forEach {
            val j = n1 - nums[it]
            if (j < 0) {
                return@forEach
            }
            if (dp[j] == dp[n1] - 1) {
                res += it.toString()
                n1 = j
                return@repeat
            }
        }
    }

    println(res)
}


Measured memory_bytes: 68260
#include<cstdio>
#include<cstring>

int n,d[200001],fa[200001],D[200001],Fa[200001],hd[400002],cnt,ans[2000001],x,y,po[200001];
bool bo[2000001];

struct node
{
	int to,next,la;
}e[2000001];

void addedge(int x,int y)
{
	e[++cnt].next=hd[x];
	e[hd[x]].la=cnt;
	hd[x]=cnt;
	e[cnt].to=y;
	e[cnt].la=0;
}

int calc(int x) {return ((x-1)^1)+1;}

void del(int x,int i)
{
	if (i==hd[x]) hd[x]=e[i].next;
	else e[e[i].la].next=e[i].next,e[e[i].next].la=e[i].la;
}

void dfs(int x)
{
	for (int i=hd[x]; i; i=e[i].next)
	{
		del(x,i); del(e[i].to,calc(i));
		ans[i]=ans[calc(i)]=i;
		dfs(e[i].to);
	}
}

int main()
{
	scanf("%d",&n); y=2*n+1;
	memset(d,0,sizeof(d));
	memset(D,0,sizeof(D));
	memset(hd,0,sizeof(hd)); cnt=0;
	for (int i=1; i<=n; i++) 
		{scanf("%d",&x),fa[i]=x; if (x==-1) addedge(y,i),addedge(i,y); else d[x]++,addedge(i,x),addedge(x,i);}
	for (int i=1; i<=n; i++) 
		{scanf("%d",&x),Fa[i]=x; if (x==-1) addedge(y,i+n),addedge(i+n,y); else D[x]++,addedge(i+n,x+n),addedge(x+n,i+n);}
	for (int i=1; i<=n; i++) if ((d[i]&1)!=(D[i]&1)) {printf("IMPOSSIBLE\n"); return 0;}
	for (int i=1; i<=n; i++) if (!(d[i]&1)) addedge(i,i+n),addedge(i+n,i),po[i]=cnt;
	dfs(y); printf("POSSIBLE\n");
	for (int i=1; i<=n; i++)
		if (d[i]&1) printf("0 "); else if (e[ans[po[i]]].to<=n) printf("-1 "); else printf("1 ");
	printf("\n");
	return 0;
}

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

class Program {
    public static void Main() {
#if USE_IDE
        var exStdIn = new System.IO.StreamReader("./../../TestStdin.txt");
        Console.SetIn(exStdIn);
#endif
        var n = int.Parse(Console.ReadLine());
        int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int[] b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int[] diff = new int[n];

        for (int i = 0; i < n; i++) {
            diff[i] = a[i] - b[i];    // 正なら合格
        }

//        int[] diff = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

        Array.Sort(diff);
//        var total = diff.Sum();
        long total = 0;
        for (int i = 0; i < n; i++) {
            total += diff[i];
        }    
        
        if (total < 0) {
            Console.WriteLine(-1);
            return;
        }

        var shortNum = 0;
        for (shortNum = 0; shortNum < n; shortNum++) {
            if (0 <= diff[shortNum]) {
                break;
            }
        }

        if (shortNum == 0) {
            Console.WriteLine(0);
            return;
        }
        
        long husoku = 0;
        for (int i = 0; i < n; i++) {
            if (diff[i] < 0) {
                husoku -= diff[i];
            }
        }

        var c = 0;
        for (int i = n-1; i >= 0; i--) {
            husoku -= diff[i];
            c++;
            if (husoku <= 0) {
                Console.WriteLine(shortNum + c);
                return;
            }
        }
    }
}

Measured memory_bytes: 34012
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <limits.h>

using namespace std;

int A, B, Q;
vector<long long> s, t,x;

int main() {

	cin >> A >> B >> Q;

	s.resize(A+2);
	t.resize(B+2);
	x.resize(Q);

	s[0] = LLONG_MIN/4;
	s[A + 1] = LLONG_MAX/4;
	t[0] = LLONG_MIN/4;
	t[B + 1] = LLONG_MAX/4;

	for (int i = 1; i <= A; i++) cin >> s[i];
	for (int i = 1; i <= B; i++) cin >> t[i];
	for (int i = 0; i < Q; i++) cin >> x[i];

	long long s_n[2],t_n[2];
	long long ans,d1,d2;
	for (int i = 0; i < Q; i++) {
		auto it = lower_bound(s.begin(), s.end(), x[i]);
		s_n[1] = it - s.begin();
		s_n[0] = s_n[1] - 1;

		it = lower_bound(t.begin(), t.end(), x[i]);
		t_n[1] = it - t.begin();
		t_n[0] = t_n[1] - 1;

		ans = LLONG_MAX/2;

		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2;k++) {
				d1 = abs(x[i] - s[s_n[j]]) + abs(s[s_n[j]] - t[t_n[k]]);
				d2 = abs(x[i] - t[t_n[j]]) + abs(t[t_n[j]] - s[s_n[k]]);

				ans = min({ ans,d1,d2 });
			}
		}

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

Measured memory_bytes: 3712
n = int(input())
a = n % 10
if a == 2 or a == 4 or a == 5 or a == 7 or a == 9 :
 print ("hon")
elif a == 0 or a == 1 or a == 6 or a == 8 :
 print ("pon")
else :
 print ("bon")

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

int main() {
  string s;
  cin >> s;
  
  int size = s.size();
  
  int hug = 0;
  for (int i = 0; i < size / 2; i++) {
    if (s.at(i) != s.at(size-i-1)) hug++;
  }
  
  cout << hug << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e8
#define EPS 1e-9

#define rep2(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) rep2(i,0,n)
#define ll long long
#define P pair<int,int>
#define pb push_back

char c[]={'r','g','b'};
string s;

int main(){
	while(cin>>s&&s!="0"){
		map<string,int> M;
		queue<string> Q;
		M[s]=0;
		Q.push(s);
		int ans=INF;
		while(Q.size()){
			string s=Q.front();
			int step=M[s],same=0;
			Q.pop();
			rep(i,s.size()-1){
				if(s[i]!=s[i+1]){
					char a=s[i],b=s[i+1];
					rep(j,3){
						if(s[i]!=c[j]&&s[i+1]!=c[j]){
							s[i]=s[i+1]=c[j];
							break;
						}
					}
					if(!M[s]){
						M[s]=step+1;
						Q.push(s);
					}
					s[i]=a;s[i+1]=b;
				}
				else same++;
			}
			if(same==s.size()-1){
				ans=step;
				break;
			}
		}
		if(ans==INF)cout<<"NA"<<endl;
		else cout<<ans<<endl;
	}
}

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

int main (void) {
    int N;
    cin >> N;
    vector<tuple<string, int, int>> restaurant(N);
    string s;
    int p;
    for ( int i=0; i<N; i++ ) {
        cin >> s >> p;
        restaurant.at(i) = make_tuple(s, p * (-1), i+1);
    }

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

    for ( auto i : restaurant )
        cout << get<2>(i) << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
def f(c):
 if sum(c)in c:return 1
 if 5 in c:return 0
 if 4 in c:
  k=c.index(4);c[k]-=3
  if f(c):return 1
  c[k]+=3
 if 3 in c:
  k=c.index(3);c[k]-=3
  if f(c):return 1
  c[k]+=3
 for i in range(7):
  if c[i]and c[i+1]and c[i+2]:
   c[i]-=1;c[i+1]-=1;c[i+2]-=1
   if f(c):return 1
   c[i]+=1;c[i+1]+=1;c[i+2]+=1
n='123456789'
for e in sys.stdin:
 c=[list(e).count(j)for j in n]
 a=[]
 for i in range(9):
  t=c[:];t[i]+=1
  if f(t):a+=[i+1]
 if a:print(*a)
 else:print(0)


Measured memory_bytes: 5580
n,k,q=gets.chomp.split().map(&:to_i)
kouho=Array.new(n,0)
survive_line= q-k+1

q.times do |question|
  answered=gets.to_i-1
  kouho[answered] +=1
end  
kouho.each do |k|
  if k >= survive_line
    puts "Yes"
  else
    puts "No"
  end  
end  


Measured memory_bytes: 3196
N = int(input())
a = list(map(int, input().split()))

ans = 1000000000

a_min = min(a)
a_max = max(a)

for i in range(a_min,a_max+1):
    S = 0
    for j in range(N):
        S += (a[j]-i)**2
    ans = min(S,ans)

print(ans)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
  int n,f=0;
  while(1){
    int m[501]={};
  cin>>n;
  if(n==0) break;
    cin>>m[10]>>m[50]>>m[100]>>m[500];
    if(f==1) cout<<endl;
  n=m[500]*500+m[100]*100+m[50]*50+m[10]*10-n;
  m[500]-=n/500,n%=500,m[100]-=n/100,n%=100,m[50]-=n/50,n%=50,m[10]-=n/10;
  for(int i=10;i<=500;i+=10) if(m[i]>0) cout<<i<<" "<<m[i]<<endl;
  f=1;
  }
     return 0;
}

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

int main() {
    int k, x;
    cin >> k >> x;
    
    for (int i = x-k+1; i < x+k; ++i) {
        cout << i << " ";
    }
    cout << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
S = str(input())
count =0
flag = 1
if S[1]=='R':
    if S[0]=='R'and S[2]=='R':
        count= 3
    elif S[0]=='R'and S[2]=='S':
        count= 2
    elif S[0]=='S'and S[2]=='R':
        count= 2
    elif S[0] == 'S' and S[2] == 'S':
        count = 1
else:
    if S[0]=='R'and S[2]=='R':
        count= 1
    elif S[0]=='S'and S[2]=='R':
        count= 1
    elif S[0]=='R'and S[2]=='S':
        count= 1
    elif S[0] == 'R' and S[2] == 'R':
        count = 1
print(count)

Measured memory_bytes: 9144
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next()); //N軒の店があり
        int M = Integer.parseInt(sc.next()); //M本の栄養ドリンクを買いたい

        long[] A = new long[N]; //iの店　1本Ai円の栄養ドリンクを
        int[] B = new int[N]; //Bi本買える
        //key：値段　value：本数
        Map<Long, Integer> map = new TreeMap<>();

        for(int i=0; i<N; i++) {
            A[i] = Long.parseLong(sc.next());
            B[i] = Integer.parseInt(sc.next());
            if(map.containsKey(A[i])) {
                map.put(A[i], map.get(A[i])+B[i]);
            }else {
                map.put(A[i], B[i]);
            }
        }

        Long count = 0l;
        Long total = 0l;
        for (Long str : map.keySet()) {
            for (int i = 0; i < map.get(str); i++) {
                if(count >= M) break;
                total += str;
                count++;
            }
        }
        System.out.println(total);
    }
}


Measured memory_bytes: 68808
import fractions

def lcm(a,b):
        return (a*b)//fractions.gcd(a,b)

a,b,c,d=map(int,input().split())
until_b = b-(b//c)-(b//d)+(b//lcm(c,d))
until_a = (a-1)-((a-1)//c)-((a-1)//d)+((a-1)//lcm(c,d))
print(until_b-until_a)

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int m; cin >> m;
    out(48-m);
}

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

const int INF=1001001001;
int dp[100200];

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>h(n);
    rep(i,n)cin>>h[i];
    rep(i,100200)dp[i]=INF;
    dp[0]=0;
    for(int i=0; i<n; ++i){
        for(int j=1; j<=k; ++j){
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout<<dp[n-1]<<endl;
}

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

int main() {
	int a[100];
	int i=0;
	int x,y;
	while(cin>>x>>y){
		a[i]=x+y;
		i++;
	}
	for(int j=0;j<i;j++){
		int count=1;
		while(a[j]>=10){
			a[j]=a[j]/10;
			count++;
		}
		cout<<count<<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 2984
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;
ll power(ll x, ll  y)  
{  
    ll res = 1;     // Initialize result  
    x = x % mod;
    y=y%mod;
    while (y > 0)  
    {  
        if (y & 1)  
            res = ((res%mod)*(x%mod)) % mod;  
        y = y>>1; // y = y/2  
        x = ((x%mod)*(x%mod)) % mod;  
    }  
    return res%mod;  
}  
  
int main(){
    ll n,m;
    cin>>n;ll a[n+2];ll hash[200005]={0};
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    if(n%2==0)
    {
    	if(a[0]!=1) {cout<<"0\n";return 0;}
    	if(a[1]!=1) {cout<<"0\n";return 0;}
    	for(int i=2,j=3;i<n;i+=2,j+=2){
    	if(a[i]==j && a[i+1]==j){}else {cout<<"0\n";return 0;}}
    	
    }
    else
    {
    	if(a[0]!=0) {cout<<"0\n";return 0;}
    	for(int i=1,j=2;i<n;i+=2,j+=2){
    	if(a[i]==j && a[i+1]==j){}else {cout<<"0\n";return 0;}}
    }

   ll ans = 1;
	for (ll i = 1; i <=(n/2); i++) {
		ans *= 2;
		ans %= mod;
	}
	cout << ans << endl;
    }
    
    
   

    


Measured memory_bytes: 1024
S = input()

bin_0 = "".join(["0" if i % 2 == 0 else "1" for i in range(len(S))])
bin_1 = "".join(["1" if i % 2 == 0 else "0" for i in range(len(S))])
lis_S = [ i for i in S]
# 差が小さい方を使用
if abs(int(S,2) - int(bin_0,2)) <= abs(int(S,2) - int(bin_1,2)):
# 01010...を採用
	res = sum([ 1  for i in range(len(S)) if bin_0[i] != lis_S[i]])
else:
# 10101...を採用
	res = sum([ 1  for i in range(len(S)) if bin_1[i] != lis_S[i]])
print(res)

Measured memory_bytes: 4452
num = gets

for j in 1..(num.to_i)    
  data = gets
  triangle = data.split(' ').map{|i| i.to_i}.sort
 
  if triangle[0]**2 + triangle[1]**2 == triangle[2]**2
    puts "YES"
  else
    puts "NO"
  end
end

Measured memory_bytes: 8776
N = int(input())
a = list(map(int, input().split()))
a.reverse()
mod = 10**9 +7
ans = 0
S=[0]
for i in range(0,N):
    S.append(S[i]+a[i])
ans = 0
for j in range(len(a)):
    ans +=(a[j]*S[j])
print(ans%mod)

Measured memory_bytes: 31408
fun main(args: Array<String>) {
    var a= readLine()
    var array=a!!.split(" ")
    var b= readLine()
    if(b!!.indexOf("-")==array[0].toInt()){
        var array2=b.split("-")
        if(array2[0].length!=array[0].toInt()||array2[1].length!=array[1].toInt()){
            println("No")
            return
        }
        try{
            var c=array2[0].toInt()
            var d=array2[1].toInt()
            println("Yes")
        }catch(e:Exception){
            println("No")
        }
    }else{
        println("No")
    }
}

Measured memory_bytes: 37816
n,a,b=map(int,input().split())
mod=10**9+7
def modinv(a):
    return pow(a, mod-2, mod)
def comb(n, r):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1) % mod
    return res
t=pow(2,n,mod)-1
t=(t-comb(n,a)-comb(n,b))%mod
print(t)

Measured memory_bytes: 3064
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << "\n"; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "abc168_b.cpp"

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

  int k;
  string s;
  cin >> k >> s;
  if (s.length() <= k) {
    cout << s << endl;
  } else {
    cout << s.substr(0, k) << "..." << endl;
  }
}


Measured memory_bytes: 3644
#include <stdio.h>
//#pragma GCC optimize("O2")
long long int a[200000], b[200000];
long long int a_xor[200000], b_xor[200000];
int main(void){
    int n;
    int m = 15;//baseの数
    long long int base[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 43, 47, 53};
    long long int mod = 100000009;
    scanf("%d", &n);
    int i, j, k;
    for(i = 0; i < n; i++){
        scanf("%lld", &a[i]);
    }
    for(i = 0; i < n; i++){
        scanf("%lld", &b[i]);
    }
    //b_iとb_i+1のxorを求める, aも同様に求める
    for(i = 0; i < n; i++){
        b_xor[i] = (b[i] ^ b[(i+1)%n]) + 1;//b []が0になるのを防ぐため1を足す
        a_xor[i] = (a[i] ^ a[(i+1)%n]) + 1;
    }
    // for(i = 0; i < n; i++){
    //     printf("a: %d b: %d\n", a_xor[i], b_xor[i]);
    // }

    //初期(k=0)のhash値を求める
    long long int ahash[m], bhash[m];
    for(j = 0; j < m; j++){
        ahash[j] = 0;
        bhash[j] = 0;
        for(i = 0; i < n; i++){
            ahash[j] += a_xor[i];
            ahash[j] %= mod;
            bhash[j] += b_xor[i];
            bhash[j] %= mod;
            if(i == n - 1){
                break;
            }
            ahash[j] *= base[j];
            ahash[j] %= mod;
            bhash[j] *= base[j];
            bhash[j] %= mod;
        }
    }

    //base^(n-1)%mod の値を求める
    long long int tmp[m];
    for(j = 0; j < m; j++){
        tmp[j] = 1;
        for(i = 0; i < n - 1; i++){
            tmp[j] *= base[j];
            tmp[j] %= mod;
        }
    }

    //kでfor文を回す
    for(i = 0; i < n; i++){
        int cnt = 0;
        for(j = 0; j < m; j++){
            if(ahash[j] == bhash[j]){
                cnt++;
            }
        }
        
        if(cnt == m){
            printf("%lld %lld\n", i, b[0]^a[i]);
        }

        //ahashを1つずらす
        for(j = 0; j < m; j++){
            ahash[j] = (ahash[j] - tmp[j]*a_xor[i])*base[j] + a_xor[i];
          if(ahash[j] < 0){
          ahash[j] += -(ahash[j] / mod + 1)*mod;
          }
            while(ahash[j] < 0){
                ahash[j] += mod; 
            }
            ahash[j] %= mod;
        }
        
    }
    return 0;
}

Measured memory_bytes: 9764
#include <cstdio>
const int MAXK = 1e5+5;
const int MAXN = 105;
int dp[MAXK];
int A[MAXN];
int K, N;

// Win : exists a losing state to reach.
// Lose: every state is a winning state.

int dfs(int cur) {
  if (dp[cur] != -1) {
    return dp[cur];
  }
  int win = 1;
  for (int i = 0; (i < N) && (A[i] <= cur); ++i) {
    win &= dfs(cur - A[i]);
  }
  return dp[cur] = (win ^ 1);
}

int main() {
  scanf(" %d%d", &N, &K);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }
  for (int i = 0; i <= K; ++i) dp[i] = -1;
  puts(dfs(K) ? "First" : "Second");
  return 0;
}

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

public class Main{
	public static String judge(double[][] n){		
		if( n[1][0]-n[0][0] == 0 && n[3][1]-n[2][1] == 0 ){
			return "YES";
		}
		if( n[3][0]-n[2][0] == 0 && n[1][1]-n[0][1] == 0 ){
			return "YES";
		}
		double a = (n[1][1]-n[0][1])/(n[1][0]-n[0][0]);
		double b = (n[3][0]-n[2][0])/(n[3][1]-n[2][1]);
		if( a == -b ){
			return "YES";
		}
		return "NO";
	}
	
	public static void main(String[] args) throws IOException{
		Scanner stdIn = null;
		List<String> result = new ArrayList<String>();
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			while( stdIn.hasNext() ){
				double[][] n = new double[4][2];
				for(int i = 0; i < 4; i++){
					for(int j = 0; j < 2; j++){
						n[i][j] = stdIn.nextDouble();
					}
				}
				result.add(judge(n));
			}
			for(String str : result){
				System.out.println(str);
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

				

Measured memory_bytes: 12000
#include<iostream> 
#include<algorithm> 
#include<cstdio> 
#include<string>
#include<cmath>
#include<cstring>
using namespace std; 
int main() 
{ 
	int a,b;
	cin>>a>>b;
	if(a%2==0||b%2==0)
	{
		printf("No\n");
	}
	else
	printf("Yes\n");
	return 0; 
}


Measured memory_bytes: 256
# N, M = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars
# T = gets.chomp.chars

a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
d = gets.chomp.to_i
e = gets.chomp.to_i
k = gets.chomp.to_i

arr = [a, b, c, d, e]
arr.sort!
if (arr[4] - arr[0]) > k
  print ":(\n"
else
  print "Yay!\n"
end


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

int main() {
  
  int N, M; cin >> N >> M;
  
  char tableA[N][N]; char tableB[M][M];
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> tableA[i][j];
    }
  }
  
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      cin >> tableB[i][j];
    }
  }
  
  for (int i = 0; i < N - M + 1; i++) {
    for (int j = 0; j < N - M + 1; j++) {
      
      bool flag = true;
      
      for (int k = 0; k < M; k++) {
        for (int l = 0; l < M; l++) {
          
          if (tableA[i + k][j + l] != tableB[k][l]) flag = false;
          
        }
      }
      
      if (flag) {
        cout << "Yes" << endl;
        return 0;
      }
      
    }
  }
  
  cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	Yes(a + b >= c);

	return 0;
}





Measured memory_bytes: 256