akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
ll A[5000001],bin[5000001];
vector<ll>v;
map<int,int>myMap;
set<int>mySet;
vector<pair<ll,ll> >vp;
/* Precode Start Here *\



     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
int main()
{
   stack<char>st;
   ll n;
   char a;
   cin>>n;
   string s;
   cin>>s;
   for(ll i=0;i<n;i++)
   {
       a=s[i];
       if(st.size()!=0)
       {
           if(st.top()!=a)
           {
               st.push(a);
           }
       }
       else
       {
           st.push(a);
       }
   }
   cout<<st.size()<<endl;
return 0;
}



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

int funcx(int x, int y, int z){
	return x*x + y*y + z*z + x*y + y*z + z*x;
}

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

int x, y, z;
int n; 

int nn = sqrt(N);
//cout << nn << endl;

for ( n = 1; n<=N; n++){
	int count = 0;
	for ( x = 1; x <= nn+1; x++){
		for ( y = 1; y <= nn+1; y++){
			for ( z = 1; z <= nn+1; z++){
				if (funcx(x,y,z) == n){
					count++;
				}
				if (funcx(x,y,z) > n){
					break;
				}
			}
		}
	}
	cout << count << endl;
}


return 0;
}


Measured memory_bytes: 3676
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

d, n = nm()

if n == 100:
    print(100**d * (n + 1))
else:
    print(100**d * n)

Measured memory_bytes: 3696
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            int x = Integer.parseInt(br.readLine());
            if (x >= 1200) {
                System.out.println("ARC");
            } else {
                System.out.println("ABC");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

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

	ll a, b, c;
	cin >> a >> b >> c;
	ll d = c - a - b;
	if (d > 0 && 4 * a * b < d * d)
		cout << "Yes\n";
	else
		cout << "No\n";
}


Measured memory_bytes: 256
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(a*b);
	}
}


Measured memory_bytes: 35772
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
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; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int V, E;
struct edge { LL to, cost; };
int start;
LL d[100100]; //距離
vector<edge> vec[100100];

void dijkstra() {
	for (int i = 0; i < 100100; i++)d[i] = HINF<LL>();
	priority_queue<pii, std::vector<pii>, std::greater<pii>> pq;
	d[start] = 0;
	pq.push(make_pair(d[start], start));//cost,to
	while (!pq.empty()) {
		pii p = pq.top();
		pq.pop();
		int i = p.second;
		if (d[i] < p.first)continue;
		for (int k = 0; k < vec[i].size(); k++) {
			edge e = vec[i][k];
			if (d[e.to] <= d[i] + e.cost)continue;
			d[e.to] = d[i] + e.cost;
			pq.push(make_pair(d[e.to], e.to));
		}
	}
}

int main() {
	cin >> V >> E >> start;
	int a, b, c;
	for (int i = 0; i < E; i++) {
		cin >> a >> b >> c;
		vec[a].push_back(edge{ b,c });
		//vec[b].push_back(edge{ a,c });
	}
	dijkstra();
	REP(i, V) {
		if (d[i] == HINF<LL>()) {
			cout << "INF" << endl;
		}
		else {
			cout << d[i] << endl;
		}
	}
}


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

word = input()
known_words = [word]
for i in range(n-1):
    word = input()
    if word in known_words:
        print('No')
        exit()
    if word[0] != known_words[-1][-1]:
        print('No')
        exit()
    known_words.append(word)
print('Yes')


Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <vector>
#include <set>
#include <queue>

using namespace std;

int h,w,n;
char s[1252];
int mp[1252][1252];
int ys[11];
int xs[11];
bool used[1252][1252];
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int bfs(int sy,int sx,int gy,int gx){
	queue<int> qy,qx,qdist;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)
		used[i][j]=false;
	qy.push(sy);
	qx.push(sx);
	qdist.push(0);
	used[sy][sx] = true;
	while(!qy.empty()){
		int y,x,dist;
		y = qy.front(); qy.pop();
		x = qx.front(); qx.pop();
		dist = qdist.front(); qdist.pop();
		if(gy==y && gx==x)return dist;
		for(int i=0;i<4;i++){
			int ny,nx,ndist;
			ny = y+dy[i];
			nx = x+dx[i];
			ndist = dist+1;
			if(ny<0 || ny>=h || nx<0 || nx>=w)continue;
			if(used[ny][nx])continue;
			if(mp[ny][nx]==1)continue;
			used[ny][nx] = true;
			qy.push(ny);
			qx.push(nx);
			qdist.push(ndist);
		}
	}
	return -1;
}

int main(){
	scanf("%d%d%d",&h,&w,&n);
	for(int i=0;i<h;i++){
		scanf("%s",s);
		for(int j=0;j<w;j++){
			mp[i][j] = (s[j]=='X'?1:0);
			if(s[j]!='X' && s[j]!='.'){
				if(s[j]=='S'){
					ys[0]=i;
					xs[0]=j;
				}else{
					ys[s[j]-'0']=i;
					xs[s[j]-'0']=j;
				}
			}
		}
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		ans += bfs(ys[i],xs[i],ys[i+1],xs[i+1]);
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }



typedef pair<ll, pair<ll, ll>> prr;
int main() {
    int n; cin >> n;
    string s; cin >> s;
    char now = 'X';
    int ans = 0;
    rep(i, n) {
        if(now != s[i]) {
            now = s[i];
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MAX_V 101
using namespace std;

/* ?????£?????????????§£ O(|V|+|E|) */
int V; //????????°
vector<int> G[MAX_V]; //??°???????????£??\??????????????¨???
vector<int> rG[MAX_V];//?????????????????????????????°??????
vector<int> vs;       //??°?????????????????????
bool used[MAX_V];     //?????§???????????????
int cmp[MAX_V];       //?±????????????£?????????????????????????????????

