akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repin(a, n)  \
    vector<ll> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repins(a, n)     \
    vector<string> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repind(a, n)     \
    vector<double> a(n); \
    rep(i, n) { cin >> a[i]; }
#define in(a) \
    ll a;     \
    cin >> a;
#define ins(a) \
    string a;  \
    cin >> a;
#define ind(a) \
    double a;  \
    cin >> a;
template <class T>
inline void out(T a) {
    cout << a << endl;
}
inline void out(double a) { printf("%.10f\n", a); }
#define all(x)        (x).begin(), (x).end()    //昇順
#define rall(x)       (x).rbegin(), (x).rend()  //降順
#define rep2(i, a, b) for (ll i = (a); i < (b); ++i)
#define yes           out("Yes");
#define no            out("No");

int main() {
    ins(s);

    if (s == "RRR") {
        out(3);
        return 0;
    }
    if (s[0] == 'R' && s[1] == 'R') {
        out(2);
        return 0;
    }
    if (s[1] == 'R' && s[2] == 'R') {
        out(2);
        return 0;
    }

    if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
        out(1);
        return 0;
    }

    out(0);
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int f[101][10];
int g_arr[8];
#define mod 1000000007

int g(int x) {
	if (x < 0)
		return 1;
	else
		return g_arr[x];
}

int main(int argc, char **argv) {
	int h, w, k;
	cin >> h >> w >> k;
	g_arr[0] = 1;
	g_arr[1] = 2;
	for (int i = 2; i < w - 1; i++) {
		g_arr[i] = g_arr[i - 1] + g_arr[i - 2];
	}
	for (int i = 0; i <= w + 1; i++) {
		f[0][i] = (i == 1) ? 1 : 0;
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 0; j <= w + 1; j++) {
			if (j == 0 || j == w + 1) {
				f[i][j] = 0;
			} else {
				f[i][j] = (1ll * f[i - 1][j - 1] * g(j - 3) * g(w - 1 - j)
						 + 1ll * f[i - 1][j] * g(j - 2) * g(w - 1 - j)
						 + 1ll * f[i - 1][j + 1] * g(j - 2) * g(w - 1 - (j + 1))) % mod;
			}
		}
	}
	cout << f[h][k] << endl;
	return 0;
}



Measured memory_bytes: 256
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let nm: Vec<u32> = read_vec();
    let n = nm[0];
    let m = nm[1];
    let ans = n * (n - 1) / 2 + m * (m - 1) / 2;
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int a=0;
        int b=0;
        for (int i=0;i<s.length();i=i+2){
            int cur = s.charAt(i)-'0';
            if (cur == 1 ) ++a;
            else ++b;
        }
        for (int i=1;i<s.length();i=i+2){
            int cur = s.charAt(i)-'0';
            if (cur == 0 ) ++a;
            else ++b;
        }
        System.out.println(Math.min(a,b));
    }
}


Measured memory_bytes: 25556
import numpy as np

