akhauriyash/Code-Regression huggingface dataset:
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		int n;
		string s;
		cin >> n >> s;
		int k = 0,ans = 0;
		for (int i=0 ; i<n ; i++)
		{
			if(s[i]=='.')
			k++;
			ans=k;
		}
		for (int i=0 ; i<n ; i++)
		{
			if(s[i]=='.')
			k--;
			else
			k++;
			ans = min(ans,k);
		}
		cout << ans << endl;
		
		
		//cout << abs(cnt1-cnt2) << endl;
		return 0;  
}  


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

using namespace std;

string s;

int main() 
{
	ios::sync_with_stdio(false);
	
    cin>>s;
    
	int ans=s.size(),len=s.size();
	
    for (register int i=0;i<s.size()-1;++i)
        if(s[i]!=s[i+1])
            ans=min(ans,max(i+1,len-i-1));
    
	cout<<ans<<endl;
    
	return 0;
}

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

using namespace std;

#define pb push_back
#define F first
#define S second
#define fast_cin() ios_base::sync_with_stdio(false)
#define ALL(v) v.begin(), v.end()
#define smid ((i + j) >> 1)
#define lc (sidx * 2)
#define rc (lc + 1)


#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


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


const int mod = 1e9 + 7;
const ll inf = 4e18;
const ll ninf = -inf;
const int imax = 2e9;

int main()
{
	ll  a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	ll ans = 0;
	if(2 * c < a + b) {
		ll mn = min(x, y);
		ans += mn * c * 2;
		x -= mn;
		y -= mn;
		if(x > 0) {
			ans += x * min(2 * c, a);
		} else {
			ans += y * min(2 * c, b);	
		}
	} else {
		ans += a * x + b * y;
	}
	cout << ans << endl;
}

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

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

  vector<int> vec(n);
  for(int i = 0; i < n; i++){
    cin >> vec.at(i);
  }

  int flag = 1,num = 0;
  while(flag) {
    flag = 0;
    for(int j = n - 1; j >= 1; j--){
      int container;
      if(vec.at(j) < vec.at(j - 1)) {
        container = vec.at(j);
        vec.at(j) = vec.at(j - 1);
        vec.at(j-1) = container;
        flag = 1;
        num++;
      }
    }
  }

  for(int i = 0; i < n; i++){
    if(i > 0) cout << " ";
    cout << vec.at(i);
  }

  cout << endl;
  cout << num << endl;

  
}


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

#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod	%1000000007
#define FOR(I,N) for(I=0;I<N;++I)

int main()
{
	ll h,w,k,i,j;
	cin>>h>>w;
	char c[h+1][w+1];
	ll a[h+1][w+1];
	memset(a,0,sizeof(ll)*(h+1)*(w+1));
	memset(c,'.',sizeof(char)*(h+1)*(w+1));
	for(i=1;i<=h;++i)
	{
		for(j=1;j<=w;++j)
		{
			cin>>c[i][j];
		}
	}
	a[1][1]=1;
	for(k=3;k<=h+w;++k)
	{
		i=min(k-1,h);
		j=k-i;
		while(i>0 && j<=w)
		{
			if(c[i][j]!='#')
			{
				a[i][j] = (a[i-1][j] + a[i][j-1])mod;
			}
			--i;  ++j;
		}
	}
	cout<<a[h][w];
}

Measured memory_bytes: 9088
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stack>
#include <array>
#include <queue>
#include <string>
#include <vector>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <new>
#include <map>
#define ESP (1e-13)
#define INF 2000000000
#define ll long long

using namespace std;

int main() {
	string s;
	cin >> s;
	cout << s[0] << s.length() - 2 << s[s.length() - 1] << endl;
}


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

