akhauriyash/Code-Regression huggingface dataset:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan
import cmath as cma
import copy as cp
import sys
import re
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

a,b = imap()
ans = a*b
print(ans)


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

#define INF (1<<30)

long long dp[1010][10010];
/*
	dp[i][j]: i番目までの魔法から、ダメージ総和がjとなるように選んだ時の、
	コスト総和の最小値

	(*)もし存在しなければINF
*/

int main(){
	int h,n;	cin>>h>>n;
	vector<int> damage(n),cost(n);
	for(int i=0;i<n;i++)cin>>damage[i]>>cost[i];

	for(int i=0;i<10010;i++)dp[0][i]=INF;
	dp[0][0]=0;

	for(int i=0; i<n; i++){
		for(int d=0; d<=10000; d++){
			if(d<damage[i])dp[i+1][d]=dp[i][d];
			else{
				dp[i+1][d]=min(dp[i][d],dp[i+1][d-damage[i]]+cost[i]);
			}
		}
	}

	long long NG=0,OK=INF;

	while(OK-NG>1){
		long long mid=(OK+NG)/2;

		for(int i=h;i<=10000;i++){
			if(dp[n][i]<=mid){
				OK=mid;	break;
			}
		}

		if(OK!=mid)NG=mid;
	}
	cout<<OK<<endl;

	return 0;
}


Measured memory_bytes: 78592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007
const int N=200005;

ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }

bool ch(int num, set <int> st) {
    while(num>0) {
        int dig=num%10;
        if(st.find(dig)!=st.end()) return 0;
        num/=10;
    }
    return 1;
}



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    cout<<fixed<<setprecision(15);
    
    int n;
    cin>>n;

    int a[n];

    int mn=200,mx=-200;
    for(int i=0;i<n;i++) {
        cin>>a[i];
        if(a[i]<mn) mn=a[i];
        if(a[i]>mx) mx=a[i];
    }

    int ans=INT_MAX;

    for(int i=mn;i<=mx;i++) {
        int tmp=0;
        for(int j=0;j<n;j++) {
            tmp+=((a[j]-i)*(a[j]-i));
        }
        ans=min(ans,tmp);
    }

    cout<<ans;


    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
long long a[200005];
long long pre[200005];
long long last[200005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i = 1;i<=n;i++){
			scanf("%lld",&a[i]);
	}
	long long sumpre=0,sumlast=0;
	for(int i = 1;i<n;i++){
		sumpre=sumpre+a[i];
		pre[i]=sumpre;
//		printf("%lld++\n",pre[i]);
	}
	for(int i = n;i>1;i--){
		sumlast=sumlast+a[i];
		last[i]=sumlast;
//		printf("%lld+++\n",last[i]);
	}
	long long d=(1ll<<60);
	for(int i = 1;i<n;i++){
//		printf("%lld\n",pre[i]-last[i+1]);
		d=min(d,abs(pre[i]-last[i + 1]));
	}
	printf("%lld\n",d);
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int a[100000];
int main()
{
	int n,i,m=1000000001,c;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}  
	sort(a,a+n);
	for(i=0;i<n-1;i++)
	{
		if(m>=abs(a[n-1]/2-a[i]))
		{
			m=abs(a[n-1]/2-a[i]);
			c=a[i];
		}
	}
	printf("%d %d",a[n-1],c);
	return 0;
}

Measured memory_bytes: 640
import sys
import itertools

def calc_time(ts):
  time = 0
  for t in ts[:-1]:
    time += t
    tmp = time % 10
    if tmp != 0:
      time += 10 - tmp
  return time + ts[-1]

times = [int(input()) for _ in range(5)]
results = [calc_time(ts) for ts in itertools.permutations(times, 5)]

