akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main() {
    int A, B, C;
    int X;
    cin >> A >> B >> C >> X;
    int Xcount = 0;
    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= C; k++) {
                int total = i * 500 + j * 100 + k * 50;
                if (total == X) {
                    Xcount++;
                }
            }
        }
    }
    cout << Xcount++ << endl;
}

Measured memory_bytes: 256
import itertools
N = int(input())
xy_list = [list(map(int, input().split())) for _ in range(N)]

ans = 0
num = 0
for xy in itertools.permutations(xy_list):
    ans_pre = 0
    for i in range(N-1):
        ans_pre += ((xy[i][0]-xy[i+1][0])**2 + (xy[i][1]-xy[i+1][1])**2)**(0.5)
    num += 1
    ans += ans_pre
print(ans/num)

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

int main() {
    string s;
    int w;
    cin >> s >> w;
    string ans = "";
    for (int i=0; i<s.size(); ++i) {
        if (i%w == 0) ans += s[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>

using namespace std;

map<int, int> factorize(int n) {
  map<int, int> m;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ++m[i];
      n /= i;
    }
  }
  if (n != 1) m[n] = 1;
  return m;
}

int main() {
  int n;
  cin >> n;
  cout << n << ":";
  for (auto p : factorize(n)) {
    for (int i = 0; i < p.second; i++) {
      cout << " " << p.first;
    }
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n, k;
    cin >> n >> k;
    long long x;
    x = n%k;
    long long tmp;
    tmp = x;
    //if(x%k==0){
    //    cout << 0 << endl;
    //}else{
        while(tmp<=x){
            tmp = (long long)abs(x-k);
            //cout << "tmp=" << tmp << endl;
            x = min(tmp,x);
            //cout << "x=" << x << endl;
            //cout << "res=" << x-n << endl;
        }
        cout << x << endl;
    //}
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}
void solve(long long N)
{

    if (N % 2 == 0)
    {
        ll ans = 0;
        N /= 10;
        while (N != 0)
        {

            ans += N;
            N /= 5;
        }
        cout << ans << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
   int m,d;
   cin>>m>>d;
   int count=0;
   for(int i=22;i<=d;i++)
   {
   	  int a=i%10;
      
   	  int b=i/10;
        
   	  if(a*b<=m&&a>1&&b>1)
   	  {
             
   	  	count++;
   	  }

   }
   cout<<count;



	return 0;
}


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

typedef long long int ll;

int main(){

  int n;
  string s;
  cin >> n;
  cin >> s;
  if(n%2==1)cout << "No" << endl;
  else{
    for(int i=0;i<n/2;i++){
      if(s[i]!=s[i+n/2]){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }

}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;

int n, a;
ll cnt;
bool flag;

int main() {
	cin >> n;
	flag = false;
	cnt = 0;
	lp(n) {
		cin >> a;
		if (flag&&a != 0) {
			cnt++;
			a--;
		}
		cnt += a / 2;
		if (a % 2)flag = true;
		else flag = false;
	}
	cout << cnt << endl;
	return 0;
}

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

int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(d * -1 <= a - c && a - c <= d) cout << "Yes" << endl;
  else if((d * -1 <= a - b && a - b <= d) && (d * -1 <= b - c && b - c <= d)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;             
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define res register LL
#define LL long long
#define inf 0x3f3f3f3f
inline LL read() {
	res s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {
		if(ch=='-')w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
	return s*w;
}
inline void write(res w) {
	if(w<0)putchar('-'),w=-w;
	if(w>9)write(w/10);
	putchar(w%10+'0');
}
inline LL f(res x) {
	if(!x) return 0;
	else return x%10+f(x/10);
}
int main() {
	res k=read();
	res num=0,ans=1,p=1;
	while(num<k) {
		write(ans),puts("");
		res ans1=ans+p,ans2=ans+p*10;
		if(ans1*f(ans2)<=ans2*f(ans1)) {
			ans=ans1;
		} else {
			ans=ans2;
			p*=10;
		}
		num++;
	}
	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[] v = new int[N];
		int[] c = new int[N];
		int count=0;
		
		for(int i=0;i<N;i++) {
			v[i]=sc.nextInt();
		}
		for(int i=0;i<N;i++) {
			c[i]=sc.nextInt();
		}
		
		for(int i=0;i<N;i++) {
			if(v[i]-c[i]>=1) {
				count+=v[i]-c[i];
			}
		}
		System.out.println(count);
		sc.close();
	}
}


Measured memory_bytes: 21844
def solve(w, h, x, y):
    #   h|-----|--|
    #    |-----|--|
    #    |-----|--|
    #   y|-----o--|
    #    |-----|--|
    #    0     x  w

    is_multi = (x == w/2) and (y == h/2)
    return "{:05f}".format(float((h * w)/2)), is_multi


if __name__ == '__main__':
    w, h, x, y = map(int, input().split())
    area, is_multi = solve(w, h, x, y)
    print(area, int(is_multi))


Measured memory_bytes: 2940
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  # floor(x/b)がギリギリ割り切れない辺りが一番大きくなりそう
  # -> 実験してみるとmath.floor(a*x/b)-a*math.floor(x/b)はループしてそう
  # -> 答えはfloor(x/b)がギリギリ割り切れないときの値に決め打つぜ！
  a,b,n=LI()
  x=min(n,b-1)
  return math.floor(a*x/b)-a*math.floor(x/b)

# main()
print(main())


Measured memory_bytes: 10804
#include <iostream>
#include <algorithm>
#include <iterator>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

    cout << a/b << ' ';
    cout << a%b << ' ';
    cout.precision(5);
    cout.setf(ios::fixed, ios::floatfield );
    cout << (double)a/b << endl;

}


Measured memory_bytes: 3284
/// Updated! https://www.youtube.com/watch?v=U07_n9xGIlM
#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define dbug printf("I am here\n");
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int maxn = 2e5+100;

const ll inf = 1e18;
double X[maxn];
int main()
{
    fast;
    int n , k;
    cin >> n >> k;
    for(int i = 1; i<=n; i++){
        cin >> X[i];
        X[i] = ((X[i]*(X[i]+1))/2.0)/X[i];
    }
    queue < double > see;
    double ans = 0 , SUM = 0;
    for(int i = 1; i<=n; i++){
        see.push(X[i]);
        SUM += X[i];
        if(see.size()>k){
            SUM -= see.front();
            see.pop();
        }
        ans = max(ans , SUM);
    }
    printf("%.8lf",ans);
    return 0;
}
/*



*/



Measured memory_bytes: 3456
import math
num = int(input())
num_list = list(map(int,input().split()))
ans = sum(num_list)/2
#numl = sum(num_list[:num//2])
#numr = sum(num_list[num//2:num])
#print(ans,numl,numr)
total = 0
flag = "off"
for i in range(num):
  total += num_list[i]
  if total >= ans:
    #print(ans)
    if ans -(total - num_list[i]) < total - ans:
      ans = ans -(total - num_list[i])
    else:
      ans = total - ans     
    break
#print(n1,n2)
#print(min((n2-ans),(ans-n1)))
print(math.ceil(ans*2))

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

using namespace std;

int main()
{
    int N;
    string s;
    cin >> N >> s;
    int countr = 0;
    int countb = 0;
    for(int i = 0; i < N; i++)
    {
        if(s[i] == 'R')
        {
            countr++;
        }
        else
        {
            countb++;
        }
    }
    if(countr > countb)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

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

#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;

int mod = 1e9 + 7;

void mul(vector<vector<ll>>& A, vector<vector<ll>> B) {
	int n = A.size();

	vector<vector<ll>> C(n, vector<ll>(n));

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			for(int k = 0; k < n; k++) {
				C[i][j] += A[i][k]*B[k][j];
				C[i][j] %= mod;
			}
		}
	}
	A = C;
}

vector<vector<ll>> mpow(vector<vector<ll>>& A, ll x) {
	if(x == 1) {
		return A;
	}

	auto ans = mpow(A, x/2);
	mul(ans, ans);
	if(x % 2 == 1) {
		mul(ans, A);
	}
	return ans;

}

void solve(void) {

	int n;
	ll k;

	cin >> n >> k;

	vector<vector<ll>> A(n, vector<ll>(n));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			cin >> A[i][j];
		}
	}

	A = mpow(A, k);
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			ans += A[i][j];
			ans %= mod;
		}
	}

	cout << ans << '\n';

}