int main() {
    long n, m, p, y, temp, cnt = 1;
    cin >> n >> m;
    vector<pair<pair<long, long>, long>> info(m);
    vector<long> ans(m, 0);
    rep(i, m) {
        cin >> p >> y;
        info.at(i) = make_pair(make_pair(p, y), i);
    }
    sort(info.begin(), info.end());
    temp = info.at(0).first.first;
    rep(i, m) {
        if(temp != info.at(i).first.first) {
            cnt = 1;
            temp = info.at(i).first.first;
        }
        ans.at(info.at(i).second) = 1000000 * info.at(i).first.first + cnt;
        cnt++;
    }
    rep(i, m) cout << setfill('0') << right << setw(12) << ans.at(i) << endl;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
int dx[2] = {-1, 0};
int dy[2] = {0, -1};
long long vec[1010][1010];
int MOD = 1e9 + 7;
int main(){
	int h, w;
	cin>>h>>w;
	vector<string> board(h, "");
	for(int i = 0; i < h; ++i){
		cin>>board[i];
	}
	if(board[0][0] != '#')vec[0][0] = 1;	
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			if(board[i][j]=='#')continue;
			for(int k = 0; k < 2; ++k){
				int x = dx[k] + i;
				int y = dy[k] + j;
				if(x >= 0 && y >= 0){
					if(board[x][y] != '#')vec[i][j] = (vec[i][j] + vec[x][y]) % MOD;
				}
			}
		}
	}
	cout<<vec[h - 1][w - 1]<<endl;
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int count = 0;
    for( int b=1; b<N; ++b ){
        int a = N/b;
        if( a*b == N ) count += a-1;
        else count += a;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>

using namespace std;

void solve(int N, vector<int> A) {
  int ans = *max_element(A.begin(), A.end()) - *min_element(A.begin(), A.end());
  printf("%d\n", ans);
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  solve(N, A);
  return 0;
}

Measured memory_bytes: 504
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int Min(int a, int b, int c) {
	int min = a;
	if(b < min) min = b;
	if(c < min) min = c;

	return min;
}

int main() {
	int x, y, z;
	int n;

	while(1) {
		cin >> x >> y >> z;
		if(x == 0 && y == 0 && z == 0) {
			break;
		}
		double min = Min((x * x + y * y), (y * y + z * z), (z * z + x * x));  

		cin >> n;
		while(n--) {
			int r;
			cin >> r;
			r = 4 * r * r;
			
			cout << (min < r ? "OK" : "NA") << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N=100;
    cin>>N;
    pair<pair<string,int>,int> p[N];
    for(int i=0;i<N;i++){
        int n;
        string s;
        cin>>s>>n;
        p[i]=make_pair(make_pair(s,-n),i);
    }
    sort(p,p+N);
    for(int i=0;i<N;i++){
        cout<<p[i].second+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int main(){
    int n;
    ll m;
    cin >> n >> m;
    vector<ll> v(n+1);
    rep(i, n) cin >> v[i+1];
    rep(i, n) v[i+1] += v[i];

    map<ll, ll> mp;
    rep(i, n) mp[v[i+1]%m]++;

    ll ans = 0;
    for(auto p: mp){
        if(p.first == 0) ans += p.second;
        ans += p.second * (p.second - 1) / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4992
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = AtRead::from(i);
    let (n, c) = i.read2::<usize, usize>();
    let mut d = Vec::new();
    for _ in 0..c {
        d.push(i.read_vec::<usize>(c));
    }
    let mut x = Vec::new();
    for _ in 0..n {
        let mut xi = i.read_vec::<usize>(n);
        for xii in xi.iter_mut() {
            *xii -= 1;
        }
        x.push(xi);
    }
    writeln!(o, "{}", solve(&d, &x)).unwrap();
}
fn solve(d: &[Vec<usize>], c: &[Vec<usize>]) -> usize {
    let mut d_sum = vec![vec![0; d.len()]; 3];
    for ci in 0..d.len() {
        for x in 0..c.len() {
            for y in 0..c.len() {
                d_sum[(x + y) % 3][ci] += d[c[x][y]][ci];
            }
        }
    }
    let mut result = usize::max_value();
    for i0 in 0..d.len() {
        for i1 in 0..d.len() {
            if i1 == i0 {
                continue;
            }
            for i2 in 0..d.len() {
                if i2 == i0 || i2 == i1 {
                    continue;
                }
                result = min(result, d_sum[0][i0] + d_sum[1][i1] + d_sum[2][i2]);
            }
        }
    }
    result
}

mod utils {
    use super::*;

    pub struct AtRead<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        {$f:ident($($v:ident: $t:ident),*)} => {
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                $(
                    let $v = next(i);
                )*
                ($($v),*)
            }
        };
    }

    impl<R: BufRead> AtRead<R> {
        pub fn from(r: R) -> Self {
            AtRead {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(v1: T1, v2: T2) }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
    }

    fn next<'a, T: FromStr, I: std::iter::Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }
}


Measured memory_bytes: 6396
import sys
input=sys.stdin.readline
a,b,h,m=map(int,input().split())
x=0.5*(60*h+m)
y=6*(60*h+m)
x=x%360
y=y%360
z=abs(x-y)
import math
z=math.radians(z)
ans=a**2+b**2-2*a*b*math.cos(z)
ans=math.sqrt(ans)
print(ans)


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

using namespace std;

typedef long long ll;

const ll M = 4e18;
ll n, x, y;
ll d[4005][4005];

int main()
{
    scanf("%lld%lld%lld", &n, &x, &y);
    for(ll i = 0; i <= 4000; i++)
    {
        for(ll j = 0; j <= 4000; j++)
        {
            d[i][j] = M;
        }
    }
    d[0][0] = 0;
    for(ll i = 0; i < n; i++)
    {
        ll t1, t2, t3;
        scanf("%lld%lld%lld", &t1, &t2, &t3);
        for(ll j = 4000; j >= t1; j--)
        {
            for(ll k = 4000; k >= t2; k--)
            {
                d[j][k] = min(d[j][k], d[j - t1][k - t2] + t3);
            }
        }
    }
    ll ans = M;
    for(ll i = x, j = y; i <= 4000 && j <= 4000; i += x, j += y)
    {
        ans = min(ans, d[i][j]);
    }
    if(ans == M) printf("-1\n");
    else printf("%lld\n", ans);
    return 0;
}


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

int main() {
	int n; 
	while (cin >> n, n != 0) {
		map<int, int> color;
		for (int i = 0; i < n; i++) {
			int m; cin >> m; 
			color[m]++;
		}
		bool found = false;
		for (map<int, int>::iterator color_i = color.begin();
				color_i != color.end(); color_i++) {
			if (color_i->second > n / 2) {
				found = true;
				cout << color_i->first << endl;
			}
		}
		if (!found) cout << "NO COLOR" << endl;
	}
	return 0;
}

Measured memory_bytes: 1936
#include<bits/stdc++.h>
using namespace std;
int b[1000002];
int main()
{
    int  n,c=0,i;
    cin>>n;
    int a[n+3];
    for(i=2;i<=n;i++)
    {
    	cin>>a[i];
    	b[a[i]]++;
    }
    for(i=1;i<n;i++)
    {
    	cout<<b[i]<<endl;
    }
    cout<<"0"<<endl;

}

Measured memory_bytes: 5156
(defn ^:dynamic LucasNumber [N]
  (case N
    0 (bigint 2)
    1 (bigint 1)
     (+ (LucasNumber (dec N)) (LucasNumber (dec (dec N))))))

(binding [LucasNumber (memoize LucasNumber)]
  (->> (read)
    int
    LucasNumber
    (printf "%s\n")))

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

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

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int h, w;
  while (cin >> h >> w) {
    const int N = 100 + 5;
    char g[N][N];
    fill(&g[0][0], &g[N - 1][N - 1] + 1, '#');
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        cin >> g[i + 1][j + 1];
      }
    }
    for (int i = 0; i < h + 2; ++i) {
      for (int j = 0; j < w + 2; ++j) {
        cout << g[i][j];
      }
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {

	string S;
	cin >> S;

	string a, b;
	int YY, MM;
	a = S.substr(0, 2);
	b = S.substr(2, 3);



	bool YYMM = false, MMYY = false;

	YY = stoi(a);
	MM = stoi(b);

	//yymm
	if (MM <= 12 && MM >= 1) YYMM = true;
	if (YY <= 12 && YY >= 1)  MMYY = true;


	if (YYMM && MMYY) cout << "AMBIGUOUS" << endl;
	else if (YYMM) cout << "YYMM" << endl;
	else if (MMYY) cout << "MMYY" << endl;
	else cout << "NA";
}

Measured memory_bytes: 256
P,S=print,sorted
n,k,*t=map(int,open(i:=0).read().split())
l=S([a<1<exit(P(-1)),a-1,i:=i+1]for a in t)[::-1]
*_,r=zip(*l)
while k:
 b=r;k-=1
 for t in S(l)[::-1]:
  if t[2]-b[-1]:t[1]or exit(P(-1));t[1]-=1;r+=t[2],
P(len(r),*r)

Measured memory_bytes: 9360
class Stack:
    MAX = 101

    def __init__(self):
        self.S = [None] * self.__class__.MAX
        self.top = 0

    def is_empty(self):
        return self.top == 0

    def is_full(self):
        return self.top >= self.__class__.MAX - 1

    def push(self, x):
        self.top += 1
        self.S[self.top] = x

    def pop(self):
        self.top -= 1
        return self.S[self.top + 1]


arr = [str(s) for s in input().split()]
stack = Stack()
# for s in arr:
#     if s in ["+", "-", "*"]:
#         stack.push(
#             eval("".join(map(str, [stack.pop(), s, stack.pop()][::-1]))))
#     else:
#         stack.push(int(s))
[stack.push(
    eval("".join(map(str, [stack.pop(), s, stack.pop()][::-1])))) if s in ["+", "-", "*"]
    else stack.push(int(s)) for s in arr]
print(stack.pop())



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

bool bo[6010];
int n,p[6010],tA[3010],tB[3010],tnA,tnB,len,la,fn[6010],gn[6010],po[6010],fp[6010];
char s[6010],f[6010][6010],g[6010][6010];

int main()
{
	scanf("%d%s",&n,s+1),tnA=tnB=0;
	for (int i=1; i<=2*n; i++)
		if (s[i]=='a') tA[++tnA]=i; else tB[++tnB]=i;
	for (int i=1; i<=n; i++) p[tA[i]]=tB[i],p[tB[i]]=tA[i];
	for (int i=1; i<=2*n; i++) if (s[i]=='b'&&p[i]>i)
	{
		int P=p[i];
		bo[i]=bo[p[i]]=1;
		for (int j=i+1; j<=P; j++)
			if (s[j]=='b'&&p[j]>j) P=p[j],bo[j]=bo[p[j]]=1;
		po[i]=P,gn[i]=0;
		for (int j=1; j<=2*n; j++) if (bo[j]) g[i][++gn[i]]=s[j],bo[j]=0;
	}
	fn[2*n+1]=0,fp[2*n+1]=0;
	for (int i=2*n; i; i--) 
		if (s[i]=='b'&&p[i]>i)
		{
			fn[i]=gn[i]+fn[po[i]+1];
			for (int j=1; j<=gn[i]; j++) f[i][j]=g[i][j];
			for (int j=1; j<=fn[po[i]+1]; j++) f[i][j+gn[i]]=f[po[i]+1][j];
			fp[i]=max(fp[po[i]+1],po[i]);
			bool bo=0;
			for (int j=1; j<=fn[i]&&j<=fn[i+1]; j++)
				if (f[i][j]!=f[i+1][j])
				{
					bo=1;
					if (f[i][j]<f[i+1][j]) 
					{
						fn[i]=fn[i+1],fp[i]=fp[i+1];
						for (int k=1; k<=fn[i]; k++) f[i][k]=f[i+1][k];
					}
					break;
				}
			if (!bo&&fn[i]<fn[i+1])
			{
				fn[i]=fn[i+1],fp[i]=fp[i+1];
				for (int j=1; j<=fn[i]; j++) f[i][j]=f[i+1][j];
			}
		} else 
		{
			fn[i]=fn[i+1],fp[i]=fp[i+1];
			for (int j=1; j<=fn[i]; j++) f[i][j]=f[i+1][j];
		}
	for (int i=1; i<=fn[1]; i++) putchar(f[1][i]);
	len=0,la=fp[1];
	for (int i=1; i<=n; i++) 
	{
		int mi=2*n+1;
		for (int j=la+1; j<=2*n; j++)
			if (s[j]=='a'&&p[j]<mi) mi=p[j];
		if (mi==2*n+1) break;
		la=mi,len++;
	}
	for (int i=1; i<=len; i++) putchar('a'),putchar('b');
	return puts(""),0;
} 

Measured memory_bytes: 69760
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			String t = sc.nextLine();
			
			
			t = t.replace("apple","JWU");
			t = t.replace("peach","apple");
			t = t.replace("JWU","peach");
			
			System.out.println(t);  
		}
	}

}




Measured memory_bytes: 26032
# AOJ 0076 Treasure Hunt II
# Python3 2018.6.15 bal4u

import math

MAX = 1005
r, d = [0.0]*MAX, [0.0]*MAX
r[1] = 1.0
for i in range(2, MAX):
	d[i] = d[i-1] + math.atan(1 / r[i-1])
	r[i] = math.sqrt(r[i-1]**2 + 1)

while True:
	i = int(input())
	if i < 0: break
	print(r[i]*math.cos(d[i]), r[i]*math.sin(d[i]), sep='\n')


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

public class Main {
	public static void main(String[] args) throws Throwable {
		MyScanner sc = new MyScanner();
		String nkq = sc.nextString();
		String[] nkqArr = nkq.split(" ");
		int n = Integer.parseInt(nkqArr[0]);
		int k = Integer.parseInt(nkqArr[1]);
		int q = Integer.parseInt(nkqArr[2]);

		// N人のスコア(0始まり注意)
		int[] scores = new int[n];
		// 最初の持ち点としてKではなく0を設定
		for (int i = 0; i < n; i++) {
			scores[i] = 0;
		}

		// Q行分ループ
		for (int i = 0; i < q; i++) {
			int winner = sc.nextInt();
			// (正解者の番号-1)に1加算
			int before = scores[winner - 1];
			scores[winner - 1] = before + 1;
		}

		// N人分ループ
		for (int i = 0; i < n; i++) {
			int result = scores[i];
			if (k > q - result) {
				// 点数 > 誤答数(=問題数 - 正解数)
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}

	static class MyScanner {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		public String nextString() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(nextString());
		}

		public String[] nextStringArr() throws IOException {
			return nextString().split(" ");
		}

		public Integer[] nextIntArr() throws IOException {
			String[] strArr = nextStringArr();
			Integer[] intArr = new Integer[strArr.length];
			for (int i = 0; i < strArr.length; i++) {
				intArr[i] = Integer.parseInt(strArr[i]);
			}
			return intArr;
		}
	}

}


Measured memory_bytes: 63840
"""
N = int(input())
N,M = map(int,input().split())
N_list = list(map(int,input().split()))
"""

A,B = map(int,input().split())

cnt = 1
loop_cnt = 0
while cnt < B:
  cnt -= 1
  cnt += A
  loop_cnt += 1
  
  
print(loop_cnt)


Measured memory_bytes: 3060
#define MAX 100
#define INF 168435450

typedef struct node{
 int flg;
 int cost;
}node;

int min(int a,int b){
if(a < b)return a;
return b;
}

int min_idx(node N[],int n){
int idx;
int i;
int mini=268435450;

for(i=0;i<n;i++){
 if(N[i].flg==0 && N[i].cost<mini){
   mini=N[i].cost;
   idx=i;
 }
}

return idx;
}

int main(){
int n,x,y,d;
int i,j,k,u;
int Dis[MAX][MAX];
node N[MAX];

scanf("%d",&n);

for(i=0;i<n;i++){N[i].flg=0;N[i].cost=INF;
 for(j=0;j<n;j++){
  Dis[i][j]=INF;
  if(i==j)Dis[i][j]=0;
 }
}

for(i=0;i<n;i++){
 scanf("%d %d",&x,&k);
 for(j=0;j<k;j++){
  scanf("%d %d",&y,&d);
  Dis[x][y]=d;
 }
}

N[0].cost=0;

for(i=0;i<n;i++){
 u=min_idx(N,n);

 if(N[u].flg==0){
    N[u].flg=1;
    for(j=0;j<n;j++){
     if(Dis[u][j]!=INF){
      N[j].cost=min(N[j].cost,N[u].cost+Dis[u][j]);
     }
    }
 }
}

for(i=0;i<n;i++)
 printf("%d %d\n",i,N[i].cost);

return 0;
}



Measured memory_bytes: 2052
n, m, x = map(int, input().split())
c = list()
a = list()
for i in range(n):
  row_input = list(map(int, input().split()))
  c.append(row_input[0])
  a.append(row_input[1:])
inf_value = 2*sum(c)
def choose_next_row(partial_choice):
  if len(partial_choice) == n:
    if all(sum(partial_choice[i]*a[i][j] for i in range(n))>=x for j in range(m)):
      return sum(include*cost for include, cost in zip(partial_choice, c))
    else:
      return inf_value
  return min(choose_next_row(partial_choice+[0]), choose_next_row(partial_choice+[1]))
ans = choose_next_row([])
if ans == inf_value:
  print(-1)
else:
  print(ans)

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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define mp make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front 
#define pb push_back
#define pp push
#define lb lower_bound 
#define ub upper_bound

int n,k;
int cnt=0;

int main() {
//	freopen("in.txt","r",stdin);
//	freopen("out.txt","w",stdout);
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>n>>k;
    while(n)
    {
    	n/=k;
    	cnt++;
	}
	cout<<cnt<<endl;
    /* end code */
	return 0;
}

Measured memory_bytes: 256
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define PB push_back
#define SZ size
#define MP make_pair

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);
const bool DEBUG = 0;

int N;
ll ans = 0;
ll arr[500005];

int main()
{
	int i, j;

	scanf("%d", &N);

	for(int i = 0; i < 3 * N; i++)
	{
		scanf("%lld", &arr[i]);
	}

	sort(arr, arr + (3 * N) );
	reverse(arr, arr + (3 * N ));

	int limit = 3 * N;

	int c = 0;
	for(int i = 1; c < N; i+=2)
	{
		ans += arr[i];
		c++;
	}

	cout << ans;



	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
#include <deque>
#include <cassert>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <chrono>
#include <ctime>
#include <random>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <iterator>
#include <climits>
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
#define INF 2001001001
#define MOD 1000000007

ll N,M,V,P;
ll a[100001];
ll b[100001];

void sortrev(ll arr[]){
  for (ll i=0;i<N;i++)
    arr[i]*=-1;
  sort(arr,arr+N);
   for (ll i=0;i<N;i++)
    arr[i]*=-1;
}

bool check(ll ind){
  ll VAL=a[ind]+M;
  bool skip=false;
  for (ll i=0;i<N;i++)
    b[i]=a[i];
  b[ind]+=M;
  sortrev(b);
  if (b[P-1]>a[ind]+M)
    return false;
  vector<ll>room;
  ll strictg=0;
  ll sum=0;
  //for (ll i=0;i<N;i++)
  //  cout<<b[i]<<' ';
  //cout<<endl;
  for (ll i=0;i<N;i++){
    if (b[i]==VAL && !skip){
      skip=true;
      continue;
    }
    if (strictg<P-1){
      strictg++;
      room.push_back(INF);
    }
    else{
      if (VAL-b[i]<0)
	return false;
      //cout<<"ADD: "<<M<<' '<<(VAL-b[i])<<endl;
      sum+=min(M,(VAL-b[i]));
      room.push_back(VAL-b[i]);
    }
  }
  //for (ll x:room)
  //  cout<<x<<' ';
  //cout<<endl;
  //sort(room.begin(),room.end());
  //reverse(room.begin(),room.end());
  //cout<<sum<<' '<<M<<' '<<V-strictg-1<<endl;
  if (sum>=(M)*(V-strictg-1))
    return true;
  else
    return false;
}

int main()
{
  //ios_base::sync_with_stdio(0);cin.tie(0);
  //freopen (".in","r",stdin);
  //freopen (".out","w",stdout);
  cin>>N>>M>>V>>P;
  for (ll i=0;i<N;i++)
    cin>>a[i];
  sortrev(a);
  ll low=0,high=N+1,mid;
  while (low+1<high){
    mid=(low+high)/2;
    //cout<<"MID: "<<mid<<endl;
    if (check(mid-1))
      low=mid;
    else
      high=mid;
  }
  cout<<low<<endl;
  return 0;
}


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

#define in cin
#define out cout

#define REP(i,n) for(int i=0; i<n; i++)
#define REP2(i,s,e) for(int i=s; i<e; i++)
#define REPE(i,s,e) for(register int i=s; i<=e; i++)
#define REPR(i,s,e) for(int i=s; i>=e; i--)

#define all(v) v.begin(), v.end()
#define pb push_back

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, int>
#define rd(n) scanf("%d", &n)

#define x first
#define y second
#define intINF 2147483647
#define llINF 9223372036854775807LL
#define MOD 1000000007

#define mx 51

int main()
{
    int n, a; in >> n >> a;
    ll dp[mx][mx][mx*mx]; memset(dp, 0, sizeof(dp));

    int x[55];
    REP(i, n) in >> x[i];
    int sum = x[0];
    dp[0][0][0] = 1;
    dp[0][1][x[0]] = 1;

    REP2(i, 1, n)
    {
        sum += x[i];
        REPE(j, 0, i+1)
        {
            REPE(k, 0, sum)
            {
                dp[i][j][k] += dp[i-1][j][k];
                if(k-x[i] >= 0 && j) dp[i][j][k] += dp[i-1][j-1][k-x[i]];
            }
        }
    }

    ll res = 0;
    REPE(i, 1, n) res += dp[n-1][i][a*i];
    out << res << "\n";

    return 0;
}


Measured memory_bytes: 53120
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> p(n, k-q);
    
    for(int i = 0; i < q; i++){
        int a;
        cin >> a;
        --a;
        p[a]++;
    }
    
    for(int i = 0; i < n; i++){
        if(p[i] <= 0) puts("No");
        else puts("Yes");
    }
    
}

Measured memory_bytes: 1024
N,W = map(int,input().split())
wv = []
for i in range(N):
    a = list(map(int,input().split()))
    wv.append(a)
sumv = sum([i[1] for i in wv])
dp = [[10**10 for i in range(sumv+1)] for j in range(N+1)]
for i in range(N+1):
    dp[i][0] = 0
for i in range(N):
    for j in range(sumv+1):
        if j - wv[i][1] >=0 :
            dp[i+1][j] = min(dp[i][j], dp[i][j-wv[i][1]] + wv[i][0])
        else:
            dp[i+1][j] = dp[i][j]

for i in range(sumv,-1,-1):
    if dp[-1][i] <= W:
        print(i)
        break



Measured memory_bytes: 173448
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

template<class Ty>
using passive_queue = priority_queue<Ty, vector<Ty>, greater<Ty>>;

struct Problem {

	void Solve() {
		const ULL M = 998244353;
		const ULL Z = 1000000000000000000 % 998244353;


		UL N; cin >> N;

		vector<UL> POWZ(N + 1); POWZ[0] = 1;
		rep(i, N) POWZ[i + 1] = POWZ[i] * Z % M;
		vector<ULL> A[3];

		const UL X = min(N, 512u);

		rep(t, 3) {
			UL S; cin >> S;
			vector<vector<UL>> E(N);
			rep(j, S) {
				UL u, v; cin >> u >> v; u--; v--;
				E[min(u, v)].push_back(max(u, v));
			}
			A[t].resize(X);
			vector<UL> F(X, -1), G(N);
			for (UL v = N - 1; v != -1; v--) {
				for (UL e : E[v]) F[G[e]] = v;
				while (F[G[v]] == v) G[v]++;
				A[t][G[v]] += POWZ[v + 1];
				A[t][G[v]] %= M;
			}
		}

		ULL ans = 0;
		{
			rep(a, X) rep(b, X) {
				UL c = a ^ b; if (c >= X) continue;
				ans += A[0][a] * A[1][b] % M * A[2][c] % M;
				ans %= M;
			}
		}

		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 5200
n,m=map(int,input().split())
h=list(map(int,input().split()))
ans=[]
hold=[]
for i in range(0,m):
  a,b=map(int,input().split())
  hold+=[a,b]
  if(h[a-1]>h[b-1]):
    ans.append(b)
  elif(h[a-1]<h[b-1]):
    ans.append(a)
  else:
    ans.append(a)
    ans.append(b)
ans=set(ans)
hold=set(hold)
print(n-len(ans))



Measured memory_bytes: 30680
import java.util.*;
import java.math.*;
import java.io.*;

public class Main{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int tt = in.nextInt();
		double a = Math.PI*2*tt;
		System.out.println(String.format("%.20f", a));
	}
}

Measured memory_bytes: 35856
#include<bits/stdc++.h>
using namespace std;
int a[200005],b[200005],i,n;
long long ans;
struct str{
	int x,s;
};
bool operator <(str a,str b)
{
	return a.s<b.s;
}
priority_queue<str> q;
int main()
{
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=0;i<n;i++)
	{
		scanf("%d",&b[i]);
		q.push((str){i,b[i]});
	}
	while(!q.empty())
	{
		str x=q.top();
		q.pop();
		if(a[x.x]==b[x.x])
			continue;
		int s=b[(x.x-1+n)%n]+b[(x.x+1)%n];
		if(b[x.x]<=s)
			break;
		if(a[x.x]>=s)
		{
			if((b[x.x]-a[x.x])%s==0)
			{
				ans+=(b[x.x]-a[x.x])/s;
				b[x.x]=a[x.x];
			}
			else
				break;
		}
		else
		{
			ans+=b[x.x]/s;
			b[x.x]%=s;
			q.push((str){x.x,b[x.x]});
		}
	}
	for(i=1;i<=n;i++)
		if(a[i]!=b[i])
		{
			printf("-1");
			return 0;
		}
	cout<<ans;
}


Measured memory_bytes: 3700
while True:
    supply,motor,cable=(int(x) for x in input().split())
    if supply==0 and motor==0:
        break
    checknum=int(input())
    
    reslist=[2]*(supply+motor+cable)
    stack=[]
    for i in range(checknum):
        no1,no2,no3,result=(int(x)-1 for x in input().split())
        result+=1
        if result==1:
            reslist[no1], reslist[no2], reslist[no3]=1,1,1
        else:
            stack.append((no1,no2,no3))

    for i in range(len(stack)):
        t=stack[i]
        no1,no2,no3=t[0],t[1],t[2]
        if reslist[no1]==1 and reslist[no2]==1:
            reslist[no3]=0
        elif reslist[no3]==1 and reslist[no2]==1:
            reslist[no1]=0
        elif reslist[no3]==1 and reslist[no1]==1:
            reslist[no2]=0
            
    for i in range(len(reslist)):
        print(reslist[i])


Measured memory_bytes: 5728
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define all(a) a.begin(),a.end()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)

typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int inf = 1e9;

struct Segtree {
	int n;
	vpii dat;

	void init(int n_) {
		n = 1;

		while (n < n_) n *= 2;

		dat.resize(2 * n);

		for (int i = 0; i < 2 * n - 1; ++i) dat[i] = pii(0, -inf);
	}

	void update(int a, int x) {
		int idx = a;
		a += n - 1;

		dat[a].fst += x;
		dat[a].scd = -idx;

		while (a > 0) {
			a = (a - 1) / 2;
			dat[a] = max(dat[a * 2 + 1], dat[a * 2 + 2]);
		}
	}

	pii get_max() {
		return dat[0];
	}
};

typedef pair<int, pair<int, int> > Query;

int res[100010];

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

	Segtree seg;
	seg.init(N);

	vector<Query> queries(R);

	rep(i, R) {
		int d, t, x;
		scanf("%d%d%d", &d, &t, &x);

		-- d;

		queries[i] = Query(t, pii(d, x));
	}

	queries.PB(Query(L, pii(0, 0)));
	
	sort(all(queries));

	rep(i, R) {
		Query query = queries[i];
		Query next_query = queries[i + 1];

		seg.update(query.scd.fst, query.scd.scd);

		if (query.fst != next_query.fst) {
			res[-seg.get_max().scd] += next_query.fst - query.fst;
		}
	}

	int ma = -1;
	int ans = -1;

	rep(i, N) {
		if (ma < res[i]) {
			ma = res[i];
			ans = i;
		}
	}

	printf("%d\n", ans + 1);
}

