akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;


int main() {
	int n, k;
	cin >> n >> k;
	vector<int>h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector<int>dp(n, INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= k; j++) {
			if (i + j >= n)continue;
			if (dp[i + j] > dp[i] + abs(h[i] - h[i + j])) {
				dp[i + j] = dp[i] + abs(h[i] - h[i + j]);
			}
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin>>N>>K;
    vl a(N);
    rep(i,N)cin>>a[i];
    sort(all(a));
    ll ans=0;
    rep(i,N-K)ans+=a[i];
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int n;cin>>n;
    int x[n],ab=0;
    int s1=0,s2=0;

    
    rep(i,n){
        cin >> x[i];
        s1+=x[i];
    } 
    ab = s1;
    rep(i,n){
        s2+=x[i];
        s1-=x[i];
        
        ab=min(ab,abs(s1-s2));
    }
    cout << ab << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  static int kaizyo(int n){
    int sum=1;
    for(int i=n;i>0;i--){
      sum*=i;
    }
    return sum;
  }
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int N=scan.nextInt();
    double[] x=new double[N];
    double[] y=new double[N];
    for(int i=0;i<N;i++){
      x[i]=scan.nextDouble();
      y[i]=scan.nextDouble();
    }
    int n=kaizyo(N);
    double[] trail=new double[n];
    double average=0;
    int k=0;
    double ans=0;
    for(int i=0;i<N-1;i++){
      for(int j=i+1;j<N;j++){
        trail[k++]=Math.sqrt((x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i]));
      }
    }
    int X=2*kaizyo(N-1);
    for(int i=0;i<k;i++){
        ans+=(trail[i]*X);
    }
    average=(double)ans/n;
    System.out.println(average);
  }
}

Measured memory_bytes: 25172
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define repr(i,a,b) for (int i = a; i > b; --i)
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)
#define forn(x,	n) for(long long int x = 0; x < n ;++ x) 
#define null NULL
#define eps 0.000000001
#define mod 1000000007
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (int)V.size()
#define _ <<" "<<
#define MAX INT_MAX
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
double dp[3001][3001];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 	
	//freopen ("randomshit.txt","r",stdin);
int n;
cin>>n;
double a[n];
forn(x,n){cin>>a[x];}
dp[0][0]=1-a[0];
dp[0][1]=a[0];
for(int i=1;i<n;i++)
{
	for(int j=0;j<=n;j++)
	{
		if(j==0){ dp[i][j]=(dp[i-1][j])*(1-a[i]);}
		else 
			{ dp[i][j]=dp[i-1][j]*(1-a[i])+(dp[i-1][j-1])*(a[i]);}
	}
}
double net=0;
int mid=(n/2)+1;
for(int i=n;i>=mid;i--)
{ 
   net+=dp[n-1][i];
  // cout<<net<<endl;
}
cout<<setprecision(10)<<net;
}



Measured memory_bytes: 70528
N, M = map(int, input().split())
student_positions = [input().split() for _ in range(N)]
student_positions = [[int(a[0]), int(a[1])] for a in student_positions]
check_points = [input().split() for _ in range(M)]
check_points = [[int(a[0]), int(a[1])] for a in check_points]


def calc_manhattan_distance(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])


def get_closest_point(x, candidates):
    prev_distance = 10 ** 10
    for idx, candidate in enumerate(candidates):
        distance = calc_manhattan_distance(x, candidate)
        if distance < prev_distance:
            prev_distance = distance
            target_idx = idx
    return target_idx


for p in student_positions:
    print(get_closest_point(p, check_points)+1)


