akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
using ll =long long;
using namespace std;

struct coordinate{
    double x,y;
};
struct line{
    coordinate p,q;
};
struct triangle{
    coordinate s,u,t;
};
triangle kochCurve(line l){
    triangle ret;
    ret.s.x=l.p.x+(l.q.x-l.p.x)/3;
    ret.s.y=l.p.y+(l.q.y-l.p.y)/3;
    ret.t.x=l.p.x+2*(l.q.x-l.p.x)/3;
    ret.t.y=l.p.y+2*(l.q.y-l.p.y)/3;
    ret.u.x=(ret.t.x-ret.s.x)*cos(M_PI/3)-(ret.t.y-ret.s.y)*sin(M_PI/3)+ret.s.x;
    ret.u.y=(ret.t.x-ret.s.x)*sin(M_PI/3)+(ret.t.y-ret.s.y)*cos(M_PI/3)+ret.s.y;
    return ret;
}

void koch(int n,line l){
    if(n==0){
        return;
    }
    triangle ret=kochCurve(l);
    line temp;
    temp.p=l.p,temp.q=ret.s;
    koch(n-1,temp);
    cout<<fixed<<setprecision(6)<<ret.s.x<<" "<<ret.s.y<<endl;
    temp.p=ret.s,temp.q=ret.u;
    koch(n-1,temp);
    cout<<fixed<<setprecision(6)<<ret.u.x<<" "<<ret.u.y<<endl;
    temp.p=ret.u,temp.q=ret.t;
    koch(n-1,temp);
    cout<<fixed<<setprecision(6)<<ret.t.x<<" "<<ret.t.y<<endl;
    temp.p=ret.t,temp.q=l.q;
    koch(n-1,temp);
    
}
int main(){
    int n;
    cin>>n;
    line l;
    l.p.x=0.0;
    l.p.y=0.0;
    l.q.x=100.0;
    l.q.x=100.0;
    cout<<fixed<<setprecision(6)<<l.p.x<<" "<<l.p.y<<endl;
    koch(n,l);
    cout<<fixed<<setprecision(6)<<l.q.x<<" "<<l.q.y<<endl;
}