Measured memory_bytes: 19816
#[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 s = scan!();
    let splited = s.split_whitespace().collect::<Vec<_>>();
    let (a, b): (i64, i64) = (splited[0].parse().unwrap(), splited[2].parse().unwrap());
    if splited[1] == "+" {
        println!("{}", a + b)
    } else {
        println!("{}", a - b)
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<ll> cnt(26);
	rep(i,n)cnt[s[i]-'a']++;
	ll ans=1;
	rep(i,26)ans=ans*(cnt[i]+1)%mod;
	cout<<(ans+mod-1)%mod<<endl;
	return 0;
}

Measured memory_bytes: 512
n = int(input())
p=[int(i) for i in input().split()]
mod = 10**9+7
p.sort()
ans = 0
for i,c in enumerate(p):
    mult = (pow(2,n-1-i,mod)+(n-1-i)*pow(2,n-2-i,mod))%mod if i+1!=len(p) else 1
    ans = (ans + ( (pow(2,i,mod)*c)%mod ) * mult )%mod
ans = (ans*pow(2,n,mod))%mod
print(ans)

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BDifferentDistribution {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    in >> n;
	    ll a, b;
	    vector<pair<ll, ll>> v;
	    for(int i=0; i<n; i++){
	        in >> a >> b;
	        v.push_back(make_pair(b, a));
	    }

	    sort(v.begin(), v.end());

        out << v[0].second + v[0].first << endl;
	}
};