void add_edge(int from,int to){
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v){
  used[v]=true;
  for(int i=0;i<G[v].size();i++)if(!used[G[v][i]])dfs(G[v][i]);
  vs.push_back(v);
}

void rdfs(int v,int k){
  used[v]=true;
  cmp[v]=k;
  for(int i=0;i<rG[v].size();i++) if(!used[rG[v][i]])rdfs(rG[v][i],k);
}

int scc(){
  memset(used,0,sizeof(used));
  vs.clear();
  for(int v=0;v<V;v++) if(!used[v]) dfs(v);
  
  memset(used,0,sizeof(used));
  int k=0;
  for(int i=vs.size()-1;i>=0;i--)if(!used[vs[i]]) rdfs(vs[i],k++);
  return k;
}

double p[MAX_V];

int main(){
  while(cin>>V,V){
    for(int i=0;i<V;i++) G[i].clear(),rG[i].clear();
    
    for(int i=0,m;i<V;i++){
      cin>>p[i]>>m;
      for(int j=0,a;j<m;j++)cin>>a,add_edge(i,a-1);
    }
    int n=scc();
    vector<double> col(n,1);
    vector<bool> root(n,1);

    for(int i=0;i<V;i++){
      col[cmp[i]]*=p[i];
      for(int j=0;j<G[i].size();j++)
	if(cmp[G[i][j]]!=cmp[i]) root[cmp[G[i][j]]]=0;
    }
    double ans=1;
    for(int i=0;i<n;i++)if(root[i])ans*=1-col[i];
    printf("%.10f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 3300
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const ll maxn = 1e6 + 111;
const ll mod = 1e9 + 7;
int a[maxn];
int m = 0, p[maxn];
void divide(int n) {
    for (int i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            int cnt = 0;
            while (n % i == 0) n /= i, ++cnt;
            p[i]++;
        }
    }
    if (n > 1) p[n]++;
}
int main() {
    int n;
    scanf("%d", &n);
    int num = 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        divide(a[i]);
    }
    int tot = 0;
    int tot2 = 0;
    int flag1 = 0;
    for (int i = 1; i <= 1000000; ++i) {
        if (p[i] == 0) continue;
        if (p[i] != 1) flag1 = 1;
        if (p[i] == n) ++tot2;
    }
    if (!flag1) {
        puts("pairwise coprime");
    } else if (tot2 == 0) {
        puts("setwise coprime");
    } else {
        puts("not coprime");
    }
    return 0;
}

Measured memory_bytes: 11440
#include <cstdio>
#include <cmath>
#include <utility>

using namespace std;

using point=pair<double, double>;

int n;

void koch(int n, point &p1, point &p2)
{
    if(n){
        point s=make_pair((2*p1.first+p2.first)/3, (2*p1.second+p2.second)/3);
        point t=make_pair((p1.first+2*p2.first)/3, (p1.second+2*p2.second)/3);
        double xx=t.first-s.first, yy=t.second-s.second;
        point u=make_pair((xx-sqrt(3)*yy)/2+s.first, (sqrt(3)*xx+yy)/2+s.second);

        koch(n-1, p1, s);
        printf("%f %f\n", s.first, s.second);
        koch(n-1, s, u);
        printf("%f %f\n", u.first, u.second);
        koch(n-1, u, t);
        printf("%f %f\n", t.first, t.second);
        koch(n-1, t, p2);
    }
}

int main()
{
    int n;
    scanf("%d", &n);
    point p1=make_pair(0, 0), p2=make_pair(100, 0);
    printf("%f %f\n", p1.first, p1.second);
    koch(n, p1, p2);
    printf("%f %f\n", p2.first, p2.second);
    return 0;
}

Measured memory_bytes: 2676
#include <iostream>
#include <cstdlib>
using namespace std;
struct Node{
    int key;
    Node *p,*l,*r;
};
Node *root,*NIL;
void insert(int key){
    Node *y = NIL;//根节点的父节点
    Node *x = root;//根节点
    Node *z = (Node *)malloc(sizeof(Node));
    z->key = key;
    z->l = NIL;
    z->r = NIL;
    while(x!=NIL){
        y = x;//记录key的父节点
        if(z->key<x->key){
            x = x->l;//寻找key的父节点
        }else{
            x = x->r;
        }
    }
    z->p = y;
    if(y == NIL){
        root = z;
    }else if(y->key<z->key){//决定是左儿子还是右二子
        y->r = z;
    }else{
        y->l = z;
    }
}
void preTW(Node *u){
    if(u!=NIL){
        cout<<" "<<u->key;
        preTW(u->l);
        preTW(u->r);
    }
}
void inTW(Node *u){
    if(u!=NIL){
        inTW(u->l);
        cout<<" "<<u->key;
        inTW(u->r);
    }
}
void findx(int key){
    Node *x = root;
    while(x!=NIL){
        if(key == x->key){
            cout<<"yes"<<endl;
            return;
        }else if(key<x->key){
            x = x->l;
        }else{
            x = x->r;
        }
    }
    cout<<"no"<<endl;
}
int main()
{
    int n,key;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s=="insert"){
            cin>>key;
            insert(key);
        }else if(s=="print"){
            inTW(root);
            cout<<endl;
            preTW(root);
            cout<<endl;
        }else if(s=="find"){
            cin>>key;
            findx(key);
        }
    }

    return 0;
}



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