Measured memory_bytes: 3284
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int r = 0;
	for (int i = 0; i < n; ++i)
	{
		r += (s[i] == 'R');
	}
	if (r == 0 || r == n)
		cout << 0 << '\n';
	else
	{
		int ans = 0;
		for (int i = 0; i < r; ++i)
		{
			ans += (s[i] == 'W');
		}
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 3744
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

main = do
  n <- readLn :: IO Int
  as <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine :: IO [Int]
  print $ solve as

solve :: [Int] -> Int


solve (a:b:c:as)
  | a < b && b < c = 1 + solve (b:c:as)
  | a > b && b > c = 1 + solve (b:c:as)
  | otherwise = solve (b:c:as)

solve a = 0

Measured memory_bytes: 3928
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


H,W = MI()
a = [LS2() for _ in range(H)]

from collections import defaultdict

d = defaultdict(int)
for i in range(H):
    for j in range(W):
        d[a[i][j]] += 1

if H % 2 == 0 and W % 2 == 0:
    for key in d.keys():
        if d[key] % 4 != 0:
            print('No')
            exit()
    print('Yes')

if H % 2 == 0 and W % 2 != 0:
    H,W = W,H

if H % 2 != 0 and W % 2 == 0:
    a = 0
    for key in d.keys():
        if d[key] % 2 != 0:
            print('No')
            exit()
        elif d[key] % 4 != 0:
            a += 1
    if a <= W//2:
        print('Yes')
        exit()
    else:
        print('No')
        exit()

if H % 2 != 0 and W % 2 != 0:
    a,b = 0,0
    for key in d.keys():
        if d[key] % 4 == 1:
            a += 1
        elif d[key] % 4 == 3:
            a += 1
            b += 1
        elif d[key] % 4 == 2:
            b += 1
    if a <= 1 and b <= H//2 + W//2:
        print('Yes')
        exit()
    else:
        print('No')
        exit()


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

using int64 = long long;

int64 getCounter(vector<int64>& parent, vector<int64>& counter, int64 k) {
  if (parent[k] < 0)
    return counter[k];
  int64 p = parent[k];
  parent[k] = -1;
  return counter[k] += getCounter(parent, counter, p);
}

int main() {
  int64 n, q;
  cin >> n >> q;
  vector<int64> parent(n, -1);
  vector<int64> counter(n, 0);
  for (int64 i = 0; i < n - 1; ++i) {
    int64 a, b;
    cin >> a >> b;
    parent[b - 1] = a - 1;
  }
  for (int64 i = 0; i < q; ++i) {
    int64 p, x;
    cin >> p >> x;
    counter[p - 1] += x;
  }
  for (int64 i = 0; i < n; ++i) {
    if (i)
      cout << " ";
    cout << getCounter(parent, counter, i);
  }
  cout << "\n";

  return 0;
}


Measured memory_bytes: 5504
// abc132c.cpp : Divide the Problems
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

#define rep(i,n) for(int i=0;i<(n);i++)
#define in(x) cin>>(x)
#define oute(x) cout<<(x)<<endl

int main(){
  int N; in(N);
  vi D(N); rep(i,N) in(D[i]);
  sort(D.begin(), D.end());
  oute(D[N/2] - D[N/2-1]);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define vii vector<int>
#define task "RESORT"
#define pll pair<int, int>
#define fi first
#define se second
using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;
const int N = 1000005;
ll n, m, a[N], k, tong, t, d[N];
ll ans;
void dfs(int i, int j, ll tong)
{
    ans = max(ans, tong + d[(i-1) * m + j]);
    if(i > 1 && a[(i-2)*m+j] > a[(i-1)*m+j])
        dfs(i-1, j, tong + d[(i-1) * m + j]);
    if(j > 1 && a[(i-1)*m+j-1] > a[(i-1)*m+j])
        dfs(i, j-1, tong + d[(i-1) * m + j]);
    if(i < n && a[(i)*m+j] > a[(i-1)*m+j])
        dfs(i+1, j, tong + d[(i-1) * m + j]);
    if(j < m && a[(i-1)*m+j+1] > a[(i-1)*m+j])
        dfs(i, j+1, tong + d[(i-1) * m + j]);
}
unsigned long long  mn;
inline void sol()
{
	cin >> n;
	ans = 1;
	ll mx = 1e18;
	for(int i = 1; i <= n; i ++)
    {
        cin >> a[i];
    }
    sort(a+1, a+1+n);
    for(int i = 1; i <= n; i ++)
    {
        if(a[i] != 0)
        {
            if(ans > mx / a[i] )
            {
                k = mx / a[i];
                if(ans - 1 == mx)
                {
                    if(ans * a[i] > mx)
                    {
                        ans = -1;
                        break;
                    }
                }
                else
                {
                    ans = -1;
                    break;
                }

            }
        }

        ans *= a[i];
    }
    cout << ans;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen(task".INP", "r"))
    {
		freopen(task".INP","r",stdin);
		freopen(task".OUT","w",stdout);
    }
	sol();
}










Measured memory_bytes: 4452
import time
N = int(input())
L = list(map(int, input().split()))

L = sorted(L)

# print(L)

# 三角形なのでa>b>cになるように選べば, a+b>cとなる
ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        # print("i:{}, j:{}".format(i, j))
        b = L[j]
        left = j+1
        right = N-1
        c = L[N-1]
        if a+b>c:
            # print("true - k:{}".format(N-1))
            # print("num_c:{}".format())
            ans += N-j-1
        else:
            mid = right
            while left < right:
                if mid == (left+right)//2:
                    break
                mid = (left+right)//2
                # print("left:{}, mid:{}, right:{}".format(left, mid, right))
                c = L[mid]
                if a+b>c:
                    left = mid
                else:
                    right = mid
                # time.sleep(0.05)
            # print("false - k:{}".format(mid))
            if a+b>c:
                # print("a+b>c:{}".format(True))
                ans += mid - j
            else:
                # print("a+b>c:{}".format(False))
                ans += mid - j - 1
        # print("ans of ({},{}): {}".format(i,j,ans))

print(ans)


Measured memory_bytes: 45016
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█  
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {
    
    lld n; cin >> n;
    double jp = 0, bt = 0;
    for4(i, 0LL, n, 1LL) {
        double val; string s; 
        cin >> val >> s;
        if (s == "JPY") jp += val;
        else bt += val;
    }
    double ans = jp + 380000.0 * bt;

    cout << ans;



    cout << "\n"; 

    return;
}


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

    lld T3X0 = 0, T353 = 1;

    // TESTCASES() 
        solveEachTest(T353 - T3X0);
    return 0;
}
// Random Thought : numb on binarysearch  

Measured memory_bytes: 3836
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define vci vector<ll>
#define vcs vector<string>
#define vcp vector<pair<ll, ll>>
#define vct vector<tuple<ll, ll, ll>>
using namespace std;
//vector<vector<ll>> vv(n, vector<ll>(n));

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll x = max(a, c), y = min(b, d);
	cout << max(0LL, y - x) << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
  int n,i;
  double sum=0;
 
  scanf("%d",&n);
  double x[n];
  char u[n][4];
  
  for(i=0;i<n;i++){
    
    scanf("%lf %s",&x[i],u[i]);
    
    if(u[i][0]=='B')
      x[i]=x[i]*380000;
    sum=sum+x[i];
  }
 
  printf("%f",sum);
 
  return 0;
}
  

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

ll dp[110][100100];
	