int main() {
	BDifferentDistribution solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <queue>

using namespace std;

priority_queue<long long int> que;

long long int N;

void dfs(long long int n, int flag3, int flag5, int flag7) {
    if(N>=n) {
        if(flag3 && flag5 && flag7) {
            que.push(n);
        }
        n *= 10;
        dfs(n+3, flag3+1, flag5, flag7);
        dfs(n+5, flag3, flag5+1, flag7);
        dfs(n+7, flag3, flag5, flag7+1);
    }
}

int main() {
    cin >> N;

    dfs(0, 0, 0, 0);
    
    cout << que.size() << endl;

    return 0;
    
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Otoshidama
            string s = Console.ReadLine();

            var opVariations = GetAllOpVariations(s).ToList();

            long sum = CalcSumOfAllVariations(s, opVariations);
            Console.WriteLine(sum);
        }

        static long CalcSumOfAllVariations(string s, List<string> opVariations)
        {
            var array = s.ToCharArray();
            long sum = 0;

            foreach(var op in opVariations)
            {
                string formula = "";

                for(int i = 0; i < s.Length; i++)
                {
                    formula += s[i].ToString();

                    try
                    {
                        if (op[i] == '1')
                        {
                            formula += '+';
                        }
                    }
                    catch (IndexOutOfRangeException)
                    {
                    }
                }

                sum += CalcSum(formula);
            }

            return sum;
        }

        static long CalcSum(string formula)
        {
            var list = formula.Split('+').ToList();
            return list.ConvertAll(x => long.Parse(x)).Sum();
        }

        static IEnumerable<string> GetAllOpVariations(string s)
        {
            int count = CountVariations(s);
            List<int> numbers = new List<int>();

            for(int i = 0; i < count; i++)
            {
                decimal d = ConvertNumberingFromDecimal(i, 2);
                numbers.Add((int)d);
            }

            int digits = numbers.Max().ToString().Length;
            
            foreach(int num in numbers)
            {
                yield return num.ToString().PadLeft(digits, '0');
            }
        }

        static int CountVariations(string s)
        {
            double d = s.Length - 1;
            return (int)Math.Pow(2, d);
        }

        static decimal ConvertNumberingFromDecimal(decimal sourceNumber, int bit)
        {
            //[summary]10進法の数字をn進法に変換
            //変換方法については、以下リンクの最下部を参照
            //http://manabi.matiralab.com/binary/

            var list = new List<decimal>();
            decimal num = sourceNumber;

            //元の数字が"n"で割れなくなるまで繰り返し
            while (num >= bit)
            {
                decimal mod = num % bit;
                list.Add(mod);

                num = Math.Floor(num / bit);
            }

            list.Add(num);

            //記憶した数字の順番を入れ替える
            list.Reverse();

            //Listの値を結合して、数字に変換
            string s = string.Join("", list);
            return decimal.Parse(s);
        }
    }
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a < b) swap(a, b);
  
  for (int i = 0; i < a-1; i++) {
    b = (b * 10) + (b % 10);
  }
  cout << b << endl;
}