print(min(results))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;
	
	int arr[4] = {-1, -1, -1, -1};
	bool hasans = true;
	
	for (int i = 0; i < m; ++i){
		int s, c;
		cin >> s >> c;
		
		if (arr[s] != -1 && arr[s] != c) hasans = false;
		arr[s] = c;
	}
	int ans = 0;
	if (hasans){
		for (int i = 1; i <= n; ++i){
			if (arr[i] != -1){
				ans = ans * 10 + arr[i];
				if (ans == 0 && n != 1){
					hasans = false;
				}
			}
			else{
				if (i == 1 && n > 1){
					ans = 1;
				}
				else{
					ans *= 10;
				}
			}
		}
	}
	if (hasans){
		cout << ans;
	}
	else{
		cout << -1;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long Int;
Int a[108000];
Int res[108000];
vector<Int> hoge, fuga;

int main(){
  Int n;
  cin >> n;
  Int nowmax = 0;
  for(Int i = 0;i < n;i++){
    cin >> a[i];
    hoge.push_back(a[i]);
  }
  sort(hoge.begin(), hoge.end());
  fuga = hoge;
  fuga.push_back(0);
  sort(fuga.begin(), fuga.end());
  for(int i = 1;i <= n;i++)fuga[i] += fuga[i-1];
  for(Int i = 0;i < n;i++){
    if(a[i] > nowmax){
      Int piyo = upper_bound(hoge.begin(), hoge.end(), a[i]) - hoge.begin();
      Int poyo = upper_bound(hoge.begin(), hoge.end(), nowmax) - hoge.begin();
      
      res[i] = fuga[piyo] - fuga[poyo] + (n - piyo) * (a[i] - nowmax) - (piyo - poyo) * nowmax;
      nowmax = a[i];
    }
  }
  for(Int i = 0;i < n;i++)cout << res[i] << endl;
  return 0;
}

Measured memory_bytes: 4324
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;


int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<long long int>> c(10, vector<long long int>(10, 0));
    for (int i = 0; i < 10;i++){
        for (int j = 0; j < 10;j++){
            cin >> c[i][j];
        }
    }
    for (int k = 0; k < 10;k++)
    {
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                c[i][1] = min(c[i][1], c[i][j] + c[j][1]);
            }
        }
    }
    int in, num[10] = {}, ans = 0;
    for(int i = 0; i < h * w;i++){
        cin >> in;
        if(in != -1){
            num[in]++;
        }
    }
    for(int i = 0; i < 10;i++){
        ans += num[i] * c[i][1];
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    char c;
    cin >> c;
    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
n, ma, mb = gets.chomp.split(' ').map(&:to_i)
items = []
n.times do
  items << gets.chomp.split(' ').map(&:to_i)
end
sa, sb, sc = items.inject([0, 0, 0]) do |acc, i|
  [acc[0] + i[0], acc[1] + i[1], acc[2] + i[2] ]
end
dp = Array.new(n + 1)
(n + 1).times do |i|
  dp[i] = Array.new(sa + 1)
  (sa + 1).times { |j| dp[i][j] = Array.new(sb + 1, sc + 1) }
end
dp[0][0][0] = 0
n.times do |i|
  a, b, c = items[i]
  (sa + 1).times do |j|
    (sb + 1).times do |k|
      if j - a >= 0 && k - b >= 0
        dp[i + 1][j][k] = [dp[i][j][k], dp[i][j - a][k - b] + c].min
      else
        dp[i + 1][j][k] = [dp[i + 1][j][k], dp[i][j][k]].min
      end
    end
  end
end
min = sc + 1
(1..n).each do |i|
  (1..sa).each do |j|
    (1..sb).each do |k|
      min = [min, dp[i][j][k]].min if j * mb == k * ma
    end
  end
end
puts min == sc + 1 ? -1 : min

Measured memory_bytes: 21116
#include <bits/stdc++.h>
using namespace std;
int n, k;
double x[65], y[65], c[65], r[65];
double eps = 1e-8;

double dist(pair<double, double> p, pair<double, double> q) {
	double xx = (p.first - q.first)*(p.first - q.first);
	double yy = (p.second - q.second)*(p.second - q.second);

	return sqrt(xx + yy);
}

vector<pair<double, double>> circle_circle_intersection(double x1, double y1, double r1, double x2, double y2, double r2) {
	vector<pair<double, double> > ans;
	double d = dist(make_pair(x1, y1), make_pair(x2, y2));
	if (d > r1 + r2) {
		return ans;
	}
	if (x1 == x2 && y1 == y2) {
		ans.push_back(make_pair(x1, y1)); return ans;
	}
	if (d < abs(r1 - r2)) {
		ans.push_back(make_pair(x1, y1)); return ans;
	}

	double a = (r1*r1 - r2*r2 + d*d)/(2*d);
	double h = sqrt(r1*r1 - a*a);


	double x3 = (x2 - x1)*(a/d) + x1;
	double y3 = (y2 - y1)*(a/d) + y1;

	ans.emplace_back(x3 + h*(y2 - y1)/d, y3 - h*(x2 - x1)/d);
	ans.emplace_back(x3 - h*(y2 - y1)/d, y3 + h*(x2 - x1)/d);

	return ans;
}

int check(double t) {
	int ans = 0;
	for (int i = 0; i < n; i++) {
		r[i] = t/c[i];
	}

	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			vector<pair<double, double> > pts = circle_circle_intersection(x[i], y[i], r[i], x[j], y[j], r[j]);
			for (auto p: pts) {
				int cnt = 0;
				for (int k = 0; k < n; k++) {
					if (dist(p, make_pair(x[k], y[k])) <= r[k] +eps) cnt++;
				}
				ans = max(ans, cnt);
			}
		}
	}
	

	return ans;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	if (k == 1) {
		cout << "0\n"; exit(0);
	}
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> c[i];
	}

	double l = 0, r = 100000000;
	while(r-l>=1e-8)
	{
		double mid = (l + r)/2;

		if (check(mid) >= k) {
			r = mid;
		} else {
			l = mid;
		}
	}
	cout << fixed << setprecision(9) << r << '\n'; 

	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())

#繰り返し自乗法だよ
#これはnのp乗をmで割ったあまりをだすよ
def modular_w_binary_method (n,m,p):
    ans=1 if n>0 else 0
    while(p>0):
        if p%2==1:
            ans=(ans*n)%m
        n=(n**2)%m
        p//=2
    return ans
#mod上でのaの逆元を出すよ
"""
    フェルマーの小定理より a**(p)%p==a isTrue
    これを利用すれば a**(p-2)%p==a**(-1) isTrue
    元と逆元とをかけてpで割れば1が余るよ！
"""
def modular_inverse(a,prime):
    return(modular_w_binary_method(a,prime,prime-2))
#逆元を使うと容易に頑張れるｃ
def conbination(n,a,mod=10**9+7):
    #cはイラない
    res=1 
    for s in range(a):
        res=(res*(n-s)*(modular_inverse(s+1,mod)))%mod

        
    return res
#操作から作れるものの組み合わせは何個かー＞同じものでも違う方法で構成できるかから考える方法もある
"""
"""

#solution:

#input
N,=pin()
T=[int(input()) for i in range(N)]
from fractions import gcd
def lcm2(x, y):
    return (x * y) // gcd(x, y)