Measured memory_bytes: 3064
import java.util.*;
public class Main{
	public static void main(String[] argus){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int recoverSum = 0;
		int[] del = new int[N+1];
		int ans = 0;
		
		for(int i=0; i<N; i++){
			del[i] = sc.nextInt();
		}
		
		for(int j=0; j<N; j++){
			for(int h=j+1; h<N; h++){
				ans = del[j] * del[h];
				recoverSum += ans;
				ans = 0;
			}
		}
		
		System.out.println(recoverSum);
	}
}


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main(void){
    int h, w;
	while(1){
		std::cin >> h >> w;
		if(!h && !w)
			break;
		for(int j = 0; j < h; j++){
			for(int i = 0; i < w; i++){
				std::cout << '#';
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
}



Measured memory_bytes: 3080
//Author : Sidiq Tri Pratikto
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
//order_of_key(x) = number of elements stricly smaller than x
//find_by_order(x) = return x-th largest element
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	int S, W;
	scanf("%d%d", &S, &W);
	if (W >= S) {
		printf("unsafe\n");
	} else {
		printf("safe\n");
	}
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long[] nn = sc.LongArray();

        nn = nn.OrderBy(num => num).ToArray();

        bool ok = string.Join("", nn.Select(num => num.ToString())) == "1479";

        string answer = ok ? "YES" : "NO";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 28492
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>
#include <list>
#include <queue>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  string s, t; cin>>s>>t;
  vector<int> s_table(26,0), t_table(26,0);
  for(int i=0; i < (int)s.size(); i++) {
    s_table[s[i] - 'a']++;
    t_table[t[i] - 'a']++;
  }

  sort(s_table.begin(), s_table.end());
  sort(t_table.begin(), t_table.end());

  string ans = "No";
  if(s_table == t_table) ans = "Yes";
  cout << ans << endl;
}


Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
    int n, y;
    cin >> n >> y;
    int unit[] = {10000, 5000, 1000};
    bool flag = false;
    rep(i,n+1){
        if(flag)break;
        rep(j,n+1){
            int sen = (n-i-j);
            if(sen < 0)continue;
            if(i*unit[0]+j*unit[1]+sen*unit[2] == y){
                cout<<i<< " "<<j<<" "<<sen<<endl;
                flag = true;
            }
        }
    }
    if(!flag){
        cout << -1 << " " << -1 << " "<<-1<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define max3(x,y,z) max(x,max(y,z))
ll dp[100009][3]= {-1};
ll inf = -1*1e9;
ll n;
ll arr[100009][3];


int main()
{
  cin >> n;
  memset(dp,-1,sizeof dp);
  for(int i=0;i<n;i++)
  {

    cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
  }  
  
dp[0][1]=arr[0][1];dp[0][2]=arr[0][2];dp[0][0]=arr[0][0];
for(int i=1;i<n;i++)
{
for(int j=0;j<3;j++)
for(int k=0;k<3;k++)
if(k!=j)
dp[i][j]=max(dp[i][j],dp[i-1][k]+arr[i][j]);

}
cout<<max3(dp[n-1][0],dp[n-1][1],dp[n-1][2]);

}

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

public class Main {
    
    public static void main(String[] argv) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int n = Integer.parseInt(str[0]);
        int W = Integer.parseInt(str[1]);

        int[] v = new int[n];
        int[] w = new int[n];
        for (int i = 0; i < n; i++) {
            str = br.readLine().split(" ");
            v[i] = Integer.parseInt(str[0]);
            w[i] = Integer.parseInt(str[1]);
        }

        int[][] dp = new int[n+1][W+1];
        for(int i=0; i<n+1; i++) dp[i][0] = 0;
        for(int i=0; i<W+1; i++) dp[n][i] = 0;

        for(int i=n-1; i>=0; i--){
            for(int j=W; j>=0; j--){
                if(w[i] > j){
                    dp[i][j] = dp[i+1][j];
                } else {
                    dp[i][j] = Integer.max(dp[i+1][j], dp[i+1][j-w[i]] + v[i]);
                }
            }
        }

        System.out.println(dp[0][W]);

    }
}

Measured memory_bytes: 29076
#include<bits/stdc++.h>
using namespace std;
long long x,a,b,c,counter;
long long every;
int main()
{
     cin>>a>>b>>c>>x;
    for (int i=0;i<=a;++i)
    for (int j=0;j<=b;++j)
    for (int k=0;k<=c;++k)
    {
        every=k*50+j*100+i*500;
        if(every==x)++counter;
        if(every>x)break;
    }
    cout<<counter<<endl;
    return 0;
}
//Ben Konjac Jac can only be violently enumerated.

Measured memory_bytes: 256
while (h, w = gets.split(" ").map(&:to_i)) != [0,0]
  line = ["#." * (w / 2) + "#" * (w % 2), ".#" * (w / 2) + "." * (w % 2)]
  h.times do |i|
    puts line[i % 2]
  end
  puts
end

Measured memory_bytes: 8548
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,h=parseMap(split(readline()))
    a,b=[],[]
    for i in 1:n
        A,B=parseMap(split(readline()))
        push!(a,A)
        push!(b,B)
    end
    sort!(a,rev=true)
    sort!(b,rev=true)
    ans=0
    for i in b
        if h<=0 || a[1]>i
            break
        end
        h-=i
        ans+=1
    end
    println(ans+max(0,cld(h,a[1])))
end
main()

Measured memory_bytes: 152824
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,m,ans=0;
    cin >> n >> m;
    vector<int> a(n+2),l(m),r(m);
    for (int i=0;i<m;i++){
        cin >> l.at(i) >> r.at(i);
    }
    for (int i=0;i<n+2;i++){
        a.at(i)=0;
    }
    for (int i=0;i<m;i++){
        a.at(l.at(i))++;
        a.at(r.at(i)+1)--;
    }
    for (int i=1;i<n+1;i++){
        a.at(i)=a.at(i-1)+a.at(i);
        if (a.at(i)==m) ans++;
    }
    cout << ans << endl;
}

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

int main(){

  char str[100010];
  int len,i,count=0;

  scanf("%s",str);
  len=strlen(str);

  for(i=0;i<len-1;i++){
    if(str[i]!=str[i+1]) count++;
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn gcd(a: usize, b: usize) -> usize{
    if b == 0{
        return a;
    }

    return gcd(b, a%b);
}

fn lcm(a: usize, b: usize) -> usize{
    return a*b /gcd(a, b);
}

//21:37
fn main(){
    let n: usize = read_as_vec()[0];
    let a: Vec<usize> = read_as_vec();

    let mut m = 1;

    let mut ans = 0;
    for &elem in &a{
        ans += (elem -1);
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
from heapq import *
import copy


#int(input())
#map(int,input().split())
N=int(input())
S=Counter([input() for i in range(N)]).most_common()
S=[i[0] for i in S if i[1]==S[0][1]]
for i in sorted(S):
    print(i)


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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

vector<vector<pair<int, int> > > edge;//edge[i][j] firstがiからj番目のノード、secondがその重み
vector<int> d(100005,INF);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
	cin >> n;
	vi c(n-1), s(n-1), f(n-1);
	rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
	rep(i,n){
		int ans = 0;
		for(int j = i; j < n-1; j++){
			if(ans <= s[j]){
				ans = s[j];
			}else{
				if((ans - s[j]) % f[j] != 0){
					ans += (f[j] - (ans - s[j]) % f[j]);
				}
			}
			ans += c[j];
		}
		cout << ans << '\n';
	}
	return 0;
}

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

using namespace std;

queue<int>q[1005];
set<pair<int,pair<int,int> > >s;
set<int>temp;

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

    int n,i,j,x,y,now=0,cnt=0;
    cin>>n;
    for(i=1;i<=n;i++){
        for(j=1;j<n;j++){
            cin>>x;
            q[i].push(x);
        }
    }
    for(i=1;i<=n;i++){
        x = q[i].front();
        if(s.find({2,{min(i,x),max(i,x)}}) == s.end())
            s.insert({2,{min(i,x),max(i,x)}});
        else{
            s.erase(s.find({2,{min(i,x),max(i,x)}}));
            s.insert({1,{min(i,x),max(i,x)}});
        }
    }
    while(!s.empty()){
        auto it = s.begin();
        while(it!=s.end()){
            if(it->first == 2)break;
            x = (it->second).first;
            y = (it->second).second;
            q[x].pop();q[y].pop();
            temp.insert(x);
            temp.insert(y);
            now++;it++;
        }
        if(now==0){
            cout<<"-1\n";
            return 0;
        }
        while(now){
            it = s.begin();
            s.erase(it);
            now--;
        }
        for(auto ii = temp.begin();ii!=temp.end();ii++){
            x = *ii;if(q[x].empty())continue;
            if(s.find({2,{min(x,q[x].front()),max(x,q[x].front())}})==s.end())
                s.insert({2,{min(x,q[x].front()),max(x,q[x].front())}});
            else{
                s.erase(s.find({2,{min(x,q[x].front()),max(x,q[x].front())}}));
                s.insert({1,{min(x,q[x].front()),max(x,q[x].front())}});
            }
        }
        temp.clear();
        cnt++;
    }
    cout<<cnt<<'\n';
    return 0;
}


Measured memory_bytes: 4736
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
 
//============================================================================
#define pred(x) ((x)-1)
#define succ(x) ((x)+1)
//============================================================================
//============================================================================
#define P_START 0.0
#define P_FINISH 100.0
//============================================================================
#define PI 3.141592653589793
#define DMAX 0.005
#define MAXN 6
unsigned int a;
double d, lsX,lsY,costbl[MAXN], sintbl[MAXN];
 
void koch(int n)
{
    double x,y;
    if (!n){
        x=d * costbl[a % MAXN]+lsX; y=d * sintbl[a % MAXN]+lsY;
        printf("%lf %lf\n", x, y);
        lsX=x, lsY=y;
    }else {
        n--; d /= 3;  koch(n);  a++;  koch(n);
        a += 4;  koch(n);  a++;  koch(n);
        d *= 3;
    }
}
//----------------------------------------------------------------------------
void input(FILE *file)
{
    short n;
 
    fscanf(file, "%hd", &n);
    for (a = 0; a < MAXN; a++) {
        costbl[a] = cos(a * PI / 3);
        sintbl[a] = sin(a * PI / 3);
    }
    d = P_FINISH;  a = 0; lsX=lsY=P_START;
    printf("%lf %lf\n", lsX, lsY);
    koch(n);
}
//============================================================================
#ifndef DESKTOP
int main()
{
    input(stdin);
    return 0;
}
#endif

Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll INF = 1e10;
int main()
{
    int x, y;
    cin >> x >> y;
    ll a = INF, b = INF, c = INF, d = INF;
    ll mx = -x;
    ll my = -y;
    if(y >= x) a = y-x;
    if(y >= mx) b = y-mx + 1;
    if(my >= x) c = my-x + 1;
    if(my >= mx) d = my-mx+2;

    cout << min(min(a, b), min(c, d)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,m;
    ll k;
    cin>>n>>m>>k;
    vector<ll> sa,sb;
    sa.push_back(0);
    sb.push_back(0);
    rep(i,n){
        ll a;
        cin>>a;
        sa.push_back(a);
    }
    rep(i,m){
        ll b;
        cin>>b;
        sb.push_back(b); 
    }
    for(int i=1;i<n+1;i++) sa[i]+=sa[i-1];
    for(int i=1;i<m+1;i++) sb[i]+=sb[i-1];

    int ans=0;
    int id=m;
    rep(i,n+1){
        if(sa[i]>k) break;
        while(sa[i]+sb[id]>k){
            id--;
        }
        //cout<<i<<" "<<id<<endl;
        ans=max(ans,i+id);
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 7956
N = int(input())
S = input()

left = 0
right = 0
for i in range(N):
    if S[i] == ".":
        right += 1

ans = left + right

for i in range(N):
    if S[i] == "#":
        left += 1
    else:
        right -= 1
    ans = min(ans, left + right)

print(ans)


Measured memory_bytes: 3500
import math
input_num = int(input())
sqrt_num = math.floor(math.sqrt(input_num))

min_count = 1 + input_num
for i in range(sqrt_num + 1, 1, -1):
  if(input_num % i == 0) and (min_count > input_num//i + i):
    min_count = input_num//i + i
print(min_count - 2)


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

const ll INF = 1001001001001001001;
const int MAX = 5e5 + 10;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    ll sum = 0, ans = INF, tmp = 0;
    for(int i = 0; i < n; i++){
        sum += a[i];
        if(i % 2 == 0 && sum <= 0){
            tmp += 1 - sum;
            sum = 1;
        }
        if(i % 2 == 1 && sum >= 0){
            tmp += sum + 1;
            sum = -1;
        }
    }
    ans = min(ans, tmp);
    tmp = 0;
    sum = 0;
    for(int i = 0; i < n; i++){
        sum += a[i];
        if(i % 2 == 0 && sum >= 0){
            tmp += sum + 1;
            sum = -1;
        }
        if(i % 2 == 1 && sum <= 0){
            tmp += 1 - sum;
            sum = 1;
        }
    }
    ans = min(ans, tmp);
    cout << ans << endl;
}

Measured memory_bytes: 3808
// AGC015_A
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    ll N, A, B;
    cin >> N >> A >> B;
    
    // calculation
    if (N == 1) {
        if (abs(A - B) == 0) {
            cout << 1 << "\n";
        } else {
            // 3, 4 とかもありえない
            cout << 0 << "\n";
        }
    } else if (B < A) {
        // min = 4, max = 3 とかはありえない
        cout << 0 << "\n";
    } else {
        // N >= 2
        if ((B - A) == 0) {
            cout << 1 << "\n";
        } else {
            ll sum_min = A + B + A*(N-2), sum_max = A + B + B*(N-2);
            cout << sum_max - sum_min + 1 << "\n";
        }
    }
    
    return 0;
}


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

using namespace std;
char a[100010];
int main(){
	int n, m;
	scanf("%d", &n);
	scanf("%s", a+1);
	a[0] = a[1];
	int t = 1;
	for (int i = 1; i <= n; i++) {
		if (a[i] != a[i-1]) t++;
	}
	printf("%d\n", t);
	return 0;
}

Measured memory_bytes: 384
import collections
s=input()
c = collections.Counter(s[2:-1])
if s[0]=="A" and c["C"] == 1:
    for item in s:
        if item.isupper() == True and item!="A" and item!="C":
            print("WA")
            exit()
    print("AC")
else:
    print("WA")



Measured memory_bytes: 38256
#include <iostream>

using namespace std;

int findMax(int* ary, int size);
int findMin(int* ary, int size);

int main()
{
	int N, M, X, Y;
	int x_max, y_min;
	bool result;

	cin >> N >> M >> X >> Y;

	int* x = new int[N];
	int* y = new int[M];

	for (int i = 0; i < N; i++) cin >> x[i];
	for (int i = 0; i < M; i++) cin >> y[i];

	x_max = findMax(x, N);
	y_min = findMin(y, M);

	if ( (x_max < y_min) 
	  && (X < x_max)
	  && (y_min < Y) ) result = true;
	else result = false;

	if (result) cout << "No War" << endl;
	else cout << "War" << endl;

	return 0;
}

int findMax(int* ary, int size)
{
	int max = ary[0];

	for (int i = 1; i < size; i++) {
		if (max < ary[i]) max = ary[i];
	}

	return max;
}

int findMin(int* ary, int size)
{
	int min = ary[0];

	for (int i = 1; i < size; i++) {
		if (min > ary[i]) min = ary[i];
	}

	return min;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    for(int T = 0; T < t ; T++){
        ll a, b, v, w;
        cin >> a >> v;
        cin >> b >> w;
        ll t;
        cin >> t;
        ll dis = abs(b - a);
        ll rs = v - w;
        if(rs <= 0)
            std::cout << "NO" << std::endl;
        else if(dis/rs > t)
            cout << "NO" << endl;
        else if(dis/rs == t && dis%rs!=0){
            cout << "NO" << endl;
        }
        else{
            cout << "YES" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3632
S=[]
ans=0
l=0

def bc(i,las,sum):
    global ans
    if i==l:
        ans+=int(S[las:])+sum
        return False
    if bc(i+1,las,sum):
        return True
    if bc(i+1,i+1,sum+int(S[las:i+1])):
        return True
    return False

S=input()
l=len(S)-1
bc(0,0,0)
print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;
typedef vector<vector<ll>> matrix;

void die() {
  cout << "0\n";
  exit(0);
}

map<int, int> must;

void force(int x, int y) {
  if(must.count(x) && must[x] != y) die();
  must[x] = y;
}

void solve() {
  int n;
  vector<int> ltor, rtol;
  cin >> n;
  ltor.resize(n);
  rtol.resize(n);
  for(int i = 0; i < n; i++) cin >> ltor[i];
  for(int i = 0; i < n; i++) cin >> rtol[i];
  force(0, ltor[0]);
  for(int i = 1; i < n; i++) {
    if(ltor[i] != ltor[i-1]) force(i, ltor[i]);
  }
  force(n-1, rtol[n-1]);
  for(int i = n-2; i >= 0; i--) {
    if(rtol[i] != rtol[i+1]) force(i, rtol[i]);
  }
  {
    int curr = 0;
    for(int i = 0; i < n; i++) {
      if(must.count(i)) curr = max(curr, must[i]);
      if(curr != ltor[i]) die();
    }
  }
  {
    int curr = 0;
    for(int i = n-1; i >= 0; i--) {
      if(must.count(i)) curr = max(curr, must[i]);
      if(curr != rtol[i]) die();
    }
  }

  ll ret = 1;
  for(int i = 0; i < n; i++) {
    if(must.count(i)) continue;
    ret *= min(ltor[i], rtol[i]);
    ret %= 1000000007;
  }
  cout << ret << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


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

int main(){
	int n, m, l;
	int i, j, k;
	long long *A, *B, *C;


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


	A = malloc(sizeof(long long)*n*m);
	
	B = malloc(sizeof(long long)*m*l);

	C = malloc(sizeof(long long)*n*l);


	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			scanf("%d", &A[i*m+j]);
		}
	}
	for(i=0; i<m; i++){
		for(j=0; j<l; j++){
			scanf("%d", &B[i*l+j]);
		}
	}
	for(i=0; i<n; i++){
		for(j=0; j<l; j++){
			C[i*l+j] = 0;
			for(k=0; k<m; k++){
				C[i*l+j] = C[i*l+j] +  A[i*m+k] * B[k*l+j]; 
			}
		}
	}
	for(i=0; i<n; i++){
		for(j=0; j<l; j++){
			if(j>0)
				printf(" ");
			printf("%ld", C[i*l+j]);
		}
		printf("\n");
		
	}	


	free(A);
	free(B);
	free(C);

	return 0;

}


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

int main()
{
    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;
    
    vector<int> ans(n, 0);
    
    for(int i = 0; i < n - 1; ++i) {
        for(int j = i+1; j < n; ++j) {
            int dist = abs(j - i);
            dist = min(dist, abs(i - x) + 1 + abs(y - j));
            //dist = min(dist, abs(i - y) + 1 + abs(x - j));
            ans[dist]++;
        }
    }
    
    for(int i = 1; i < n; ++i){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int c=0,cc=0;
    string s;cin>>s;

    for(int  i=0;i<s.size();i++)
    {
        if(s[i]=='A')
            c++;
        else
            cc++;
    }
    if(c>0&&cc>0)
        cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256
a,b = gets.strip.split.map(&:to_i)
cnt = 0 
x = (a..b).to_a
x.each do |y|
  if y.to_s[0]==y.to_s[-1] && y.to_s[1]==y.to_s[-2]
    cnt += 1
  end
end
puts cnt

Measured memory_bytes: 14992
# @uthor : Kaleab Asfaw
from sys import stdin, stdout
# Fast IO
# from math import gcd

def input():
	a = stdin.readline()
	if a[-1] == "\n": a = a[:-1]
	return a
def print(*argv, end="\n", sep=" "):
	n = len(argv)
	for i in range(n):
		if i == n-1: stdout.write(str(argv[i]))
		else: stdout.write(str(argv[i]) + sep)
	stdout.write(end)
# Others
mod = 10**9+7
def lcm(x, y): return (x * y) / (gcd(x, y))
def fact(x, mod=mod):
	ans = 1
	for i in range(1, x+1): ans = (ans * i) % mod
	return ans
def arr2D(n, m, default=0):
	lst = []
	for i in range(n): temp = [default] * m; lst.append(temp)
	return lst
def sortDictV(x): return {k: v for k, v in sorted(x.items(), key = lambda item : item[1])}

def solve(n):
	return 1-n

n = int(input())
print(solve(n))

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

using namespace std;
vector<bool> a;
int main()
{
    int n;
    cin>>n;
    a.assign(2*n+2,true);
    for(int i = 2;i<a.size();i++)
    {
        if(a[i])
        {
            if(i>=n)
            {
                cout<<i;
                break;
            }
            for(int j = i*i;j<a.size();j+=i)a[j]=false;
        }
    }
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	if(sz(s)==1){ cout << s <<"\n"; return 0;}
	int n = sz(s) -1;
	ll sm =0;
	rep(i, 1<<n){
		int st=0; 
		rep(j, n){
			if(i>>j &1){
				ll su = stoll(s.substr(st, j+1-st));
				sm += su; st= j+1;
			}
		}
		ll su = stoll(s.substr(st));
		//dbg(st,su);
		sm +=su;
	}
	cout << sm <<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>

using namespace std;

long long MOD=1000000007;

//A:0 G:1 C:2 T:3

bool check(int a,int b,int c,int d){
    if(b==0&&c==1&&d==2){return true;}
    if(b==1&&c==0&&d==2){return true;}
    if(b==0&&c==2&&d==1){return true;}
    if(a==0&&c==1&&d==2){return true;}
    if(a==0&&b==1&&d==2){return true;}
    
    return false;
}

int main(void){

    int N;
    cin>>N;

    int dp[101][5][5][5];


    for(int i=0;i<N+1;i++){
        for(int j=0;j<5;j++){
            for(int k=0;k<5;k++){
                for(int l=0;l<5;l++){
                    dp[i][j][k][l]=0;
                }
            }
        }
    }
    
    dp[0][4][4][4]=1;

    for(int i=0;i<N;i++){
        for(int j=0;j<5;j++){
            for(int k=0;k<5;k++){
                for(int l=0;l<5;l++){
                    for(int m=0;m<4;m++){
                        if(check(j,k,l,m)){continue;}
                        dp[i+1][k][l][m]+=dp[i][j][k][l];
                        dp[i+1][k][l][m]%=MOD;
                    }
                }
            }
        }
    }

    int ans=0;
    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++){
            for(int k=0;k<5;k++){
                ans+=dp[N][i][j][k];
                ans%=MOD;
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)
#define myforInv(i,N) for(i=N;i>=0;i--)
#define myforFLInv(i,f,l) for(i=f;i>l;i--)
#define ifMeetBoundaryCondition(x,xMax,xMin,y,yMax,yMin) if(x < xMax && x >= xMin &&y < yMax && y >= yMin)
#define INF pow(10,9)
using namespace std;

int dx[] = {1,-1,0,0},dy[]={0,0,1,-1};

int main(){
	int A,B,i,j;
	cin >> A >> B;
	int minX = ceil(12.5*A);
	int maxX = ceil(12.5*(A+1)-1);
	int minY = 10*B;
	int maxY = 10*(B+1)-1;

	myforFL(i,minX,maxX+1){
		myforFL(j,minY,maxY+1){
			if(i == j){
				cout << i << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if (a == b && b != c){
        printf("Yes");
    }else if(b == c && a != c){
        printf("Yes");        
    }else if (a == c && b != c){
        printf("Yes");        
    }else{
        printf("No");
    }
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<bitset>
#include<functional>
#include<climits>
using namespace std;
typedef pair<int,int>pii;
const int INF=1e9;
const int dx[]={0,-1,0,1},dy[]={-1,0,1,0};



int main(){
    int n;
    while(cin>>n,n){
        int v[100];
        for(int i=0;i<n;i++)cin>>v[i];
        int t;cin>>t;
        int ub=n-1,lb=0;
        int cnt=0;
        bool flag=true;
        while(ub>=lb){
            cnt++;
            int mid=(ub+lb)/2;
            if(v[mid]>t)ub=mid-1;
            else if(v[mid]<t)lb=mid+1;
            else if(v[mid]==t){
                cout<<cnt<<endl;
                flag=false;
                break;
            }
        }
        if(flag)cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const bool DEBUG = 0;
const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int x; cin>>x;
	if(x==0) cout<<1<<'\n';
	else cout<<0<<'\n';
	
	return 0;
}


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

//#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 #if 0
int main() {
    long long  N = 100;
    long long X,R=100;

    cin >> X;

    for(int i=0;i<X;i++){
        N += R*0.01;
        R = N;
    }

    cout << N << endl;


}
#endif

int main(){
    long long  N = 100;
    long long X,R=100;
    int i;
    cin >> X;

    for(i=1; ;i++){
        N += R*0.01;
        R = N;
        
        if(N>=X){
            break;
        }
    }

    cout << i << endl;
    

}

Measured memory_bytes: 3596
//writer：Sakura
//problem：Zero-Sum Ranges
//id：
//from：

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
//#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int a[200005];
map<ll,int> t;
int n;
ll sum=0;
ll ans=0;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d",&n);
	t[0]=1;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
		ans+=t[sum];
		t[sum]+=1;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 13568
h, w = map(int, input().split())
l = [0]*(h+2)
l[0] = '.'*(w+2)
l[-1] = '.'*(w+2)

for _ in range(1, h+1):
  l[_] = '.' + str(input()) + '.'

for i in range(1, h+1):
  for j in range(1, w+1):
    if l[i][j] == '.':
      continue
    else:
      if all (l[i+i_][j+j_] == '.' for i_, j_ in ([1, 0], [-1, 0], [0, 1], [0, -1])):
        print('No')
        exit()
      else:
        continue
else:
  print('Yes')

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

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

//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n, q;
  cin >> n >> q;
  vector<stack<ll>> st(n);

  REP(i,q){
    ll com;
    cin >> com;
    if(com == 0){
      ll t, x;
      cin >> t >> x;
      st[t].push(x);
    }
    else if(com == 1){
      ll t;
      cin >> t;
      if(!st[t].empty()) cout << st[t].top() <<endl;
    }
    else{
      ll t;
      cin >> t;
      if(!st[t].empty()) st[t].pop();
    }
  }
    
  return 0;
}




Measured memory_bytes: 5236
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int n = stdIn.nextInt();
			if(n == 0)
			{
				break;
			}
			List<Integer> list = new ArrayList<Integer>();
			for(int i = 0; i < n; ++i)
			{
				int a = stdIn.nextInt();
				list.add(a);
			}
			int max = -99999999;
			for(int i = 0; i < n; ++i)
			{
				int sum = 0;
				for(int j = i; j < n; ++j)
				{
					sum += list.get(j);
					if(sum > max)
					{
						max = sum;
					}
				}
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
int main()
{
    int n, i, j;
    scanf("%d", &n);

    for(i=1; i<=9; i++)
    {
        for(j=i; j<=9; j++)
        {
            if(i*j == n)
            {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");

    return 0;
}


Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let x = scan!(i64);
    if x < 1200 {
        println!("ABC")
    } else {
        println!("ARC")
    }
}


Measured memory_bytes: 4352
def count(x):
    cnt=0
    while x!=0:
        if x%2==0:
            x//=2
            cnt+=1
        else:
            break
    return cnt
n=int(input())
a=list(map(int,input().split()))
ans=0
for aa in a:
    if aa%2==0:
        ans+=count(aa)
print(ans)



Measured memory_bytes: 4148
#include <stdio.h>
int main(){
    int x,y;

    do{
     scanf("%d %d",&x,&y);
     if(x==y && x==0)break;
     if(x<y)
       printf("%d %d\n",x,y);
     else
       printf("%d %d\n",y,x);
    }while(1);
    
    return 0;
}
    

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;

string s, t;
const int max_l = 3010;
vector<vector<int>> dp(max_l, vector<int>(max_l, 0));
vector<vector<string>> dps(max_l, vector<string>(max_l, ""));

int main() {
    cin >> s >> t;
    int len_s = s.size();
    int len_t = t.size();
    rp(i, 1, len_s + 1) {
        rp(j, 1, len_t + 1) {
            chmax(dp.at(i).at(j), dp.at(i-1).at(j));
            chmax(dp.at(i).at(j), dp.at(i).at(j-1));
            if(s.at(i-1) == t.at(j-1)) {
                chmax(dp.at(i).at(j), dp.at(i-1).at(j-1) + 1);
            }
        }
    }
    string res = "";
    int i = s.size();
    int j = t.size();

    while(i>0 && j>0) {
        if(dp.at(i).at(j) == dp.at(i-1).at(j)) i--;
        else if(dp.at(i).at(j) == dp.at(i).at(j-1)) j--;
        else {
            res = s.at(i-1) + res;
            i--;
            j--;
        }
    }

    cout << res;
    return 0;
} 

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

using namespace std;

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

    if(abs(x-a) < abs(x-b)){
        cout << 'A' << endl;
    }else{
        cout << 'B' << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// 2017-01-10
#include <iostream>
using namespace std;

int H = 0;

void maxHeapify(int* a, int i) {
	int l = 2 * i + 1;
	int r = 2 * i + 2;
	int largest;
	if (l <= H && a[l] > a[i]) {
		largest = l;
	} else {
		largest = i;
	}
	if (r <= H && a[r] > a[largest]) {
		largest = r;
	}
	if (largest != i) {
		int t = a[i];
		a[i] = a[largest];
		a[largest] = t;
		maxHeapify(a, largest);
	}
}

void buildMaxHeap(int* a) {
	for (int i = (H + 1) / 2 - 1; i >= 0; i--) {
		maxHeapify(a, i);
	}
}

int main() {
	int a[500002] = {};
	cin >> H;
	for (int i = 0; i < H; i++) {
		cin >> a[i];
	}
	buildMaxHeap(a);
	for (int i = 0; i < H; i++) {
		cout << ' ' << a[i];
	}
	cout << endl;
	return 0;
}

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

void bubbleSort(int *, int); // N 個の要素を含む 0-オリジンの配列 A


int main() {
  int i, N, *A;
  
  scanf( "%d" , &N );
  A = (int *)malloc(N * sizeof(int));
  for( i=0; i<N; i++ ) scanf( "%d" , &A[i] );
  bubbleSort(A, N);
  
  return 0;
}


void bubbleSort(int *A, int N) {
  int flag=1, i=0, j, temp, count=0; // flag=1 : 逆の隣接要素が存在する
  
  while ( flag ) { // flag != 0
    flag = 0;
    for ( j=(N-1); j>i; j-- ) {
      if ( A[j] < A[j-1] ) {
        temp = A[j];
        A[j] = A[j-1];
        A[j-1] = temp;
        count++;
        flag = 1;
      }
    }
    i++;
  }
  for ( j=0; j<(N-1); j++ ) printf( "%d " , A[j] );
  printf( "%d\n%d\n" , A[N-1] , count );
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool>> vec2bool;
typedef vector<vector<int>> vec2int;
typedef vector<vector<double>> vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int n, m;
  cin >> n >> m;
  cout << ((n > m) ? "safe" : "unsafe") << endl;
}


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

int main(){
    int N, Y;
    cin >> N >> Y;
    int a = -1, b = -1, c = -1;
    rep(i, N+1){
        rep(j, N+1){
            if(i+j > N) continue;
            int k = N-(i+j);
            if(i*10000+j*5000+k*1000 == Y) a = i, b = j, c = k;
        }
    }
    cout << a << ' ' << b << ' ' << c << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>

using namespace std;
const long long mod = 1e9 + 7;

int main()
{
    int n,i;
    long long sum;

    while(scanf("%d",&n) != EOF)
    {
        sum = 1;
        for(i = 1;i <= n;i++)
        {
            sum = sum * i % mod;
        }
        printf("%lld\n",sum%mod);
    }

    return 0;
}


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

int main(){
	int A,B,C;
	cin>>A>>B>>C;

	if (A>B){
		swap(A,B);
	}
	if (A>C){
		swap(A,C);
	}
	if(B>C){
		swap(B,C);
	}

	cout<<C-A<<endl;
}


Measured memory_bytes: 256