Measured memory_bytes: 256
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    if m == -1 or f == -1 or m + f < 30:
        print('F')
    elif m + f < 50 and r < 50:
        print('D')
    elif m + f < 65:
        print('C')
    elif m + f < 80:
        print('B')
    else:
        print('A')



Measured memory_bytes: 5592
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int LIS(const vector<pii>& a)
{
	int size=a.size();
	if(size==0)
		return 0;
	
	vi dp(size);
	dp[0]=1;
	repi(i,1,size){
		rep(j,i){
			if(a[j].first<a[i].first && a[j].second<a[i].second)
				dp[i]=max(dp[i],dp[j]+1);
		}
	}
	return *max_element(allof(dp));
}

int main()
{
	for(int n;cin>>n,n;){
		vector<pii> a(n);
		rep(i,n) cin>>a[i].first>>a[i].second;
		int m; cin>>m;
		a.resize(n+m);
		repi(i,n,n+m)
			cin>>a[i].first>>a[i].second;
		
		sort(allof(a));
		cout<<LIS(a)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }


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

  ll a, b;
  cin >> a >> b;
  cout << a* b << endl;
  return 0;
}

Measured memory_bytes: 3652
n = int(input())
a = list(map(int, input().split()))
c = 0
s = 0
d = 0
j = 0
for i in range(n):
	d = 0
	while j < n and s & a[j] == 0:
		s += a[j]
		j += 1
	s -= a[i]
	c += j-i
