akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c;
    cin >> a >> b >> c;

    if (a < b && b < c) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }

    return 0;
}

Measured memory_bytes: 1176
import re
import sys
import copy

def get_count(s):
  count02=0
  pattern = "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+"
  result = re.finditer(pattern, s)
  for res in result:
    l = res.end()-res.start()
    if l>1:
      #切り捨て
      count02 += l//2
  return count02

s = input()
k = int(input())
count01=0
count02=0

#case01
if len(s)==1:
  print(k//2)
  sys.exit(0)
  
#case02
tmp = s[0]
flag=True
for i in range(len(s)):
  if s[i]!=tmp:
    flag=False
if flag==True:
  print((len(s)*k)//2)
  sys.exit(0)

#case03
s_org = copy.deepcopy(s)
s2 = copy.deepcopy(s)
if s[0]==s[-1]:
  tmp = s[0]

  offset01=0
  while s[0]==tmp:
    offset01+=1
    s = s[1:] + s[0]
    #print(s)
  offset02=0
  while s2[-1]==tmp:
    offset02+=1
    s2 = s2[-1] + s2[:-1]
    #print(s2)
  k -= 1
  print(get_count(s_org[:offset01]) + get_count(s)*k + get_count(s_org[offset01:]))
  sys.exit(0)

  
#case04
print(get_count(s)*k)


Measured memory_bytes: 3688
#include<stdio.h>

int main(void){
  
    int h,w;
    int i,j;
    
    
    while(1){
        scanf("%d %d",&h,&w);
        if(h==0&&w==0){
            break;
        }else{
            for(i=0;i<h;i++){
                for(j=0;j<w;j++){
                    printf("#");
                }
                printf("\n");
            }
            printf("\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 1760
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int N = ri();
		Console.WriteLine((N + 1) / 2);
	}

	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main() {

  string S, T;
  int count = 0;

  // S : 予報
  // T : 実際
  cin >> S >> T;
  
  for (int i=0; i < S.size(); i++) {
    if (S[i] == T[i]) {
      count++;
    }    
  }
  
  // 結果の出力
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;


int N, K;
vector<int> p,D;




int main()
{

	cin >> N;
	cin >> K;

	D = p = vector<int>(N);

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

		D[i] = (p[i] + 1);
	}

	int ans2 = 0;

	
	int tmpsum = 0;

	for (int i = 0; i < K; i++) {
		tmpsum += D[i];
	}
	ans2 = tmpsum;


	for (int i = K; i < N; i++) {
		tmpsum -= D[i - K];
		tmpsum += D[i];

		ans2 = max(ans2,tmpsum);
	}
	
	double ans = ans2 / (2.0);

	cout << fixed << setprecision(10) << ans << endl;

	return 0;
}



Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Acrostic
            var S = Console.ReadLine();
            int w = int.Parse(Console.ReadLine());
            var ans = "";

            for (int i = 0; i < S.Length; i += w)
            {
                ans += S[i];
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
 
#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};
 
signed main(){
    
    int longest[26];
    int last[26];
    int koho[26];
    int k,ans=INF;
    string s;
    cin>>s;
    rep(26){
        longest[i]=INF;
        last[i]=-1;
    }
    
    for(int i=0;s[i]!='\0';++i){
        if(last[s[i]-'a']==-1){
            longest[s[i]-'a']=i;
        }
        else{
            longest[s[i]-'a']=fmax(i-last[s[i]-'a']-1,longest[s[i]-'a']);
        }
        last[s[i]-'a']=i;
        k=i;
    }
    

    rep(26){
        koho[i]=fmax(k-last[i],longest[i]);
    }
    
    rep(26){
        ans=fmin(ans,koho[i]);
    }
    
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long L;
L brute(L n,L p){
    L pep[n],bowl=p,id=0;
    memset(pep,0,sizeof(pep));
    while(1){
        if(bowl){
            pep[id]++;
            bowl--;
        }
        else{
            bowl+=pep[id];
            pep[id]=0;
        }
        if(pep[id]==p)return id;
        id++;
        if(id==n)id=0;
    }
}
int main()
{
    L n,p;
    while(scanf("%lld%lld",&n,&p)&& n||p ){
        n=brute(n,p);
        printf("%lld\n",n);
    }
    return 0;
}



Measured memory_bytes: 3232
//cod2016_final_c.cpp
//Sat Aug  3 18:54:29 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int lan[m];
	fill(lan,lan+m,0);
	int member[n];
	fill(member,member+n,0);

	int num = 1;
	member[0] = 1;

	vector<int> vec[n];

	int kzero;
	cin >> kzero;
	vec[0].push_back(kzero);
	for (int i=0;i<kzero;i++){
		int temp;
		cin >> temp;
		temp--;
		vec[0].push_back(temp);
		lan[temp] = 1;
	}
	member[0] = 1;

	for (int i=1;i<n;i++){
		int k;
		cin >> k;
		vec[i].push_back(k);
		int flag = 0;
		for (int j=0;j<k;j++){
			int temp;
			cin >> temp;
			temp--;
			vec[i].push_back(temp);
			if (lan[temp]==1){
				flag = 1;
			}
		}
		if (flag || i==0){
			for (int j=0;j<vec[i][0];j++){
				lan[vec[i][j+1]] = 1;
			}
			member[i] = 1;
			num++;
		}
	}

	while (num<n){
		int initnum = num;
		for (int i=1;i<n;i++){
			int flag = 0;
			if (member[i]==1){
				continue;
			}
			for (int j=0;j<vec[i][0];j++){
				if (lan[vec[i][j+1]]==1){
					flag = 1;
					break;
				}
			}
			if (flag){
				for (int j=0;j<vec[i][0];j++){
					lan[vec[i][j+1]] = 1;
				}
				member[i] = 1;
				num++;
			}
		}

		for (int i=n-1;i>=1;i--){
			int flag = 0;
			if (member[i]==1){
				continue;
			}
			for (int j=0;j<vec[i][0];j++){
				if (lan[vec[i][j+1]]==1){
					flag = 1;
					break;
				}
			}
			if (flag){
				for (int j=0;j<vec[i][0];j++){
					lan[vec[i][j+1]] = 1;
				}
				member[i] = 1;
				num++;
			}
		}
		if (initnum==num){
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;

}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

void solve(){
    int N;
    cin>>N;
    while(N>0){
        int rem=N%10;
        if(rem==7){
            out("Yes");
            return ;
        }
        N/=10;
    }
    out("No");

}

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


Measured memory_bytes: 3592
#include <iostream>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
using namespace std;

void solution(const vector<vector<bool> > wallX, const vector<vector<bool> > wallY)
{
    int goalX = wallX[0].size()-2;
    int goalY = wallX.size()-1;

    queue<int> length;
    queue<int> currX;
    queue<int> currY;
    length.push(1);
    currX.push(0);
    currY.push(0);
    vector<vector<bool> > history(goalY+1, vector<bool>(goalX+1, false));
    history[0][0] = true;

    while(length.size() > 0){
        int x = currX.front();
        int y = currY.front();
        if(x == goalX && y == goalY)
            break;
        if(!wallX[y][x] && !history[y][x-1]){
            length.push(length.front()+1);
            currX.push(x-1);
            currY.push(y);
            history[y][x-1] = true;
        }
        if(!wallX[y][x+1] && !history[y][x+1]){
            length.push(length.front()+1);
            currX.push(x+1);
            currY.push(y);
            history[y][x+1] = true;
        }
        if(!wallY[y][x] && !history[y-1][x]){
            length.push(length.front()+1);
            currX.push(x);
            currY.push(y-1);
            history[y-1][x] = true;
        }
        if(!wallY[y+1][x] && !history[y+1][x]){
            length.push(length.front()+1);
            currX.push(x);
            currY.push(y+1);
            history[y+1][x] = true;
        }

        length.pop();
        currX.pop();
        currY.pop();
    }

    if(length.size() > 0){
        cout << length.front() << endl;
    }else{
        cout << '0' << endl;
    }
}

int main()
{
    for(;;){
        int x, y;
        cin >> x >> y;
        if(x == 0 && y == 0)
            break;

        vector<vector<bool> > wallX(y, vector<bool>(x+1, true));
        vector<vector<bool> > wallY(y+1, vector<bool>(x, true));

        int tmp;
        for(int i=0; i<y-1; ++i){
            for(int j=0; j<x-1; ++j){
                cin >> tmp;
                wallX[i][j+1] = (tmp == 1);
            }
            for(int j=0; j<x; ++j){
                cin >> tmp;
                wallY[i+1][j] = (tmp == 1);
            }
        }

        for(int i=0; i<x-1; ++i){
            cin >> tmp;
            wallX[y-1][i+1] = (tmp == 1);
        }

        solution(wallX, wallY);
    }

    return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define PYES cout << "Yes" << endl
#define PNO cout << "No" << endl

typedef long long LL;
typedef long double LD;

int main(){
  int a,b;
  cin >> a >> b;
  cout << max(2*a-1,max(2*b-1,a+b)) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d = new int[n];
        for (int i = 0; i < n; i++) {
            d[i] = sc.nextInt();
        }
        int count = 0;
        boolean[] bool = new boolean[100];
        for (int i = 0; i < n; i++) {
            if (!bool[d[i] - 1]) {
                count++;
                bool[d[i] - 1] = true;
            }
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 23380
import math
import cmath

def area(b,c):
    theta = cmath.phase(b)
    C = (c)*complex(math.cos(-theta),math.sin(-theta))
    return abs(b)*C.imag/2

P = []
try:
    while True:
        x,y = map(float,input().split(','))
        P.append(complex(x,y))
except EOFError:
    pass
except ValueError:
    pass
P.append(P[0])
N = len(P)
total = 0.0
for i in range(0,N-1):
    b,c = P[i],P[i+1]
    total += area(b,c)
print(abs(total))


Measured memory_bytes: 5796
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define fi first
#define ii pair<int,int>
#define iil pair<ll,ll>
#define se second
#define ld long double
#define mod 1000000007
#define popcount __builtin_popcountll
#define x0 zxcxzcsacasd
#define x1 ghfghujfgfg
#define y0 olkjhdnncvcv
#define y1 bhvgrewm345345435
#define debug(x) std::cerr<<#x<<": "<<(x)<<'\n'
#define all(x) x.begin(), x.end()
using namespace std;
ll C[1010][3030];
ll fac[6060];
ll inv[6060];
ll p(ll a, ll b){
	if(b==0)return 1;
	ll r = p(a, b/2);
	r*=r;
	r%=mod;
	if(b%2)r*=a;
	return r%mod;
}
ll get(int a, int b){
	ll ret = fac[a];
	ret*=inv[b];
	ret%=mod;
	ret*=inv[a-b];
	ret%=mod;
	return ret;
}
int main(){
	fac[0] = 1;
	inv[0] = 1;
	for(ll i=1;i<6060;i++){
		fac[i] = fac[i-1] * i;
		fac[i]%=mod;
		inv[i] = p(fac[i], mod - 2);
	}
	ll amid = 0;
	int s;
	cin>>s;
	for(int i = 1;i<=1000;i++){
		int r = s - 3 * i;
		if(r < 0)break;
		amid+=get(s - 2*i - 1, i-1);
		amid%=mod;
	}
	cout<<amid<<endl;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,arr[102],ans=0;
    scanf("%d %d",&n,&x);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
    }
    sort(arr,arr+n);
    for(int i=0;i<n;i++)
    {
        if(i==(n-1)&&arr[i]!=x)
        {
            break;
        }
        else if(arr[i]<=x)
        {
            x=x-arr[i];
            ans++;
        }
        else
            break;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N,D;
  cin >> N >> D;
  
  vector<vector<int>> x(N, vector<int>(D));
  for(int i= 0; i<N;i++){
    for(int j = 0;j<D;j++){
      cin >> x.at(i).at(j);
    }
  }
  int ans = 0;
  for(int i = 0;i<N;i++){
    for(int j = i+1;j<N;j++){
      int diff = 0;
      int Y = 0;
      for(int k = 0; k<D;k++){
        diff = x.at(i).at(k) - x.at(j).at(k);
      Y += diff*diff;
      }
      for(int K = 1; K<=Y;K++){
        if( K*K == Y ){
          ans++;
        }
      }
      
    }
  }
  cout << ans << endl;
}
      

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

int main() {

	int N, tmp = 1, count = 0, ans;

	cin >> N;

	while (1) {

		tmp *= 2;
		if (tmp > N) {
		
			ans = tmp / 2;
			break;

		}

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    X, Y = LI_()

    reward = (300000, 200000, 100000, 0)

    ans = reward[min(X, 3)] + reward[min(Y, 3)] + (400000 if X == Y == 0 else 0)
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10052
#include <iostream>

int main() {
  int x1, y1, x2, y2;
  std::cin >> x1 >> y1 >> x2 >> y2;

  int a = x2 - x1;
  int b = y2 - y1;

  int x3 = x2 - b;
  int y3 = y2 + a;
  int x4 = x3 - a;
  int y4 = y3 - b;

  std::cout << x3 << ' ' << y3 << ' '
            << x4 << ' ' << y4 << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <climits>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

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

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

    ll ans = 0;
    for (ll i = 0; i < N; i++)
    {
        ll hi;
        cin >> hi;
        ans += (hi >= K ? 1 : 0);
    }
    cout << ans << endl;
}

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

int main (void) {
	long long a, b;
	scanf("%lld%lld", &a, &b);
	if (a > b) swap(a,b);

	if (a == 2 && b == 2) {
		printf("1\n");
		return 0;
	}

	long long x, y, z;
	long long ans = a * (b % 3 != 0) * (a % 3 != 0);
	if (b % 3 == 1) {
		x = ((b / 3) + 1) * a, y = (2 * (b / 3)) * (a / 2), z = (2 * (b / 3)) * (a - a / 2);
		ans = min(ans, max(x,max(y,z)) - min(x,min(y,z)));
		x = ((b / 3)) * a, y = (2 * (b / 3) + 1) * (a / 2), z = (2 * (b / 3) + 1) * (a - a / 2);
		ans = min(ans, max(x,max(y,z)) - min(x,min(y,z)));
	} else if (b % 3 == 2) {
		x = ((b / 3) + 2) * a, y = (2 * (b / 3)) * (a / 2), z = (2 * (b / 3)) * (a - a / 2);
		ans = min(ans, max(x,max(y,z)) - min(x,min(y,z)));
		x = ((b / 3)) * a, y = (2 * (b / 3) + 2) * (a / 2), z = (2 * (b / 3) + 2) * (a - a / 2);
		ans = min(ans, max(x,max(y,z)) - min(x,min(y,z)));
		x = ((b / 3) + 1) * a, y = (2 * (b / 3) + 1) * (a / 2), z = (2 * (b / 3) + 1) * (a - a / 2);
		ans = min(ans, max(x,max(y,z)) - min(x,min(y,z)));
	}
	swap(a,b);
	if (b > 2 && b % 3 == 1) {
		x = ((b / 3) + 1) * a, y = (2 * (b / 3)) * (a / 2), z = (2 * (b / 3)) * (a - a / 2);
		ans = min(ans, max(x,max(y,z)) - min(x,min(y,z)));
		x = ((b / 3)) * a, y = (2 * (b / 3) + 1) * (a / 2), z = (2 * (b / 3) + 1) * (a - a / 2);
		ans = min(ans, max(x,max(y,z)) - min(x,min(y,z)));
	} else if (b > 2 && b % 3 == 2) {
		x = ((b / 3) + 2) * a, y = (2 * (b / 3)) * (a / 2), z = (2 * (b / 3)) * (a - a / 2);
		ans = min(ans, max(x,max(y,z)) - min(x,min(y,z)));
		x = ((b / 3)) * a, y = (2 * (b / 3) + 2) * (a / 2), z = (2 * (b / 3) + 2) * (a - a / 2);
		ans = min(ans, max(x,max(y,z)) - min(x,min(y,z)));
		x = ((b / 3) + 1) * a, y = (2 * (b / 3) + 1) * (a / 2), z = (2 * (b / 3) + 1) * (a - a / 2);
		ans = min(ans, max(x,max(y,z)) - min(x,min(y,z)));
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

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

  int a = 0;
  while (s[a] != 'A') {
    a++;
  }

  int z = s.size() - 1;
  while (s[z] != 'Z') {
    z--;
  }

  cout << z - a + 1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; string S; 
	cin >> N >> S; 
	long long int Fac[100010] = {}; 
	Fac[0] = 1; 
	long long int P = 1e9 + 7; 
	for(int i = 1; i <= 100005; i++){
		Fac[i] = Fac[i-1] * (long long) i % P; 
	}
	if(S.at(0) == 'W' || S.at(N*2-1) == 'W'){
		cout << 0 << endl; return 0; 
	}
	long long int stock = 0; 
	long long int ans = 1; 
	for(int i = 0; i < N*2; i++){
		if(S.at(i) == 'B' && stock % 2 == 0){
			stock ++; 
		}
		else if(S.at(i) == 'B' && stock % 2 == 1){
			ans *= stock; ans %= P; 
			stock --; 
			if(stock < 0){
				cout << 0 << endl; return 0; 
			}
		}
		else if(S.at(i) == 'W' && stock % 2 == 0){
			ans *= stock; ans %= P; 
			stock --; 
			if(stock < 0){
				cout << 0 << endl; return 0; 
			}
		}
		else if(S.at(i) == 'W' && stock % 2 == 1){
			stock ++; 
		}
	}
	if(stock != 0){
		cout << 0 << endl; return 0; 
	}
	long long int final = ans * Fac[N] % P; 
	cout << final << endl; 
}

Measured memory_bytes: 1412
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 数値
		long a = sc.nextInt();
		long b = sc.nextInt();

		boolean isa = false;
		boolean isb = false;
		boolean nai = false;

		for (int i = 1; i <= 1000; i++) {
			if ((int) (i * 0.08) == a) {
				isa = true;
			}
			if ((int) (i * 0.1) == b) {
				isb = true;
			}

			if (isa && isb) {
				System.out.println(i);
				break;
			}
			if (i == 1000) {
				System.out.println(-1);
			}
			isa = false;
			isb = false;
		}

	}
}


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

int it;

bool solve(string str)
{
	if (str[it] == '(') {
		it++;
		bool flag1 = solve(str);
		
		if (str[it] == '*') {
			it++;
			bool flag2 = solve(str);
			it++;
			return flag1&&flag2;
		}
		else if (str[it] == '+') {
			it++;
			bool flag2 = solve(str);
			it++;
			return flag1 | flag2;
		}
		else {
			it++;
			it++;
			bool flag2 = solve(str);
			it++;
			return (!flag1) | flag2;
		}
	}
	else if (str[it] == '-') {
		it++;
		return !solve(str);
	}
	else if (str[it] == 'T') {
		it++;
		return true;
	}
	else if (str[it] == 'F') {
		it++;
		return false;
	}
}

int main()
{
	while (true) {
		string str;

		cin >> str;

		if (str == "#") {
			break;
		}

		int str_size = str.size();
		bool flag = true;
		int equalpos;

		rep(i, str.size()) {
			if (str[i] == '=') {
				equalpos = i;
			}
		}

		rep(i, 1 << 11) {
			string temp = str;

			rep(j, str_size) {
				if (temp[j] >= 'a'&&temp[j] <= 'k') {
					if ((i >> (temp[j] - 'a')) % 2 == 0) {
						temp[j] = 'F';
					}
					else {
						temp[j] = 'T';
					}
				}
			}

			it = 0;
			string temp1 = temp.substr(0, equalpos);
			bool flag1 = solve(temp1);
			it = 0;
			string temp2 = temp.substr(equalpos + 1);
			bool flag2 = solve(temp2);

			if (flag1 != flag2) {
				flag = false;
				break;
			}
		}

		if (flag == true) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
const int MOD = 1000000007;
//sort(all(x))とするとソートできるよ

LL cnt;
LL N;
bool three = false;
bool five = false;
bool seven = false;
vector<int> keta;
int Nsize;

unsigned GetDigit(unsigned num){
    if(num == 0)return 1;
    return log10(num)+1;
}

void DFS(LL n,int nex,LL &cnt,vector<int> &k){

    if(n*10+nex > N)return;
    int nsize = GetDigit(n);
    if(nsize >= Nsize)return;
    if(n == 0){
        k[0] = nex;
    }
    else{
        k[nsize] = nex;
    }

    for(int i = nsize+1;i<Nsize;i++){
        k[i] = 0;
    }
    rep(i,Nsize){
        if(k[i] == 3)three = true;
        if(k[i] == 5)five = true;
        if(k[i] == 7)seven = true;
    }

    if(three && five && seven)cnt++;

    three = false;
    five = false;
    seven = false;


    
    DFS(n*10 + nex,3,cnt,keta);
    DFS(n*10 + nex,5,cnt,keta);
    DFS(n*10 + nex,7,cnt,keta);
    return;
}

int main(){
    cin >> N;
    Nsize = GetDigit(N);
    keta.resize(Nsize);
    DFS(0,3,cnt,keta);
    DFS(0,5,cnt,keta);
    DFS(0,7,cnt,keta);
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define ARRAYMAX 2000010

int A[ARRAYMAX], B[ARRAYMAX],C[10000];

void CountingSort(int max, int n){
    int i, j;

    for(i=0; i<max+1; i++){
        C[i]=0;
    }

    for(j=0; j<n; j++){
        C[A[j]]++;
    }

    for(i=1; i<max+1; i++){
        C[i] = C[i] + C[i-1];
    }

    for(j=n-1; j>=0; j--){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
}

int main(){
    int n, max;
    int i;

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

    CountingSort(max, n);

    for(i=1; i<n+1; i++){
        printf("%d", B[i]);
        if(i != n) printf(" ");
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 17348
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(){
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> L(C);
  for(int i = 0; i < C; ++i) cin >> L[i];
  vector< vector<int> > W(C);
  int c, w;
  for(int i = 0; i < N; ++i){
    cin >> c >> w;
    --c;
    W[c].push_back(w);
  }
  priority_queue<int> pq;
  for(int i = 0; i < C; ++i){
    sort(W[i].begin(), W[i].end(), greater<int>());
    for(int j = 0; j < min(L[i], (int)W[i].size()); ++j){
      pq.push(W[i][j]);
    }
  }
  long long int ans = 0;
  for(int i = 0; i < M; ++i){
    if(pq.empty()) break;
    int w = pq.top();
    pq.pop();
    ans += w;
  }
  cout << ans << endl;
  return 0;
}



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

namespace Sample
{
	class Program
	{
		static void Main(string[] args)
		{
			var array = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
			var a = array[0];
			var b = array[1];
			var c = array[2];

			var result = (a < b) && (b < c) ? "Yes" : "No";
			Console.WriteLine(result);
		}
	}
}



Measured memory_bytes: 18428
#include<stdio.h>

int main(){
  int a,b;
  scanf("%d %d", &a, &b);
  if (0 < a) {
    printf("Positive\n");
  } else if (b < 0) {
    printf((b-a)%2 == 0 ? "Negative\n" : "Positive\n");
  } else {
    printf("Zero\n");
  }
}


Measured memory_bytes: 128
#include<stdio.h>;
int main(){
	long long int a, b=0;
	scanf("%lld", &a);
	for (int i=1; i<=a; i++){
		if(i%3==0 || i%5==0){
			b+=0;
		}
		else{
		b+=i;
	}
	}
	printf("%lld", b);
	
	return 0;
}

Measured memory_bytes: 1728
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b&&b!=c&&a!=c){
		printf("%d\n",c);
	}
	else if(b==c&&b!=a&&c!=a){
		printf("%d\n",a);
	}
	else{
		printf("%d\n",b);
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

template <typename T>
void say(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}


/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


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

	string s = "aiueo";

	for (int i = 0; i < 5; i++) {
		if (c == s[i]) {
			cout << "vowel" << endl;
			return 0;
		}
	}

	cout << "consonant" << endl;

	return 0;
}

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

#define MAX_N 100000

int n;
int a[MAX_N];

int int_sort( const void *c1, const void *c2 )
{
	int a1 = *(int *)c1;
	int a2 = *(int *)c2;
	
	if ( a1 > a2 ) return -1;
	if ( a1 < a2 ) return 1;
	return 0;
}

int main(void)
{
	long long ans;
	int i;
	
	scanf( "%d", &n );
	
	for( i=0; i<n; i++ ) {
		scanf( "%d", &a[i] );
	}
	
	qsort( (void *)a, n, sizeof(a[0]), int_sort );
	
	ans = 1;
	
	for( i=0; i<n-1; i++ ) {
		
		if ( a[i] == a[i+1] ) {
			ans *= a[i];
			i += 2;
			break;
		}
		
	}
	
	for( ; i<n-1; i++ ) {
		
		if ( a[i] == a[i+1] ) {
			ans *= a[i];
			break;
		}
		
	}
	
	if ( i == n-1 ) printf( "0\n" );
	else printf( "%lld\n", ans );
	
	return 0;
}

Measured memory_bytes: 892
s = input()

co = 0
ans = 0
for i in range(len(s)) :
    if s[i] == "A" or s[i] == "T" or s[i] == "G" or s[i] == "C" :
        co += 1
        ans = max(ans, co)
    else :
        co = 0
print(ans)


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

const int N = 1e5 + 10;
int n,m;
vector <int> a[N];
int deg[N],Res[N];
void doc() {
    cin >> n >> m;
    for (int i = 1; i <= n - 1 + m; i++) {
        int u,v;
        cin >> u >> v;
        a[u].push_back(v);
        deg[v]++;
    }
}
void solve() {
    queue <int> Q;
    for (int i = 1; i <= n; i++) {
        if (deg[i] == 0) Q.push(i);
    }
    assert(Q.size() == 1);
    while (Q.size() != 0) {
        int u = Q.front(); Q.pop();
        for (int v : a[u]) {
            deg[v]--;
            if (deg[v] == 0) {
                Res[v] = u;
                Q.push(v);
            }
        }
    }
    for (int i = 1; i <= n; i++) cout << Res[i] << '\n';
}
int main(){
    doc();
	solve();
}


Measured memory_bytes: 7040
#include<stdio.h>

int n, A[2000];

int main(){
 int q, m, i;
  scanf("%d", &n);
  for( i=0 ; i<n ; i++ ) scanf("%d", &A[i]);
  scanf("%d", &q);
  for( i=0 ; i<q ; i++ ) {
    scanf("%d", &m);
    if( Exhaustive(0, m)==1 ) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}


int Exhaustive( int j, int m ){
  if(m==0) return 1;
  if(j>=n) return 0;
  int res = Exhaustive( j+1, m ) || Exhaustive( j+1, m-A[j] );
  return res;
}

Measured memory_bytes: 580
import math
import os
import random
import re
import sys

def check_non_decreasing_squares(n: int, a: list):
    p = a[0]
    for i in range(1, n):
        if a[i] > p:
            p = a[i]
        if p - a[i] == 1 or p - a[i] == 0:
            continue
        print("No")
        exit(0)
    print("Yes")

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().rstrip().split()))
    check_non_decreasing_squares(n, a)

Measured memory_bytes: 15344
#include <bits/stdc++.h>
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
using namespace std;
map <int,int> mp;
typedef pair<int, int> P;
typedef long long ll;
static const int MAX=100000;
static const int NMAX=50;
static const int MMAX=50;
int height[1000],a,b;

void solve(){
    height[0]=0;
    for(int i=1;i<1000;i++)
        height[i] = height[i-1]+i;
    
    cout <<height[b-a]-b <<"\n";
}

int main(){
    cin >> a >> b;
    
    solve();
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n,m = list(map(int,input().split()))
a = [int(input()) for i in range(m)]

inf=float("inf")

fib_memo = [-inf for i in range(n+1)]
fib_memo[0] = 1
if 1 in a:
    fib_memo[1]=0
else:
    fib_memo[1]=1
for i in a:
    fib_memo[i]=0

if 1 in [a[i] - a[i-1] for i in range(1,m)]:
    print(0)
    import sys
    sys.exit()
else:
    cur_fib_i = 2
    while cur_fib_i <= n:
        if fib_memo[cur_fib_i]==0:
            pass
        else:
            fib_memo[cur_fib_i] = fib_memo[cur_fib_i-1] + fib_memo[cur_fib_i-2]
        cur_fib_i += 1
print(fib_memo[n]%1000000007)
#print(fib_memo)


Measured memory_bytes: 460312
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
     ll n,a[100005],q,sum=0;
     cin>>n;
     map<ll,ll> mp;
     for(int i=0;i<n;i++)
     {
       cin>>a[i];
       if(mp.empty() || mp.find(a[i])==mp.end())
         mp[a[i]]=1;
       else
         mp[a[i]]++;
       sum+=a[i];
     }    
    cin>>q;
     while(q--)
     {
       ll b,c;
       cin>>b>>c;
       sum=sum-(b*mp[b])+(c*mp[b]);
       mp[c]+=mp[b];
       mp[b]=0;
       cout<<sum<<"\n";
       
     }
     return 0;
}


Measured memory_bytes: 10356
# array = [*1..q].map { |_| gets.split.map(&:to_i) }
# n = gets.split.map(&:to_i)
# a = [*1..m].repeated_combination(n).to_a
def chmin(a, b) a < b ? a : b end
def chmax(a, b) a > b ? a : b end
INF = Float::INFINITY

n = gets.to_i
h = gets.split.map(&:to_i)


dp = [INF]*(n+1)

dp[1] = 0

1.upto(n) do |i|
  if i == 1
    dp[i] == 0
  elsif i == 2
    dp[i] = dp[1] + (h[1] - h[0] ).abs
  else
    dp[i] = chmin(dp[i - 1] + (h[i - 1] - h[i - 2]).abs , dp[i - 2] + (h[i - 1] - h[i - 3]).abs)
  end
end

puts dp[n]




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

int n,m,c,cm;
int kei;
int a[20],b[20];

void sai(int s){
  cm--;
  kei = s + a[cm] * b[cm];
  if(cm != 0){
    sai(kei);
  }
}

int main(){
  cin >> n >> m >> c;
  int ans=0;
  for(int i=0;i<m;i++){
    cin >> b[i];
  }
  for(int j=0;j<n;j++){
    cm = m;
    kei = 0;
    for(int i=0;i<m;i++){
      cin >> a[i];
    }
    sai(kei);
    if(kei + c > 0)ans =ans + 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MAX_N 51
using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin>>n>>m;
    vector<int> w[100010];
    for(int i = 1; i<=n; i++){
        int a,b;
        cin>>a>>b;
        w[a].push_back(b);
    }
    priority_queue<int> pq;
    ll ans = 0;
    for(int i = 1; i<= m; i++){
        for(int j = 0; j < w[i].size(); j++) pq.push(w[i][j]);
        if(!pq.empty()){
            int ww = pq.top();pq.pop();
            ans += ww;
        }
    }
    cout<< ans <<endl;
    return 0;
}

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


class main{
  public static void Main(string[] args){
    string[] s = Console.ReadLine().Split(" ");
    int n = int.Parse(s[0]);
    int m = int.Parse(s[1]);
    int c = int.Parse(s[2]);
    int[] b = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    var a = new System.Collections.Generic.List<int[]>(n);
    int sum = 0;
    int cnt = 0;
    
    for(int i = 0; i < n; i++){
      var values = Console.ReadLine().Split(' ').Take(m);
      a.Add(values.Select(s => int.Parse(s)).ToArray());
      
      for(int j = 0; j < m; j++){
        sum += a[i][j]*b[j];
      }
      sum += c;
      if(sum > 0) cnt++;
      sum = 0;
    }
    
    Console.WriteLine(cnt);
  }
}

Measured memory_bytes: 28380
from collections import Counter
n=int(input())
cnt=0
ans=[]
for i in range(2,int((2*n)**0.5)+1):
    for j in range(2,int((2*n)**0.5)+1):
        for k in range(2,int((2*n)**0.5)+1):
            if (i*i + j*j + k*k)%2==0 and (i*i + j*j + k*k)<=2*n and (i+j-k>1) and (i+k-j>1) and (k+j-i>1):
                ans.append((i*i + j*j + k*k)//2)
ans.sort()
A=Counter(ans)
for i in range(1,n+1):
    print(A[i])

Measured memory_bytes: 88920
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,red=0,blue=0;
    char c;
    while(cin>>c){
        if (c=='0')red++;
        if (c=='1')blue++;
    }
    ans=red+blue-abs(red-blue);

    dbg{
        if(true)cout <<"YES"<<endl;
        else cout <<"NO"<<endl;
    }

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> intpair;
typedef std::pair<long long, long long> llpair;

#define mod 1000000007
#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i, n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using namespace std;

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

	intpair tiket[4];
	rep(i, 4) {
		int t;
		int n;
		cin >> t >> n;

		int price;
		switch (t) {
		case 1:
			price = 6000;
			break;
		case 2:
			price = 4000;
			break;
		case 3:
			price = 3000;
			break;
		default:
			price = 2000;
			break;
		}

		cout << price * n << "\n";
	}

	return 0;
 }



Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

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

    int len = s.size();
    vector<int> count(len, 0);

    int cnt = 1;
    for (int i=1; i<len; i++) {
        if (s[i-1] != s[i]) {
            if (s[i] == 'L') {
                count[i] = cnt / 2;
                count[i-1] = cnt - count[i];
            }
            cnt = 1;
        } else {
            cnt += 1;
        }
    }
    cnt = 1;
    for (int i=len-1; i>=0; i--) {
        if (s[i] != s[i+1]) {
            if (s[i] == 'R') {
                int num = cnt / 2;
                count[i] += num;
                count[i+1] += cnt - num;
            }
            cnt = 1;
        } else {
            cnt += 1;
        }
    }

    for (int i=0; i<len; i++) {
        if (i != 0) cout << " ";
        cout << count[i];
    }
    cout << endl;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> piipi;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int a[200005];
deque<int> dq;
int main(){
    int n, b = 0;
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        scanf("%d", &a[i]);
        if(b == 0) dq.push_back(a[i]);
        else dq.push_front(a[i]);
        b ^= 1;
    }   
    if(b == 0){
        for(int i=0;i<sz(dq);i++) printf("%d ", dq[i]);
    }
    else{
        for(int i=sz(dq)-1;i>=0;i--) printf("%d ", dq[i]);  
    }
}

Measured memory_bytes: 5368
A,B =[int(x) for x in input().split()]

def bunkai(n):
    sosu= {1}
    tmp = n
    
    if tmp%2 == 0:
        while tmp%2==0:
            tmp //=2
        sosu.add(2)
    
    for i in range(3,int(n**0.5)+1,2):
        if tmp%i == 0:
            while tmp%i==0:
                tmp //=i
            sosu.add(i)
            
    if tmp!=1:
        sosu.add(tmp)
                
    if sosu==[1]:
        sosu.add(n)
    
    return sosu

def check_sosu(n,x):
    ans=0
    tmp = n
    for i in x:
        if (tmp % i) == 0:
            ans+=1
    return ans

ans = check_sosu(B,bunkai(A))

print(ans)

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

int main() {
	int N;
	cin >> N;
	if (N == 1) {
		puts("Hello World");
	}
	else {
		int A, B;
		cin >> A >> B;
		cout << A + B << endl;
	}
	return 0;
}

Measured memory_bytes: 256
while True:
    a=0
    ma=0
    mi=99999
    n = int(input())
    if n == 0:
        break
    else:
        for i in range(n):
            b=int(input())
            a=a+b
            if ma<b:
                ma=b
            if mi>b:
                mi=b
        answer=(a-ma-mi)//(n-2)
        print(answer)


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

// calculate |gcd|.
// if  ether num is 0, return 0
long long GCD(long long left, long long right) {
  if(left == 0 || right == 0) return 0;
  if(left < 0) left *= -1;
  if(right < 0) right *= -1;
  if(left < right) swap(left, right);
  long long nextnum, ansgcd = -1;
  while(ansgcd == -1) {
    nextnum = left % right;
    if(nextnum == 0) ansgcd = right;
    left = right;
    right = nextnum;
  }
  return ansgcd;
}

long long LCM(long long left, long long right) {
  return left / GCD(left, right) * right;
}

long long n, x, gcd = 1;

long long solve();

int main() {
  cin >> n >> x;
  gcd = GCD(n, x);
  n /= gcd;
  x /= gcd;
  cout << gcd * solve() << endl;
  return 0;
}

long long solve() {
  if(n - x < x) x = n - x;
  if((n - x) % x == 0) return (n - x) * 3;
  long long ans = n + 2 * ((n - x) / x) * x,
            y = (n - x) % x;
  while(1) {
    ans += 2 * y * (x / y);
    if(x % y == 0) {
      ans -= y;
      break;
    }
    long long tmp = y;
    y = x % y;
    x = tmp;
  }
  return ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
     vector<int> v;
     int n,m,cnt=0,cnt1=0;
     scanf("%d%d",&n,&m);
     int k,ch,i,j;
     for(i=0;i<n;++i)
     {
        scanf("%d",&k);
       for(j=0;j<k;++j)
       {
         scanf("%d",&ch);
         v.push_back(ch);
       }
       
       
     }
  
  sort(v.begin(),v.end());
  for(i=0;i<v.size();++i)
  {
    cnt=0;
     for(j=i;j<v.size();++j)
     {
       if(v[i]==v[j])
          cnt++;
          
        else
           break;
     }
    
    if(cnt==n)
        cnt1++;
  }
  
  printf("%d",cnt1);
            
}


Measured memory_bytes: 256
from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

def main():
    s = input()
    ss = "abcdefghijklmnopqrstuvwxyz"
    for i in range(25):
        if s == ss[i]:
            print(ss[i+1])
            exit()

    
main()


Measured memory_bytes: 3060
use std::io;

fn main() {
     let n: usize = {
        let mut n = String::new();
        io::stdin().read_line(&mut n).unwrap();
        n.trim_right().to_owned().trim().parse().unwrap()
    };

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let w: Vec<i32> = buf.split_whitespace().map(|s| s.parse().unwrap()).collect();
    let sum: i32 = w.iter().sum();
    let mut bb: Vec<i32> = vec![];
    for i in 0..n {
        let (a, b) = w.split_at(i);
        let asum: i32 = a.iter().sum();
        let bsum: i32 = b.iter().sum();
        bb.push(i32::abs(asum - bsum));
    }
    bb.sort();
    println!("{}", bb[0]);
}

Measured memory_bytes: 4352
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[10007],b[10007],f[10007];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int h,n;
    cin>>h>>n;
    for(int i=1;i<=n;++i)
        cin>>a[i]>>b[i];
    for(int i=1;i<=h;++i)
        f[i]=1e9;
    f[0]=0;
    for(int i=1;i<=n;++i)
        for(int j=0;j<=h;++j){
            int x=max(0,j-a[i]);
            f[j]=min(f[j],f[x]+b[i]);
        }
    cout<<f[h];
    return 0;
}


Measured memory_bytes: 256
N = input()
N=int(N)
n=0
if N <= 111:
    n = 111
elif N <= 222:
    n = 222
elif N <= 333:
    n= 333
elif N <= 444:
    n = 444
elif N <= 555:
    n = 555
elif N <= 666:
    n = 666
elif N <= 777:
    n = 777
elif N <= 888:
    n = 888
elif N <= 999:
    n = 999
print(n)

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

const int MAXN = 200;
int k = 1;
int p[MAXN], used[MAXN];
int in_m[MAXN];
vector<int> g[MAXN];
int arr[MAXN][MAXN];

bool dfs(int v) {
    // cout << k << " " << v << endl;
    used[v] = k;
    for (auto u : g[v]) {
        if (p[u] == -1) {
            p[u] = v;
            in_m[v] = 1;
            return true;
        }
        if (used[p[u]] != k && dfs(p[u])) {
            in_m[v] = 1;
            p[u] = v;
            return true;
        }
    }
    return false;
}

main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> arr[i][j];
        }
    }
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            g[j].clear();
            p[j] = -1;
            in_m[j] = 0;
        }
        for (int j = 0; j < n; ++j) {
            for (int k = i; k < m; ++k) {
                g[j].push_back((arr[j][k] + m - 1) / m - 1);
            }
        }
        for (int j = 0; j < n; ++j) {
            k++;
            dfs(j);
        }
        for (int j = 0; j < n; ++j) {
            int x = p[j];
            for (int k = i; k < m; ++k) {
                if ((arr[x][k] + m - 1) / m - 1 == j) {
                    swap(arr[x][k], arr[x][i]);
                    break;
                }
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cout << arr[i][j] << " ";
        }
        cout << endl;
    }
    for (int i = 0; i < m; ++i) {
        vector<int> col;
        for (int j = 0; j < n; ++j) {
            col.push_back(arr[j][i]);
        }
        sort(col.begin(), col.end());
        for (int j = 0; j < n; ++j) {
            arr[j][i] = col[j];
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cout << arr[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

ll dp[100][2];
int main()
{
	int N;
	cin >> N;
	ll K;
	cin >> K;
	vector<ll> A(N);
	rep(i, N)cin>>A[i];

	for (int i = 0; i < 100; i++) dp[i][0] = dp[i][1] = -1;
	dp[45][0] = 0;
	for(int d = 44; d >= 0; --d){
		ll mask = 1LL<<d;
		int num = 0;
		for (int i = 0; i < N; i++) if(A[i] & mask) ++num; // d桁目が立ってるやつの数

		if (dp[d+1][1] >= 0) chmax(dp[d][1], dp[d+1][1] + mask * max(num, N-num));
		if (dp[d+1][0] >= 0) {
			if (K & (1LL<<d)) {
				chmax(dp[d][1], dp[d+1][0] + mask * num);
				chmax(dp[d][0], dp[d+1][0] + mask * (N - num));
			}
			else {
				chmax(dp[d][0], dp[d+1][0] + mask * num);
			}
		}
	}
	cout << max(dp[0][0], dp[0][1]) << endl;
}


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

int main(){
    ll N; cin >> N;
    map<ll,ll> md,ms;
    rep(i,0,N){
        ll a; cin >> a;
        md[i+1-a]++ ; ms[i+1+a]++;
    }
    ll ans = 0;
    for(auto &d : md){
        ans += d.second * ms[d.first];
    }
    cout << ans << endl;
}

Measured memory_bytes: 37772
#include <stdio.h>
int main(void){
    int i, n, a[100];
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &a[i]);
    }
    for(i=n-1; i>0; i--){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[0]);
    return 0;
}


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

int main(){
	string s;
	int ans = 0;
	while(getline(cin, s)){
		//if(s == "ab")break;
		for(int i = 0;i < s.size();i++){
			if('0' <= s[i] && s[i] <= '9'){
				int tmp = s[i++] - '0';
				while('0' <= s[i] && s[i] <= '9'){
					tmp *= 10;
					tmp += s[i++]-'0';
				}
				ans += tmp;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3116
import sys
from collections import deque
l = deque(sys.stdin.readlines())
n, m = (int(x) for x in l[0].split())
l.popleft()

from_1, to_n = set(), set()
for a, b in deque((int(x) for x in l[i].split()) for i in range(m)):
    if a == 1: from_1.add(b)
    elif b == n: to_n.add(a)

print("POSSIBLE" if from_1 & to_n else "IMPOSSIBLE")

Measured memory_bytes: 196560