int main() {
    int N;
    cin >> N;
    bool a=0;
    for(int i=1; i<=9; i++){
        for(int j=1; j<=9; j++){
            if(i*j == N) {
                a=1;
                break;
            }
        }
    }
    if(a) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
X=int(input())
def is_prime(q,k=100):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    for i in range(3,k):
        x,y = q,i
        while y:
            x, y =  y, x % y
        if x != 1: continue
        if pow(i, q-1, q) != 1:
            return False
    return True
flag=False
while(flag==False):
    if is_prime(X):
        print(X)
        flag=True
        break
    X+=1

Measured memory_bytes: 3064
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    };
    if s[0].is_lowercase() {
        println!("a");
    } else {
        println!("A");
    }
}


Measured memory_bytes: 2168
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
using ll = long long;


int main(void)
{
    ll k, n;
    cin >> k >> n;

    vector<ll> houses(n);
    for (size_t i = 0; i < n; i++)
    {
        cin >> houses[i];
    }

    ll max_dist = houses[0] + k - houses[n - 1];
    for (size_t i = 0; i < n - 1; i++)
    {
        max_dist = max(houses[i + 1] - houses[i], max_dist);
    }

    cout << k - max_dist << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s= sc.next();
        int ans = 0;
        for (int i = 0 ; i < 4 ; i++) {
            String t = s.substring(i, i + 1);
            if (t.equals("+")) {
                ans++;
            } else {
                ans--;
            }
        }
        System.out.println(ans);

    }

}

Measured memory_bytes: 22868
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