int main(){
	ll n, wc; cin >> n >> wc;
	vector<ll> w(n+1, 0);
	vector<ll> v(n+1, 0);
	for( int i = 1; i <= n; ++i ){
		cin >> w[i] >> v[i];
	}
	for( int i = 0; i < 110; ++i ){
		for( int j = 1; j < 100100; ++j ){
			dp[i][j] = INF;
		}
	}
	ll sum = 0;
	for( ll i = 1; i <= n; ++i ){
		sum += v[i];
		for( ll j = 1; j <= sum; ++j ){
			dp[i][j] = dp[i-1][j];
			if( j >= v[i] ){
				dp[i][j] = min( dp[i][j], dp[i-1][j-v[i]] + w[i] ); 
			}
		}
	}
	int ans = 0;
	for( int i = sum; i > 0; --i ){
		if( dp[n][i] <= wc ){
			ans = max(ans, i);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 86400
n = int(input())
a = input().split(" ")
odds = a[1::2]
evens = a[0::2]
if (n%2)==0:
    odds.reverse()
    ans = odds + evens
    print(' '.join(ans))
else:
    evens.reverse()
    ans = evens + odds
    print(' '.join(ans))

Measured memory_bytes: 26436
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Digits
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int c = 0;
  while (n > 0) n /= k, c++;

  printf("%d\n", c);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;

int main() {
	int N;
	cin >> N;
	
	int a, b;
	string str;
	vector<pair<string, int> > p(N) ;
	for(int i = 0; i < N; ++i) {
		cin >> str >> a;
		b = 101 - a;
		stringstream ss;
		ss << bitset<8>(b);
		str = str + ss.str();
		p[i] = make_pair(str, i + 1); 
	}
	sort(p.begin(), p.end());
	for(int i = 0; i < N; ++i) {
		cout << p[i].second << endl;
	}
}



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

int main(){
    while(1){
        string g;
        cin >> g;
        if(g=="#"){
            break;
        }

        int y,m,d;
        cin >> y >> m >> d;


        if((y==31&&m>=5)||(y>=32)){
            cout << "? " << y-30 << " " << m << " " << d << endl;
        }else{
            cout << g << " " << y << " " << m << " " << d << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3112
use std::cmp;
use proconio::{input,fastout};

#[fastout]
fn main() {
    input! {
        n: i32,
        k: i32,
    }
    let mut ans = 1;
    for _ in 0..n {
        ans = cmp::min(ans+k, ans*2);
    }
    println!("{}", ans);
}

Measured memory_bytes: 2172
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    REP(i, N) {
        if (A[i] % 2 == 0) {
            if (A[i] % 3 && A[i] % 5) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}


Measured memory_bytes: 256
// Problem : C - Linear Approximation
// Contest : AtCoder Regular Contest 100
// URL : https://atcoder.jp/contests/arc100/tasks/arc100_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()

const int N = 1e6 + 1, mod = 1e9 + 7, inf = 2e9;

int n, a[N];
ll ans = 0;

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] -= i;
	}
	sort(a + 1, a + n + 1);
	int m = a[n >> 1];
	for (int i = 1; i <= n; i++) {
		ans += abs(a[i] - m);
	}
	m = a[n / 2 + 1];
	ll res = 0;
	for (int i = 1; i <= n; i++) {
		res += abs(a[i] - m);
	}
	ans = min(ans, res);
	cout << ans;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int a,b,ans;
int main(void){
    while(1){
        ans=0;
        cin>>a>>b;
        if(a==0&&b==0)return 0;
        for(int i=1;i<=a;i++){
            for(int j=i+1;j<=a;j++){
                for(int k=j+1;k<=a;k++){
                    if(i+k+j==b)ans++;
                }
            }
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3112
from math import tan, radians
a,b,x=map(int,input().split())
def f(d):
    if a*tan(radians(d))<b:
        return a*(a*b-a**2*tan(radians(d))/2)-x
    else:
        return a*b**2/2/tan(radians(d))-x
ld,rd=0,90-1e-6
while rd-ld>10**(-7):
    md=(rd+ld)/2
    if f(md)>0:
        ld=md
    else:
        rd=md
print(md)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << a[k-1] << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
long long X;
cin>>X;
long long num=0;
long long cur=100;
while(cur<X){
    cur*=1.01;
    num+=1;
}

cout<<num<<"\n";
return 0;
}



Measured memory_bytes: 3596
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-05-19 20:12:22
---------------------------------*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int main(int argc, char const *argv[])
{
	int n, k;
	cin >> n >> k;
	int m = 1<<n;
	if(k >= m)	cout << -1 << endl;
	else if(k == 0){
		for(int i = 0; i < m; ++i){
			cout << i << ' ' << i << ' ';
		}
		cout << endl;
	} else if(n != 1){
		for(int i = m -1; i >= 0; --i){
			if(i == k)	continue;
			cout << i << ' ';
		}
		cout << k << ' ';
		for(int i = 0; i <m; ++i){
			if(i == k)	continue;
			cout << i << ' ';
		}
		cout << k << endl;
	} else	cout << -1 << endl;
	return 0;
}

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

int main() {
    int N,W;
    int w1;
    cin>>N>>W;
    
    vector<int> st[4];
    for(int i=0;i<N;i++){
        int w,v;
        cin>>w>>v;
        if(i==0) w1=w;
        st[w-w1].push_back(v);
    }
    for(int i=0;i<4;i++){
        sort(begin(st[i]),end(st[i]));
        st[i].push_back(0);
        reverse(begin(st[i]),end(st[i]));
        for(int j=1;j<st[i].size();j++){
            st[i][j]+=st[i][j-1];
        }
    }
    int ret=0;
    
    for(ll i=0;i<st[0].size();i++){
        for(ll j=0;j<st[1].size();j++){
            for(ll k=0;k<st[2].size();k++){
                for(ll l=0;l<st[3].size();l++){
                    ll fact=w1*i+(w1+1)*j+(w1+2)*k+(w1+3)*l;
                    if(fact<=W){
                        ret=max(ret,st[0][i]+st[1][j]+st[2][k]+st[3][l]);
                    }
                }
            }
        }
    }
    cout<<ret<<endl;
}

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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(M);
  rep(i,M)cin >> A.at(i);
  int sum=0;
  rep(i,M) sum+=A.at(i);
  if(N>=sum) cout << N-sum;
  else cout << -1;
  return 0;
}


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

#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
typedef pair<ll,ll> pll;

const ll MX = 1e18;
int n;
ll ans;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    ans = 1;
    bool good = 1;
    for (int i = 1; i <= n; i++)
    {
        ll x;
        cin >> x;
        if (x == 0)
        {
            cout << "0\n";
            return 0;
        }
        if (ans > MX/x)
            good = 0;
        ans *= x;
    }
    cout << (good ? ans : -1) << '\n';
    return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
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;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int N,A;cin>>N>>A;
    int dp[N+1][2501];
    REP(i,N+1)REP(j,2501)dp[i][j]=0;
    dp[0][0]=1;
    REP(i,N){
        int x;cin>>x;
      	RREP(k,N){
          	REPS(j,2500){
            	if(j-x<0)continue;
            	dp[k+1][j]+=dp[k][j-x];
            }
        }
    }
    int ans=0;
    REPS(i,N){
        ans+=dp[i][A*i];
    }
  	cout<<ans<<endl;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

template< class Abel > class RMQ {
public:
  RMQ(int _n) {
    init(_n);
  }

  void init(int _n) {
    N = 1;
    while (N < _n) {
      // 頂点数を2のべき乗にする
      N <<= 1;
    }
    d.resize(2 * N - 1);
    for (int i = 0; i < 2 * N - 1; ++i) {
      d[i] = INF;
    }
  }

  void update(int k, Abel a) {
    // kの位置を葉まで移動
    k += N - 1;
    d[k] = a;
    // 頂点まで値を更新する
    while (k > 0) {
      k = (k - 1) / 2;
      d[k] = min(d[k * 2 + 1], d[k * 2 + 2]);
    }
  }

  // 呼び出しは[a, b)の!!!半開区間!!!
  Abel _query(int _a, int _b) {
    return query(_a, _b, 0, 0, N);
  }
  
  
private:
  int N;
  vector< Abel > d;

  // 呼び出しでミスをする可能性があるので、privateにしておく
  Abel query(int a, int b, int k, int l, int r) {
    // [a, b)に対して、[l, r)が範囲として成立していない
    if (!(a < r && l < b)) return INF;
    
    // [a, b)が[l, r)を完全にカバーしている(queryを再帰的に呼び出しても範囲は狭まるだけ)
    if (a <= l && r <= b) return d[k];
    
    // それ以外の時、葉の2つの子の最小値を再帰的に求める
    Abel vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    Abel vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(vl, vr);
  }
  
};

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

  CIN(N, L);
  RMQ< int > rmq(N + 1);

  // vector< int > a(N);
  REP(i, N) {
    CIN(a);
    rmq.update(i, a); 
  }

  REP(lb, N - L + 1) {
    cout << rmq._query(lb, lb + L);
    if (lb == N - L) cout << endl;
    else cout << " ";
  }
  
  return 0;
}




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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>

typedef long long ll;

int main() {
  int N, M;
  cin >> N;
  map<int, int> D_cnt, T_cnt;
  for (int i = 0; i < N; i++) {
    int d;
    cin >> d;
    D_cnt[d] = D_cnt[d] + 1;
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    int t;
    cin >> t;
    T_cnt[t] = T_cnt[t] + 1;
  }

  string ans = "YES";
  for (auto x : T_cnt) {
    if (D_cnt[x.first] < x.second) ans = "NO";
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 18944
n=int(input())
x= [list(map(int, input().split())) for i in range(n)]
ans="No"
for i in range(n-2):
    if (x[i][0]==x[i][1]) and (x[i+1][0]==x[i+1][1]) and (x[i+2][0]==x[i+2][1]):
        ans="Yes"
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#include <vector>
#include <map>
#include <cstring>
#include <set>
using namespace std;

typedef long long ll;

ll n, a[100005], rj;
ll dp[100005][2];

ll f(int p, int pr)
{
    if (p == n - 1)
        return a[n - 1] * (pr ? -1 : 1);
    if (dp[p][pr] != -1)
        return dp[p][pr];
    return dp[p][pr] = max(f(p + 1, 0) + a[p] * (pr ? -1 : 1),
                           f(p + 1, 1) - a[p] * (pr ? -1 : 1));
}

int main()
{
    memset(dp, -1, sizeof dp);
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    cout << f(0, 0) << endl;
}

Measured memory_bytes: 7296
a = list(input())
b = list(input())
c = list(input())
next = a.pop(0)
while True:
  if next == "a":
    if a == []:
      print("A")
      break
    else:
      next = a.pop(0)
  elif next == "b":
    if b == []:
      print("B")
      break
    else:
      next = b.pop(0)
  else:
    if c == []:
      print("C")
      break
    else:
      next =c.pop(0)

Measured memory_bytes: 9128
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
int main(){
    int s[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;

    
    
    
    cout << s[k - 1] << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC146 D

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

n = I()
graph = [[] for _ in range(n)]
edge = []
for i in range(n-1):
    a,b = LI()
    a -= 1
    b -= 1
    graph[a].append((b,i))
    graph[b].append((a,i))
    edge.append((a,b,i))

m = 0
for i in range(n):
    m = max(m,len(graph[i]))

print(m)
ans = [None]*(n-1)
que = deque()
que.append((0,0))
while que:
    v,color = que.popleft()
    cnt = 1
    for u,i in graph[v]:
        if ans[i] == None:
            if cnt != color:
                ans[i] = cnt
                que.append((u,cnt))
                cnt += 1
            else:
                ans[i] = cnt+1
                que.append((u,cnt+1))
                cnt += 2
print(*ans)



Measured memory_bytes: 84128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x = 0;
  int y = 0;
  
  while (a > 0){
    a -= d;
    x++;
  }
  
  while (c > 0){
    c -= b;
    y++;
  }
  
  if (x >= y){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
n = int(input())
a = [int(i) for i in str(input()).split(" ")]
b = [int(i) for i in str(input()).split(" ")]
c = [int(i) for i in str(input()).split(" ")]

r = 0
for i in range(n):
  r = r + b[a[i] - 1]
  if i != 0 and (a[i - 1] + 1) == a[i]:
    r = r + c[a[i] - 1 - 1]

print(r)

Measured memory_bytes: 3064
#include <cstdio>

long dist(long x, long y){
  return x*x+y*y;
}

int main(){
  long n, d;
  scanf("%ld%ld", &n, &d);
  long ans = 0;
  for(int i = 0; i < n; i++){
	long x, y;
    scanf("%ld%ld",&x, &y);
    if(dist(x, y) <= d*d){
      ans++;
    }
  }
  printf("%ld\n", ans);
}

Measured memory_bytes: 1708
import java.util.Scanner;

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

		long res=1;
		long wari=1000000007;


		int kaisu=sc.nextInt();


		for(int i=1; i<=kaisu; i++) {
			res*=i;
			res=res%wari;
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 21844
#include <stdio.h>

int a[100005];

int main(){
    int N, L;
    scanf("%d%d", &N, &L);
    for(int i=1; i<=N; i++) scanf("%d", &a[i]);
    for(int i=1; i<N; i++) if(a[i]+a[i+1] >= L){
        printf("Possible\n");
        for(int j=1; j<i; j++) printf("%d\n", j);
        for(int j=N-1; j>=i; j--) printf("%d\n", j);
        return 0;
    }
    printf("Impossible");
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000.0
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<double,int> P;

struct edge{int to, cap, rev; };

vector<edge> G[202];
int level[202];
int iter[202];

void init(){
	rep(i,202){
		G[i].clear();
		level[i] = 0;
		iter[i] = 0;
	}
}

void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to, cap, G[to].size()});
	G[to].push_back((edge){from, 0, G[from].size()-1});
}

void bfs(int s){
	memset(level,-1,sizeof(level));
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while(!que.empty()){
		int v = que.front(); que.pop();
		for(int i = 0; i < G[v].size(); i++){
			edge &e = G[v][i];
			if(e.cap > 0 && level[e.to] < 0){
				level[e.to] = level[v]+1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v, int t, int f){
	if(v == t) return f;
	for(int &i = iter[v]; i < G[v].size(); i++){
		edge &e = G[v][i];
		if(e.cap > 0 && level[v] < level[e.to]){
			int d = dfs(e.to, t, min(f,e.cap));
			if(d > 0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t){
	int flow = 0;
	for(;;){
		bfs(s);
		if(level[t] < 0) return flow;
		memset(iter,0, sizeof(iter));
		int f;
		while((f = dfs(s, t, INF)) > 0){
			flow += f;
		}
	}
}


int n, m;
double x[100], y[100], v[100];
double xx[100], yy[100];
vector<P> dis[202];

void solve(){
	rep(i,202) dis[i].clear();
	rep(i,n){
		cin >> x[i] >> y[i] >> v[i];
	}
	rep(i,m){
		cin >> xx[i] >> yy[i];
		rep(j,n){
			double dist = (sqrt(pow(xx[i]-x[j],2)+pow(yy[i]-y[j],2)))/v[j];
			dis[j+1].push_back(P(dist,100+i+1));
		}
	}
	double st = 0.0, en = 1000000000.0, mid;
	rep(u,100){
		mid = (st+en)/2;
		init();
		rep(i,n) add_edge(0,i+1,1);
		rep(i,m) add_edge(100+i+1,201,1);
		rep(i,202){
			rep(j,dis[i].size()){
				P p = dis[i][j];
				if(p.first > mid) continue;
				add_edge(i,p.second,1);
			}
		}
		if(m <= max_flow(0,201)) en = mid;
		else st = mid;
	}
	
	
	printf("%.9f\n", st);
}

int main(){
	while(cin >> n >> m){
		if(n == 0 && m == 0) break;
		solve();
	}
}

Measured memory_bytes: 1784
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int H, W;

char mp[505][505], A[505][505], B[505][505];

int main() {
  scanf("%d%d", &H, &W);
  for (int i = 1; i <= H; ++i)
    scanf("%s", mp[i] + 1);
  for (int i = 1; i <= H; ++i)
    for (int j = 1; j <= W; ++j)
      A[i][j] = B[i][j] = '.';
  for (int i = 1; i <= H; ++i) {
    A[i][1] = '#', B[i][W] = '#';
    if (i & 1) {
      for (int j = 2; j < W; ++j) A[i][j] = '#';
    } else {
      for (int j = 2; j < W; ++j) B[i][j] = '#';
    }
  }

  for (int i = 1; i <= H; ++i)
    for (int j = 1; j <= W; ++j)
      if (mp[i][j] == '#') {
	if (!(i & 1)) A[i][j] = '#';
	else B[i][j] = '#';
      }

  for (int i = 1; i <= H; ++i)
    printf("%s\n", A[i] + 1);
  puts("");
  for (int i = 1; i <= H; ++i)
    printf("%s\n", B[i] + 1);
  
  return 0;
}


Measured memory_bytes: 1408
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int N = s.length();
        int M = t.length();
        int[][] dp = new int[N + 1][M + 1];
        int[][] prevI = new int[N + 1][M + 1];
        int[][] prevJ = new int[N + 1][M + 1];

        for (int i = 1; i < N + 1; i++) {
            for (int j = 1; j < M + 1; j++) {
                if (dp[i-1][j] >= dp[i][j-1]) {
                    dp[i][j] = dp[i-1][j];
                    prevI[i][j] = i - 1;
                    prevJ[i][j] = j;
                } else {
                    dp[i][j] = dp[i][j-1];
                    prevI[i][j] = i;
                    prevJ[i][j] = j-1;
                }
                if (s.charAt(i - 1) == t.charAt(j - 1)) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                    prevI[i][j] = i-1;
                    prevJ[i][j] = j-1;
                }
            }
        }
        List<Character> ansList = new ArrayList<>();
        int n = N - 1;
        int m = M - 1;
        int len = 0;
        while (n >= 0 && m >= 0 && len < dp[N][M]) {
            int pi = prevI[n+1][m+1];
            int pj = prevJ[n+1][m+1];
            if (pi == n && pj == m) {
                ansList.add(s.charAt(n));
            } 
            n = pi-1;
            m = pj-1;
        }
        Collections.reverse(ansList);
        StringBuilder sb = new StringBuilder();
        for (Character c : ansList) {
            sb.append(c);
        }
        String ans = sb.toString();
        System.out.println(ans);
    }
}

Measured memory_bytes: 169292
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1e9+1
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  vector<double>A(n);
  for (int i = 0; i < n; ++i)
  {
   int a;
   cin >> a;
   A[i] = 1.0/a;
  }
  double ans = 0.0;
  for (int i = 0; i < n; ++i)
  {
    ans += A[i];
  }
  cout << 1.0/ans << endl;
	return 0;
}	

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

ll a,b,c,d,e,f;

int main(){
	cin.sync_with_stdio(false);
	cin>>a>>b>>c>>d>>e>>f;
	ll resa=0,resb=0;
	resa+=b;
	resb+=b;
	if(a>0&&d>0&&e>0){
		resa+=3;
		resa+=floor((a-1)/2)*2;
		resa+=floor((d-1)/2)*2;
		resa+=floor((e-1)/2)*2;
	}
	resb+=floor(a/2)*2;
	resb+=floor(d/2)*2;
	resb+=floor(e/2)*2;
	cout<<max(resa,resb)<<endl;
	return 0;
}


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

using namespace std;

int main(){
    int x,y,s;
    while(cin>>x>>y>>s,x){
        int ans=0;
        for(int i=1;i<=s-1;++i){
            for(int j=i;j<=s-1;++j){
                if(i*(100+x)/100+j*(100+x)/100==s)ans=max(ans,i*(100+y)/100+j*(100+y)/100);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3096
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n, k;
    string s;
    cin >> n >> s >> k;
    -- k;

    for(int i=0; i<n; ++i){
        if(s[i] != s[k])
            s[i] = '*';
    }
    cout << s << endl;

    return 0;
}


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

public class Main {
	static int a, b, c;

	public static void main(String[] args) {
		try {
			BufferedReader br = createBufferedReader();
			String line = br.readLine();
			final int N = Integer.parseInt(line);
			int[] a = new int[N];
			int[] b = new int[N - 1];
			line = br.readLine();
			StringTokenizer st = new StringTokenizer(line, " ");
			for (int i = 0; i < N - 1; i++) {
				b[i] = Integer.parseInt(st.nextToken());
			}
			a[0] = b[0];
			int sum = a[0];
			for (int i = 1; i < N - 1; i++) {
				a[i] = min(b[i - 1], b[i]);
				sum += a[i];
			}
			a[N - 1] = b[N - 2];
			sum += a[N - 1];
			System.out.println(sum);
		} catch (IOException ioe) {
			ioe.printStackTrace();
		} catch (IllegalArgumentException iae) {
			iae.printStackTrace();
			System.err.println("入力が正しくありません。");
		}
	}

	private static int min(final int a, final int b) {
		return (a < b) ? a : b;
	}

	// 以下問題問わずに共通部分
	// 標準入力の BufferedReader を返す.
	private static BufferedReader createBufferedReader() {
		InputStreamReader isr = new InputStreamReader(System.in);
		return new BufferedReader(isr);
	}
}


Measured memory_bytes: 23252
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N, K, Q = map(int, input().split())

g = [0 for i in range(N)]

for i in range(Q):
    A = int(input())
    g[A-1] += 1

for i in range(N):
    if Q - g[i] >= K:
        print("No")
    else:
        print("Yes")



Measured memory_bytes: 85472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll A, B;
  cin >> A >> B;
  ll g = __gcd(A,B);
  ll s = g;
  ll ans = 1;
  for(ll i=2; i*i<=s; i++){
    if(g%i==0){
      ans+=1;
      while(g%i==0){
        g/=i;
      }
    }
  }
  if(g>1){
    ans++;
  }
  cout << ans;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a,b;
	cin>>a>>b;
	a+=b;
	if(a>=10)cout<<"error"<<endl;
	else cout<<a<<endl;
}











Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	while(1){
		int n,x,a=0;
		cin>>n>>x;
		if(n==0&&x==0)break;
		for(int i=1;i<=n-2;i++){
			for(int j=2;j<=n-1;j++){
				for(int k=3;k<=n;k++){
					if(i<j&&j<k)if(i+j+k==x)a=a+1;
				}
			}
		}
		cout<<a<<endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
LL a[100000];
LL cnt1[100001]; //cnt1[i]::=(a[n]=iであるような組の数）
LL cnt2[100001]; //cnt2[i]::=(a[n+1]=iであるような組の数）
LL sum[100001]; //sum[i]::=(a[n+1]=iであるような組の順送りボタンを押す回数の和）
int main() {
	int n, m;
	cin >> n >> m;
	rep(i, n) {
		cin >> a[i];
	}
	LL ans, tmp = 0;
	int x = 0;
	rep(i, n - 1) {
		cnt1[a[i]]++;
		cnt2[a[i + 1]]++;
		if (a[i] < a[i + 1]) {
			sum[a[i + 1]] += a[i + 1] - a[i];
			tmp += a[i + 1] - a[i];
		}
		else {
			sum[a[i + 1]] += m - a[i] + a[i + 1];
			tmp += a[i + 1];
			x++;
		}
	}
	ans = tmp;
	REP(i, 1, m) {
		tmp -= x;
		tmp += sum[i];
		x += cnt1[i];
		x -= cnt2[i];
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main(){

  int a, b, c;
  int i;
  int cnt = 0;
  
  scanf("%d %d %d", &a, &b, &c);

  for(i = a; i <= b; i++){
    if(c % i == 0)
      cnt++;
  }

  printf("%d\n", cnt);

  return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

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

    scanf("%d %d", &d, &n);

    if(d == 0){
        if(n != 100)
            printf("%d\n", n);
        else
            printf("%d\n", n+1);
    }
    
    else if(d == 1){
        if(n != 100)
            printf("%d\n", n*100);
        else
            printf("%d\n", (n+1)*100);
    }

    else{
        if(n != 100)
            printf("%d\n", n*10000);
        else
            printf("%d\n", (n+1)*10000);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int n,k,x,y,a,b,c;
	scanf("%d %d %d %d",&n,&k,&x,&y);
	if(n>k){
		a=k*x;
		b=(n-k)*y;
		c=a+b;
		printf("%d\n",c);
	}
	else{
		a=n*x;
		printf("%d",a);
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int n;
  cin >> n;
  int ans = 100000;
  FOR(i, 1, n)
  {
    int a = i;
    int b = n - a;
    int tmp = 0;
    while (a != 0)
    {
      tmp += a % 10;
      a /= 10;
    }
    while (b != 0)
    {
      tmp += b % 10;
      b /= 10;
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  //ピラミッド外の平地の座標も取り得る、とかいう想定がいるのかも。
  //そんな座標データを取る意味があるか疑問だが。そうだとしたらつらい。
  int N, x, y, h=0, high=0 ,low=1e9;
  cin >> N;
  vector<vector<int>> A(N, vector<int>());
  for(int i=0; i<N; i++){
    int temp=h;    
    cin >> x >> y >> h;
    A[i].push_back(x);
    A[i].push_back(y); 
    A[i].push_back(h);
    if(temp<h) high=i;
    low=min(low,h);
  }
  bool finish=false;
  for(int i=0; i<=100; i++){
    for(int j=0; j<=100; j++){
      bool parfect=true;
      int h1=abs(i-A[high][0])+abs(j-A[high][1])+A[high][2];
      for(int k=0; k<N; k++){
//        cout<<"i:"<<i<<" j:"<<j<<" k:"<<k<<" h1:"<<h1<<endl;
        int h2=abs(i-A[k][0])+abs(j-A[k][1])+A[k][2];
        if(A[k][2]!=low && h1!=h2) break;
        else if(A[k][2]==low && h1!=h2) parfect=false;
        if(k==N-1){
          x=i, y=j, h=h1;
          if(parfect) finish=true;
        }
      }
      if(finish) break;   
    }  
  if(finish) break;
  }
  cout << x << " " << y << " " << h <<endl;
}


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

int main() {
	ll A,B,C,D;
	cin >> A >> B >> C >> D;
	set<ll> X;
	X.insert(A);
	X.insert(B);
	if(A < 0 && 0 < B){
		X.insert(0);
	}
	set<ll> Y;
	Y.insert(C);
	Y.insert(D);
	if(C < 0 && 0 < D){
		Y.insert(0);
	}
	ll mx = -1000000000000000000LL;
	for(auto it = X.begin(); it != X.end(); it++){
		for(auto jt = Y.begin(); jt != Y.end(); jt++){
			mx = (mx < (*it)*(*jt) ? (*it)*(*jt) : mx);
		}
	}

	cout << mx << endl;
	return(0);
}


Measured memory_bytes: 3640
from collections import Counter

N = input()
A = map(int, raw_input().split())
C = Counter(A)

m1 = -1
m2 = -1

for k in C.keys():
    if C[k] >= 4 and m1 < k:
        m1, m2 = k, k
    elif C[k] >= 2 and m1 < k:
        m1, m2 = k, m1
    elif C[k] >= 2 and m2 < k:
        m2 = k

if m1 < 0 or m2 < 0:
    print 0
else:
    print m1 * m2


Measured memory_bytes: 16424
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>
#include <cmath>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

struct Vector {
   llong x, y;
   llong dot(Vector r) const {
      return x * r.x + y * r.y;
   }
   void add(Vector r) {
      x += r.x;
      y += r.y;
   }
};


int N;
Vector V[100];

double solve() {
   llong best = 0;
   REP(k, N) {
      Vector d = V[k];  // direction of travel
      if (d.x == 0 && d.y == 0) continue;

      Vector sum = {0, 0};
      REP(i, N) {
         if (d.dot(V[i]) <= 0) continue;
         sum.add(V[i]);
      }
      llong cur = sum.dot(sum);
      if (best < cur)
         best = cur;
   }
   
   
   REP(k1, N) {
      Vector d1 = V[k1];  // direction of travel
      if (d1.x == 0 && d1.y == 0) continue;
      REP(k2, N) {
         Vector d2 = V[k2];  // direction of travel
         if (d2.x == 0 && d2.y == 0) continue;

         Vector d = d1;
         d.add(d2);

         Vector sum = {0, 0};
         REP(i, N) {
            if (d.dot(V[i]) <= 0) continue;
            sum.add(V[i]);
         }
         llong cur = sum.dot(sum);
         if (best < cur)
            best = cur;
      }
   }
   
   return sqrt(best);
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);
   cout.precision(15);
   cout << fixed;

   cin >> N;
   REP(i, N)
      cin >> V[i].x >> V[i].y;

   double res = solve();
   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;

int main(){
  ll n, pp;
  cin >> n >> pp;
  map<ll, int> mp;
  for (ll i = 2; i <= 1e6; i++) {
    while (pp % i == 0) {
      pp /= i;
      mp[i]++;
      if (pp == 1LL) break;
    }
    if (pp == 1LL) break;
  }
  if (pp != 1LL) mp[pp]++;
  ll ans = 1LL;
  for (auto p: mp) {
    if (p.second >= n) {
      for (int i = 0; i < p.second / n; i++) {
        ans *= p.first;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define ub upper_bound
#define lb lower_bound
#define clr(x) memset(x,0,sizeof(x))
#define sws ios::sync_with_stdio(false); cin.tie(0)
#define pi acos(-1)
#define rep(I, N) for (ll I = 0; I < (N); ++I)
#define repp(I, A, B) for (ll I = (A); I <= (B); ++I)
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
const ll N = 2e5 + 5 ;
int main()
{
    sws;
    //clock_t clk;
    //clk = clock();
    //freopen("A.in", "r", stdin); 
    //freopen("A.out", "w", stdout);

    int n;
    cin >> n;
    int a[n + 1];
    repp(i,1,n) cin >> a[i];
    map<int,int> m;
    repp(i,1,n)
    {
        m[a[i]]++;
        m[a[i] - 1]++;
        m[a[i] + 1]++;
    }
    int mx = -1;
    map<int,int> :: iterator it;
    for(it = m.begin(); it != m.end(); it++)
    {
        mx = max(mx,it->SS);
    }
    cout << mx;

    //clk = clock() - clk;
    //cout << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; 
int main() {
    ll n;
    cin>>n;
    ll h[n];
    for (ll i=0;i<n;i++)
    cin>>h[i];
      ll dp[n+1];
      dp[0]=0;
      dp[1]=0;
      dp[2]=abs(h[1]-h[0]);
      for (ll i=3;i<=n;i++)
      {
          dp[i]=min ((dp[i-1]+(abs(h[i-1]-h[i-2]))),(dp[i-2] +(abs(h[i-1]-h[i-3]))));
      }
      cout<<dp[n];
}


Measured memory_bytes: 1792