def lcm(numbers):
        return reduce(lcm2,numbers,1)
print(lcm(T))

#print(h)
#print(m)
#print(["No","Yes"][cond])
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""

Measured memory_bytes: 68460
#include <stdio.h>
#define WHITE 1
#define BLACK 0
#define INF 1000000
#define NIL 1000000
int n;
int G[100][100];
int prim(int);
int main() {
  int w=0;
  int s;
  int i,j;
  
  

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&G[i][j]);
    }
  }
  
  
  
  s=0;
  w=prim(s);
    
   

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

  return 0;
}
int prim(int s){
  int i,j,k,l;
  int u,v,a=0;
  int d[100];
  int pi[100];
  int color[100];
  int mincost=0;

  for(u=0;u<n;u++){
    d[u]=INF;
    pi[u]=NIL;
    color[u]=WHITE;
  }
  d[s]=0;
  while(1){
    mincost=INF;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }
    if(mincost==INF) break;

    color[u]=BLACK;
    for(j=0;j<n;j++){
      v=G[u][j];
      if(v!=-1){
	if(color[j]!=BLACK && G[u][j]<d[j]){
	  pi[j]=u;
	  d[j]=G[u][j];
	}
      }
    }
      
     
  }


  for(i=0;i<n;i++){
    a+=d[i];
    
  }
  return a;
}

Measured memory_bytes: 636
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

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


	long sum1 = a[0];	//i項までの和
	long sum2 = a[0];
	long count1=0;	//a1が正のとき
	long count2=0;	//a1が負のとき
	if (a[0] >= 0) {
		count2 = 1 + a[0];
		sum2 = -1;
	}
	if (a[0] <= 0) {
		count1 = 1 - a[0];
		sum1 = 1;
	}

	for (int i = 1; i < n; i++) {
		if (sum1*(sum1 + a[i]) <0) {
			sum1 = sum1 + a[i];
		}
		else {
			if (sum1 > 0) {
				//sum1+a1-count1=-1
				count1 += abs(sum1+1+a[i]);
				sum1 = -1;
			}
			else {
				//sum1+a2+count2=1;
				count1 += abs(a[i] + sum1 - 1);
				sum1 = 1;
			}
		}

		if (sum2*(sum2 + a[i]) <0) {
			sum2 = sum2 + a[i];
		}
		else {
			if (sum2 > 0) {
				count2 += abs(sum2 + 1 + a[i]);
				sum2 = - 1;
			}
			else {
				count2 += abs(a[i] + sum2 - 1);
				sum2 = 1;
			}
		}
		//cout << "count1:"<<count1<<" sum1:"<<sum1 << endl;
		//cout << "count2:"<<count2 << " sum2:"<<sum2<<endl;
	}

	if (count1 < count2) {
		cout << count1 << endl;
	}
	else {
		cout << count2 << endl;
	}
	cin >> n;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <functional>

using namespace std;

using LR = pair<long, long>;

using OrderedRanges = multiset<LR, function<bool(const LR &, const LR &)>>;

class Ranges {
    OrderedRanges lefts;
    OrderedRanges rights;

public:
    Ranges(const vector<LR> &ranges) :
        lefts(ranges.begin(), ranges.end(),
              [](const LR &lhs, const LR &rhs) {
                  return lhs.first > rhs.first ||
                      lhs.first == rhs.first && lhs.second > rhs.second;
              }),
        rights(ranges.begin(), ranges.end(),
               [](const LR &lhs, const LR &rhs) {
                   return lhs.second < rhs.second ||
                                       lhs.second == rhs.second &&
                                       lhs.first < rhs.first;
        })
    {}

    LR pop(OrderedRanges &take_from, OrderedRanges &other) {
        auto first = take_from.begin();
        LR ret = *first;
        take_from.erase(first);
        other.erase(other.find(ret));
        return ret;
    }

    LR pop(bool left) {
        return left ? pop(lefts, rights) : pop(rights, lefts);
    }

    // friend ostream &operator<<(ostream &os, const Ranges &ranges);
};

// ostream &operator<<(ostream &os, const Ranges &ranges) {
//     os << ranges.lefts << "," << ranges.rights << endl;
//     return os;
// }

long calc(const vector<LR> &ranges, bool left) {
    Ranges world(ranges);
    long current = 0;
    long ret = 0;
    for(long i=0; i<ranges.size(); i++) {
        // cerr << i << ": " << endl;
        LR pair = world.pop(left);
        // cerr << "popped: " << pair << endl;
        // cerr << "world: " << world << endl;
        if(left) {
            if (current < pair.first) {
                ret += pair.first - current;
                current = pair.first;
            }
        } else {
            if (current > pair.second) {
                ret += current - pair.second;
                current = pair.second;
            }
        }
        left = !left;
    }
    ret += abs(current);
    return ret;
}

int main() {
    long N;
    cin >> N;
    vector<LR> ranges;
    for(long i=0; i<N; i++){
        long l, r;
        cin >> l >> r;
        ranges.push_back(make_pair(l, r));
    }

    //cerr << "start calc v1" << endl;
    long v1 = calc(ranges, true);
    long v2 = calc(ranges, false);

    //cerr << "v1:" << v1 << endl;
    //cerr << "v2:" << v2 << endl;

    cout << max(v1, v2) << endl;
}