class mod {
public:
    mod() {m_n = 0;}
    mod(ll n) {if (n >= 0) m_n = n % MOD; else m_n = n % MOD + MOD;}
    friend bool operator== (const mod& a, const mod& b) {return a.m_n == b.m_n;}
    friend bool operator!= (const mod& a, const mod& b) {return !(a == b);}
    friend mod operator+ (const mod& a, const mod& b) {return (a.m_n + b.m_n) % MOD;}
    friend mod& operator+= (mod& a, const mod& b) {return a = a + b;}
    friend mod operator- (const mod& a) {return -a.m_n;}
    friend mod operator- (const mod& a, const mod& b) {return (a.m_n + (-b.m_n)) % MOD;}
    friend mod& operator-= (mod& a, const mod& b) {return a = a - b;}
    friend mod operator* (const mod& a, const mod& b) {return (a.m_n * b.m_n) % MOD;}
    friend mod& operator*= (mod& a, const mod& b) {return a = a * b;}
    friend mod mod_pow(const mod& n, ll r) {
        if (r == 0) {
            return 1;
        } else if (r < 0) {
            return mod_pow(n, (MOD - 2) * (-r));
        } else if (r % 2 == 0) {
            mod tmp = mod_pow(n, r / 2);
            return tmp * tmp;
        } else {
            return n * mod_pow(n, r - 1);
        }
    }
    friend mod operator/ (const mod& a, const mod& b) {return a * mod_pow(b, -1);}
    friend mod& operator/= (mod& a, const mod& b) {return a = a / b;}
    friend ostream& operator<< (ostream& os, const mod& n) {os << n.m_n; return os;}
    friend istream& operator>> (istream& is, mod& n) {ll tmp; is >> tmp; n = mod(tmp); return is;}
private:
    ll m_n;
};
mod mod_pow(ll n, ll r) {return mod_pow(mod(n), r);}

#define FACT_MAX 1000000
mod t_fact[FACT_MAX], t_fact_inv[FACT_MAX];
mod fact(int n)
{
    if (n == 0 || n == 1) return t_fact[n] = 1;
    if (t_fact[n] != 0) return t_fact[n];
    else return t_fact[n] = n * fact(n-1);
}
mod fact_inv(int n)
{
    if (t_fact_inv[n] != 0) return t_fact_inv[n];
    else return t_fact_inv[n] = mod_pow(fact(n), -1);
}
mod comb(int n, int k) {if (n < 0 || k < 0 || k > n) return 0; else return fact(n) * fact_inv(n - k) * fact_inv(k);}
mod multi_choose(int n, int k) {return comb(n + k - 1, k);}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    for (int n = 0; n <= N; ++n) {
        fact(n); fact_inv(n);
    }
    
    vector<mod> DP(N+1);
    DP[0] = 1;
    for (int F = C; F*A <= N && F <= D; ++F) {
        DP[F*A] = mod_pow(t_fact_inv[A], F) * t_fact_inv[F];
    }
    for (int d = 1; d <= B-A; ++d) {
        for (int n = N; n >= 0; --n) {
            for (int  F = C; F*(A+d) <= n && F <= D; ++F) {
                DP[n] += DP[n-F*(A+d)] * mod_pow(t_fact_inv[A+d], F) * t_fact_inv[F];
            }
        }
    }
    cout << DP[N] * fact(N) << endl;

    return 0;
}


Measured memory_bytes: 15872
from itertools import product

n, m = map(int, input().split())
s = [None for _ in range(m)]

for i in range(m):
    s[i] = list(map(int, input().split()))

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

ans = 0
for tpl in product([0, 1], repeat=n):
    for i in range(m):
        cnt = 0
        is_on = True
        for j in range(s[i][0]):
            if tpl[s[i][j + 1] - 1] == 1:
                cnt += 1
        if cnt % 2 != p[i]:
            is_on = False
            break
    if is_on:
        ans += 1

print(ans)


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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	cin >> n;
	i64 ans = 0, sum = 0;
	rep(i, 0, n) {
		int a;
		cin >> a;
		if (a == 0) {
			ans += sum / 2;
			sum = 0;
		}
		sum += a;
	}
	ans += sum / 2;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main()
{
	ll int a;
		cin>>a;
		double b;
		cin>>b;
		ll int ans = a*(ll int)(100*b+0.5)/100;
		cout<<ans<<endl;
	return 0;
}


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