int main(void) {

	solve();
	return 0;
}


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

using namespace std;


int main()
{
	int N,a=0;

	cin >> N;

	string S;



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

		if (S == "Y") {
			a = 1;
		}

	}

	if (a == 1) {
		cout << "Four" << endl;
	}
	else {
		cout << "Three" << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;
const long long MINF = LLONG_MIN;

// -------------------------------------------------------

int N;
string s;
char t[1010101];

void init_t() {
  rep(i, 0, N) { t[i] = 0; }
}

void print_t() {
  rep(i, 0, N) { cout << t[i]; }
}

bool check_t() {
  if (s[N - 1] == 'o') {
    if (t[N - 1] == 'S') {
      if (t[N - 2] == t[0]) {
        return true;
      }
    } else {
      if (t[N - 2] != t[0]) {
        return true;
      }
    }
  } else {
    if (t[N - 1] == 'S') {
      if (t[N - 2] != t[0]) {
        return true;
      }
    } else {
      if (t[N - 2] == t[0]) {
        return true;
      }
    }
  }

  return false;
}

bool check_t_top() {
  if (s[0] == 'o') {
    if (t[0] == 'S') {
      if (t[N - 1] == t[1]) {
        return true;
      }
    } else {
      if (t[N - 1] != t[1]) {
        return true;
      }
    }
  } else {
    if (t[0] == 'S') {
      if (t[N - 1] != t[1]) {
        return true;
      }
    } else {
      if (t[N - 1] == t[1]) {
        return true;
      }
    }
  }

  return false;
}

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

  char tzero[] = {'S', 'S', 'W', 'W'};
  char tone[] = {'S', 'W', 'S', 'W'};

  rep(j, 0, 4) {
    init_t();
    t[0] = tzero[j];
    t[1] = tone[j];
    repe(i, 1, N - 2) {
      if (t[i] == 'S') {
        if (s[i] == 'o') {
          t[i + 1] = t[i - 1];
        } else {
          t[i + 1] = t[i - 1] == 'S' ? 'W' : 'S';
        }
      } else {
        if (s[i] == 'o') {
          t[i + 1] = t[i - 1] == 'S' ? 'W' : 'S';
        } else {
          t[i + 1] = t[i - 1];
        }
      }
    }
    if (check_t() && check_t_top()) {
      print_t();
      return 0;
    }
    // cout << j << " ";
    // rep(i, 0, N) { cout << t[i]; }
    // cout << endl;
  }

  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3852
n=int(input())
v=list(map(int,input().split()))
odd=[v[i] for i in range(1,n,2)]
even=[v[i] for i in range(0,n,2)]
from collections import defaultdict
d_odd=defaultdict(int)
d_even=defaultdict(int)
for i in range(len(odd)):
    d_odd[odd[i]]+=1
for i in range(len(even)):
    d_even[even[i]]+=1

d_odd=sorted(d_odd.items(),key=lambda x:x[1],reverse=True)
d_even=sorted(d_even.items(),key=lambda x:x[1],reverse=True)
if d_odd[0][0]!=d_even[0][0]:
    ans=(len(odd)-d_odd[0][1])+(len(even)-d_even[0][1])
else:
    if len(d_odd)==1 and len(d_even)==1:
        ans=len(odd)
    elif len(d_odd)==1:
        ans=(len(even)-d_even[1][1])
    elif len(d_even)==1:
        ans=(len(odd)-d_odd[1][1])
    else:
        x=(len(odd)-d_odd[1][1])+(len(even)-d_even[0][1])
        y=(len(odd)-d_odd[0][1])+(len(even)-d_even[1][1])
        ans=min(x,y)
print(ans)

Measured memory_bytes: 66540
/*
 * main.c
 *
 *  Created on: 2019/06/22
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef unsigned long long int uint64_t;

uint64_t gcd(uint64_t a, uint64_t b)
{
	uint64_t tmp = 0;
	if(a >= b) {
	} else {
		return gcd(b,a);
	}
	while((tmp = a%b)) {
		a = b;
		b = tmp;
	}
	return b;
}

int main()
{
	uint64_t A = 0, B = 0, C = 0, D = 0;
	uint64_t ac = 0, ad = 0, x = 0;
	uint64_t bc = 0, bd = 0, ans = 0;
	uint64_t xa = 0, xb = 0;
	scanf("%llu %llu %llu %llu", &A, &B , &C, &D);

	// 1 - Aまで
	ac = (A-1) - (A-1)/C;
	ad = (A-1) - (A-1)/D;
	bc = B - (B/C);
	bd = B - (B/D);
	x = (C*D)/gcd(C, D);
	xa = (A-1) - (A-1)/x;
	xb = B - B/x;
	ans = (bc - ac) + (bd - ad) - (xb - xa);
	//printf("x=%llu ac = %llu ad = %llu bc = %llu bd = %llu xa = %llu xb = %llu\n",
	//		x, ac, ad, bc, bd, xa, xb);
	printf("%llu\n",ans);
    return 0;
}


Measured memory_bytes: 128
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
if A < B:
    if B + W*T <= A + V*T:
        print("YES")
    else:
        print("NO")
else:
    if B - W*T >= A - V*T:
        print("YES")
    else:
        print("NO")




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

typedef long long i64;
const int maxn = 1e5 + 2;

int t_in[maxn];
int main() {
	// your code goes here
	int n,id;
	while(scanf("%d",&n)==1){
		for(int i=1;i<=n; i++){
			scanf("%d",&id);
			t_in[id] = i;
		}
		for(int i=1;i<=n;i++) printf("%d ", t_in[i]);
		
	}
	return 0;
}

Measured memory_bytes: 4088
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
u = set(s)
count = []
cnt = 0
for i in u:
    count.append(s.count(i))
    count[cnt] -= t.count(i)
    cnt += 1
res = max(count)
if res <= 0:
    print(0)
else:
    print(res)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue> 
using namespace std;
const int INF = 0x3f3f3f3f;

struct edge
{
	int to;     //另一个点
	int dis;    //路的权值 
	int cost;   //建设成本
	edge(){}
	edge(int to,int dis,int cost):to(to),dis(dis),cost(cost){} 
	bool operator > (const edge& b) const
	{
		if(dis!=b.dis)
		{
			return dis>b.dis;
		}
		else
		{
			return cost > b.cost;
		}
	}
};

vector<edge> G[10100];
int V,M;   //V为顶点数，M为路数 
bool used[10100];

int main()
{
	while(cin>>V>>M)
	{
		if(V == 0)
		{
			return 0;
		}
		for(int i = 0;i < V;i++)
		{
			G[i].clear();
		}
		for(int i = 0;i < M;i++)
		{
			int u,v,d,c;
			cin>>u>>v>>d>>c;
			u--;v--;    //适应从0开始 
			G[u].push_back(edge(v,d,c));
			G[v].push_back(edge(u,d,c)); 
		}
		int ans = 0;
		priority_queue<edge,vector<edge> ,greater<edge> > q;
		fill(used,used + V,0);
		q.push(edge(0,0,0));
		while(!q.empty())
		{
			edge p = q.top();
			q.pop();
			int v = p.to;
			if(used[v])
			    continue;
			used[v] = true;
			ans = ans + p.cost;
			for(int i = 0;i < G[v].size() ;i++)
			{
				edge e = G[v][i];
				q.push(edge(e.to,p.dis + e.dis,e.cost) ); 
			}
		} 
		cout<<ans<<endl;
	} 
}


Measured memory_bytes: 5408
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 100010;
const int INF = 2147483600;
const LL Mod = 1000000007;

int N,K;
int a[MAXN+1],b[MAXN+1];
int sum[MAXN+1];
LL f[610][610]; LL g[MAXN+1]; 
inline int S(int l,int r){ return sum[r]-sum[l-1]; }
inline bool In(int x,int l,int r){ return x>=l&&x<=r; }

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read()*2,K=read();
	for(int i=1;i<=K;i++){
		a[i]=read(),b[i]=read();
		sum[a[i]]=sum[b[i]]=1;
	} LL ans=0; g[0]=1;
	for(int i=1;i<=N;i++){
		if(i&1) g[i]=0;
		else g[i]=g[i-2]*(i-1)%Mod;
	}
	for(int i=1;i<=N;i++) sum[i]+=sum[i-1];
	for(int len=1;len<=N;len++){
		if(len&1) continue;
		for(int i=1;i+len-1<=N;i++){
			int j=i+len-1; bool flag=0;
			for(int k=1;k<=K;k++){
				if(In(a[k],i,j)&&!In(b[k],i,j)) {
					flag=1; break;
				} if(!In(a[k],i,j)&&In(b[k],i,j)){
					flag=1; break;
				}
			} if(flag){
				f[i][j]=0; continue;
			}
			f[i][j]=g[len-S(i,j)];
			for(int k=i;k<j;k++)
				f[i][j]=(f[i][j]-g[j-k-S(k+1,j)]*f[i][k]%Mod+Mod)%Mod; 
			(ans+=f[i][j]*g[N-len-2*K+S(i,j)]%Mod)%=Mod;
		}
	} printf("%lld\n",ans);
	return 0;
}




Measured memory_bytes: 3584
# coding: utf-8


def main():
    tax_8, tax_10 = map(int, input().split())

    rate8 = 0.08
    rate10 = 0.1
    value8 = tax_8 / rate8
    value10 = tax_10 / rate10
    price_min = int(min(value8, value10))
    price_max = int(max(value8, value10)) + 1

    for price in range(price_min, price_max + 1):
        if int(price * rate8) == tax_8 and int(price * rate10) == tax_10:
            print(price)
            return 0
   
    print('-1')

    return 0


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>

using namespace std;

int main()
{
	int A, B;

	cin >> A >> B;

	int p, m, f;

	p = A + B;

	m = A - B;

	f = A * B;

	if (max(p,m)>f)
	{
		cout << max(p,m) << endl;
	}
	else
	{
		cout << f << endl;
	}

	


	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())
s_reverse = s[::-1]
ans = 0
r_cnt = 0
b_cnt = 0
g_cnt = 0
r = [0] * n
b = [0] * n
g = [0] * n
for i in range(n):
    if s_reverse[i] == 'R':
        r_cnt += 1
    elif s_reverse[i] == 'G':
        g_cnt += 1
    else:
        b_cnt += 1
    r[n-i-1] = r_cnt
    g[n-i-1] = g_cnt
    b[n-i-1] = b_cnt
    
for i in range(n-2):
    for j in range(i+1, n-1):
        if s[i] == 'R' and s[j] == 'G':
            if (2*j - i) < n:
                if s[j+(j-i)] == 'B':
                    ans -= 1
            ans += b[j+1]
        elif s[i] == 'R' and s[j] == 'B':
            if (2 * j - i) < n:
                if s[j+(j-i)] == 'G':
                    ans -= 1
            ans += g[j+1]
        elif s[i] == 'G' and s[j] == 'R':
            if (2 * j - i) < n:
                if s[j+(j-i)] == 'B':
                    ans -= 1
            ans += b[j+1]
        elif s[i] == 'G' and s[j] == 'B':
            if (2 * j - i) < n:
                if s[j+(j-i)] == 'R':
                    ans -= 1
            ans += r[j+1]
        elif s[i] == 'B' and s[j] == 'R':
            if (2 * j - i) < n:
                if s[j+(j-i)] == 'G':
                    ans -= 1
            ans += g[j+1]
        elif s[i] == 'B' and s[j] == 'G':
            if (2 * j - i) < n:
                if s[j+(j-i)] == 'R':
                    ans -= 1
            ans += r[j+1]

print(ans)

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
	if ( ch == 'A' ) return 1;
	else if ( ch == 'C') return 2;
	else if ( ch == 'G') return 3;
	else if ( ch == 'T') return 4;
	else return 0;
}

long long getKey(char str[]) {
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); ++i) {
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0; ; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0 ) return 1;
		else if ( strlen(H[h]) == 0) return 0;
	}
	return 0;
}

int insert(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0; ; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if ( strcmp(H[h], str) == 0 ) return 1;
		else if (strlen(H[h]) == 0 ) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main() {
	int i, n, h;
	char str[L], com[9];
//	for ( i = 0; i < M; i++) H[i][0] = '\0';
	scanf("%d", &n);

	for (i = 0; i < n; ++i) {
		scanf("%s %s", com, str);

		if (com[0] == 'i') {
			insert(str);
		} else {
			if (find(str)) {
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 14908
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair
#define sz size
#define inf 1e9+5
 
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n;
    cin>>n;
    vector<ll> arr(n);
    for(ll i=0;i<n;i++)cin>>arr[i];
    ll ans=0;
    sort(arr.begin(),arr.end());
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            ll temp = arr[i]+arr[j];
            ll pos = lower_bound(arr.begin(),arr.end(),temp) - arr.begin();
            ans+=(pos-j-1);
        }
    }
    cout<<ans;

    return 0;  
}

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

int main(){
	ll n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	vector<pair<ll,ll>> p(n);
	rep(i,n){
		cin >> p[i].first >> p[i].second;
		a[i] = p[i].first;
		b[i] = p[i].second;
	}
	ll mn = 0;
	sort(a.begin(),a.end());
	if(n % 2 == 0){
		mn = a[n/2] + a[n/2-1];
	}else{
		mn = a[n/2];
	}
	ll mx = 0;
	sort(b.begin(),b.end());
	if(n % 2 == 0){
		mx = b[n/2] + b[n/2-1];
	}else{
		mx = b[n/2];
	}
	ll ans = mx - mn + 1;
	cout << ans << endl;
    return 0;
}



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

int main(){
    ll n;
    cin>>n;
    map<ll,int>mp;
    while(1){
        bool ok=false;
        for(int i=2; i<=sqrt(n); ++i){
            if(n%i==0){
                ok=true;
                mp[i]++;
                n/=i;
                break;
            }
        }
        if(!ok)break;
    }
    if(n>=2)mp[n]++;
    int ans=0;
    for(auto&p:mp){
        int x=1,y=p.second;
        while(x<=y){
            y-=x;
            x++;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3584
A = int(input())
B = int(input())
C = int(input())
X = int(input())

num_case = 0

for i in range(A+1) :
	A_sum = 500 * i
	if A_sum > X :
		break
	for j in range(B+1) :
		AB_sum = A_sum + 100 * j
		if AB_sum > X :
			break
		for k in range(C+1) :
			ABC_sum = AB_sum + 50 * k
			if ABC_sum == X :
				num_case += 1
				break
			elif ABC_sum > X :
				break
print(num_case)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, W;
	cin >> N >> W;

	vector<Int> w(N);
	vector<Int> v(N);

	for (Int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
	}

	vector<vector<Int>> dp(N + 10, vector<Int>(W + 10));//dp[i][w]::i-1番目までの商品から重さwを超えないように選んだ時の価値の最大値
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j <= W; j++) {
			//i番目の商品を選ぶ場合
			if (j - w[i] >= 0) {
				dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i + 1][j]);
			}
			//i番目の商品を選ばない場合
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
		}
	}
	cout << dp[N][W] << "\n";

}

Measured memory_bytes: 87296
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <complex>

using namespace std;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;

#define int i64

signed main() {
	string abcd;
	cin >> abcd;

	for(int bit = 0; bit < (1 << 3); bit++) {
		int now = abcd[0] - '0';
		for(int i = 0; i < 3; i++) {
			if(bit & (1 << i)) now += abcd[i + 1] - '0';
			else now -= abcd[i + 1] - '0';
		}
		if(now == 7) {
			cout << abcd[0];
			for(int i = 0; i < 3; i++) {
				if(bit & (1 << i)) cout << "+";
				else cout << "-";
				cout << abcd[i + 1];
			}
			cout << "=7" << endl;
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
ll MOD = 1000000007;
ll INF = 214748364700000000;
double EPS = 1e-12;
double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;


int main(){
   ll N,C;cin >> N >> C;
   vector<vector<ll>> D(C,vector<ll>(C));
   vector<vector<ll>> color(N,vector<ll>(N));
   vector<vector<ll>> cnt(3,vector<ll>(C));
   rep(i,C) rep(j,C) cin >> D[i][j];
   rep(i,N) rep(j,N){
       cin >> color[i][j];
       color[i][j]--;
       cnt[(i+j)%3][color[i][j]]++;
   }
   ll ans = INF;
   rep(i,C){
       rep(j,C){
           rep(k,C){
               if(i == j || j == k || k == i) continue;
               ll cost = 0;
               rep(l,C)cost += D[l][i] * cnt[0][l];
               rep(l,C)cost += D[l][j] * cnt[1][l];
               rep(l,C)cost += D[l][k] * cnt[2][l];
               ans = min(ans,cost);
           }
       }
   }
   cout << ans << endl;
}

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

namespace AtCoderTutorial
{
    public class AtCoder174
    {
        public static void Main(string[] args)
        {
            var input = int.Parse(Console.ReadLine());


            if (input >= 30)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 27524
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#define range(i, n) for (int i = 0; i<n; i++)
using namespace std;
using ll = long long;
int main(){
    int a;
    cin >> a;
    int sum;
    sum = a + pow(a,2) + pow(a,3);
    cout << sum;
    return 0;
}

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

int kaibun(string s){
  int pt = s.size()-1;
  //cout << pt << endl;
  
  int ans = 1;
  if(pt == 0) return ans;
  
  for(int i=0; 2*i<=pt; i++){
    if(s[i]!=s[pt-i]) ans=0;
    //cout << s[i] << " " << s[pt-i] << endl;
  }
  return ans;
}

int main() {
  string s;
  cin >> s;
  
  string ans="Yes";
  if(kaibun(s)!=1) ans = "No";
  
  string temp = s.substr( 0,(s.size()/2) );
  //cout << temp;
  if(kaibun(temp) !=1 ) ans = "No";
  
  temp = s.substr( (s.size()+3)/2-1,s.size());
  if(kaibun(temp) !=1 ) ans = "No";
  
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 int main(){
    int n; cin >> n;int a[n];
    for(int i = 0; i < n; i++)cin >> a[i];sort(a, a+n);
    
    long long w = 0;
    int i = n-1;
    int sum = 0;
    while(sum < 4){
      long long x = a[i];
      int y= 1;int j = i;
      while(a[j] == a[j-1]){
        y += 1;
        j -= 1;
      }
      if(y >= 4 and sum == 0){
        w = x*x;
        sum = 4;
      }else if(y == 2){
        if(sum == 2){
          w *= x;
        }else{
          w = x;
        }
        sum += 2;
        i -= 2;
      }else if(y == 3){
        if(sum == 2){
          w *= x;
        }else{
          w = x;
        }
        sum += 2;
        i -= 3;
      }else{
        i -= 1;
      }
    }
  cout << w << endl;
}


Measured memory_bytes: 640
c=list(int(input()) for i in range(5))
amari=0
ma=0
for i in range(5):
    if c[i]%10!=0:
        amari+=10-(c[i]%10)
        if 10-(c[i]%10)>ma:
            ma=(10-(c[i]%10))           
time=sum(c)+(int(amari-ma))
print(int(time))

Measured memory_bytes: 3060
over = 10**18

n = int(input())
a = list(map(int, input().split()))
ans = 1;

for i in range(n):
  if a[i] == 0:
    ans = 0
if not ans == 0:
  for i in range(n):
    ans = ans * a[i]
    if ans > over:
      ans = -1
      break
if ans < 0:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 84668
def main():
    n = int(raw_input())
    s = raw_input()

    total = 0
    prep = 0
    for c in s:
        if c == '(':
            total += 1
        else:
            total -= 1

        if total < 0:
            prep += 1
            total = 0

    print '(' * prep + s + ')' * total


main()



Measured memory_bytes: 27884
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>

using namespace std;

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

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

  vector<ll> L(87);
  L[0] = 2;
  L[1] = 1;
  for (int i = 2; i < 87; i++)
  {
    L[i] = L[i - 1] + L[i - 2];
  }
  cout << L[N] << endl;
}


Measured memory_bytes: 256
n = int(input())
a = [int(input()) for i in range(n)]
max_a = max(a)
second_a = sorted(a)[-2]
max_count = a.count(max_a) - 1
if max_count:
    [print(max_a) for _ in range(len(a))]
else:
    [print(max_a) if a[i] != max_a else print(second_a) for i in range(len(a))]


Measured memory_bytes: 14208
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 	    make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define mod        1000000007
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll power(ll a , ll b,ll modi)
{
    a%=modi;
    ll res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % modi ;
        }
        b/=2 ;
        a = (a*a) % modi ;
    }
    return res ;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=1;
	//cin>>t;
	while(t--)
	{
	char ch;
	cin>>ch;
	if(ch>=65&&ch<=90)
        cout<<"A";
    else
        cout<<"a";
	}
return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> a(N); rep(i, 0, N) {
		cin >> a[i];
	}
	sort(all(a));
	int ans1 = a.back();
	auto it = lower_bound(all(a), ans1 / 2);
	if (it == a.end()) {
		cout << a.back() << " " << *(it - 1) << endl;
	}
	else if (it == a.begin()) {
		cout << a.back() << " " << *it << endl;
	}
	else {
		double mididx = a.back() / 2.0;
		dump(mididx);
		if (*it - mididx < mididx - *(it-1)) {
			cout << a.back() << " " << *it << endl;
		}
		else {
			cout << a.back() << " " << *(it - 1) << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)
//__builtin_popcountll()

int main(){

    fast;
    int T;
    T=1;
    //cin>>T;
    while(T--){
    	ll n,i,j;
    	cin>>n;
    	ll a[n];
    	for(i=0;i<n;i++)
    	{
    		cin>>a[i];
		}
		ll s[n+1];
		s[n-1]=a[n-1];
		for(i=n-2;i>=0;i--)
		{
			s[i]=s[i+1]+a[i];
		}
		ll ans=0;
		for(i=0;i<n-1;i++)
		{
			ans+=(a[i]*(s[i+1]%mod))%mod;
			ans%=mod;;
		}
		cout<<ans;
		
		
    
    	

    }

}


Measured memory_bytes: 6772
def main():
    A = list(input())
    N = len(A)
    K = int(input())

    DP0 = [[0] * (K+1) for _ in range(N+1)]
    DP1 = [[0] * (K+1) for _ in range(N+1)]

    DP0[0][0] = 1
    #print(A)
    for i in range(1, N+1):
        for k in range(0, K+1):
            if k >= 1:
                DP0[i][k] = (int(A[i-1]) == 0) * DP0[i-1][k] + (int(A[i-1]) >= 1) * DP0[i-1][k-1]
                DP1[i][k] = DP0[i-1][k-1]*max(int(A[i-1])-1, 0) + DP0[i-1][k]*(int(A[i-1]) >= 1) + DP1[i-1][k-1]*9 + DP1[i-1][k]
            else:
                DP0[i][k] = (int(A[i-1]) == 0) * DP0[i-1][k]
                DP1[i][k] = DP0[i-1][k]*(int(A[i-1]) >= 1) + DP1[i-1][k]
            #print("#===#")
            #print(DP0)
            #print(DP1)

    print(DP0[N][K] + DP1[N][K])

if __name__ == "__main__":
    main()


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

int main() {
    string str;
    cin >> str;
    int count=0;
    for(int i=0;i<3;i++) if(str.at(i)==str.at(i+1)) count++;
    if(count!=0) cout << "Bad" << endl;
    else cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    ll N, L, T;
    cin >> N >> L >> T;
    ll x[N]; int w[N];
    rep(i, N){
        cin >> x[i] >> w[i];
    }
    ll cnt = 0;
    ll a = (2*T)/L, b = (2*T)%L;
    if(w[0] == 1){
        vector<int> v;
        rep(i, N){
            if(w[i] == 2) v.pb(x[i]-x[0]);
        }
        cnt = a*sz(v);
        for(auto &e: v) if(e < b) cnt++;
        cnt %= N;
    }
    else{
        vector<int> v;
        rep(i, N){
            if(w[i] == 1) v.pb(L+x[0]-x[i]);
        }
        cnt = a*sz(v);
        for(auto &e: v) if(e <= b) cnt++;
        cnt %= N;
        cnt = (N-cnt)%N;
    }
    ll res[N];
    rep(i, N){
        if(w[i] == 1) res[i] = (x[i]+T)%L;
        else res[i] = (x[i]+L*T-T)%L;
    }
    ll pos = res[0];
    sort(res, res+N);
    int id = 0;
    rep(i, N){
        if(res[i] == pos) {id = i; break;}
    }
    rep(i, N){
        cout << res[(N+id-cnt+i)%N] << endl;
    }
}

Measured memory_bytes: 5716
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

#define BLACK 1
#define WHITE 2

int fie[10][10][10];
int n,m,p;

void put(int x,int y,int color){
    for(int i=n;i>=0;i--){
        if(fie[x][y][i]!=0){
            fie[x][y][i+1] = color;
            return ;
        }
    }
    fie[x][y][0] = color;
}


bool dfs(int x,int y,int z,int dx,int dy,int dz){
    vector<int> v;
    rep(i,m){
        int ddx = x+dx*(i);
        int ddy = y+dy*(i);
        int ddz = z+dz*(i);
        
        if(ddx<0||ddy<0||ddz<0)return false;
        if(ddx>=n||ddy>=n||ddz>=n)return false;
        
        v.pb( fie[ddx][ddy][ddz] );
    }
    
//    cout<<x<<" "<<y<<" "<<z<<" "<<dx<<" "<<dy<<" "<<dz<<endl;
//    rep(i,v.size()){
//        cout<<v[i]<<" ";
//    }
//    cout<<endl;
    int t = v[0];
    for(int i=1;i<v.size();i++){
        if(v[i]!=t)return false;
    }
    if(t!=0)return true;
    else return false;
}


bool check(){
    int dx[] = {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,-1,-1,-1,-1,-1,-1,-1,-1,-1};
    int dy[] = {-1,-1,-1,0 ,0 ,0 ,1 ,1 ,1 ,-1,-1,-1,0 ,0 ,1 ,1 ,1 ,-1,-1,-1,0 ,0 ,0 ,1 ,1 ,1 };
    int dz[] = {-1,0 ,1 ,-1,0 ,1 ,-1,0 ,1 ,-1,0 ,1 ,-1,1 ,-1,0 ,1 ,-1,0 ,1 ,-1,0 ,1 ,-1,0 ,1 };
    rep(i,n){
        rep(j,n){
            rep(k,n){
                if(fie[i][j][k] == 0)continue;
//                cout<<i<<" "<<j<<" "<<k<<endl;
                
                rep(l,26){
                    if(dfs(i,j,k,dx[l],dy[l],dz[l]))return true;
                }
            }
        }
    }
//    cout<<endl;
    return false;
}


int main(){
    while(cin>>n>>m>>p&&(n||m||p)){
        rep(i,10)rep(j,10)rep(k,10)fie[i][j][k] = 0;
        int win=-1,turn=-1;
        bool f=true;
        rep(i,p){
            int x,y;
            cin>>x>>y;
            x--,y--;
            int color;
            if(i%2==0)color = BLACK;
            else color = WHITE;
            put(x,y,color);
            if( check() && f){
                win = color;
                turn = i;
                f=false;
            }
        }
        if(win==-1)cout<<"Draw"<<endl;
        else if(win==BLACK){
            cout<<"Black "<<turn+1<<endl;
        }
        else if(win==WHITE){
            cout<<"White "<<turn+1<<endl;
        }
    }
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int N;
    cin >> N;
    vector<int> X(N);
    REP (i, N) cin >> X[i];
    int ans = 1LL << 30;
    for (int p = 1; p <= 100; ++p) {
        int sum = 0;
        REP (i, N) {
            sum += (X[i] - p) * (X[i] - p);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("in.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("out.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		int max = h[0];
		int cnt = 1;
		for (int i = 1; i < n; i++) {
			if (max > h[i]) {
			} else if (max < h[i]) {
				cnt++;
				max = h[i];
			} else if (max == h[i]) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}


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

int main() {
  double a,b,c,d;
  cin >>a>>b;
  c=a/2;
  d=b/2;
  int e,f;
  e=a/2;
  f=b/2;
  if (c==e){
    cout <<"Even"<<endl;
  }
  else{
    if (d==f){
    cout <<"Even"<<endl;
    }
    if (d!=f){
    cout <<"Odd"<<endl;
    }
  }// ここにプログラムを追記
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
struct edge{ll to,cost;};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,A[200001],B[200001];
    cin>>n;
    rep(i,n) cin>>A[i]>>B[i];
    sort(A,A+n),sort(B,B+n);
    if(n%2){
        cout<<B[n/2]-A[n/2]+1;
    }
    else{
        cout<<(B[n/2-1]+B[n/2])-(A[n/2-1]+A[n/2])+1;
    }
}

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

int main()
{
    ll n,m;
    while(~scanf("%lld%lld",&n,&m))
    {
        if(m==n*2)
        {
            printf("%lld\n",n);
        }
        else if(m<n*2)
        {
            printf("%lld\n",m/2);
        }
        else
        {
            printf("%lld\n",n+(m-2*n)/4);
        }
    }
}


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

int main(){
    deque<int> a;
    int n, q, d, num, i;
    scanf("%d", &n);
    for(i = 0; i < n; i ++){
        scanf("%d %d", &q, &d);
        if(q == 0){
            scanf("%d", &num);
            if(d == 0) a.push_front(num);
            else a.push_back(num);
        }
        else if(q == 1){
            printf("%d\n", a[d]);
        }
        else if(q == 2){
            if(d == 0) a.pop_front();
            else a.pop_back();
        }
    }
}


Measured memory_bytes: 4684
from itertools import product
n = int(input())
cnt = 0
for i in range(3, len(str(n))+1):
	for p in product(["7","5","3"], repeat = i):
		if len(set(p)) == 3:
			p = int("".join(p))
			if p <= n:
				cnt += 1
print(cnt)

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, M;
P AB[100100];
int D[100100];
std::vector<P> G[100100];
bool used[100100];
std::vector<int> codes;

void dfs(int v, int p, int ei){
    used[v] = true;
    
    // for(auto [w, ej] : G[v]){
    for(auto &p : G[v]){
        int w, ej;
        std::tie(w, ej) = p;

        if(used[w]){continue;}

        dfs(w, v, ej);
    }

    if(D[v] == 1 && p != -1){
        codes.emplace_back(ei);
        D[v] = 0;
        D[p] ^= 1;
    }
}

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

    std::cin >> N >> M;

    for(int i=1;i<=N;++i){
        std::cin >> fst(AB[i]) >> snd(AB[i]);
    }

    std::sort(AB + 1, AB + 1 + N);

    for(int i=1;i<=N+1;++i){
        D[i] = snd(AB[i-1]) ^ snd(AB[i]);
    }

    for(int i=1;i<=M;++i){
        int L, R;
        std::cin >> L >> R;

        L = std::lower_bound(AB + 1, AB + 1 + N, std::make_tuple(L, 0)) - AB;
        R = std::upper_bound(AB + 1, AB + 1 + N, std::make_tuple(R, 1)) - AB;

        if(L < R){
            G[L].emplace_back(R, i);
            G[R].emplace_back(L, i);
        }
    }

    for(int i=1;i<=N+1;++i){
        unless(used[i]){
            dfs(i, -1, -1);
        }
    }

    for(int i=1;i<=N+1;++i){
        if(D[i] == 1){
            std::cout << -1 << std::endl;
            return 0;
        }
    }

    std::cout << codes.size() << std::endl;

    std::sort(codes.begin(), codes.end());

    for(int i=0;i<codes.size();++i){
        std::cout << codes[i] << " \n"[i + 1 == codes.size()];
    }
}


Measured memory_bytes: 15228
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[int(input())-1])



Measured memory_bytes: 2940