Measured memory_bytes: 14320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int X,Y; cin >> X >> Y;
  int ans = 0;
  if (X == 1 && Y == 1) ans = 1000000;
  else ans = max(4-X,0)*100000 + max(4-Y,0)*100000;
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
	string a;
	cin >> a;
	int aa[4] = {0};
	string nn = "NWSE";
	for (int i = 0; i < a.size(); i++) {
		for (int j = 0; j < 4; j++) {
			if (a[i] == nn[j]) {
				aa[j]++;
				break;
			}
		}
	}
	if (aa[0] > 0 && aa[2] > 0) {
		if (aa[1] > 0 && aa[3] > 0) {
			cout << "Yes" << endl;
		} else if (aa[1] == 0 && aa[3] == 0) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else if (aa[0] == 0 && aa[2] == 0) {
		if (aa[1] > 0 && aa[3] > 0) {
			cout << "Yes" << endl;
		} else if (aa[1] == 0 && aa[3] == 0) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define F first
#define S second
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define N 200010
using namespace std;
void solve()
{
    ll n; cin>>n;
    vector<ll> v(n+1,1);
    for(int i=2;i<=n;i++)
    {
        for(int j=i;j<=n;j+=i)
            v[j]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
        ans+=i*v[i];
    cout<<ans<<endl;

}
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int t=1;
  //cin>>t;
  //freopen("b2.in", "r", stdin);
  //freopen("output2.txt", "w", stdout);
  for(int i=1;i<=t;i++)
  {
      solve();
  }
  return 0;
}



Measured memory_bytes: 81332
from functools import reduce
n = int(input())
xs = [int(input()) for i in range(n)]

def euclid_gcd(a, b):
    assert(a >= b)
    while b != 0:
        _, m = divmod(a, b)
        a, b = b, m
    return a


def lcm(a, b):
    if b > a:
        a, b = b, a
    assert(a >= b)
    gcd = euclid_gcd(a, b)
    return a*b//gcd

print(reduce(lcm, xs))


Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n);
    vector<ll> a(n);
    in(a);
    ll sum1=0,sum2=0,left=-10000000000,right=10000000000,mid;
    while(left<right){
        mid=(left+right)/2;
        sum1=0;
        sum2=0;
        for(int i=0;i<n;i++){
            sum1+=abs(a[i]-(left+i+1));
            sum2+=abs(a[i]-(right+i+1));
        }
        if(right-left==1)break;
        if(sum1<sum2){
            right=mid;
        }else{
            left=mid;
        }
    }
    out(min(sum1,sum2));
}

Measured memory_bytes: 4860
import bisect

N=int(input())
L=list(map(int, input().split()))
L.sort()

ans=0
for i in range(N-2):
  for j in range(i+1,N-1):
    #small = bisect.bisect_left(L, L[j]-L[i])
    large = bisect.bisect_left(L, L[j]+L[i])    
    #print(i,j,L[i],L[j],"  ",L[j]-L[i],L[j]+L[i],small,large)
    ans += max(large-j-1,0)    

print(ans)

Measured memory_bytes: 43100
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;
int main()
{
	long N,ANS1=0,ANS2=0;
	//vector<long long> T;
	long long T1,T2;
	cin >> N;
	cin >> T1;

	for (int i = 0; i < N-1; i++)
	{
		cin >> T2;
		if (T1 >= T2)
		{
			ANS1++;
		}
		else
		{
			if (ANS1 > ANS2)
			{
				ANS2 = ANS1;
			}
			ANS1 = 0;
		}
		if (i == N - 2)
		{
			if (ANS1 > ANS2)
			{
				ANS2 = ANS1;
			}
		}
		T1 = T2;
	}
	cout << ANS2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <functional>
#include <array>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long int ull;
typedef vector<int> vi;
#define rep(i,a,n) for(int i = (a);i < (n);i++)
#define per(i,a,n) for(int i = (a);i > (n);i--)
#define lep(i,a,n) for(int i = (a);i <= (n);i++)
#define pel(i,a,n) for(int i = (a);i >= (n);i--)
#define all(v) (v).begin(),(v).end()
#define clr(a,b) memset((a),(b),sizeof(a))
#define sz size()
#define pb push_back
#define print(x) cout << x << endl
#define INF 1e+9+7
int n,m,ans = 1;
int x[105];
int d[105];
string s,t;

int main(){
  clr(d,false);
  cin >> n;
  rep(i,0,n){
    cin >> m;
    if(m % 2 == 0)d[i] = 2;
    else d[i] = 1;
  }
  rep(i,0,n){
    ans *= d[i];
  }
  print(pow(3,n)-ans);
  return 0;
}

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

int h, w, k;
int d[9];

void init() {
  for (int i = 0; i <= w; i++) {
    d[i] = 1;
  }
  for (int i = 2; i <= w; i++) {
    d[i] = d[i-1] + d[i-2];
  }
}

vector<vector<long long> > mul(vector<vector<long long> > a, vector<vector<long long> > b) {
  vector<vector<long long> > v(w, vector<long long>(w, 0));
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < w; j++) {
      long long tmp = 0;
      for (int k = 0; k < w; k++) {
        tmp += a[i][k] * b[k][j];
        tmp %= mod;
      }
      v[i][j] = tmp;
    }
  }
  return v;
}

int main() {
  cin >> h >> w >> k;
  init();
  vector<vector<long long> > v(w, vector<long long>(w, 0));
  vector<vector<long long> > ans(w, vector<long long>(w, 0));
  for (int i = 0; i < w; i++) {
    ans[i][i] = 1;
    for (int j = i; j < w; j++) {
      if (abs(i-j) > 1) continue;
      v[i][j] = d[i] * d[w-j-1];
      v[j][i] = v[i][j];
    }
  }
  while (h != 0) {
    if (h % 2) {
      ans = mul(ans, v);
    }
    h /= 2;
    v = mul(v, v);
  }
  cout << ans[0][k-1] << endl;
  return 0;
}


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

