akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define mian main
#define Max(x,y) (x>y ? x : y)
#define Min(x,y) (x<y ? x : y)
typedef long long ll;

int n;
int ans;
int minx=1e9;
int a[110];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=100;i++)
	{
		int sum=0;
		for(int j=1;j<=n;j++)
		{
			sum+=(a[j]-i)*(a[j]-i);
		}
		if(sum<minx)
		{
			minx=sum;
		}
	}
	printf("%d",minx);
	return 0;
}











Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include <algorithm>
#include <set>
#include<math.h>
#include<vector>
#include<map>
using namespace std;

int main(){
    int n;
    cin >> n ;
    int a[n];
    int t,i=0;
    map<int,int> count;
    for(i = 0;i < n;i++){
        cin >> t;
        a[i] = t;
        count[a[i]] = 0;
    }
    for(int j = 0;j < n;j++){
        count[a[j]] +=1;
        count[a[j]+1] += 1;
        count[a[j]+2] += 1;
        //cout << a[j] << endl;
        //cout << count[a[j]] << endl;

    }
    int tmp = 0;
    for(i = 0;i<n;i++){
        //cout << count[i] << endl;
        //cout << count[i] << endl;
       if(count[a[i]] > tmp){
           tmp = count[a[i]];
       }
    }
    cout << tmp << endl;
}

Measured memory_bytes: 5120
#include <iostream>
using namespace std;
int main() {
    int n;
    cin>>n;
    int a;
    int ans=0;
    for(int i=1;i<=n;i++){
        cin>>a;
        if(i&1){
            if(a&1) ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}


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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define MOD  1000000007
#define mod1 1000000009
#define var    int i,j,c=0,t,l,r,mid,z=0,k,x,y

//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};
int n,m;

int main()
{
    var;
    sf(n);
    while(n>0)
    {
        if(n%10==7)
        {
            pf("Yes\n");
            return 0;
        }
        n/=10;
    }
    pf("No\n");
}


Measured memory_bytes: 3688
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const ll INF = 10000000000000;
using namespace std;//namespace
 
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}//transform
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//#define int long long // yabai
 
#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define ALL(obj) (obj).begin(),(obj).end()// iterator
 
#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair
 
 
int main(){
 
    ll n,max_;
    cin>>n>>max_;
    vector<ll>w(n);
    vector<ll>v(n);
    REP(i,n)cin>>w[i]>>v[i];

    vector<vector<ll>> vec(4);
    REP(i,n)vec[w[i]-w[0]].pb(v[i]);
    REP(i,4)sort(ALL(vec[i]),std::greater<int>());

    vector<int> bit_(4,0);
    ll sum=0;
    while(bit_[0]!=vec[0].size()||bit_[1]!=vec[1].size()||bit_[2]!=vec[2].size()||bit_[3]!=vec[3].size()){
        if(bit_[0]!=vec[0].size())bit_[0]++;
        else if(bit_[1]!=vec[1].size()){bit_[0]=0;bit_[1]++;}
        else if(bit_[2]!=vec[2].size()){bit_[0]=0;bit_[1]=0;bit_[2]++;}
        else if(bit_[3]!=vec[3].size()){bit_[0]=0;bit_[1]=0;bit_[2]=0;bit_[3]++;}
        if(bit_[0]*w[0]+bit_[1]*(w[0]+1)+bit_[2]*(w[0]+2)+bit_[3]*(w[0]+3) <= max_){

            sum=max(
                accumulate(vec[0].begin(),vec[0].begin()+bit_[0],0LL)+
                accumulate(vec[1].begin(),vec[1].begin()+bit_[1],0LL)+
                accumulate(vec[2].begin(),vec[2].begin()+bit_[2],0LL)+
                accumulate(vec[3].begin(),vec[3].begin()+bit_[3],0LL),
                sum);
        }
    }
    cout<<sum<<endl;

    return 0;
}


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

int main(void) {
    int N;
    cin >> N;
    vector<long long> A(N);
    bool zero_flag = false;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        if (!A[i]) zero_flag = true;
    }
    if (zero_flag) {
        cout << 0 << "\n";
        return 0;
    }
    double log_sum = 0;
    for (int i = 0; i < N; ++i) log_sum += log10(A[i]);
    if (log_sum > 18.5) {
        cout << -1 << "\n";
        return 0;
    }
    long long ans = 1;
    for (int i = 0; i < N; ++i) ans *= A[i];
    if (ans > 1000000000000000000) cout << -1 << "\n";
    else cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4084
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
d = gets.chomp.to_i
e = gets.chomp.to_i
arr = [a,b,c,d,e]
smallest = 10000
[*0..4].permutation(5){|i|
  time = 0
  i.each_with_index{|j, ind|
    time += arr[j]
    if(time % 10 > 0 && ind < 4)
      time += 10
      time -= time % 10
    end
  }
  smallest = [time, smallest].min
}
puts smallest


Measured memory_bytes: 1788
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String,
    }

    let marble_count = s.split("").filter(|&n| n == "1").count();

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


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    vector<int> A(5);
    vector<int> P={0,1,2,3,4};
    int ans=0;
    for(int i=0;i<5;i++){
        cin >> A[i];
    }
    int f=1000000000;
    do{
        ans=0;
        for(int i=0;i<5;i++){
            while(ans%10!=0)ans+=1;
            ans+=A[P[i]];
        }
        f=min(f,ans);
    }while(next_permutation(P.begin(),P.end()));
    cout << f << endl;
    return 0;
}


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