print (c)


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

int main()
{
	char s[30];
	int a[26]={0};
	scanf("%s",s);
	int n=strlen(s);
	for(int i=0;i<n;i++)
		a[s[i]-'a']++;
	int dif=0;
	for(int i=0;i<26;i++)
		if(a[i]>1){
			dif=1;	break;
		}	
	if(dif==0)
		printf("yes");
	else
		printf("no");
	return 0; 
}

Measured memory_bytes: 128
<?php

function tokenize($str) {
	$index = 0;
	$result = array();
	while($index < strlen($str)) {
		$t = $str[$index++];
		if ($t == "@") {
			$len = $str[$index++];
			$char = $str[$index++];
			$run = "";
			for ($i = 0; $i < $len; $i++) {
				$run .= $char;
			}
			$result[] = $run;
		} else {
			$result[] = $t;
		}
	}
	return implode("", $result);
}

function main() {
	while ($input = trim(fgets(STDIN))) {
		echo tokenize($input) . "\n";
	}
}

main();

Measured memory_bytes: 6612
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string S;
  cin >> S;
  int min=10000000;
  for(int i=0; i<S.size()-2; i++){
    string s=S.substr(i,3);
    int x=stoi(s);
    int d=abs(753-x);
    if(d<min)
      min=d;
  }
  cout << min << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

/* -- template -- */

int main() {
    int N, M; cin >> N >> M;
    int sum = 0;
    int A[M];rep(i, M) cin >> A[i], sum += A[i];
    if(N - sum >= 0)
        cout << N - sum << endl;
    else
        cout << -1 << endl;

}


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

int main(){
  int N;
  cin >> N;
  int a;
  float b;
  if(N%2==1){
    a=N/2+1;
    b=(float)a/N;
  }
  else{
    a=N/2;
    b=(float)a/N;
  }
  cout << b <<endl;
}

Measured memory_bytes: 256
n=int(input())
sa=[]
a=list(map(int,input().split()))
s=0
for ai in a:
  s+=ai
  sa.append(s)

ans=abs(sa[-1]-2*sa[0])
for i in range(1,n-1):
  ans=min(ans,abs(sa[-1]-2*sa[i]))
print(ans)


Measured memory_bytes: 24832