int main()
{
	int x=0,y=0,tmp_y = 0;
	double X=0,Y=0;
	char dummy;
	while(cin >> x >> dummy >> y){
		if(!x && !y)break;

		X += x*cos(tmp_y*3.14159265359/180);
		Y += x*sin(tmp_y*3.14159265359/180);

		tmp_y += y;
	}

	cout << (int)Y << endl << (int)X << endl;
	cin >>x;
	return 0;
}

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

 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;

//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const LL INF=LONG_MAX;
const double EPS=0.00001;
const long double PI = acos(-1.0);


int main(){
    int N;cin>>N;
    vector<int>A(1e5+4,0);
    REP(i,N){
        int a;
        cin>>a;a++;
        A[a]++;
        A[a-1]++;
        A[a+1]++;
    }
    int maxi=0;
    REP(i,1e5+4)maxi=max(maxi,A[i]);
    cout<<maxi<<endl;
    return 0;
}


Measured memory_bytes: 640
N, D = map(int, input().split())
List = [list(map(int, input().split())) for _ in range(N)]

import math

cnt = 0

for i in range(N-1):
    for j in range(i+1, N):
        tmp = 0
        for k in range(D):
            tmp += (List[i][k]-List[j][k])**2
        if math.sqrt(tmp).is_integer():
            cnt+=1
print(cnt)

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

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;
  int count = 0;
  for (int i = std::min(a, b); 1 <= i; i--) {
    if (a % i == 0 && b % i == 0) {
      count++;
    }
    if (count == c) {
      std::cout << i << std::endl;
      break;
    }
  }
  return 0;
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int flag=1;
  
  if(N%2==1) flag=0;
  if(N%2==0){
  	rep(i, N/2){
  		if(S[i]!=S[i+N/2]) flag=0;
  	}
  }
  if(flag==1) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(int argc, char const *argv[]) {
	string str;

	cin >> str;

	cout << str.rfind('Z') - str.find('A') + 1 << endl;

	return 0;
}

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