n = int(input())
a = list(map(int, input().split()))
a_max = max(a)
lst = [0] * (a_max + 1)
cnt = 0
# if len(a) <= 1:
#     print(0)
# else:
for i in a:
    if lst[i] > 1:  # 配列中のカウントが2以上なら以降の処理を省略
        continue
    for j in range(a_max // i + 1):  # Aiの倍数にインクリメント(配列の上限はa[-1])
        lst[i * j] += 1
    # lst[1::i] += 1
for i in a:
    if lst[i] == 1:
        cnt += 1
print(cnt)

Measured memory_bytes: 51380
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=int_fast64_t;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double EPS=1e-9;
const int MOD=1e9+7;
int main(){
    string s;cin>>s;
    int n=s.length();
    ll c=0;
    ll ans=0;
    for(int i=0;i<n;i++){
        if(s[i]=='B'){
            c++;
        }else{
            ans+=c;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, T, A;
    cin >> N >> T >> A;
    int H[N];
    int ans_index = 0;
    double mi = 500;
    for(int i = 0; i < N; i++){
        cin >> H[i];
        if(mi > fabs(A-((double)T-H[i]*0.006))){
            ans_index = i;
            mi =  fabs(A-((double)T-H[i]*0.006));
        }
    }
    cout << ans_index+1 << endl;

}

Measured memory_bytes: 256
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define inf INT_MAX/3
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define FOR(i,a,b) for( int i=(a),_b=(b);i<=_b;i++)
#define DOW(i,b,a) for( int i=(b),_a=(a);i>=_a;i--)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
map<int,int>mp;
set<int> s;
int main()
{
    fast;
    int n,sum = 0;
    cin >> n;
    int ara[n];
    for (int i = 0; i < n; i++)
    {
        cin >> ara[i];
    }
    sort (ara,ara+n,greater<int>());
    for (int i = 0; i < n; i++)
    {
        if (i == 0)
        {
            sum += ara[i] / 2;
        }
        else
        {
            sum += ara[i];
        }
    }
    cout << sum << '\n';
    return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("in.txt", "r", stdin);
	int n, m;
	cin >> n >> m;
	vector<bool> a(n+1, false);
	vector<int> b(n+1);
	rep(i,0,m) {
		int x;
		string s;
		cin >> x >> s;
		if(s == "AC") {
			a[x] = true;
		} else {
			if(!a[x]) {
				b[x]++;
			}
		}
	}
	int x = 0;
	int y = 0;
	rep(i,1,n+1) {
		if(a[i]) {
			x++;
			y += b[i];
		}
	}
	cout << x << " " << y << '\n';
	return 0;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(1000000)
def mincost(n,h,i,dp):
    if i==(n-1):
        return 0
    elif i==(n-2):
        return abs(h[n-1]-h[i])
    mncost=sys.maxsize
    for j in range(i+1,i+3):
        if dp[j]==-1:
            cost=mincost(n,h,j,dp)
            dp[j]=cost
        else:
            cost=dp[j]
        mncost=min(mncost,cost+abs(h[j]-h[i]))
    return mncost

n=int(input())
h=[int(x) for x in input().split()]
dp=[-1 for i in range(n)]
print(mincost(n,h,0,dp))

Measured memory_bytes: 101504
#include<iostream>
using namespace std;
int P[10010];
int n,num;
void init(int N)
{
    for(int i=0;i<N;i++)
    {
        P[i]=i;
    }
}
int root(int a)
{
    if(P[a]==a)
        return a;
    return(P[a]=root(P[a]));
}
bool is_same_set(int a,int b)
{
    return root(a)==root(b);
}
void unite(int a,int b)
{
    P[root(a)]=root(b);
}
int main()
{
    cin>>n>>num;
    init(n);
    int a,b,q;
    for(int i=0;i<num;i++)
    {
        cin>>q>>a>>b;
        if(q==0)
            unite(a,b);
        if(q==1)
            cout<<is_same_set(a,b)<<endl;        
    }
return 0;
}


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

int main(){
  int H,W;
  cin >>H>>W;
  int count=0;
  vector<vector<char>> V(H,vector<char>(W));
  vector<bool> I(H,true);
  vector<bool> J(W,true);

  //Vを作成
  rep(i,H){
    rep(j,W){
      cin >>V.at(i).at(j);
    }
  }
  
  //横探索
  rep(i,H){
    rep(j,W){
      if(V.at(i).at(j)== '#')
        count++;
    }
    if(count==0)
      I.at(i)=false;   
    count=0;
  }
  
  //縦探索
  rep(j,W){
    rep(i,H){
      if(V.at(i).at(j)== '#')
        count++;
    }
    //cout << count <<endl;
    if(count==0)
      J.at(j)=false; 
    count=0;
  }
  
  //出力
  rep(i,H){
    rep(j,W){
      if(I.at(i) && J.at(j)){
        cout << V.at(i).at(j);
        count++;
      }    
    }
    if(count>0){
      cout << endl;
      count =0;
    }
  }
  cout << endl;
}

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

int main(){
  long W,H;
  double x,y;
  cin>>W>>H>>x>>y;
  cout<<fixed<<setprecision(12)<<double(W*H)/2<<' ';
  if(2*x == W && 2*y == H)
    cout<<1<<endl;
  else
    cout<<0<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,sum;

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

    if((a>=b && a%b==0 && c>0 )||(a==b && c==0)){
        cout<<"NO";
        return 0;
    }
    else if(a+c == b){
        cout<<"YES";
        return 0;
    }
    else
    {
        int i=1;
        while(sum<=1000000000)
        {
            if((a*i - c)%b == 0)
            {
                cout<<"YES";
                return 0;
            }
            sum=a*i;
            i++;
        }
    }
    cout<<"NO";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<list>
using namespace std;
static const int MAX = 100000;
static const int INFTY = (1<<29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s){
    queue<int> q;
    q.push(s);
    V[s] = true;
    while( !q.empty() ){
        int u = q.front(); q.pop();
        out.push_back(u);
        for(int i=0; i<G[u].size(); i++){
            int v = G[u][i];
            indeg[v]--;
            if(indeg[v] == 0 && !V[v]){
                V[v] = true;
                q.push(v);
            }
        }
    }    
}

void tsort(){
    for(int i=0; i<N; i++){
        indeg[i] = 0;
    }

    for(int u=0; u<N; u++){
        for(int i=0; i<G[u].size(); i++){
            int v = G[u][i];
            indeg[v]++;
        }
    }

    for(int u=0; u<N; u++)
        if(indeg[u] == 0 && !V[u]) bfs(u);

    for(list<int>::iterator it = out.begin(); it != out.end(); it++){
        cout << *it << endl;
    }
}

int main(){
    int s, t, M;

    cin >> N >> M;

    for(int i=0; i<N; i++) V[i] = false;

    for(int i=0; i<M; i++){
        cin >> s >> t;
        G[s].push_back(t);
    }

    tsort();

    return 0;
}


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

//int abs(int a){
//    if(a<0) a = -a;
//    return a;
//}

int main(){

    int w,h,x,y,r;
 //   int absx,absy;
    cin >> w >> h >> x >> y >> r;

 //   absx = abs(x);
 //   absy = abs(y);

    if((x < 0) | (y < 0)) cout << "No" << endl;
    else if (((x + r) <= w) 
        && ((x - r) >= 0)
        && ((y + r) <= h) 
        && ((y - r) >= 0)){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        return 0;
}



Measured memory_bytes: 3116
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>


using namespace std;

int main()
{
	int h, w, n, c[101][101], a, asum=1;
	scanf("%d %d", &h, &w);
	scanf("%d", &n);
	for(int i=1; i<=n; i++){
		scanf("%d", &a);
		for(int j=asum; j<asum+a;j++){
			int x, y;
			if(j%w==0){
				x=j/w;
				if(x%2==0){
					y=1;
				}else{
					y=w;
				}
			}else{
				x=j/w+1;
				if(x%2==0){
					y=x*w-j+1;
				}else{
					y=j-(x-1)*w;
				}
			}
			c[x][y]=i;
		}
		asum=asum+a;
	}

	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			printf("%d ", c[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
//DP用
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 long long INF = 1LL << 60;

int main() {
    int x;
    cin >> x;
    if(x >= 1200) {
        cout << "ARC";
    }else {
        cout << "ABC";
    }
    return 0;
}



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

int main()
{
    int n;
    cin>>n;
    int sm=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                int ans=__gcd(i,j);
                sm+=__gcd(ans,k);
            }
        }
    }
    
    cout<<sm<<"\n";
    
    
}

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

using namespace std;

int main(){
 	string s;
  	cin >> s;
  	int flag=0;
  	for(int i=0;i<3;i++){
      if(s[i]=='7') flag=1;
    }
  if(flag) cout << "Yes\n";
  else cout << "No\n";
}

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

int n;

void dfs(string s,char mx){
	if(s.size()==n){
		cout<<s<<"\n"s;
		return;
	}
	for(char c='a';c<=mx+1;++c){
		string t=s;
		t+=c;
		dfs(t,max(mx,c));
	}
}

int main(){
	cin>>n;
	dfs("",'a'-1);
}

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

int main(){
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<n+1;i++){
		cin>>a[i];
	}
	a[0] = a[n+1] =0;
	int res = 0;
	for(int i=1;i<n+2;i++){
		res += abs(a[i]-a[i-1]);
	}

	int dif = 0,ans=0;
	for(int i=1;i<n+1;i++){
		dif = abs(a[i]-a[i-1]) + abs(a[i+1]-a[i]) - abs(a[i+1]-a[i-1]);
		ans = res - dif;
		cout <<ans <<endl;
	}
}


Measured memory_bytes: 1664
l = ((1,3,5,7,8,10,12),(4,6,9,11),(0,2))
x,y = map(int, input().split())
p = 0
for i in l:
	if x in i and y in i:
		p = 1
		break
ans = 'Yes' if p == 1 else 'No'
print(ans)

Measured memory_bytes: 9084
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
constexpr int MOD = 1e9 + 7;
constexpr int MAX = 200020;

long long fac[MAX], inv[MAX], finv[MAX];
void CombInit(){
    fac[0] = inv[0] = finv[0] = 1;
    fac[1] = inv[1] = finv[1] = 1;
    for(int i=2; i<MAX; ++i){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

long long Comb(int n,int k){
    if(n < 0 || k < 0 || n < k) return 0;
    return (fac[n] * finv[n-k] % MOD) * finv[k] % MOD;
}

int main() {
    int H,W,A,B;cin>>H>>W>>A>>B;
    CombInit();
    ll ans = 0;
    for(int i=B; i < W; ++i){
        ans += Comb(H-1-A + i, i) * Comb(W-1-i + A-1, A-1) % MOD;
        ans %= MOD;
    }
    cout << ans << '\n';
    return 0;
}

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

int main(){
    long long int n;
    cin >> n;
    
    long long int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    /*
    long long int s[n];
    s[0] = a[0];
    for(int i=1;i<n;i++){
        s[i] *= (s[i-1]%1000000007);  
    }
    
    long long int sum=0;
    for(long long int i=0;i<=n-2;i++){
        for(long long int j=i+1;j<=n-1;j++){
            sum += ((a[i]*a[j])%1000000007);
            sum %= 1000000007;
        }
    }
    cout << sum << endl;
    */

   /*----------------------------------------------
    解説：累積和を用いて処理しよう！
    a[i]*a[i+1] + a[i]*a[i+2] + ... + a[i]*a[n]
    = a[i] * (a[i+1] + a[i+2] + ... + a[n])
    この()内で累積和を用いる
   ----------------------------------------------*/
   long long int sum[n]; //累積和 sum[0] = a[0], sum[1] = sum[0] + a[1], sum[2] = sum[1] + a[2], a[i]+...+a[j]=s[j]-s[i-1]
   sum[0] = a[0];
   for(int i=1;i<n;i++){
       sum[i] = sum[i-1] + a[i];
       sum[i] %= 1000000007;
   }

   long long int ans = 0;
    long long int mod_sum;
   for(int i=0;i<n;i++){
       //cout << i << " " << sum[n-1] - sum[i] << endl;
       mod_sum = (sum[n-1]-sum[i]) % 1000000007;
       if(mod_sum<0){//sum[n-1]-sum[i]のmod1000000007が正しくなるようにする
           mod_sum+=1000000007;
       }
       ans += (a[i]*mod_sum % 1000000007);
       ans %= 1000000007;
   }
   ans %= 1000000007;
    cout << ans << endl;
}

Measured memory_bytes: 6736
n=input()
if len(n)==1:
  print(int(n))
else:
  cnt=n[1:].count('9')
  if cnt==len(n)-1:
    print(int(n[0])+9*(len(n)-1))
  else:
    print(int(n[0])-1+9*(len(n)-1))


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

int main()
{
    int N;
    string X;

    cin >> N;

    bool bl_four = false;
    for (int i = 0; i < N; i++)
    {
        cin >> X;
        if (X == "Y")
        {
            bl_four = true;
            break;
        }
    }
    if (bl_four)
    {
        cout << "Four" << endl;
    }
    else
    {
        cout << "Three" << endl;
    }
}

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

int main()
{  
   string ch;
   cin>>ch;
   int sum=0;
   for(int i=0;i<ch.size();i++){
       sum+=ch[i]-'0';
   }
   if(sum==1) cout<<10<<endl;
   else cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
    vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i); 
  }
    sort(vec.begin(), vec.end()); 
 int count = 0;
    for (int i = 0; i < K; i++) {
      count = count + vec.at(i);
    }
    cout << count << endl;
  
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(){
  int n,x,t;
  int minute,time;
  scanf("%d %d %d",&n,&x,&t);
  minute=n/x;
  if(n%x==0){
  	time = minute*t;
  }
  else{
    time=(minute+1)*t;
  }
  printf("%d",time);
  return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#include <atcoder/dsu>

using namespace atcoder;
using namespace std;
typedef long long ll;

int main()
{
  ll n, m;
  cin >> n >> m;
  dsu d(n);
  for (ll _ = 0; _ < m; _++)
  {
    ll a, b;
    cin >> a >> b;
    d.merge(a-1, b-1);
  }
  cout << d.groups().size() - 1;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c)
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))

#define mod          10000007
#define PI           acos(-1.0)
#define MAX3(a,b,c)  max(a,max(b,c))

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

//x = 1e18 means 10^18
//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//printf("%I64d\n", a);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

// int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1};  // 4 Direction
// int dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1};  // 8 Direction
// int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1};  // Knight Direction
// int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1};  // Hexagonal Direction

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//unordered_map <ll, ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A;
//bitset<32> bset1;
//bool ok = true;
//char ch;
//string S, T, U;

ll i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, flag=0, cnt=0;

double x, y;

int main()
{
    cin>>n;

    x = (double)n/108;
    y = x*100;
    a = ceil(y);
    b = floor(a*1.08);

    if(b==n)
    {
        cout<<a<<endl;
    }
    else
    {
        cout<<":("<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
N=int(input())
S=str(input())

ALF=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
d=[]
for i in range(len(S)):
  a=ALF.index(S[i])
  if N+a > 25:
    d.append(ALF[N+a-26])
  else:
    d.append(ALF[N+a])

print("".join(d))



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    string s,t;
    cin>>s>>t;
    int cnt=0;
    rep(i,3){
        if(s[i]==t[i]) cnt++;
    }
    cout<<cnt;
}

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

using namespace std;

int main()
{
    vector<int> A(3);
    cin >> A.at(0) >> A.at(1) >> A.at(2);

    sort(A.begin(), A.end());
    
    int ans = 10000;
    do{
	int cost = 0;
	int a = A.at(0);
	for(int i = 1; i < A.size(); i++){
	    cost += abs(A.at(i) - a);
	}
	ans = min(ans, cost);
    }while(next_permutation(A.begin(), A.end()));

    cout << ans << endl;
    
}


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

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

int main() {
    int N;
    cin >> N;
    vector<double> x(N);
    vector<string> u(N);

    rep(i, N)
        cin >> x.at(i) >> u.at(i);
    
    double ans = 0;
    rep(i, N) {
        if (u.at(i) == "JPY")
            ans += x.at(i);
        else   
            ans += (380000.0 * x.at(i));
    }

    cout << ans << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007
//#define harmonic(n) 0.57721566490153286l+log(n)

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; ///4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};///8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};///Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; ///Hexagonal Direction

inline int in() { int x; scanf("%d", &x); return x; }
int gcd(int a,int b) { return b==0 ? a:gcd(b,a%b);}
int power( int x, int n)
{
    if(n==0)return 1;
    else if(n%2==0)
    {
        int y=power(x,n/2);
        return y*y;
    }
    else
        return x*power(x,n-1);
}
//abcdefghijklmnopqrstuvwxyz//
const int sz=300010;
const int mx=sz*4;
#define left(x) x<<1
#define right(x) (x<<1)+1
int a[sz];
struct segmenttree
{
    int n;
    int st[mx];
    void build()
    {
        mem(st,0);
        return;
        //build(1,0,n-1);
    }
    void update(int p,int l,int r,int i,int j,int v)
    {
        //printf("%d %d %d %d\n",l,r,i,j);
        if(l>r||l>j||r<i) return;
        if(l>=i&&r<=j)
        {
            st[p]=v;
            return;
        }
        //printf("%d %d\n",st[p],v);
        update(left(p),l,(l+r)/2,i,j,v);
        update(right(p),1+(l+r)/2,r,i,j,v);
        int p1=st[left(p)],p2=st[right(p)];
        st[p]=max(p1,p2);
    }
    void update(int i,int j,int v)
    {
        update(1,0,n-1,i,j,v);
    }

    int query(int p,int l,int r,int i,int j)
    {
        if(i>r||j<l)
            return -1;
        if(l>=i&&r<=j) return st[p];
        int p1=query(left(p),l,(l+r)/2,i,j);
        int p2=query(right(p),(l+r)/2+1,r,i,j);
        if(p1==-1) return p2;
        if(p2==-1) return p1;
        return max(p1,p2);
    }
    int query(int i,int j)
    {
        return query(1,0,n-1,i,j);
    }
};

segmenttree seg;
int dp[300010];
int main()
{
    #ifdef CP
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif // CP
    int n=in(),k=in(),i;
    seg.n=300005;
    for(i=0;i<n;i++)
        a[i]=in();
    seg.build();
    dp[0]=1;
    seg.update(a[0],a[0],1);
    int x,y,ans=1;
    for(int i=1;i<n;i++)
    {
        x=max(a[i]-k,0);
        y=min(a[i]+k,300000);
        dp[i]=seg.query(x,y)+1;
        seg.update(a[i],a[i],dp[i]);
        ans=max(ans,dp[i]);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 10896
n,l,*a=map(int,open(0).read().split())
for i,(x,y) in enumerate(zip(a,a[1:])):
	if x+y>=l:
		print("Possible")
		r=list(range(n))
		print("\n".join(map(str,r[1:i+1]+r[n:i:-1])))
		exit()
print("Impossible")

Measured memory_bytes: 19660
package main

import (
        "bufio"
        "fmt"
        "os"
)

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func lowerBound(a []int, x int) int {
        n := len(a)
        ok := n
        ng := -1
        for ok-ng > 1 {
                mid := (ok + ng) / 2
                if a[mid] >= x {
                        ok = mid
                } else {
                        ng = mid
                }
        }
        return ok
}

func main() {
        var s string
        var t string

        s = readLine()
        t = readLine()

        idxs := make([][]int, 256)

        for i := 0; i < len(s); i++ {
                idxs[s[i]] = append(idxs[s[i]], i)
        }

        n := int64(len(s))
        cur := int64(0)
        ng := false

        for i := 0; i < len(t); i++ {
                is := idxs[t[i]]
                if is == nil || len(is) == 0 {
                        ng = true
                        break
                }
                base := (cur / n) * n

                nidx := lowerBound(is, int(cur%n))
                if nidx == len(is) {
                        cur = base + int64(is[0]) + n + 1
                } else {
                        cur = base + int64(is[nidx]) + 1
                }
        }
        if ng {
                fmt.Println(-1)
        } else {
                fmt.Println(cur)
        }
}

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

int main(){
  string s, t;
  cin >> s >> t;
  
  bool flag=true;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i])flag = false;
  }
  if(flag)cout << "Yes";
  else cout << "No";
  
  return 0;
}


Measured memory_bytes: 3624
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int A, V, B, W, T;
	cin >> A >> V >> B >> W >> T;

	if (V <= W) {
		co("NO");
		return 0;
	}

	int sa = V - W;
	ll ikeru = ll(sa) * T;

	if (ikeru >= abs(A - B)) {
		co("YES");
	}
	else co("NO");



	Would you please return 0;
}

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

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

    int n, S, q, T;
    unordered_map<int, bool> um;
    cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> S;
        um[S] = true;
    }

    int ans = 0;
    cin >> q;
    for (int i=0; i<q; ++i) {
        cin >> T;
        if (um[T]) ans ++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
using namespace std;
int n, c, v[555555], mem[555555];
void solve(int l, int r) {
	if(r - l == 1) return; c += r - l;
	solve(l, (l + r) / 2);
	solve((l + r) / 2, r);
	merge(v + l, v + (l + r) / 2, v + (l + r) / 2, v + r, mem);
	for(int i = l; i < r; i++) v[i] = mem[i - l];
}
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &v[i]);
	solve(0, n);
	for(int i = 0; i < n; i++) {
		if(i) printf(" ");
		printf("%d", v[i]);
	}
	printf("\n%d\n", c);
}

Measured memory_bytes: 7088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<string> a(n);
  rep(i,n) cin >> a.at(i);
  bool is = true;
  map<string,int> mp;
  rep(i,n){
    mp[a.at(i)]++;
  }
  for(auto p:mp){
    if(p.second>=2) is = false;
  }
  rep(i,n-1){
    char end = a.at(i).at(a.at(i).size()-1);
    char begin = a.at(i+1).at(0);
    if(end!=begin) is=false;
  }
  if(is){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
z[4000],*a=z,*b=z+2000,m,i,j,k;main(n){for(;!scanf("%d",&n)|n;m=!printf("%d\n",m))for(i=++n;i--;j=a,a=b,b=j)for(j=n;j--;k>m?m=k:0)k=b[j]=n+~i&&getchar()>45?1+fmin(fmin(b[j+1],a[j+1]),a[j]):0;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first first
#define second se
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;



signed main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int mask = 0; mask < (1 << s.size() - 1); mask++){
        int now = s[0] - '0';
        int sum = 0;
        rep(i, 1, s.size()){
            if(mask & (1 << i - 1)){
                sum += now;
                now = 0;
            }
            now *= 10;
            now += s[i] - '0';
        }
        ans += sum + now;
    }
    o(ans);
}

Measured memory_bytes: 256
/*Infor {{{
 ******************************************************
 * > File Name: a.cpp
 * > Author: samcompu
 * > Mail: admin@samcompu.com
 * > Created Time: 2018/7/21 12:13:06
 ******************************************************
}}}*/

#include <bits/stdc++.h>

using namespace std;

/*Abbreviation {{{ */
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define ROF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define cini(a) scanf("%d", &(a))
#define cinc(a) scanf("%c", &(a))
#define cinl(a) scanf("%lld", &(a))
#define cins(a) scanf("%s", (a))
#define cind(a) scanf("%lf", &(a))
#define coui(a) printf("%d", (a))
#define couc(a) printf("%c", (a))
#define coul(a) printf("%lld", (a))
#define cous(a) printf("%s", (a))
#define coud(a) printf("%f", (a))
#define SPA printf(" ")
#define LIN printf("\n")
#define ull unsigned long long int
/*}}}*/

/*Constant {{{*/
const int MAXN = 3000;
/*}}}*/

/*Class {{{*/
/*}}}*/

/*Variable {{{*/
int a[MAXN + 1];
/*}}}*/

/*Declare {{{*/
/*}}}*/

/*Main {{{*/
int main() {
  int n;
  cini(n);
  int ans = 0;
  FOR(i, 1, n) {
    int x;
    cini(x);
    ans += x - 1;
  }
  coui(ans), LIN;
  return 0;
}
/*}}}*/

/*Define {{{*/
/*}}}*/


Measured memory_bytes: 256
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P, ll Mod) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)

int main(void) {
  int X,Y; cin >> X >> Y;
  int a,b; double a_d, b_d;
  a_d = (double)(2*Y - X) / 3.0;
  b_d = 2*Y - a_d;
  if (floor(a_d) != a_d || a_d < 0 || b_d < 0){
    cout << 0 << "\n";
    return 0;
  }
  a = (2*Y - X) / 3;
  b = Y - 2*a;
  int n = a+b;
  ll bunbo=1; ll bunshi=1;
  rep(i,a){
    bunbo = bunbo * (i+1) % M;
    bunshi = bunshi * (n-i) %M;
  }
  cout << bunshi * RS(bunbo,M-2,M) % M << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
const int MX = 1000000000;
 
int main(){
  ll X, K, D;
  cin >> X >> K >> D;
  ll np = X;
  ll ans = 0;
  ll a;
  if(np>0){
      a = np / D;
      if(a > K){
        cout << np - K*D << endl;
        return 0;
      }
      np = np - D * a;
      K -= a;
      if(K%2 == 0){
        ans = np;
      }else{
        ans = 0 - (np - D);
      }
  }else{
      a = -1*np / D;
      if(a > K){
        cout << 0 - (np + K*D) << endl;
        return 0;
      }
      np = np + D * a;
      K -= a;
      if(K%2 == 0){
        ans = 0 - np;
      }else{
        ans = np + D;
      }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3556
#include <iostream>
#include <string>
#include <stdlib.h>
#include <algorithm>
using namespace std;


int main(void) {
    int a, b;
    cin >> a >> b;
    int total = a;
    int counter = 1;
    
    if (b <= 1) {
        printf("0");
        return (0);
    }
    
    while (total < b) {
        total--;
        total += a;
        counter++;
    }
    printf("%d",counter);
    return 0;
}


Measured memory_bytes: 256
using System;using System.Linq;
class A{
    static void Main(){
while(true){        int n =int.Parse(Console.ReadLine());
    if(n==0){break;}
        for(int i=0;i<n;i++){
            int []s=Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a=s[0];
            int b=s[1];
            int c=s[2];
            int d=s[3];
            int e=s[4];
            int f=s[5];
            int g=s[6];
            int h=s[7];
            Console.Write(a*e-b*f-c*g-d*h);
            Console.Write(" ");
            Console.Write(a*f+b*e+c*h-d*g);
            Console.Write(" ");
            Console.Write(a*g+c*e-b*h+d*f);
            Console.Write(" ");
            Console.WriteLine(a*h+d*e+b*g-c*f);
            
        }

    
}    }
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
ll X, N, M;
vector<ll> cost;
vector<vector<ll>> v;

ll dfs(vector<ll> rikaido, ll total_cost, ll depth) {
  ll cur_cost = INT64_MAX;
  if (depth == N) {
    bool is_achieved = true;
    for (auto x: rikaido) {
      if (x < X) is_achieved = false;
    }
    if (is_achieved) return total_cost;
    else return INT64_MAX;
  }
  //買わない
  cur_cost = min(cur_cost, dfs(rikaido, total_cost, depth+1));
  //買う
  REP(i, M) {
    rikaido[i] += v[depth][i];
  }
  cur_cost = min(cur_cost, dfs(rikaido, total_cost+cost[depth], depth+1));
  return cur_cost;
}
int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M >> X;
  REP(i, N) {
      ll c; cin >> c;
      cost.push_back(c);
      vector<ll> tmp_v;
      REP(j, M) {
          ll tmp; cin >> tmp;
          tmp_v.push_back(tmp);
      }
      v.push_back(tmp_v);
  }
  vector<ll> rikaido(M, 0);
  ll res = dfs(rikaido, 0, 0);
  res = (res == INT64_MAX) ? -1 : res;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3660
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;
#define INF 100000005
#define MAX 1000005

int main(){
	int n, a[105], tmp, ans = 0;
	cin >> n;
	fill(a, a+105, 0);
	for(int i = 0;i < n;i++){
		cin >> tmp;
		a[tmp]++;
	}
	for(int i = 103;i > 0;i--)a[i] += a[i+1];
	for(int i = 0;i < 103;i++)if(i <= a[i])ans = i;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3092
#include <stdio.h> 
#include <math.h>
int main(void)
{
	int x[1000],y[1000],n,i;
	double p1 =0,p2 = 0, p3 = 0, p =0;

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&x[i]);
	}
	for(i=0;i<n;i++)
	{
		scanf("%d",&y[i]);
	}
	
	for(i=0;i<n;i++)
	{
		if(x[i]<y[i])
		{
			p1 = p1 + y[i] - x[i];		
			p3 = p3 + (y[i] - x[i]) * (y[i] - x[i])  * (y[i] - x[i]);
		}
		if(y[i]<x[i])
		{
			p1 = p1 + x[i] -y[i];
			p3 = p3 + (x[i] - y[i]) *  (x[i] - y[i])  *  (x[i] - y[i]);
		}
		p2 = p2 + (x[i] - y[i]) *  (x[i] - y[i]);

		if(x[i]<y[i])
		{
			if(p<y[i] - x[i])
			{
				p=y[i] - x[i];
			}
		}
		if(x[i]>y[i])
		{
			if(p<x[i] -y[i])
			{
				p = x[i] -y[i];
			}
		}
	}
	printf("%f\n%f\n%f\n%f\n",p1,sqrt(p2),pow(p3,1.0/3.0),p);


	return 0 ;
}

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

int main() {
  int c[8];
  for (int i = 0; i <= 8; i++) {
    cin >> c[i];
  }

  int s1 = c[0] - c[3];
  int s2 = c[1] - c[4];
  int s3 = c[2] - c[5];
  int s4 = c[0] - c[6];
  int s5 = c[1] - c[7];
  int s6 = c[2] - c[8];
  int s7 = c[3] - c[6];
  int s8 = c[4] - c[7];
  int s9 = c[5] - c[8];


  if (s1==s2 && s2==s3 && s4==s5 && s5==s6 && s7==s8 && s8==s9 ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
def modpow(a, n, p):
    if n == 0: return 0
    elif n == 1: return a % p
    elif n % 2: return (a * modpow(a, n - 1, p)) % p
    else:
        t = modpow(a, n // 2, p)
        return (t * t) % p

def calc(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % MOD
        q = q * (i + 1) % MOD
    return p * modpow(q, MOD - 2, MOD) % MOD
    

MOD = 10 ** 9 + 7

N, a, b = map(int, input().split())
s = modpow(2, N, MOD) - 1
print((s - (calc(N, a) + calc(N, b))) % MOD)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class MPCO2020C
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            var Ia = RIa(2);
            var N = Ia[0];
            var K = Ia[1];
            var A = RIa(N);

            for (int i = K; i < N; ++i)
            {
                string result = (A[i] > A[i - K]) ? "Yes" : "No";
                Console.WriteLine(result);
            }


#if DEBUG
            Console.WriteLine("*** end ***");
            Console.SetIn(Console.In);
            Console.ReadKey();
            Console.WriteLine();
#endif
        }

        static int RI()
        {
            return int.Parse(Console.ReadLine());
        }

        static int[] RIa(int n)
        {
            string[] sa = Console.ReadLine().Split(' ');
            int[] la = new int[n];
            for (int i = 0; i < n; ++i)
            {
                la[i] = int.Parse(sa[i]);
            }
            return la;
        }
    }
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    int n;
    cin >> n;
    vll a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    ll suma = 0, sumb = 0;
    rep(i, n) {
        if (a[i] > b[i]) suma += a[i] - b[i];
        else if (a[i] < b[i]) {
            sumb += (b[i] - a[i]) / 2 * 2;
        }
    }
    if (suma <= sumb / 2) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


Measured memory_bytes: 3752
n = int(input())
a = list(map(int, input().split()))
count0 = 0
count2 = 0
count4 = 0

for i in range(n):
    if a[i]%2 == 1:
        count0 += 1
    elif a[i]%4 == 0:
        count4 += 1
    else:
        count2 += 1

if count2 > 0:
    N = n - (count2 - 1)
else:
    N = n

if N//2 <= count4:
    print("Yes")
else:
    print("No")

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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()
#define YES()         printf("YES\n")
#define NO()          printf("NO\n")
#define Yes()         printf("Yes\n")
#define No()          printf("No\n")
#define in(a,x,b)     ((a) <= (x) && (x) < (b))

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

const int dxs[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dys[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

int prime[1001001];
bool is_prime[1001001];

int sieve(int n) {
  int p = 0;
  for (int i = 0; i < n; i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i < n; i++){
    if (is_prime[i]){
      prime[p++] = i;
      for (int j = 2*i; j < n; j+=i) is_prime[j] = false;
    }
  }
  return p;
}

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

  int N;
  cin >> N;
  string S;
  cin >> S;

  int ans = 0;
  REP(i,10) {
    auto index_i = S.find(i+48);
    if (index_i == string::npos) continue;
    REP(j,10) {
      auto index_j = S.find(j+48, index_i+1);
      if (index_j == string::npos) continue;
      REP(k,10) {
        auto index_k = S.find(k+48, index_j+1);
        if (index_k == string::npos) continue;
        ans++;
      }
    }
  }

  print(ans);
}



Measured memory_bytes: 3716
n,*t=`dd`.split.map &:to_i
v=t.map!{|e|e*2}.pop n
z=[0]*10**5
q=j=s=m=0
n.times{|i|z[j]=[z[j],v[i]].min;(j+1..j=q+=t[i]).map{|k|z[k]=[z[k-1]+1,v[i]].min}}
(j-1).downto(0){|i|s+=m=[m+1,z[i]].min}
p s/4.0

Measured memory_bytes: 2696
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC085_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] str = input.Split(' ');
            int numberOfBill = int.Parse(str[0]);
            int money = int.Parse(str[1]);
            int res10000 = -1;
            int res5000 = -1;
            int res1000 = -1;


            for (int a = 0; a <= numberOfBill; a++)
            {
                for (int b = 0; b <= numberOfBill; b++)
                {
                    int c = numberOfBill - (a + b);
                    int total = a * 10000 + b * 5000 + c * 1000;
                    if (total == money && c >= 0)
                    {
                        res10000 = a;
                        res5000 = b;
                        res1000 = c;

                        Console.WriteLine("{0} {1} {2}", res10000, res5000, res1000);
                        return;
                    }
                }
            }

            Console.WriteLine("{0} {1} {2}", res10000, res5000, res1000);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
// 入力
int R,G,B,N;
int n=3;

// DPテーブル
int dp[4][3001];
int a[4];


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

  memset(dp, 0, sizeof(dp));   // 一旦すべて 0 に
  dp[0][0] = 1;                // dp[0][0] だけ 1 に

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= N; ++j) {
      dp[i+1][j] += dp[i][j];
      if (j >= a[i]) (dp[i+1][j] += dp[i+1][j-a[i]]);
    }
  }
  cout << dp[n][N] << endl;
}

Measured memory_bytes: 256