int main() {
	long long N;
	cin >> N;
	vector<long long> A(N);
	long long ans = 0, sumA = 0, cnt_neg = 0, min_abs = 1'000'000'000;
	for (long long i = 0; i < N; i++)
	{
		cin >> A[i];
		if (A[i] < 0) {
			cnt_neg++;
			sumA -= A[i];
		}
		else sumA += A[i];
		min_abs = min(abs(A[i]), min_abs);
	}

	if (cnt_neg % 2 == 0)
	{
		ans = sumA;
	}
	else
	{
		ans = sumA - 2 * min_abs;
	}

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


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
int main(){
    ll n;cin >> n;
    ll res=0;
    vl v=divisor(n);
    for(auto p:v){
        if(p==1)continue;
        if(n/(p-1)==n%(p-1))res+=p-1;
    }
    cout << res <<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi b(n, 0);
    vi ans;
    for (ll i = n-1; i >= 0; i--) {
        int now = 0;
        for (ll j = 1; (i+1) * j <= n; ++j) {
            now += b[(i+1)*j - 1];
        }
        if (now % 2 != a[i]) {
            b[i]++;
            ans.pb(i+1);
        }
    }
    int m = accumulate(b.begin(), b.end(), 0);
    cout << m << endl;
    rep(i, sz(ans)) {
        if (i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 3192
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	static String[] cards = new String[3];
	static int[] idxes = new int[3];
	
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		for (int i=0; i<3; i++) {
			String line = br.readLine();
			cards[i] = line;
		}
		int cur = 0;
		while (true) {
			if (idxes[cur] >= cards[cur].length()) {
				break;
			}
			char next = cards[cur].charAt(idxes[cur]);
			idxes[cur]++;
			cur = next - 'a';
		}
		String player = "ABC";
		System.out.println(player.charAt(cur));
	}

}


Measured memory_bytes: 8148
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  string s;
  cin >> s;
  rep(i, s.size()) {
    if (s[i] == s[i+1]) {
      cout << "Bad" << "\n";
      return 0;
    }
  }
    cout << "Good" << "\n";
    return 0;
}


Measured memory_bytes: 256
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/B-CakesAndDounuts.py
#

n = int(input())

for i in range(n//7+1):
    for j in range(n//4+1):
        if i*7 + j*4 == n:
            print("Yes")
            exit()

print("No")


Measured memory_bytes: 3064
require 'prime'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
require 'openssl'

n,k=gsmi
k=min(k,n-1)

prev=1
1.upto k do |i|
  prev=(prev*(n-i+1)*(n-i)*OpenSSL::BN.new(i**2).mod_inverse(MOD))%MOD
  sum+=prev
  sum%=MOD
end

puts (sum+1)%MOD

Measured memory_bytes: 5372
# coding: utf-8
import itertools

n = int(input())
s = [input() for i in range(n)]
s.sort()
grs = itertools.groupby(s)
ss = []
for key, group in grs:
    cnt = len(list(group))
    ss.append([cnt, key])
sss = sorted(ss)
maxn = sss[-1][0]

for w in sss:
    if w[0] == maxn:
        print(w[1])
        

Measured memory_bytes: 41556
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++) 
#define S(v) sort(v.begin(),v.end());

const ll mod = 1E9+7;

int main()
{
   ll n;
   cin>>n;
   map<string, ll> m;
   loop(i,0,n){
      string s;
      cin>>s;
      m[s]++;
   }
   cout<<"AC x "<<m["AC"]<<endl;
   cout<<"WA x "<<m["WA"]<<endl;
   cout<<"TLE x "<<m["TLE"]<<endl;
   cout<<"RE x "<<m["RE"]<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    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;
}
// End of template code!
int main() 
{
    buff();
    int n;
    cin >> n;
    vector< vi > nei(n);
    vector< pii > edges;
    rep(i, 0, n - 1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        edges.emplace_back(min(a,b),max(a,b));
    }
    sort(all(edges));
    for(const auto& e : edges) {
        nei[e.second].push_back(e.first);
    }
    long long resp = 0ll;

    for(int i = 0; i < n; ++i)
    {
        if( nei[i].empty() ) {
            // vou adicionar 1 em todo [L, R] com L <= i e R >= i
            long long tot_L = i + 1;
            long long tot_R = n - i;
            resp += (tot_L * tot_R);
        }
        else {
            int last_viz = nei[i].back();
            long long tot_R = n - i;
            long long tot_K = i - last_viz;
            resp += (tot_K * tot_R);
            int x = sz(nei[i]);
            for(int j = 0; j < x; ++j)
            {
                if(j == 0) {
                    long long tot_L = nei[i][j] + 1;
                    long long prev_cc = (x - j);
                    long long cur_cc = 1ll;
                    long long delta = prev_cc - cur_cc;
                    resp -= tot_L * tot_R * delta;
                }
                else {
                    long long tot_L = nei[i][j] - nei[i][j - 1];
                    long long prev_cc = (x - j);
                    long long cur_cc = 1ll;
                    long long delta = prev_cc - cur_cc;
                    resp -= (tot_L * tot_R * delta);
                }
            }
        }
    }
    cout << resp << '\n';
    
    return 0;
}



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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll n;
  cin >> n;

  vector<ll> a(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
  }

  ll l = a[0];
  ll r = 0;
  for (ll i = 1; i < n; ++i) {
    r += a[i];
  }

  ll ans = abs(l-r);
  for (ll i = 1; i < n-1; ++i) {
    l += a[i];
    r -= a[i];
    ans = min(ans, abs(l-r));
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  int N ;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int cnt_Alice = 0;
  int cnt_Bob = 0;
  for (int i = 0; i < vec.size(); i++) {
    if(i == 0 || i % 2 != 1){
      cnt_Alice = cnt_Alice + vec.at(i);
    }
    else{
      cnt_Bob = cnt_Bob + vec.at(i);
    }
  }
  cout << cnt_Alice - cnt_Bob << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


int main(void) {
    int i,j;
    int n;
    cin >> n;
    vi v(n);
    rep(i,n)cin >> v[i];
    sort(all(v));
    int ans = 0;
    rep(i,n-1)ans += v[i];
    cout << ans + v[n-1]/2 << endl;

}


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

int main(void){
  int n, a, b;
  cin >> n >> a >> b;
  int x[n];
  for(int i = 0; i < n; i++) cin >> x[i];
  long long ans = 0;
  for(int i = 1; i < n; i++){
    if(((long long)x[i] - x[i - 1]) * a > b) ans += b;
    else ans += a * (x[i] - x[i - 1]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
use std::io::{stdout, Write, BufWriter};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: chars,
    }

    let ans = n.windows(3).map(|s| (753 - s.iter().map(|c| *c).collect::<String>().parse::<i64>().unwrap()).abs()).min().unwrap();

    let out = stdout();
    let mut out = BufWriter::new(out.lock());

    writeln!(out, "{}", ans).unwrap();
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
	int m, n;
	int i, j, k, c;
	
	while (scanf("%d", &m), m != 0){
		scanf("%d", &n);
		c = 0;
		for (i = 1; i <= 1000000; i *= 2){
			for (j = 1; i * j <= 1000000; j *= 3){
				for (k = 1; i * j * k <= 1000000; k *= 5){
					if (m <= i * j * k && i * j * k <= n){
						c++;
					}
				}
			}
		}
		printf("%d\n", c);
	}
	return (0);
}

Measured memory_bytes: 600
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include<bits/stdc++.h>
using namespace std ;

using ll = long long ;

class ACookieExchanges {
public:
	void solve(std::istream& cin, std::ostream& cout) {
	    int a , b , c ;
	    cin >> a >> b >> c ;
	    int x = a  , y  = b , z = c ;
	    int ans = 0 ;
	    int ok = true ;
	    while(x % 2 == 0 && y % 2 == 0 && z % 2 == 0){
	        x = (a / 2) + (b / 2);
	        y =  (a / 2) + (c / 2) ;
	        z = (b / 2) + (c / 2) ;
	        if(a == x && b == y && c == z) {
	            ok = false ;
	            break ;
	        }
	        a = x ;
	        b = y ;
	        c = z ;

	        ans++ ;
	    }
	    if(ok){
	        cout << ans ;
	    }else{
	        cout << -1 ;
	    }

	}
};



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	ACookieExchanges solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

typedef long long ll;

int N;
ll sum;
vector<int> A;
map<int, int> M;

void input_init(void) {
	cin >> N;
	A.resize(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		++(M[A[i]]);
	}
}

void calcu(void) {
	sum = (ll)0;
	map<int, int>::iterator itr;
	for (itr = M.begin(); itr != M.end(); ++itr) {
		int cnt = itr->second;
		sum += (ll)cnt * (cnt - 1) / 2;
	}
}

void solve(void) {
	for (int i = 0; i < N; ++i) {
		int cnt = M[A[i]];
		ll ans = sum - (ll)(cnt - 1);
		cout << ans << '\n';
	}
}

int main(void) {
	input_init();
	calcu();
	solve();
	return 0;
}


Measured memory_bytes: 8320
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Char
import           Data.Maybe
import qualified Data.Vector           as V

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

getIntVec n = V.unfoldrN n (BS.readInteger . BS.dropWhile isSpace) <$> BS.getLine

main = do
  n <- getInt
  as <- getIntVec n
  let m = V.foldr lcm 1 as
      as' = V.map (\i -> m `div` i) as
  print $ (sum as') `mod` 1000000007

Measured memory_bytes: 8572
#include<iostream>
#include<map>

using namespace std;

map<char,int> mp;

int main ()
{
    int n,i;
    char c;

    cin>>n;

    for(i=0;i<n;i++)
    {
        cin>>c;
        mp[c]++;
    }

    if(distance(mp.begin(),mp.end())==3)cout<<"Three"<<endl;
    else cout<<"Four"<<endl;

    return 0;
}


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

int main() {
    string S;
    int Q;
    cin >> S >> Q;
    string T;
    rep(i, Q) {
        int a;
        cin >> a;
        if (a == 1) swap(S, T);
        else {
            int b;
            char c;
            cin >> b >> c;
            if (b == 1) {
            T += c;
            } else {
                S += c;
            }
        }
    }
    reverse(T.begin(), T.end());
    T += S;
    cout << T << endl;
}

Measured memory_bytes: 1128
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 

bool isrl[100000];
int dis_nextRL[100000];//R of RL
int dis_prevRL[100000];//L of RL
int ans[100000];
int main(){
  string s;
  cin >> s;
  int n = s.size();
  int t = 0;
  vi rlpos;
  while(1){
    if(t >= s.size()) break;
    if(s[t] == 'R' && s[t+1] == 'L'){
      rlpos.pb(t);
      isrl[t] = true;
      isrl[t+1] = true;
      t+=2;
    }else{
      isrl[t] = false;
      t+=1;
    }
  }

  int tmp = 0;
  REP(i, n){
    if(isrl[i]){
      dis_prevRL[i] = 0;
      tmp = i;
    }else{
      dis_prevRL[i] = i - tmp;
    }
  }

  tmp = n - 1;
  for(int i = n - 1; i >= 0; i--){
    if(isrl[i]){
      dis_nextRL[i] = 0;
      tmp = i;
    }else{
      dis_nextRL[i] = tmp - i;
    }
  }

  REP(i, n) ans[i] = 0;
  REP(i, n){
    if(isrl[i]){
      ans[i]++;
    }else if(s[i] == 'R'){
      //gu - ki = ki
      //gu - gu = gu
      int loopRLpos = i + dis_nextRL[i];
      if(dis_nextRL[i]%2==0) ans[loopRLpos]++;
      else ans[loopRLpos+1]++;
    }else{
      //L
      int loopRLpos = i - dis_prevRL[i];
      if(dis_prevRL[i]%2==0) ans[loopRLpos]++;
      else ans[loopRLpos-1]++;
    }
  }

  REP(i, n){
    cout << ans[i];
    if(i != n - 1) cout << " ";
    else cout << endl;
  }
}

Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    int s = 0;
    cin >> n;
    for (int i=0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        s += r-l+1;
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	unsigned long long a,b,n=0,t;
	cin>>a>>b;
	t=b;
	while(t!=0)
	{
		t/=10;
		n++;
	}
	b+=(pow(10,n)*a);
	if((int)(sqrt(b))*(int)(sqrt(b))==b)
		cout<<"Yes";
	else
		cout<<"No";
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N,i;
    cin>>N>>i;
    cout<<N-i+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,a;
vector<int> v;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        if(v[i]==v[i+1]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
char a[100];
int main()
{
    cin>>a;
    for(int i=0; i<strlen(a); i++)
    {
    	if(a[i]==',') printf(" ");
    	else printf("%c", a[i]);
	}
	cout<<endl;
    return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <math.h>
#include <utility>


long long modpow(long long x, long long y, long long m)
{
  long long res = 1;
  for(long long i = 0; i < y; ++i)
  {
    res = res * x % m;
  }
  
  return res;
}

int main()
{
  std::string s;  
  std::cin >> s;
   
  long long m = 1000000007;
  long long minv27 = 370370373;
 
  size_t n = s.size();
  long long factor[n];
  
  long long f = 0;
  size_t q = 0;
  for(int i = 0; i < n; ++i)
  {
    factor[i] = f;
    switch(s[i])
    {
      case 'A':
        {
          f += 3;
          break;
        }
      case '?':
        {
          f += 1;
          ++q;
          break;
        }
    }
  }
  
  f = 0;
  for(int i = n - 1; i >= 0; --i)
  {
    factor[i] *= f;
    switch(s[i])
    {
      case 'C':
        {
          f += 3;
          break;
        }
      case '?':
        {
          f += 1;
          break;
        }
    }
  }
  
  long long total = 0;
  for(int i = 0; i < n; ++i)
  {
    switch(s[i])
    {
      case 'B':
        {
          total += (3 * factor[i]) % m;
          break;
        }
      case '?':
        {
          total += (1 * factor[i]) % m;
          break;
        }
    }
  }
  
  total = (total % m) * modpow(3, q, m) % m * minv27 % m;
  
  std::cout << total;
  
  return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
struct bar{int h,p,q; bool operator>(const bar &b)const{return h>b.h;}};
int main(){
	while(true){
		int n,m,a;
		vector<bar> vbars;
		cin>>n>>m>>a;
		if(n==0&&m==0&&a==0)break;

		for(int i = 0; i < m; ++i){
			bar b;
			cin>>b.h>>b.p>>b.q;
			vbars.push_back(b);
		}
		sort(vbars.begin(),vbars.end(),greater<bar>());
		for(unsigned int i = 0; i < vbars.size(); ++i){
			if( vbars[i].p == a ){
				a = vbars[i].q;
			}else if( vbars[i].q == a ){
				a = vbars[i].p;
			}
		}
		cout << a << endl;
	}
	return 0;
}



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

int main(){
	int N, i, j;
	int A[3][3];
	for(i = 0; i < 3; i++){
		for(j = 0; j < 3; j++){
			scanf("%d", &A[i][j]);
		}
	}
	scanf("%d", &N);
	while(N--){
		int b;
		scanf("%d", &b);
		for(i = 0; i < 3; i++){
			for(j = 0; j < 3; j++){
				if(A[i][j] == b){
					A[i][j] = 0;
				}
			}
		}
	}
	for(i = 0; i < 3; i++){
		int f = 1;
		for(j = 0; j < 3; j++){
			if(A[i][j] > 0){
				f = 0;
			}
		}
		if(f == 1){
			printf("Yes\n");
			return 0;
		}
	}
	for(i = 0; i < 3; i++){
		int f = 1;
		for(j = 0; j < 3; j++){
			if(A[j][i] > 0){
				f = 0;
			}
		}
		if(f == 1){
			printf("Yes\n");
			return 0;
		}
	}
	if(A[0][0] + A[1][1] + A[2][2] == 0 || A[0][2] + A[1][1] + A[2][0] == 0){
		printf("Yes\n");
		return 0;
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
def cc106
    s = gets.chomp
    k = gets.chomp.to_i

    if s.length == 1
        puts s
        exit
    end

    if k == 1
        puts s[0]
        exit
    end

    if s.split(//).uniq.length == 1
        puts s[0]
        exit
    end

    # 先頭から連続する１の件数を取得
    c1 = 0
    s.each_char do |c|
        if c == '1'
            c1 += 1
        else
            break
        end
    end

    if k <= c1
        puts 1
        exit
    end

    puts s[c1]
end

cc106

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

int main() {
  int N;
  cin >> N ;
  
  vector<int> A(N);
  vector<int> dp(1000000+1);
  rep (i, N)
  {
    cin >> A.at(i);
  }
  rep (i, N)
  {
    if (dp.at(A.at(i)) > 1)
    {
      continue;
    }
    
    int tmp = A.at(i);
    while (tmp <= 1000000)
    {
      dp.at(tmp)++; 
      tmp += A.at(i);
    }
  }
  int count = 0;
  rep (i, N)
  {
    //cout << A.at(i) << ' ' << dp.at(A.at(i)) << endl;
    if (dp.at(A.at(i)) == 1)
    {
      count++;
    }
  }
  cout << count << endl;

  
}

Measured memory_bytes: 7912