void hitAndBlow(int *n, int *m)
{
  int a[4], b[4], c[4] = {};

  for (int i=0; i<4; i++) {
    a[i] = *n % 10;
    *n /= 10;
    b[i] = *m % 10;
    *m /= 10;
  }

  for (int i=0; i<4; i++) {
    if (a[i] == b[i]) {
      (*n)++;
      c[i] = 1;
    }
  }

  for (int i=0; i<4; i++) {
    if (c[i]) continue;
    for (int j=0; j<4; j++) {
      if (c[j]) continue;
      if (a[i] == b[j])
	(*m)++;
    }
  }
}

int main(void)
{
  while (1) {
    int n,m;
    cin >> n >> m;
    if (!n && !m) break;
    hitAndBlow(&n, &m);
    cout << n << " " << m << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(){

	int n,i,x;
	
	scanf("%d",&n);
	
	for(i=1;i<=n;i++){
		x=i;
		if(x%3==0){
			printf(" %d",i);
		}else{
			for(x=i;x;x/=10){
				if(x%10==3){
					printf(" %d",i);
					break;
				}
			}
		}
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 600
#include<iostream>
using namespace std;
int main(){
	int a,b,x=0,y=0,cnt,i;
	cin>>a;
	for(i=0;i<a;i++){
		cin>>b;
		cnt=0;
		if(b%4==0)cnt++;
		if(b%2==0)cnt++;
		if(cnt==1)x++;
		if(cnt==2)y++;
	}
	if(y>=a-x-y)cout<<"Yes";
	else if(!x&&y==a/2)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
import collections

n = int(input())


def prime_factorize_n(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


k = []
for i in range(1, n + 1):
    k = k + prime_factorize_n(i)
c = collections.Counter(k)
d = c.most_common()
ans = 1

for k, v in d:
    ans = (ans*(v + 1)) % (10 ** 9 + 7)
print(ans)


Measured memory_bytes: 39408
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e18
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

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

	int p[200020] = { };
	//int s[200020] = { };

	rep(i, m) {
		cin >> a >> b;
		//2回 踏む駅があればよい
		if (a == 1) p[b]++;
		if (b == n) p[a]++;
	}

	REP(i,0,n) {
		if (p[i] == 2) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}

	cout << "IMPOSSIBLE" << endl;
}






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

using namespace std;

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

    int n, m, cnt = 0, sum = 0;
    cin >> n >> m;
    int arr[n];

    for (int i = 0; i < n; i++)
        cin >> arr[i], sum += arr[i];
    for (int x : arr)
        cnt += (x * 4 * m >= sum);
    cout << (cnt >= m ? "Yes\n" : "No\n");

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
int main(void){
    int k;cin>>k;
    ll ans=0;
    for(int i=1;i<=k;i++)for(int j=1;j<=k;j++)for(int l=1;l<=k;l++){
        ans+=gcd(gcd(i,j),l);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
def main():
    n,k = map(int,input().split())
    div = n//k
    A = abs(n-k*div)
    B = abs(n-k*(div+1))
    if A < B:
        x = A
    else:
        x = B
    print(x)
if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  int cur; 
  cin >> cur;
  int ans = 0;
  int c = 0;
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    if (a <= cur) c++;
    else c = 0;
    ans = max(ans, c);
    cur = a;
  }
  cout << ans << endl;
  return 0;
}


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

double t[105], v[105], st[105];
int main(){
    int n;
    cin >> n;
    double sum = 0.0;
    for(int i = 0; i < n; i++){
        cin >> t[i+1];
        st[i+1] = st[i] + t[i+1];
    }
    st[n+1] += st[n];
    for(int i = 0; i < n; i++) cin >> v[i+1];
    double ans = 0.0, prev = 0.0;
    for(double i = 0.5; i <= st[n]; i += 0.5){
        double cur = 100;
        for(int j = 0; j <= n+1; j++){
            if(j >= 1 && st[j-1] <= i && i <= st[j]){
                cur = min(cur, (double)v[j]);
            }
            if(st[j] < i){
                cur = min(cur, (double)(v[j] + (i - st[j])));
            }
            if(j >= 1 && st[j-1] > i){
                cur = min(cur, (double)(v[j] + (st[j-1] - i)));
            }
        }
        ans += (cur + prev) * 0.25;
        prev = cur;
    }
    cout << fixed << setprecision(9) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=[]
for i in range(n):
  s.append(input())
print("AC"+" x "+str(s.count("AC")))
print("WA"+" x "+str(s.count("WA")))
print("TLE"+" x "+str(s.count("TLE")))
print("RE"+" x "+str(s.count("RE")))

Measured memory_bytes: 16280
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
using namespace std;
const int N=1e6;
int n,m,head[N+10],tot=0;
bool vis[N+10],vx[N+10];
bitset <1010> bi[1010];
struct data {
    int next,num,w;
}edge[N+10];
void Add(int u,int v,int w) {
    edge[++tot].next=head[u];
    edge[tot].num=v;
    edge[tot].w=w;
    head[u]=tot;
}
bool Dfs(int x,int va) {
    if (vis[x]) return 0;
    vis[x]=1;
    for (int i=head[x];i!=-1;i=edge[i].next) {
        if (edge[i].w>=va) continue;
        int kx=edge[i].num;
        if (!Dfs(kx,edge[i].w)) return 0;
    }
    return 1;
}
int main() {
    memset(head,-1,sizeof(head));
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++) {
        int u,v;
        scanf("%d%d",&u,&v);
        Add(u,v,i);
        Add(v,u,i);
    }
    for (int i=1;i<=n;i++) {
        for (int j=1;j<=n;j++) vis[j]=0;
        vx[i]=Dfs(i,1e9);
        for (int j=1;j<=n;j++) bi[i][j]=vis[j];
    }
    int ans=0;
    for (int i=1;i<=n;i++)
        for (int j=i+1;j<=n;j++) {
            if (!vx[i]||!vx[j]) continue;
            if ((bi[i]&bi[j]).count()==0) ans++;
        }
    printf("%d\n",ans);
    return 0;
}


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

int main(){
	double a, b, C, h, S, L, rad;
	cin >> a >> b >> C;
	rad = M_PI * C / 180.0;
	h = b*sin(rad);
	S = a*h/2;
	L = a + b + sqrt(a*a + b*b - 2*a*b*cos(rad));
	printf("%.8f\n%.8f\n%.8f\n", S, L, h);
	return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a[100];
  cin >> n;
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<n; i++){
	for(int j=i-1; j>=0; j--){  
	  if(a[j]>a[j+1]) swap(a[j],a[j+1]);
	  else break;
	}
	for(int j=0; j<n; j++){
	  if(j) cout << ' '; //j==0の時実行しない。
	  cout << a[j];
	}
	cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int a[200];
int main(){
	int n,mi=100,ma=0,min=100000000;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]>ma) ma=a[i];
		if(a[i]<mi) mi=a[i];
	}
	//cout<<mi<<" "<<ma<<endl;
	for(int i=mi;i<=ma;i++){
		int s=0;
		for(int j=1;j<=n;j++){
			s=s+(a[j]-i)*(a[j]-i);
		}
		if(s<min){
			min=s;
			//cout<<min<<endl;
		}
	}
	cout<<min;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <boost/algorithm/string.hpp> 
using namespace std;
#define ll long long
#define ull unsigned long long
#define V vector<int>
#define VLL vector<ll>
#define VV vector<vector<ll>>
#define vec vector
#define P pair
#define scan(a) scanf("%d",&a)
#define print(a) printf("%d",a)
#define be(x) begin(x),end(x)
#define For(a) for(int i=0;i<a;i++)
#define Forin(j,a,b) for(int j=a;j<b;j++)
#define len(a) a.size()
#define pb push_back 
#define mp make_pair
#define Um unordered_map
#define Us unordered_set
#define F first
#define S second
#define mod 1000000007

void solve();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie();
   
    
    solve();
    cout<<"\n";
return 0;
}
void solve()
{
   string s;
   cin>>s;
   if(s[len(s)-1]!='s')
    cout<<s+"s";
else cout<<s+"es";
}

Measured memory_bytes: 3660
class segment_tree:
    n = 0
    segtree = []
    max_v = 10**10

    def __init__(self, A, max_n=2**31 - 1):
        self.N = len(A)
        self.max_v = max_n
        self.n = (self.N-1).bit_length()
        self.n = 2 ** self.n
        self.segtree = [max_n]*(2*self.n)
        for i in range(self.N):
            self.segtree[self.n+i - 1] = A[i]
        for i in range(self.n - 2, -1, -1):
            self.segtree[i] = min(self.segtree[i*2 + 1], self.segtree[i*2 + 2])

    def update(self, i, x):
        id = self.n+i - 1
        self.segtree[id] = x
        while(id > 0):
            id = (id - 1) // 2
            self.segtree[id] = min(
                self.segtree[id*2 + 1], self.segtree[id*2+2])
            #print(self.segtree[id*2 + 1], self.segtree[id*2+2])


    def query(self, a, b, k, l, r):
        if r <= a or l >= b:
            return(self.max_v)
        if a <= l and r <= b:
            return(self.segtree[k])
        else:
            vl = self.query(a, b, k*2+1, l, (l+r)//2)
            vr = self.query(a, b, k*2+2, (l+r)//2, r)
            return(min(vl, vr))


n, q = map(int, input().split())
N = (n-1).bit_length()
N = 2 ** N
A = [2**31 - 1]*n
G = segment_tree(A)
for _ in range(q):
    a, x, y = map(int, input().split())
    if a == 0:
        G.update(x, y)
    else:
        y += 1
        print(G.query(x, y, 0, 0, N))




Measured memory_bytes: 9476
#include <iostream>
#include <string>
 
int main(int argc, char* argv[]) {
  std::string line;
  std::cin >> line;
  int money = std::stoi(line);
  int div500 = money / 500;
  money -= div500 * 500;
  int div5 = money / 5;
  money -= div5 * 5;
  std::cout << std::to_string((div500*1000)+(div5*5)) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
long long x,y,n,i,r;
map<long long,long long> mp;
int main() {
    cin >> x >> n;
    for(i = 0; i < n; i++) {
        cin >> y;
        mp[y] = 1;
    }
    i = x;
    while(mp[i]) {
        i++;
    }
    r = i-x;
    i = x;
    while(mp[i]) {
        i--;
    }
    if(r < x-i) {
        cout << x+r;
    } else {
        cout << i;
    }   
    return 0;
}

Measured memory_bytes: 3592
def main():
    from sys import setrecursionlimit, stdin
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor, gcd
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**9+10

    sa,sb = input().split()
    a = int(sa)
    sb = sb.split('.')
    b100 = int(sb[0])*100
    if len(sb) ==2:
        b100 += int(sb[1])
    print(a*b100//100)
    # print(int(a*(b*10**2))//10**2)
    # print(int(a),int(b*10**2))
    # print(int(a)*int(b*10**2)//10**2)
    
main()
#999999999999999 9.99

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

int64_t rucas(int N) {
  int64_t L0 = 2LL;
  int64_t L1 = 1LL;
  int64_t tmp;
  for(int i = 1; i < N; ++i) {
    tmp = L1;
    L1 += L0;
    L0 = tmp;
  }
  return L1;
}

int main(void) {
  int N;
  cin >> N;
  cout << rucas(N) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, M;
	cin >> N >> M;

	vector<vector<Int>> A(M, vector<Int>(2));
	Int a, b;
	for (Int i = 0; i < M; i++) {
		cin >> a >> b;
		a--;
		b--;
		A[i][0] = b;//終点
		A[i][1] = a;//始点
	}

	sort(A.begin(), A.end());//終点でソート

	//区間スケジューリング
	Int ans = 0;
	Int end = 0;
	for (Int i = 0; i < M; i++) {
		if (A[i][1] >= end) {
			ans++;
			end = A[i][0];
		}
	}

	cout << ans << "\n";
}


Measured memory_bytes: 5760
using System;
using System.Linq;

namespace AtCoder
{
    class Program2
    {

        static void Main(string[] args)
        {
            var valores = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();

            int TakaH = valores[0];
            int TakaS = valores[1];
            int AokiH = valores[2];
            int AokiS = valores[3];

            bool ahoraTaka = true;

            while (TakaH > 0 && AokiH > 0)
            {
                if (ahoraTaka)
                {
                    AokiH -= TakaS;
                    ahoraTaka = false;
                }
                else
                {
                    TakaH -= AokiS;
                    ahoraTaka = true;
                }
            }

            if (TakaH <= 0)
                Console.WriteLine("No"); 
            else
                Console.WriteLine("Yes");
        }
    }
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N); 
  for(int i = 0; i<N; i++){
    cin >> a.at(i);
  }
  
  // case 1 全部0かどうかの判定
  bool case1=true;
  for(int i=0; i<N; i++){
    if(a.at(i)==0){
    }else{
      case1=false;
    }
  }
  
 // case2 and case3 
  bool case23=true;
  if(N%3!=0){
    case23=false;
  }
  sort(a.begin(), a.end());
  if(a.at(0)==0){//case2 開始
    if(a.at((N/3)-1)!=0 || a.at(N/3)!= a.at(N-1)){
      case23 = false;
    }
  }else{//case3 開始
    if( (a.at(0) != a.at((N/3)-1)) || (a.at((N/3)-1) == a.at(N/3))){
      case23 = false;
    }else if( (a.at(N/3) != a.at((2*N/3)-1)) || (a.at((2*N/3)-1) == a.at(2*N/3))){
      case23 = false;
    }else if(a.at(2*N/3) != a.at(N-1)){
      case23 = false;
    }
    if(a.at(N-1) !=( a.at((2*N/3)-1) ^ a.at((N/3)-1))){
      case23 = false;
    }
  }
  if(case1 || case23){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }
}


Measured memory_bytes: 640
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

char s[123],t[123];

int main(){
	int n=ci();
	scanf("%s",s+1);
	scanf("%s",t+1);
	rep(i,1,n){
		pt(s[i]);
		pt(t[i]);
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

int main() {
    int n, k, q;
    std::cin >> n >> k >> q;
    std::vector<int> points(n, k - q);
    for (int i = 0; i < q; i++) {
        int a;
        std::cin >> a;
        a--;
        points[a]++;
    }

    for (int i = 0; i < n; i++) {
        if (points[i] > 0) {
            std::cout << "Yes" << std::endl;
        } else {
            std::cout << "No" << std::endl;
        }
    }

    return 0;
}


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

int main() {
  //木の本数
  int N ; cin >>N;
  //木の長さの配列
  vector<int> len(N);
  
   int K ; cin >>K;
  //長さを入力し、長い順に入れ替える
  for(int i=0;i<N;i++)
  {
    cin >>len.at(i);
  }
  sort(len.begin(),len.end());
  reverse(len.begin(),len.end());
  
    for(int i=0;i<N;i++)
  {
    //cout <<len.at(i) <<" ";
  }
  //cout <<endl;
  //配列を前の要素との長さの差に変える
  vector<int> sa(N);
  for(int i=0;i<N;i++)
  {
    if(i==0)sa[i]=0;
    else
    {
      sa[i]=len[i-1]-len[i];
      //cout <<sa[i] ;
    }
  }
  //cout <<endl;
  
  //saから指定回数の長さだけ差の合計を拾っていき、これらがhより低いとそれに書き換える
 
  int h;
  int sum=0;
  for(int i=0;i+K<=N;i++)
  {
    sum=0;
    //最初とそれ以降で処理が違う
    if(i==0)
    {
      for(int j=1;j<K;j++)
      {
        sum+=sa[i+j];
      }
      //cout <<sum <<" ";
      h=sum;
    }
      //最初とそれ以降で処理が違う
    if(i>=1)
    {
      for(int j=1;j<K;j++)
      {
        sum+=sa[i+j];
      }
      //cout <<sum <<" ";
      if(sum<h)h=sum;
    }
  }
  //cout <<endl;
  cout <<h;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
    for(int n; cin >> n && n;)
	{
		int res = 0;
		vint v(n);
		
		rep(i, n) cin >> v[i];
		
		for(int j = n - 1; 0 < j; j--) for(int i = 0; i < j; i++) 
		{
			if(v[i] > v[i + 1])
			{
				swap(v[i], v[i + 1]);
				res++;
			}
		}
		
		cout << res << endl;
	}		
}

Measured memory_bytes: 0
//16, 02, 2019, 10:09:12 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int N = int(1e5 + 100);
ll suf[N];
ll pref[N];
ll mx_suf[N];
ll mx_pref[N];
ll a[N];

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

    int n;

    bool is_equal = true;
    bool is_evenodd = true;

    cin >> n;

    ll g = 0LL;

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

        g = __gcd(g, a[i]);
    }

    cout << g << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define deb(x) cout<<#x<<" is "<<x<<endl;
typedef long long ll;
using namespace std;
void dfs(int node,vector<vector<int>>&graph,vector<bool>&visited,stack<int>&st);

int main()
{
    int n,m;
    cin>>n>>m;
    vector<vector<int>>graph(n);
    vector<bool>visited(n,false);
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        graph[x].push_back(y);
    }

    stack<int>st;
    for(int i=0;i<n;i++)
        if(!visited[i])
            dfs(i,graph,visited,st);
    
    vector<int>dp(n,0);
    int ans=0;
    while(!st.empty())
    {
        int node=st.top();
        st.pop();
        for(auto child : graph[node])
        {
            dp[child]=max(dp[child],dp[node]+1);
            // cout<<node<<" "<<child<<" "<<dp[child]<<endl;
            ans=max(ans,dp[child]);
        }
    }
    cout<<ans<<endl;
}

void dfs(int node,vector<vector<int>>&graph,vector<bool>&visited,stack<int>&st)
{
    visited[node]=true;

    for(auto child : graph[node])
        if(!visited[child])
            dfs(child,graph,visited,st);
        
    st.push(node);
}

Measured memory_bytes: 13012
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
from itertools import product
from collections import deque
def resolve():
    h,w=map(int,input().split())
    G=[list(input()) for _ in range(h)]

    D=[(-1,0),(1,0),(0,-1),(0,1)]
    ans=0
    for si,sj in product(range(h),range(w)):
        if(G[si][sj]=='#'): continue

        # bfs して距離を出し、その max の max
        dist=[[INF]*w for _ in range(h)]
        dist[si][sj]=0
        Q=deque([(si,sj)])
        while(Q):
            i,j=Q.popleft()
            for di,dj in D:
                ni,nj=i+di,j+dj
                if(not (0<=ni<h and 0<=nj<w)): continue
                if(G[ni][nj]=='#'): continue
                if(dist[ni][nj]>dist[i][j]+1):
                    dist[ni][nj]=dist[i][j]+1
                    Q.append((ni,nj))

        ans=max(ans,max(dist[i][j] for i,j in product(range(h),range(w)) if dist[i][j]!=INF))

    print(ans)
resolve()

Measured memory_bytes: 47452
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define PI pair<int,int>
#define ff first
#define ss second
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)

const int M=998244353;

int32_t main() 
{ 
    boost;
   int n;
    cin>>n;
    array<int,2>a[n];
    for(int i=0;i<n;i++)
        cin>>a[i][0]>>a[i][1];
    sort(a,a+n);
    int dp[n+1]={0};
    dp[n]=1;
    stack<array<int,2>>st;
    st.push({n,(int)2e9});
    for(int i=n-1;i>=0;i--){
        while(st.top()[1]< a[i][0]+a[i][1])
            st.pop();
        int p=st.top()[0];
        dp[i]=(dp[p]+dp[i+1])%M;
        st.push({i,a[i][0]});
    }
    cout<<dp[0]<<endl;
}


Measured memory_bytes: 6656
def solve(day)
    next_sunday = {"SUN"=>7,"MON"=>6,"TUE"=>5,"WED"=>4,"THU"=>3,"FRI"=>2,"SAT"=>1}
    next_sunday[day]
end

def main()
    s = gets.chomp()
    ans = solve(s)
    p ans
end

main()

Measured memory_bytes: 1788
from functools import reduce
n = int(input())
w = list(map(int, input().split()))
n2 = int(n/2)
s1 = reduce(lambda x, y: x + y, w[:n2])
s2 = reduce(lambda x, y: x + y, w[n2:])
oldSum = s2 - s1
sum = oldSum + 1 if oldSum > 0 else oldSum - 1
while abs(sum) > abs(oldSum):
	if oldSum >= 0:
		n2 += 1
		if n2 >= n:
			break
	else:
		n2 -= 1
		if n2 < 0:
			break
	sum = oldSum
	s1 = reduce(lambda x, y: x + y, w[:n2])
	s2 = reduce(lambda x, y: x + y, w[n2:])
	oldSum = s2 - s1
print(min(abs(oldSum), abs(sum)))

Measured memory_bytes: 3572
#include <iostream>
#include <set>

int main(){

    int i;

    std::string str;
    std::cin >> str;

    if(str.size() != 26){
        std::set<char> alphabet;
        char a = 'a';

        for(i = 0; i < 26; i++){
            alphabet.insert(a);
            a++;
        }

        for(i = 0; i < str.size(); i++){
            alphabet.erase(str[i]);    
        }

        std::cout << str + *alphabet.begin() << std::endl;
        return 0;
    }else{
        int pos = -1;
        char min = 'z';
        for(i = 0; i < str.size(); i++){
            if((str[i] < str[i + 1]) == 1){
                pos = i;
            }
        }

        if(pos == -1){
            std::cout << pos << std::endl;
            return 0;
        }


        for(i = pos + 1; i < str.size(); i++){
            if(min > str[i] && str[pos] < str[i]) min = str[i];
        }

        str[pos] = min;
        for(i = 0; i < pos + 1; i++){
            std::cout << str[i];
        }
        std::cout << std::endl;
        return 0;
    }
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,k;
    cin >> n >> k;
    int32 ans = 0;
    while(n){
        ans++;
        n /= k;
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<int, int> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };


int main() {

	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	string ans;

	ans = 'U';

	int up = ty - sy;
	int side = tx - sx;
	//first round trip
	rep(i, up - 1) {
		ans += 'U';
	}
	rep(i, side) {
		ans += 'R';
	}
	rep(i, up) {
		ans += 'D';
	}
	rep(i, side) {
		ans += 'L';
	}
	// second round trip
	ans += 'L';
	rep(i, up + 1) {
		ans += 'U';
	}
	rep(i, side + 1) {
		ans += 'R';
	}
	ans += 'D';
	ans += 'R';
	rep(i, up + 1) {
		ans += 'D';
	}
	rep(i, side + 1) {
		ans += 'L';
	}
	ans += 'U';
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define min(a,b) a<b?a:b

using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int w=0,b=0;
    vector<int> a;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='#') b++;
        else w++;
    }
    for(int i=0;i<=n;i++)
    {
        if(i==0)
            a.push_back(w);
        else if(i==n)
            a.push_back(b);
        else if(s[i-1]=='#')
            a.push_back(1+a[i-1]);
        else if(s[i-1]=='.')
            a.push_back(a[i-1]-1);

    }
    vector<int>::iterator it=min_element(a.begin(),a.end());
    cout<<*it<<endl;
}


Measured memory_bytes: 1532
import java.util.*

fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val a = longList()
    var reversed = false
    val b = LinkedList<Long>()
    a.forEach {
        if (reversed) {
            b.addFirst(it)
        } else {
            b.addLast(it)
        }
        reversed = !reversed
    }
    if (reversed) {
        b.reverse()
    }
    println(b.joinToString(separator = " "))
}


Measured memory_bytes: 84164
import sys
input = sys.stdin.readline

n = int(input())
a_lst = list(map(int, input().split()))
b_lst = list(map(int, input().split()))
ans = 0

for i in range(n):
    b = b_lst[-(i+1)]
    a = a_lst[-(i+1)]
    pre_a = a_lst[-(i+2)]
    if a >= b:
        ans += b
    else:
        if b - a > pre_a:
            a_lst[-(i+2)] = 0
            ans += a + pre_a
        else:
            a_lst[-(i+2)] -= b - a
            ans += b
print(ans)

Measured memory_bytes: 18624
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=200005;
const ll inf=1e18;
struct node{
	ll mn,mn2; int col,col2;
	node(ll x=inf,int c=0){
		mn=x,mn2=inf,col=c,col2=0;
	}
	node ex(ll x){
		node res=*this;
		res.mn+=x,res.mn2+=x;
		return res;
	}
	friend node operator + (node a,node b){
		if(b.mn<a.mn) swap(a,b);
		node res=a;
		if(res.col!=b.col){
			if(b.mn<res.mn2) res.mn2=b.mn,res.col2=b.col;
		}
		else{
			if(b.mn2<res.mn2) res.mn2=b.mn2,res.col2=b.col2;
		}
		return res;
	}
} f[N],g[N];
int x[N],pa[N],cur[N],n,a,b,c,con;
vector<pii> e[N];
ll val[N],ans;

int gp(int x){
	return pa[x]==x?x:pa[x]=gp(pa[x]);
}

void dfs1(int u,int fa){
	f[u]=node(x[u],gp(u));
	for(auto v:e[u]){
		if(v.fi==fa) continue;
		dfs1(v.fi,u);
		f[u]=f[u]+f[v.fi].ex(v.se);
	}
}

void dfs2(int u,int fa){
	node res=f[u]+g[u];
	if(res.col==gp(u)){
		cur[u]=res.col2,val[u]=x[u]+res.mn2;
	}
	else{
		cur[u]=res.col,val[u]=x[u]+res.mn;
	} 
	if(fa&&e[u].size()==1) return;
	int sz=e[u].size()-(fa>0),k=0;
	vector<node> pre(sz),suf(sz);
	vector<pii> sn(sz);
	for(auto v:e[u]){
		if(v.fi==fa) continue;
		sn[k]=v,pre[k]=suf[k]=f[v.fi].ex(v.se),k++;
	}
	rep(k,1,sz-1) pre[k]=pre[k-1]+pre[k];
	per(k,sz-2,0) suf[k]=suf[k+1]+suf[k];
	g[u]=g[u]+node(x[u],gp(u));
	rep(i,0,sz-1){
		int v=sn[i].fi;
		g[v]=g[u];
		if(i-1>=0) g[v]=g[v]+pre[i-1];
		if(i+1<sz) g[v]=g[v]+suf[i+1];
		g[v]=g[v].ex(sn[i].se);
		dfs2(v,u);
	}
}

int main(){
	read(n);
	rep(i,1,n) read(x[i]);
	rep(i,1,n-1){
		read(a),read(b),read(c);
		e[a].pb(mp(b,c));
		e[b].pb(mp(a,c));
	}
	rep(i,1,n) pa[i]=i;
	for(con=n;con>=2;){
		dfs1(1,0);
		g[1]=node(inf,0);
		dfs2(1,0);
		rep(i,1,n) if(val[i]<val[gp(i)]){
			val[gp(i)]=val[i],cur[gp(i)]=cur[i];
		}
		rep(i,1,n) if(gp(i)==i&&gp(i)!=gp(cur[i])){
			ans+=val[i],pa[gp(i)]=gp(cur[i]),con--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  //数字を「dcba」と書いている＠以下の4行
  int a, b, c, d;
  a = N % 10;
  b = (N - a) / 10 % 10;
  c = (N - a - 10 * b) /100 % 10;
  d = (N - a - 10 * b - 100 * c) / 1000 % 10;
  
  cin >> a >> b >> c >> d;
  
  if ( a == b && b == c ) {
    cout << "Yes" << endl;
  }
  else if ( c == d && b == c) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = INT32_MAX;
const long long int Mod = 1000000007;
const long long int mod = 100000;//10^5
using ll = long long int; //long long int は64bit
using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using pii = pair<int,int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
//       cin.tie(0);ios::sync_with_stdio(false);
void cinit(){cin.tie(0);ios::sync_with_stdio(false);}
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////
ll cal(int x,int y,int x2,int y2){
	return max(0,abs(x-x2)+abs(y-y2));
}

ll ma[100][3]={0};
//x,y,h
int main(){
	ll n;cin>>n;int si = 0;
	rep(i,n){
		cin>>ma[i][0]>>ma[i][1]>>ma[i][2];
		if(ma[i][2]>0)si = i;
	}
	ll dif = 0;bool key = false;
	rep(i,101){
		rep(j,101){
			key = true;
			dif = cal(i,j,ma[si][0],ma[si][1])+ma[si][2];
			rep(k,n){
				if(ma[k][2]>0)if(dif!=cal(i,j,ma[k][0],ma[k][1])+ma[k][2]){
					key=false;
				}
				if(ma[k][2]==0)if(dif>cal(i,j,ma[k][0],ma[k][1])+ma[k][2]){
					key=false;
				}
			}
			if(key){
				cout<<i<<" "<<j<<" "<<dif<<endl;
				return 0;
			}
		}
	}
	return 0;
}

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

int main() {
  int a;
  int c5 = 0;
  int c7 = 0;
  for (int i=0;i<3;++i) {
    cin >> a;
    if (a == 5) c5++;
    if (a == 7) c7++;
  }
  cout << (c5 == 2 && c7 == 1 ? "YES" : "NO") << endl;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int W = l[0], a = l[1], b = l[2];
            var minA = a < b ? true : false;

            var ans = 0;
            if (minA)
                ans = b - (a + W);
            else
                ans = a - (b + W);

            Console.WriteLine(ans < 0 ? 0 : ans);
        }
    }
}


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

int main() {
  string S; cin>>S;
  bool ok=true;
  if (S[0]=='7') ok=false;
  if (S[1]=='7') ok=false;
  if (S[2]=='7') ok=false;
  if (ok) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
using namespace std;
int main() {
	string s[3];
	
	for (int i = 0; i < 3; i++)
	{
		cin >> s[i];
	}

	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			if(i==j)
				cout << s[i][j];
		}
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int area = a*b;
    int length = 2*a+2*b;
    System.out.println(area+" "+length);
        }
}


Measured memory_bytes: 26124
#include <iostream>
#include <queue>
#include <map>
#include <deque>
#include <algorithm>
#include <set>
#include <string>
#include <math.h>
#include <stdio.h>
#include<iomanip>



#define ll long long
using namespace std;

ll dp[100001];
vector<vector<ll>>adj;
ll dfs(ll node)
{
    if (dp[node] != -1)
        return dp[node];

    ll ans = 0;
    for (int i = 0; i < adj[node].size(); i++)
    {
        ans = max(dfs(adj[node][i]) + 1, ans);

    }
    return dp[node] = ans;
}

ll factorial(ll n)
{
    if (n == 1 || n == 0)
        return 1;

    return n * factorial(n - 1);
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    for (ll i = 0; i < 100001; i++) dp[i] = -1;
    ll n,m;
    cin >> n >> m;
    for (ll i = 0; i < n; i++)adj.push_back(vector<ll>(0));

    for (ll i = 0; i < m; i++)
    {
        ll x,y;
        cin >> x >> y;
        adj[x - 1].push_back(y - 1);
    }
    ll mx = 0;
    for (ll i = 0; i < n; i++)
    {
        mx = max(mx,dfs(i));

    }
    cout << mx;
    return 0;
}


Measured memory_bytes: 8688
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = (int)1e9 + 7, INF = (int)1e9;


int main(void) {
	ll n, k, i, ans, s1, s2;

	scanf("%lld%lld", &n, &k);

	ans = 0;
	for (i = k; i <= n + 1; i++) {
		s1 = i * (i - 1) / 2;
		s2 = n * (n + 1) / 2 - (n - i) * (n - i + 1) / 2;
		ans = (ans + (s2 - s1 + 1) % mod) % mod;
	}

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 3828
#include <iostream>

using namespace std;

int main()
{
    int a,b,x,c,o=0;//500.100.50
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
          for(int k=0;k<=c;k++)
    {
        if(i*500+j*100+k*50==x) o++;
    }
    cout<<o<<endl;
    return 0;
}


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

int main(){
	long long int n, k;
	cin >> n >> k;

	long long int array[100000];
	long long int count = 0;
	for(long long int i = 0; i < 100000; ++i) array[i] = 0;	
	for(long long int i = 0; i < n; ++i){
		long long int a, b;
		cin >> a >> b;
		array[a - 1] += b;
	}

	for(long long int i = 0; i < 100000; ++i){
		count += array[i];
		if(count >= k){
			cout << i + 1 << endl;
			break;
		}
	}

	return 0;
}
		

Measured memory_bytes: 1024
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    shortest = 4*10**8 + 5
    for j in range(m):
        distance = abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1])
        if distance < shortest:
            idx = j
            shortest = distance
    print(idx + 1)

Measured memory_bytes: 9128
#include <cstdio>

bool c[100000];

int main()
{
  int b[100000];
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
  {
    scanf("%d", b + i);
  }
  
  int ans = 1;
  for (int i = 0; !c[i]; i = b[i] - 1, ++ans)
  {
    c[i] = true;
    if (b[i] == 2)
    {
      printf("%d\n", ans);
      return 0;
    }
  }
  puts("-1");
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    string s;
    cin >> s;
    bool res = true;
    for (int i = s.size() - 1; i >= 0 && res == true; )
    {
        // cout << i << endl;
        string t;
        if (s[i] == 'm' || s[i] == 'e')
        {
            t = s.substr(i-4, 5);
            if (t != "dream" && t != "erase")
                res = false;
            i = i - 5;
        }
        else if (s[i] == 'r' && s[i-1] == 'e' && s[i-2] == 's')
        {
            t = s.substr(i-5, 6);
            if (t != "eraser")
                res = false;
            i = i - 6;
        }
        else if (s[i] == 'r' && s[i-1] == 'e' && s[i-2] == 'm')
        {
            t = s.substr(i-6, 7);
            if (t != "dreamer")
                res = false;
            i = i - 7;
        }
        else 
            res = false;
        // cout << t << endl;
    }
    cout << (res?"YES":"NO");
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  return res;
}

int count(ll n, vector<ll> vec) {
  int res = 0;
  for (int i = 0; i < vec.size(); ++i) {
    if (vec[i] == 1) continue;
    ll value = n, k = vec[i];
    while (k <= value) {
      if (value % k == 0) {
        value /= k;
      } else {
        value %= k;
      }
    }
    if (value == 1) res++;
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> d1 = divisor(n - 1);
  vector<ll> d2 = divisor(n);
  int ans = 0;
  ans += count(n, d1);
  ans += count(n, d2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    int64_t N, x;
    std::cin >> N >> x;

    std::vector<int64_t> A;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A.push_back(t);
    }

    std::sort(std::begin(A), std::end(A));

    int64_t ans = 0;
    for (size_t i = 0; i < A.size() - 1; ++i) {
        if (A[i] <= x) {
            ans++;
            x -= A[i];
        }
    }

    if (A[A.size()-1] == x) {
        ans++;
    }

    std::cout << ans << std::endl;

    return 0;
}


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

using namespace std;

int main()
{
    int n; cin>>n;
    double d; cin>>d;
    int cnt =0;
    while(n--)
    {   
        double x, y;
        cin>>x>>y;
        double dis = sqrt(x*x  + y*y);
        if(dis <= d)cnt++;
    }
    cout<<cnt<<endl;
    return 0;
    
}

Measured memory_bytes: 3808