int main() {
    vector<int> len(3);
    for(int i = 0; i < 3; ++i) cin >> len[i];
    for(int i = 0; i < 3; ++i) {
        const int l2 = len[(i + 1) % 3], l3 = len[(i + 2) % 3];
        if(len[i] * len[i] == l2 * l2 + l3 * l3) {
            cout << l2 * l3 / 2 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;
int main(){
    char str[128]={0};
    char check1[64]={0},check2=0;
    int cnt=0;
    while(scanf("%s",str)!=EOF){
        int len;
        bool flg = 0;
        len = strlen(str)/2;
        for(int i = 0;i < len; i++)check1[i] = str[i];
        reverse(str,str+strlen(str));
        for(int i = 0;i < len; i++){
            check2 = str[i];
            if(check1[i] != check2){
                flg = 1;
                break;
            }
        }
        if(flg == 0)cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 968
#include <iostream>
#include <string>
#include <regex>
using namespace std;

void check(string S
, const string T) {
    if(S.size() == T.size()-1) { // sizeをチェック
        // TがSで始まっているかチェック
        if(equal(S.begin(), S.end(), T.begin())) {
            // 最後が英数字化チェック
            smatch m;
            if(regex_search(T, m, regex("^.*[a-z]$"))) {
                cout << "Yes";
                exit (0);
            }
        }
    }
    cout << "No";
    exit (0);
}

int main() {
    string S,T; 
    cin >> S >> T;
    check(S,T);
    return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define ff first
#define ss second
#define pb push_back
#define vi vector<ll>
#define all(_x) _x.begin(), _x.end()
#define rep(i, s, e) for (ll i = s; i < e; i++)
#define lb(_x, _a) (lower_bound(all(_x), _a) - _x.begin())
#define ub(_x, _a) (upper_bound(all(_x), _a) - _x.begin())
ll n, tc;

int main()
{
  	// ll is int now
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string a, b;
    cin >> a >> b;
    if(a.empty() or b.empty()) cout<<' '<<'\n';
    int n = a.length();
    int m = b.length();
    int dp[n+1][m+1];

    rep(i,0,n+1) rep(j,0,m+1) dp[i][j] = 0;

    for(int i=1; i<n+1; i++)
    {
        for(int j=1; j<m+1; j++)
        {
            if(a[i-1]==b[j-1]) dp[i][j] = 1+ dp[i-1][j-1];
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    string res = "";
    int i = n, j = m;
    while(i>=1 and j>=1)
    {
        if(a[i-1]==b[j-1]){
             res+= a[i-1];
             i--;
             j--;
        }
        else
        {
            if(dp[i-1][j]>=dp[i][j-1]) i--;
            else j--;
        }
    }
    reverse(all(res));
    cout<<res<<'\n';
    
    return 0;
}


Measured memory_bytes: 35456
def solve(N,a):
    if N%2 == 1:
        return ["Second","First"][sum(a)%2]
    else:
        if min(a)%2 == 1:
            return "First"
        return ["Second","First"][sum(a)%2]


if __name__ == "__main__":
    N = int(input())
    a = list(map(int,input().split()))
    print(solve(N,a))


Measured memory_bytes: 28360
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		int steps, angle;
		double x = 0;
		double y = 0;
		double sumAngle = 0;

		while (true) {

			String[] temp = input().split(",");

			steps = Integer.parseInt(temp[0]);
			angle = Integer.parseInt(temp[1]);

			if (steps == 0 && angle == 0) {

				break;

			}

			x += steps * Math.cos(Math.toRadians(90 - sumAngle));
			y += steps * Math.sin(Math.toRadians(90 - sumAngle));
			sumAngle += angle;

		}

		System.out.println((int)x);
		System.out.println((int)y);

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 26120
N = int(input())
A = [0]+list(map(int, input().split(" ")))

dp_list = [{0, 0}, {0: 0, 1: A[1]}, {0: 0, 1: A[1] if A[1] > A[2] else A[2]}]

for i in range(3, N+1):
    b = (i-1)//2
    f = (i+1)//2
    dp_list.append({})
    for j in range(b, f+1):
        if j in dp_list[i-1]:
            dp_list[i][j] = dp_list[i-2][j-1]+A[i] if dp_list[i -
                                                              2][j-1]+A[i] > dp_list[i-1][j] else dp_list[i-1][j]
        else:
            dp_list[i][j] = dp_list[i-2][j-1]+A[i]

print(dp_list[-1][N//2])

Measured memory_bytes: 98292
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint x[20], y[20], p[20];
P px[20], py[20];
llint ansx[1<<15][20], ansy[1<<15][20];
llint cost[20][20], zcost[20][20];
llint dp[20][20];

void calc(llint mask, P px[], llint ans[1<<15][20])
{
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(i > j) continue;
			
			llint sum = 0;
			for(int k = i; k <= j; k++){
				llint id = px[k].second, x = px[k].first;
				if((mask & (1<<id)) == 0) continue;
				sum += p[id];
			}
			
			cost[i][j] = 0, zcost[i][j] = 0;
			if(sum == 0) continue;
			
			llint mid, tmp = 0;
			for(int k = i; k <= j; k++){
				llint id = px[k].second;
				if((mask & (1<<id)) == 0) continue;
				tmp += p[id];
				if(tmp >= sum/2){
					mid = px[k].first;
					break;
				}
			}
			
			for(int k = i; k <= j; k++){
				llint id = px[k].second;
				if((mask & (1<<id)) == 0) continue;
				cost[i][j] += p[id] * abs(mid - px[k].first);
				zcost[i][j] += p[id] * abs(px[k].first);
			}
		}
	}
	
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n; j++){
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= n; j++){
			for(int k = 0; k < i; k++){
				if(j-1 >= 0) dp[i][j] = min(dp[i][j], dp[k][j-1] + cost[k][i-1]);
				dp[i][j] = min(dp[i][j], dp[k][j] + zcost[k][i-1]);
			}
		}
	}
	ans[mask][0] = dp[n][0];
	for(int i = 1; i <= n; i++) ans[mask][i] = min(ans[mask][i-1], dp[n][i]);
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i] >> p[i];
		px[i] = P(x[i], i);
		py[i] = P(y[i], i);
	}
	sort(px, px+n);
	sort(py, py+n);
	
	llint N = 1<<n;
	for(int i = 0; i < N; i++){
		calc(i, px, ansx);
		calc(i, py, ansy);
		//for(int j = 0; j <= n; j++) cout << ansx[i][j] << " "; cout << endl;
	}
	
	for(int i = 0; i <= n; i++){
		llint ans = inf;
		for(int j = 0; j < N; j++){
			for(int k = 0; k <= i; k++){
				ans = min(ans, ansx[j][k] + ansy[(N-1)-j][i-k]);
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 13868
#include<bits/stdc++.h>
using namespace std;
int main(){
  	int N;cin >> N;
    vector<int> L(N);
    int sum = 0;

    //入力を受け入れる
    for(int i = 0;i < N;i++){

        cin >> L[i];
    }

    //大きい順にソート
    sort(L.begin() , L.end());
    reverse(L.begin() , L.end());

        //sumの計算
    for(int i = 1; i < N;i++){
        sum += L.at(i);
    }

    //判別
    if(L.at(0) < sum){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
 return 0;
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int N = int.Parse(Console.ReadLine());

            if (N == 1)
            {
                Console.WriteLine("Hello World");
            }
            else
            {
                int a = int.Parse(Console.ReadLine());
                int b = int.Parse(Console.ReadLine());
                Console.WriteLine(a + b);
            }
        }
    }
}

Measured memory_bytes: 13140
import sys

def main():

	S = input()
	T = input()
	
	max = 0
	count = 0
	for i in range(len(S) - len(T)+1):
		count = 0
		for j in range(len(T)):
			if S[i+j] == T[j]:
				count = count +1
		if max < count:
			max = count
	
	print(len(T) - max)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool flg = false;
  for (int i = 0; i < s.size()-1;i++){
    for (int j = i + 1; j < s.size();j++) {
      if(s[i]==s[j]){
        flg = true;
      }
    }
  }
  if(!flg){
    cout << "yes" << endl;
  }else{
    cout << "no" << endl;
  }
  return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
using namespace std;
using ll = long long;
void self_max(int &a,int b){
  a = max(a,b);
}

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

  b += a*3;

  cout << b/2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(void){
  string s; cin>>s;
  int count ,max = 0;
 
  for(int i = 0;i < s.length();i++){
    for(int t = s.length() - i;t > 0;t--){
      count=0;
      for(char x:s.substr(i,t)){
 
        if(x == 'A'||x == 'G'||x == 'C'||x == 'T'){
          count++;
          if(count > max)max = count;
        }
        else break;
 
      }
    }
  }
  cout<<max;
 
}


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

void add(long long &a, long long &b, long long n, long long &ans){
    long long count = 0;
    long long leave;
    for (int i=0; i<n; i++){
        leave = (n - a * b);
        leave -= a;
        for (int i=0; i<n; i++){
            if (leave > 0){
                count += 1;
                leave -= a;
            }
        
            else{
                break;
            }
        }
        
        ans += count * 2;
        count = 0;
        a += 1;
        b += 1;
    
    
    
    if ((n - a * b) > 0){
        ans += 1;
    }
  }
}

int main(){
    long long n, a, b, c, ans;
    cin >> n;
    a = 1;
    b = 1;
    c = 1;
    ans = 1;
    
    add(a, b, n, ans);
   

    cout << ans << endl;
}



Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    int a,b,c;
    cin >> a;
    cin >> b;
    cin >> c;
    if(a<b&&b<c){
        cout << "Yes";
    }else{
        cout << "No";
    }
    cout << endl;
}


Measured memory_bytes: 3104
n = int(input())
values = list(map(int, input().split()))

prev_direction = 0
money = 1000
stock = 0
for i, current in enumerate(values):
    if i == 0:
        continue

    yesterday = values[i - 1]
    # 上昇局面
    if current - yesterday > 0:
        if prev_direction != 1:
            # buy
            stockNum = money // yesterday
            buy = stockNum * yesterday
            money -= buy
            stock = stockNum
        prev_direction = 1

    elif current - yesterday < 0:
        # 下降局面
        if prev_direction != -1:
            sell = yesterday * stock
            stock = 0
            money += sell
        prev_direction = -1

    else:
        continue

lastSell = stock * values[len(values) - 1]
money += lastSell

print(money)


Measured memory_bytes: 9208
#include <stdio.h>

int main(){
  int x,y,a;

  scanf("%d%d",&x,&y);

  if(x<y){
    a=x;
    x=y;
    y=a;
  }

  while(y>0){
    a=x%y;
    x=y;
    y=a;
  }

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

  return 0;
}

Measured memory_bytes: 592
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int c[10][10];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	for (int i = 1; i <= 3; i++)
	{
		for (int j = 1; j <= 3; j++)
		{
			cin >> c[i][j];
		}
	}
	for (int o = -300; o <= 300; o++)
	{
		int b[4] = { 0,c[1][1] - o, c[1][2] - o, c[1][3] - o };
		int a[4] = { 0,c[1][1] - b[1], c[2][1] - b[1], c[3][1] - b[1] };
		int flag = 1;
		for (int i = 1; i <= 3; i++)
		{
			for (int j = 1; j <= 3; j++)
			{
				if (c[i][j] != a[i] + b[j])
					flag = 0;
			}
		}
		if (flag) puts("Yes"), exit(0);
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 256
import java.util.PriorityQueue;
import java.util.Scanner;

//Mobile Phone Coverage
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		double EPS = 1e-8;
		int T = 1;
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			double[][] p = new double[n][3];
			PriorityQueue<Double> qx = new PriorityQueue<Double>();
			PriorityQueue<Double> qy = new PriorityQueue<Double>();
			for(int i=0;i<n;i++){
				double x = sc.nextDouble();
				double y = sc.nextDouble();
				double r = sc.nextDouble();
				if(!qx.contains(x-r))qx.add(x-r);
				if(!qy.contains(y-r))qy.add(y-r);
				if(!qx.contains(x+r))qx.add(x+r);
				if(!qy.contains(y+r))qy.add(y+r);
				p[i][0] = x; p[i][1] = y; p[i][2] = r;
			}
			double[] x = new double[qx.size()];
			double[] y = new double[qy.size()];
			int id = 0;
			while(!qx.isEmpty())x[id++]=qx.poll();
			id = 0;
			while(!qy.isEmpty())y[id++]=qy.poll();
			double ans = 0;
			for(int i=0;i<x.length-1;i++)for(int j=0;j<y.length-1;j++){
				for(int k=0;k<n;k++){
					double lx = p[k][0]-p[k][2];
					double rx = p[k][0]+p[k][2];
					double dy = p[k][1]-p[k][2];
					double uy = p[k][1]+p[k][2];
					if(lx<x[i]+EPS&&x[i+1]<rx+EPS&&dy<y[j]+EPS&&y[j+1]<uy+EPS){
						ans += (x[i+1]-x[i])*(y[j+1]-y[j]);
						break;
					}
				}
			}
			System.out.printf("%d %.2f\n", T++, ans);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>

using namespace std;

struct node {
	int p, k, d, t;
	int* c;
};

void bfs(int x, vector<node> &nd){
	queue<int> q;
	q.push(x);
	nd[x].d = 0;
	while (!q.empty()){
		int k = q.front(); q.pop();
		if (!nd[k].k) nd[k].t = 2;
		else nd[k].t = 1;
		for (int i = 0; i < nd[k].k; i++) {
			int c = nd[k].c[i];
			q.push(c);
			nd[c].d = nd[nd[c].p].d + 1;
		}
	}
	nd[x].t = 0;
}

int main() {
	int n, st = 0;
	cin >> n;
	vector<node> nd(n);
	vector<string> type(3);
	type[0] = "root";
	type[1] = "internal node";
	type[2] = "leaf";
	for (int i = 0; i < n; i++) nd[i].p = -1;
	for (int i = 0; i < n; i++) {
		int id, k, ck;
		cin >> id >> k;
		nd[id].k = k;
		if(k) nd[id].c = new int[k];
		for (int j = 0; j < k; j++) {
			cin >> ck;
			nd[ck].p = id;
			nd[id].c[j] = ck;
		}
	}
	while (nd[st].p != -1) st = nd[st].p;
	bfs(st, nd);
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << nd[i].p << ", depth = " << nd[i].d << ", " << type[nd[i].t] << ", [";
		for (int j = 0; j < nd[i].k; j++) {
			if (j) cout << ", ";
			cout << nd[i].c[j];
		}
		cout << "]" << endl;
	}
}

Measured memory_bytes: 5992
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 999999999
#define ll long long
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
3
157
)");
#define cin input
#endif

int main()
{
	string s;
	ll k;
	cin >> s >> k;

	int j=0;
	for (int i=0; i<s.size(); i++)
	{
		if (s[i]!='1')
		{
			j=i;
			break;
		}
	}	

	if (k-1<j)
		cout << 1 << endl;
	else
	{
		cout << s[j] << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "a", stdout);
	#endif
	int n, k;
	cin >> n >> k;
	int a[n + 1];
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}	
	int mod=1e9+7;
	long long dp[n + 1][k + 1];
	dp[0][0] = 1;
	// No way to distribute when there are no students.
	for(int i = 1; i <= k; i++)
	{
		dp[0][i] = 0;
	}
	for(int i = 1; i <= n; i++)
	{
		int prefix[k + 1];
		prefix[0] = dp[i - 1][0];
		for(int y = 1; y <= k; y++)
		{
			prefix[y] =( prefix[y - 1] + dp[i - 1][y])%mod; 
		}
		for(int j = 0; j <= k; j++)
		{
			long ans = prefix[j];
			if(j > a[i])
			{
				ans = (ans - prefix[j - a[i] - 1] + mod)%mod;
			}
			dp[i][j] = ans;
			//cout << dp[i][j] << " ";
		}
		//cout << endl;
	}
	long long answer = dp[n][k];
	cout << answer%mod << endl;
	return 0;
}

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

int main(){
long i,j,k,N,ans=0,pow[12],x;
char ss[20];
scanf("%s",ss);
N=strlen(ss);
pow[0]=1;
for(i=1;i<10;i++)pow[i]=pow[i-1]*2;
pow[10]=1;pow[11]=1;
for(i=1;i<=N;i++){
for(j=0;j<=N-i;j++){
x=0;
for(k=0;k<i;k++){
x*=10;
x+=ss[j+k]-'0';
}
if(j==0||j==N-i){
ans+=x*pow[(N-i+10)%11];
}else{
ans+=x*pow[(N-i+10)%12];
}
}
}
cout <<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int a,n,m,l;
cin>>a>>n>>m>>l;
if(n>=m)
cout<<"Yes";
else if(a<=l)
cout<<"No";
else if(m/n+(m%n?1:0)<=a/l+(a%l?1:0))
cout<<"Yes";
else
cout<<"No";
}


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

int main() {
  int n;
  cin >> n;
  vector<int>x(n);
  vector<int>y(n);
  vector<int>dis(n);
  vector<int>t(n);
  vector<int>dt(n);
  for(int i = 0;i < n;i++) cin >> t[i] >> x[i] >> y[i];
  dis[0] = x[0]+y[0];
  dt[0] = t[0];
  for(int i = 1;i < n;i++){
    dis[i] = abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
    dt[i] = t[i]-t[i-1];
  }
  for(int i = 0;i < n;i++){
    if(dis[i] > dt[i] || abs(dis[i]-dt[i])%2 == 1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
int main(){
    using namespace std;
    string s;
    cin >> s;
    int ans = 0;
    if(s[0] == '1'){
        ans++;
    }
    if(s[1] == '1'){
        ans++;
    }
    if(s[2] == '1'){
        ans++;
    }
    cout  << ans << endl;
   return 0;
}

Measured memory_bytes: 256
/*
Sharif Hasan - CSE, PUST
Apr 24, 2020 02: 14 PM
*/
#include<bits/stdc++.h>
#define br cout<<"\n"
#define what(x) cout<<"in here var= "<<x<<"\n";

/*STL definations*/
#define pb push_back

#define FOR(i,n) for(int i=0;i<n;i++)
#define FROM(a,i,n) for(int i=a;i<n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int cnt[100001]={-1};
/*Main function*/
int main()
{
    long long n;long long sm=0;
    cin>>n;
    long long arr[n],cnt[100001]={0};
    FOR(i,n){
        cin>>arr[i];
        ++cnt[arr[i]];
        sm+=arr[i];
    }
    long long k;
    cin>>k;
    //cout<<sm<<endl;
    FOR(i,k){
        long long p,q;
        cin>>p>>q;
        if(cnt[p]!=0){
            long long reduced=cnt[p]*p;
            long long add=cnt[p];
           // cout<<p<<" r= "<<reduced<<" "<<add;br;
            cnt[p]=0;
            cnt[q]+=add;
            long long nxt=add*q;
            sm-=reduced;
           // cout<<sm<<" sm \n";
            sm+=nxt;
        }
        cout<<sm;br;
        
    }
    
    return 0;
}


Measured memory_bytes: 5208
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		  ll n;
           cin>>n;
           vll a(n);
           rep(i,0,n)cin>>a[i];
           //偶数を押し付ける
           bool ans=false;
           rep(i,0,n)if(a[i]%2==1)ans=true;
           if(ans)cout<<"first"<<endl;
           else cout<<"second"<<endl;
          }

Measured memory_bytes: 4056