akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map<int,int>
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define w(t) int t; cin>>t; while (t--)
#define out(x, y) cout << x << " " << y << endl
#define print(x) cout << x << endl
#define ps(x,y) fixed<<setprecision(y)<<x
#define pprint cout<<"Case #"<<tt<<": ";
const int mod = 1e9+7;
const int N = 2e5;
const int inf = 1e18;

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
bool compare (int x, int y) { return x > y;}

struct Compare {
    bool operator () (pii A, pii B) {
        return A.first > B.first;
    }
};
 struct tri{
   int x,y,z;
 };
 struct cmp{
bool operator ()(tri a,tri b){
    if(a.x==b.x)
        return a.y>b.y;
    return a.x<b.x;

}};
bool comp(pii a,pii b){
    if(a.first>b.first) return true;
    else if(a.first==b.first) return a.second<b.second;
    else return false;

}
int binarySearch(vector<int>nums, int lo, int hi, int target) {
        while (lo < hi) {
            int mid = (lo + hi)/2;
            if (nums[mid] <= target) {
                lo = mid + 1;
            } else {
                hi = mid;
            }
        }
        return lo;
    }
void solve() {

    int t = 1;
    //cin >> t;
   while(t--){
        int i,n,k;
     cin>>n>>k;
   vector<int>v(n);
     for(i=0;i<n;i++){
        cin>>v[i];
     }
     int l=0;
     for(i=k;i<n;i++){
        if(v[l]<v[i])
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
        l++;
     }
    }
}

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

   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/

    solve();

    return 0;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  int ab[M][2];
  int road[N];
  for(int i = 0; i < N; i++) road[i] =0;
  
  for(int i = 0; i < M; i++){
    cin >> ab[i][0] >> ab[i][1];
    for(int j = 0;j<N;j++){
      if(ab[i][0] == j+1) road[j]++;
      if(ab[i][1] == j+1) road[j]++;
    }
  }
  
  for(int i = 0; i < N; i++) cout << road[i] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int w, h, x, y, r;
	int t;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

	if( (0 <= x-r) && (x+r <= w) && (0 <= y-r) && (y+r <= h) ) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 1012
r = gets.chomp.to_i

array = []

r.times do
  array << gets.chop.to_i
end

minv = array[0]
maxv = array[1] - array[0]

array.each_with_index do |num, i|
  next if i.zero?
  maxv = [maxv, array[i] - minv].max
  minv = [minv, array[i]].min
end

puts maxv

Measured memory_bytes: 10540
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
    
int main(){
  int n,x,m[1001];
  cin >> n >> x;
  int S=0, M = 1001001001;
  rep(i,n) {
    cin >> m[i];
    S += m[i];
    if(m[i] < M) M = m[i];
  }  
  cout << n+(x-S)/M << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int n, a = 0;
	cin >> n;
	int p[n] = {};
	for(int i = 0; i < n; i++){
		cin >> p[i];
	}
	for(int i = 1; i < n - 1; i++){
		if((p[i] > p[i - 1] && p[i] < p[i + 1]) || p[i] < p[i - 1] && p[i] > p[i + 1]){
			a++;
		}
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))+[0]
ans=0
a_p=N+1

for a in A:
    ans+=B[a-1]+C[a-2]*(a-a_p==1)
    a_p=a
print(ans)

Measured memory_bytes: 9172
def g(A,l,m,r):
 global c
 L,R=A[l:m]+[1e9],A[m:r]+[1e9]
 i=j=0
 for k in range(l,r):
  if L[i]<R[j]:A[k]=L[i];i+=1;c+=j
  else:A[k]=R[j];j+=1
def s(A,l,r):
 if l+1<r:m=(l+r)//2;s(A,l,m);s(A,m,r);g(A,l,m,r)
if'__main__'==__name__:
 c=0
 n=int(input())
 A=list(map(int,input().split()))
 s(A,0,n)
 print(c)


Measured memory_bytes: 27488
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

ll N;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    solve();
}

// 1 <= N <= 10^9
// N は整数である

// ll N
// N 以下の平方数のうち、最大のものを出力せよ。
void solve(){
    ll ans=1;
    while((ans+1)*(ans+1)<=N)++ans;
    cout<<ans*ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
	char a[100],b[100];
	int i,na,nb;
	scanf("%s",a);
	na=strlen(a);
	scanf("%s",b);
	nb=strlen(b);
	
	if(na+1!=nb){
		printf("No\n");
	}else{
		for(i=0;i<na;i++){
			if(a[i]!=b[i]){
				printf("No\n");
				break;
			}
		}
		if(i==na){
			printf("Yes\n");
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 1664
from collections import deque

def bfs():
    # たどり着くまでにかかった回数をいれる多重リスト。
    d = [[float("inf")] * w for i in range(h)]
    # 1ノード降りるときにforで回せるようリスト化しておく
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    # 接したポイントを取り込む用のqueを定義
    que = deque([])
    # スタート地点をqueに加える。探索の際はqueから取り出すループを回すので最初だけ先に入れておく
    que.append((sx,sy))
    # スタートからスタートにかかる距離は0なのでinfを0にかえる。
    d[sx][sy] = 0
    # queがあるかぎり続ける
    while que:
        p = que.popleft()
        # 取り出した点がゴールなら終了
        if p[0] == gy and p[1] == gx:
            break
        #　それ以外の時は，接している点を4方向順に取得。一つずつ処理する。
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            # 新しく取得した座標に対しての処理
            # 迷路内に存在する座標であり，壁ではなく，まだ通ったことがなくdがinfの点なら処理する = 新しく取得した道候補の1つ
            if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] != "#" and d[nx][ny] == float("inf"):
                # 道候補をqueに加える。
                que.append((nx, ny))
                # その道候補への経路までにかかった経路をdに加える。
                d[nx][ny] = d[p[0]][p[1]] + 1
    return d[gx][gy]

h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]
sx, sy = 0, 0
gx, gy = h - 1, w - 1

white = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == ".":
            white += 1

res = bfs()
if 0 < res < float("inf"):
    # 白いマスの数から最短経路でかかるコスト分を引く
    # ゴールを黒いマスに変えることはできないためその分も引く
    print(white - res - 1)
else:
    print(-1)


Measured memory_bytes: 9428
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1000000007))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi; 

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1000000007))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi; 





int32_t main()
{
	IOS
	int n;cin>>n;
	multiset<int>s;
	vi a(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];s.insert(a[i]);
	}
	for(int i=0;i<n;i++)
	{
		s.erase(s.find(a[i]));
		cout<<*s.rbegin()<<endl;
		s.insert(a[i]);
	}
	cout<<endl;
	
	
	
}


Measured memory_bytes: 12544
#include <iostream>
using namespace std;
typedef long long ll;

ll N;
int main(){
	cin >> N;
	ll ans = 1e9;
	for(ll i=1;i*i<=N;i++){
		if(N%i!=0) continue;
		ll s = i,t = N/i,count = 0;
		while(s>0 || t>0){
			count++;
			s /= 10;
			t /= 10;
		}
		ans = min(ans,count);
	}
	cout << ans << endl;
}

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

namespace abc107_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = Convert.ToInt32(input[0]);
            int i = Convert.ToInt32(input[1]);
            Console.WriteLine(N - i + 1);
            Console.Read();
        }
    }
}


Measured memory_bytes: 11220
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
    	
    	
    	Scanner sc = new Scanner(System.in);
    	
    		
    		int p[] = new int[4];
    		for(int i = 0; i<3; i++){
    			int extract1 = sc.nextInt()-1;
    			int extract2 = sc.nextInt()-1;
    			p[extract1]++;
    			p[extract2]++;
    			
    			
    		}
    		int twice =0;
    		int thrad = 0;
    		int one =0;
    		
    		boolean zero = false;
    		for(int c=0; c<4; c++) {
    			if(p[c]==0) {zero=true;	break;}
    			if(p[c]==1) one+=1;
    			if(p[c]==2) twice +=1;
    			if(p[c]==3) thrad+=1;
    			
    			
    		}
    		
    			if(zero==true) {
    				System.out.println("NO");
    			}else {
    				if(twice==2&&one==2)System.out.println("YES");
    				else if(thrad==1&&one==3)System.out.println("NO");
    				else System.out.println("NO");
    			}
    			
    		}
    		
    		
    		
    		
    	
    		
    		}
    

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    int lr = 0;
    int rl = 0;
    int res = 0;
    for (int i = 0; i < n; ++i) {
        if (i < n-1) {
            if (s[i] == 'L' && s[i+1] == 'R') lr++;
            if (s[i] == 'R' && s[i+1] == 'L') rl++;
        }
        if (i > 0 && s[i] == 'L') {
            if (s[i-1] == 'L') res++;
        }
        if (i < n-1 && s[i] == 'R') {
            if (s[i+1] == 'R') res++;
        }
    }

    for (int i = 0; i < k; ++i) {
        if (lr > 0 && rl > 0) {
            res += 2;
            lr--; rl--;
        } else if (lr > 0) {
            res += 1;
            lr--;
        } else if (rl > 0) {
            res += 1;
            rl--;
        } else {
            break;
        }
    }
    cout << res << endl;
}

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

int main()
{
ll H , W , h , w ;
cin >> H >> W >> h >> w ;
if(H%h==0&&W%w==0){
  cout << "No" << endl;
  return 0;
}
cout << "Yes" << endl;
if(W%w!=0){
  rep(i,H){
    rep(j,W){
      if((j+1)%w)cout << 100000 << " ";
      else cout << -100000*(w-1)-1 << " ";
    }
    cout << endl;
  } 
}
else{
  rep(i,H){
    rep(j,W){
      if((i+1)%h)cout << 100000 << " ";
      else cout << -100000*(h-1)-1 << " ";
    }
    cout << endl;
  } 
}
}

Measured memory_bytes: 2048
N,A,B = map(int,input().split())
S = input()

a,b = 0,0
for c in S:
    if c=='c':
        print('No')
    elif c=='a':
        if a<A+B:
            print('Yes')
            a += 1
        else:
            print('No')
    else:
        if a<A+B and b<B:
            print('Yes')
            a += 1
            b += 1
        else:
            print('No')

Measured memory_bytes: 4016
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long int ull;
#define base 31
#define MOD 1000000007
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORs(i, a, b) for(int i = a; i >= b; i--)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define __FOR(i, a, b, k) for(int i = a; i <= b; i+= k)
#define __REP(i, a, b, k) for(int i = a; i < b; i+= k)
#define pb push_back
#define _io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define Read_ freopen("input.inp", "r", stdin)
#define Write_ freopen("output.out", "w", stdout);
using namespace std;
typedef pair <int, int> ii;
typedef vector <ii> vii;
#define fi first
#define se second
#define mp make_pair
#define N  200005
ull n,a[N],sum[N];
ull res;
int main(){
    _io; 
    cin>>n;
    FOR(i,1,n) cin>>a[i];
    sum[1]=a[1];
    FOR(i,2,n) sum[i]=sum[i-1]+a[i];
    //FOR(i,1,n) cout<<sum[i]<<" ";
    res=0;
    ull mod=1000000007;
    FOR(i,1,n){
        ull x=((a[i]%mod)*((sum[n]-sum[i])%mod))%mod;
        res+=(x%(mod));
    }
    cout<<res%mod;
}




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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
template<long long Mod = mod>
constexpr long long MOD(long long in) {
    return in % Mod;
}

int n, k;
ll v[55];
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> n >> k;

    for (int i = 0; i < n; ++i)
        std::cin >> v[i];

    auto m = std::min(n, k);
    ll ans = 0;
    for (int l = 0; l <= m; ++l)
        for (int r = 0; l + r <= m; ++r) {
            std::vector<ll> vals(l + r);
            ll res = 0;
            for (int i = 0; i < l; ++i) {
                res += v[i];
                vals[i] = v[i];
            }

            for (int i = 0; i < r; ++i) {
                res += v[n - i - 1];
                vals[l + i] = v[n - i - 1];
            }

            std::sort(vals.begin(), vals.end());
            for (int i = 0, end = std::min<int>(vals.size(), k - (l + r)); i < end; ++i) {
                if (vals[i] >= 0)
                    break;
                res -= vals[i];
            }

            ans = std::max(ans, res);
        }

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

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  long long int n,i,k;
  cin>>n>>k;
  long long int ar[n],temp1=1,temp2=1;
  for(i=0;i<n;i++)
    cin>>ar[i];
  for(i=k;i<n;i++)
  {
    if(ar[i]>ar[i-k])
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
    temp1=temp2;
  }
  return 0;
}  

      
  

Measured memory_bytes: 4640
#include <iostream>

using namespace std;

int n,A[20];

int select(int i, int m)
{
  if(m == 0){
    return 1;
  }
  if(i >= n){
    return 0;
  }
  int res = select(i + 1, m - A[i]) || select(i + 1, m);
  return res;
}

int main(void)
{
  int i, q, m[200];

  cin >> n;

  for(i = 0;i < n;i++){
    cin >> A[i];
  }

  cin >> q;

  for(i = 0;i < q;i++){
    cin >> m[i];
  }

  for(i = 0;i < q;i++){
    if(select(0, m[i])){
      cout << "yes" << endl;
    }
    else{
      cout << "no" << endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 3124
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, T int
	fmt.Scan(&N, &T)

	var ansC = math.MaxInt32
	var ansT = math.MaxInt32

	for i := 0; i < N; i++ {
		var c, t int
		fmt.Scan(&c, &t)
		if t <= T && c < ansC {
			ansC = c
			ansT = t
		}
	}
	if ansT > T {
		fmt.Println("TLE")
	} else {
		fmt.Println(ansC)
	}
}


Measured memory_bytes: 512
n, k = map(int, input().split())
p = list(map(lambda x : int(x) - 1, input().split()))
c = list(map(int, input().split()))
score = [0] * (n + 1)

max_score = -10 ** 9
for i in range(n):
    x = i
    temp_max = [-10 ** 9] * (n + 1)
    for j in range(1, n + 1):
        score[j] = score[j - 1] + c[p[x]]
        temp_max[j] = max(temp_max[j-1], score[j])
        x = p[x]
        if x == i:
            break
    if j >= k:
        max_score = max(max_score, temp_max[k])
    elif score[j] < 0:
        max_score = max(max_score, temp_max[j])
    else:
        m = k // j
        a = score[j] * (m - 1) + temp_max[j]
        b = score[j] * m + temp_max[k % j]
        max_score = max(max_score, a, b)
print(max_score)



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

int main(){
int n;
cin >> n;
int b;
int c;
int d;
int e;
int f;
int g;
int a;
a=0;
while(a<n){
cin >> b;
cin >> c;
cin >> d;
e=b*b;
f=c*c;
g=d*d;
if(e==f+g){cout <<"YES"<<endl;}
else if(f==e+g){cout <<"YES"<<endl;}
else if(g==f+e){cout <<"YES"<<endl;}
else{cout <<"NO"<<endl;}
a=a+1;}
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		if (int(1.08 * i) == n) {
			printf("%d\n", i);
			return 0;
		}
	}
	printf(":(\n");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N = 100015;
struct node{
	int t,x,y;
} no[N];
int main(){
	int n;
	scanf("%d",&n);
	int mark=1;
	for(int i=0;i<n;i++){
		long long t,x,y;
		scanf("%d %d %d",&t,&x,&y);
		if(x+y>t)
		    mark=0;
		else if(x+y<t){
			if(abs(t-x-y)%2!=0)
			    mark=0;
		}
			
	}
	if(mark)
	    printf("Yes\n");
	else
	    printf("No\n");
	return 0;
}

Measured memory_bytes: 256
x,y,z,k=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
ab=[i+j for i in a for j in b]
ab.sort(key=lambda x: -x)
c.sort(key=lambda x: -x)
ans=[]
ct=[0]
ansc=[ab[0]+c[0]]
while (len(ans)<k):
    if(ct[-1]!=0 and len(ct)<z):
        ansc+=[ab[0]+c[len(ct)]]
        ct+=[0]
    ans+=[max(ansc)]
    tmp=ansc.index(max(ansc))
    if(ct[tmp]==len(ab)-1):
        ansc[tmp]=0
    else:
        ct[tmp]+=1
        ansc[tmp]=ab[ct[tmp]]+c[tmp]
for i in ans:
    print(i)

Measured memory_bytes: 99780
import sys
input = sys.stdin.buffer.readline

MOD = 10 ** 9 + 7
INF = 2 * 10**18

in_n = lambda: int(input())
in_nn = lambda: map(int, input().split())
in_s = lambda: input().rstrip().decode('utf-8')
in_map = lambda: [s == ord('.') for s in input() if s != ord('\n')]


# 1点更新・区間クエリ（0-index）
class SegTree:

    def __init__(self, init_val, segfunc, ide_ele):

        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num

        for i in range(n):
            self.tree[self.num + i] = init_val[i]

        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):

        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):

        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

    def get(self, k):
        k += self.num
        return self.tree[k]


def main():

    M = 3 * 10**5 + 10
    N, K = in_nn()
    A = [0] * N

    for i in range(N):
        A[i] = in_n()

    seg = SegTree([0] * M, segfunc=lambda a, b: max(a, b), ide_ele=0)

    for i in range(N):
        now = A[i]
        left = max(0, now - K)
        right = min(now + K + 1, M)
        u = seg.query(left, right)
        seg.update(now, u + 1)

    ans = seg.query(0, M)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 81704
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
N = int(input())
H = list(map(int, input().split()))
dp = [float('INF')] * (10**5+10)
dp[0] = 0
for i in range(1, N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(H[i] - H[i-1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i-2] + abs(H[i] - H[i-2]))
print(dp[N-1])


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

int main(){
    int n,m;
    while(true){
    cin >>n>>m;
    if(n==0){
    	break;
    }
   
    int p[n];
    for(int i=0;i<n;i++){
        cin >>p[i];
    }
    
    
    sort(p,p+n);
    int mon=0;
    for(int i=0;i<n;i++){
        mon += p[i];
    }
    int wari = 0;
    int t=n-m;
    while(t>=0){
        wari += p[t];
        t -= m;
    }
    
    cout <<mon-wari<<endl;
    continue;
    
    }
return 0;
}

Measured memory_bytes: 3104
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"
 


int main() {
	while (1) {
		int H, W; cin >> H >> W;
		if (!H)break;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if ((i + j) % 2)cout << '.';
				else cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    string S; cin >> S;
    const string A = "CODEFESTIVAL2016";
    int ans = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] != A[i]) ans++;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int r = scan.nextInt();
        int D = scan.nextInt();
        int x = scan.nextInt();

        int[] ans = new int[10];
        for (int i = 1; i < 11; i++) {
            ans[i - 1] = r * x - D;
            x = ans[i - 1];
        }
        for (int j = 0; j < ans.length; j++) {
            System.out.println(ans[j]);
        }
    }
}


Measured memory_bytes: 23124
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
    int N;
    cin>>N;
    vector<pair<int, int> > red(N), blue(N);
    int a, b;
    rep(i, N){
        cin>>a>>b;
        red[i] = mp(a, b);
    }
    rep(i, N){
        cin>>a>>b;
        blue[i] = mp(a, b);
    }
    sort(red.begin(), red.end(), greater<pair<int, int> >());
    map<int, int> amap;
    int index;
    int tmp;
    int ans = 0;
    for(int i=0;i<N;++i){
        index = -1;
        tmp = -1;
        for(int j=0;j<N;++j){
            if((red[i].fi<blue[j].fi) && (red[i].se<blue[j].se)){
                if(((index==-1) || (tmp > blue[j].se)) && (amap[j]==0)){
                    index = j;
                    tmp = blue[j].se;
                }
            }
        }
        if(index != -1){
            amap[index]++;
            ans++;
        }
    }
    cout<<ans<<endl;
}



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


const int MAXN = 1005;

int main() {
  int n,x,y;
  cin>>n>>x>>y;
  x--;y--;
  vector<vector<int>> d(n, vector<int> (n,0));
  //左がxより前
  for (int i=0;i<=x;i++){
    for (int j=i+1;j<n;j++){
      if (j<=(y+x)/2){
        d[i][j]=j-i;
        d[j][i]=j-i;
      }
      else if (j<=y){
        d[i][j]=x-i+y-j+1;
        d[j][i]=x-i+y-j+1;
      }
      else{
        d[i][j]=j-i-(y-x-1);
        d[j][i]=j-i-(y-x-1);
      }
    }
  }
  //右がyより後ろ
  for(int i=n-1;i>=y;i--){
    for (int j=i-1;j>x;j--){
      if (j>=(x+y)/2){
      d[i][j]=i-j;
      d[j][i]=i-j;
    }
    else{
      d[i][j]=i-y+j-x+1;
      d[j][i]=i-y+j-x+1;
    }
  }
}

//ループ内
for(int i=x+1;i<y;i++){
  for(int j=i+1;j<y;j++){
    d[i][j]=min(j-i,i-x+y-j+1);
    d[j][i]=min(j-i,i-x+y-j+1);
  }
}
vector<int>ans(n,0);




rep(i,n-1){
  for (int j=i+1;j<n;j++){
  //  cout<<d[i][j]<<endl;
    ans[d[i][j]]+=1;
  }
}
for (int i=1;i<n;i++){
  cout<<ans[i]<<endl;
}

}


Measured memory_bytes: 16000
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;
int main()
{
    int n, t;
    cin >> n >> t;
    vector<int> a(n), b(n),c(n);
    int dis = 0;
    set<int> large, small;
    rep(i, n) cin >> a[i];
    int me = M;
    rep(i, n)
    {
        me = min(me, a[i]);
        b[i] = me;
    }
    int ma=0;
    rep(i,n){
        int ite=n-i-1;
        ma=max(ma,a[ite]);
        c[ite]=ma;
    }
    rep(i, n)
    {
        int l=c[i];
        int tmp=l-a[i];
        if (dis < tmp)
        {
            dis = tmp;
            large.clear();
            large.insert(l);
        }
        else if (dis == tmp)
        {
            large.insert(l);
        }
        
    }
   /* rep(i, n)
    {
        int tmp = a[i]-b[i];
        //cout<<tmp<<endl;
        if (dis < tmp)
        {
            dis=tmp;
            small.clear();
            small.insert(b[i]);
        }else if(dis==tmp){
            small.insert(b[i]);
        }
    }*/
    cout << large.size() << endl;
}


Measured memory_bytes: 3712
import sys
a = input()

for bit in range(2**3):
    x = a[0]
    for i in range(3):
        if ((bit>>i) & 1):
            x += "+"
        else:
            x += "-"
        x += a[i+1]
    if eval(x) == 7:
        print(str(x)+"=7")
        sys.exit()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n;
  cin>>n;
  vector<long long int> a;
  set<long long int> s;
  map<long long int,long long int> alr;
  for(long long int i=0; i<n; i++){
    long long int hoge;
    cin>>hoge;
    long long int ssize=s.size();
    s.insert(hoge);
    if(ssize!=s.size()){
      a.push_back(hoge);
    }else{
      alr[hoge]++;
    }
  }
  sort(a.begin(),a.end());
  map<long long int,bool> dp;
  long long int ans=0;
  for(long long int i=0; i<a.size(); i++){
    if(dp.count(a.at(i))){
      continue;
    }

    long long int j=a.at(i);
    long long int x=1;
    while(j*x<=a.at(a.size()-1)){
      dp[j*x]=true;
      x++;
    }
    if(alr.count(a.at(i))==false) ans++;
  }
  cout<<ans<<endl;
}

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

int main()
{
	int i,j,n,u,k,a;
	int v[100][100];
	cin >> n;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			v[i][j]=0;
		}
	}
	for(i=0;i<n;i++){
		cin >> u;
		cin >> k;
		for(j=0;j<k;j++){
			cin >>a;
			v[u-1][a-1]=1;
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			cout << v[i][j];
			if (j!=n-1) cout << " ";
		}
		cout<<endl;
	}
}

Measured memory_bytes: 3120
import java.util.*;

public class Main {
    static long ans = Long.MAX_VALUE;
    static long[][] graph;
    static int[] sopas;
    static int n,m,r;
    static final long ifty = Long.MAX_VALUE;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        r = in.nextInt();
        sopas = new int[r];
        for( int i = 0; i < r; i++ ) sopas[i] = in.nextInt()-1;
        graph = new long[201][201];
        for( int i = 0; i < 201; i++ ) 
            for( int j = 0; j < 201; j++ ) 
                if( i != j ) graph[i][j] = ifty;
        for( int i = 0; i < m; i++ ) {
            int u = in.nextInt()-1;
            int v = in.nextInt()-1;
            graph[u][v] = graph[v][u] = in.nextLong();
        }
        // fw -> get all pairs of shortest paths
        for( int k = 0; k < n; k++ ) {
            for( int i = 0; i < n; i++ ) {
                for( int j = 0; j < n; j++ ) {
                    if( graph[i][k] == ifty || graph[k][j] == ifty ) continue;
                    graph[i][j] = Math.min(graph[i][j], graph[i][k]+graph[k][j]);
                }
            }
        }
        for( int i = 0; i < r; i++ ) {
            boolean[] done = new boolean[r];
            done[i] = true;
            permutate( 1, i, done, 0 );    
        }
        System.out.println(ans);
        // System.out.println(Arrays.deepToString(graph));
    }

    static void permutate( int level, int previous, boolean[] done, long distance ) {
        if( level == r ) {
            ans = Math.min(ans, distance);
            return;
        }
        // for values that have not been passed
        for( int i = 0; i < r; i++ ) { 
            if( !done[i] ) {
                done[i] = true;
                int u = sopas[previous];
                int v = sopas[i];
                permutate( level+1, i, done, distance + graph[u][v] );
                done[i] = false;
            }
        }
    }

}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back


void bfs(mat G, ll s, vec& C)
{
    ll N = SZ(G);
    vector<ll> D(N, -1);
    queue<ll> Q;
    D[s] = 0;
    Q.push(s);
    
    while(!Q.empty()) {
        ll v = Q.front(); Q.pop();
        FORR(nv,G[v]) {
            if(D[nv] == -1) {
                D[nv] = D[v] + 1;
                Q.push(nv);
            }
        }
    }

    REP(i,0,N) ++C[D[i]];

}


int main()
{
    ll N, X, Y;
    cin >> N >> X >> Y;
    mat G(N);
    REP(i,0,N-1) {
        G[i].pb(i+1);
        G[i+1].pb(i);
    }
    --X; --Y;
    G[X].pb(Y);
    G[Y].pb(X);

    vec D(N, 0);
    REP(i,0,N) {
        vec C(N, 0);
        bfs(G, i, C);
        REP(j,0,N) D[j] += C[j];
    }

    REP(i,1,N) PR(D[i]/2);   

    return 0;
}

/*



*/

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int kou,sou=114514,H,W;
int main(){
    cin>>H>>W;
    char HW[H][W];
    for(int i=0;i<H;i++){ for(int o=0;o<W;o++){ scanf(" %c",&HW[i][o]); }}
    for(int i=1;i<H-1;i++){
        for(int j=1;j<H-i;j++){
	    kou=0;
            for(int o=0;o<i;  o++){ for(int f=0;f<W;f++){ if(HW[o][f]!='W'){kou++;} } }
            for(int o=i;o<i+j;o++){ for(int f=0;f<W;f++){ if(HW[o][f]!='B'){kou++;} } }
            for(int o=i+j;o<H;o++){ for(int f=0;f<W;f++){ if(HW[o][f]!='R'){kou++;} } }
            sou=min(sou,kou);
        }
    }
    cout<<sou<<endl;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll cs,ct,ans;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='S')cs++;
    else{
      if(cs){
        ans+=2;
        cs--;
      }
    }
  }
  cout<<s.size()-ans<<endl;
  return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;
const int INT_INF = 1e9;
long long gcd(long long x, long long y) {
	long long m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}


char A[100][100], B[100][100];
int N, M;
bool check(int x, int y) {
	REP(i, M) {
		REP(j, M) {
			if (A[i + x][j + y] != B[i][j])return false;
		}
	}
	return true;
}
void solve() {
	int x = 0;
	int N; cin >> N;
	string S; cin >> S;
	int mx = 0;
	REP(i, N) {
		if (S[i] == 'I')x++;
		else x--;
		mx = max(mx, x);
	}
	print(mx);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




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

int fact(int n) {
	if(n < 1)
		return 1;
	return n*fact(n - 1);
}
int abs(int n) {
	if(n < 0)
		return -1*n;
	return n;
}

int getorder(int n, int *a) {
	int i, j;
	int order = 0;
	for(i = 0; i < n; i++) {
		int count = 0;
		for(j = 0; j < i; j++)
			if(*(a + j) < *(a + i))
				count++;
		order += (*(a + i) - count)*fact(n - i - 1);
	}
	return order;
}

int main(void) {
	int n, i;
	scanf("%d", &n);
	int *p = malloc(sizeof(int)*n);
	int *q = malloc(sizeof(int)*n);
	for(i = 0; i < n; i++)
		scanf("%d", p + i);
	for(i = 0; i < n; i++)
		scanf("%d", q + i);
	printf("%d\n", abs(getorder(n, p) - getorder(n, q)));
	free(p);
	free(q);
	return 0;
}

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

int n = 0, id = 0, k = 0;
vector<int> d, p;

int depth(int id) {
	if (p[id] == -1)
		return 0;
	else if (d[p[id]] != -1)
		return d[p[id]] + 1;
	else
		return depth(p[id]) + 1;
}

int main()
{	
	cin >> n;

	vector<vector<int>> c(n);

	for (int i = 0; i < n; i++) {
		p.push_back(-1);
		d.push_back(-1);
	}

	for (int i = 0; i < n; i++) {
		cin >> id >> k;

		for (int j = 0; j < k; j++) {
			int ct = 0;
			cin >> ct;
			c[id].push_back(ct);
			p[ct] = id;
		}
	}

	for (int i = 0; i < n; i++) {
		d[i] = depth(i);
	}

	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " 
			 << p[i] << ", depth = " << d[i] << ", ";

		if (p[i] == -1)
			cout << "root, ";
		else if (c[i].size() == 0)
			cout << "leaf, ";
		else
			cout << "internal node, ";

		cout << "[";
		if (c[i].size() > 1) {
			for (unsigned int j = 0; j < c[i].size() - 1; j++)
				cout << c[i][j] << ", ";
		}
		if (c[i].size() >= 1)
			cout << c[i][c[i].size() - 1];

		cout << "]" << endl;
	}

	return 0;
}

Measured memory_bytes: 6784
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll beki[10] = {1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000};

int main(){
  string S;
  cin >> S;
  int N = S.size();
  int num[N];
  for(int i=0;i<N;i++){
    num[i] = S[i] - '0';
  }

  ll ans = 0LL;
  for(int i=0;i<(1 << (N-1));i++){
    bool ext[N-1];
    fill(ext,ext+N-1,false);
    int itmp = i;
    for(int j=0;j<N-1;j++){
      if(itmp%2==1) ext[j] = true;
      itmp/=2;
    }

    int state[N];
    state[N-1] = 0;
    for(int j=N-2;j>=0;j--){
      if(ext[j]) state[j] = 0;
      else state[j] = state[j+1] + 1;
    }

    for(int j=0;j<N;j++){
      ans += num[j] * beki[state[j]];
    }
  }


  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, q = map(int, input().split())

    tree = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = map(int, input().split())
        tree[a - 1].append(b - 1)
        tree[b - 1].append(a - 1)

    cnt = [0] * n
    for _ in range(q):
        p, x = map(int, input().split())
        cnt[p - 1] += x

    def dfs(v, p):
        for u in tree[v]:
            if u == p:
                continue
            cnt[u] += cnt[v]
            dfs(u, v)

    dfs(0, -1)
    print(*cnt)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 268464
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
    int n, h;
    cin >> n >> h;
    int ct = 0;
    for (int i = 1; i<=n; i++)
    {
        int x;
        cin >> x;
        if (x >= h)
            ct++;
    }
    cout << ct;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<vector> //動的配列
#include<string> 
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>


//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

typedef long long ll;


using namespace std;

typedef pair<int, int> P;


ll fast_pow(ll x,ll n,ll mod){
    if (n==0) return 1;
    ll res=fast_pow(x*x %mod,n/2,mod);
    if (n&1) res=res*x%mod;
    return res;
}

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int a,b,c,n;

int main(){
    int cnt=0;
    cin>>a>>b>>c>>n;
    for(int i=0;i<=(n/a);i++){
        for (int j=0;j<=(n/b);j++){
            //cout<<i<<j<<endl;
            if (a*i+b*j<=n && (n-(a*i+b*j))%c==0) cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
n, x, m = map(int, input().split())

arr = [x]
s = set()
s.add(x)
h = -1
r = 0
for i in range(n - 1):
	val = arr[-1]**2 % m
	if val not in s:
		arr += [arr[-1]**2 % m]
		s.add(arr[-1])
	else:
		h = i
		r = val
		break


res = sum(arr)
if h != -1:
	new_arr = arr[arr.index(r):]
	rest = n - (h + 1)
	c = len(new_arr)
	q = rest // c
	ssum = sum(new_arr) * q
	r = rest % c
	for i in range(r):
		ssum += new_arr[i]
	res += ssum	
	
print(res)

Measured memory_bytes: 13076
#include<stdio.h>

int main(void){

  int i,n;

  long int a,min = 1000000,max = -1000000,sum = 0;

  scanf("%d",&n);

  for(i = 1;i <= n;i++)

  {

    scanf("%ld",&a);

    if(a < min)

      min = a;

    if(a > max)

      max = a;

    sum += a;

  }

  printf("%ld %ld %ld\n",min,max,sum);

  return 0;

}

 

Measured memory_bytes: 600
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define int long long
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define deb(x) cout<<#x<<" "<<x<<endl;
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 2e6 + 7;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    void solve()
    {
        cin>>n>>k;
        cout<<(n+k-1)/k<<endl;;

    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //

    int32_t main() 
      {
        
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        
        // cin>>t;while(t--)
        solve();
        
      return 0;
      }

Measured memory_bytes: 256
K=int(input())
def gcd(a,b):
    res=0
    while b!=0:
        res=a%b
        a=b
        b=res
    return a

ans=0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            t=gcd(i,gcd(j,k))
            ans+=t
print(ans)

Measured memory_bytes: 68476
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<array>
using namespace std;
int main(){
int A;
int B;
cin>>A>>B;
if(A*B%2==0){
  cout<<"Even"<<endl;
}else{
  cout<<"Odd"<<endl;
}




















}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a; string b; cin>>a>>b;
  long long c=(b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0');
  cout<<(long long)(a*c)/100<<endl;
return 0;
}

Measured memory_bytes: 3636
A, B, C = map(int, input().split())

ans1 = (A * B * (C-C//2)) - (A * B * (C//2))
ans2 = (A * C * (B-B//2)) - (A * C * (B//2))
ans3 = (B * C * (A-A//2)) - (B * C * (A//2))
print(min(ans1, ans2, ans3))


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cstdio>
using namespace std;


int main() {
    int cube[6][6] = {{0, 3, 5, 2, 4, 0},
                      {4, 0, 1, 6, 0, 3},
                      {2, 6, 0, 0, 1, 5},
                      {5, 1, 0, 0, 6, 2},
                      {3, 0, 6, 1, 0, 4},
                      {0, 4, 2, 5, 3, 0}};
    
    int p[6] = {1, 2, 3, 4 , 5 ,6 };

    int n[6], m[6];
    for(int i = 0; i < 6; i++){
        cin >> n[i];
        if(n[i] >= 10){
            n[i]/=10;
        }
    }
    for(int i = 0; i < 6; i++){
        cin >> m[i];
        if(m[i]>=10){
            m[i]/=10;
        }
    }

    vector<int> v1;
    vector<int> v2;
    int c1[6][6];
    int c2[6][6];

    for(int i = 0; i < 6; i++){
        for(int j = 0; j < 6; j++){
            c1[i][j] = 0;
            c2[i][j] = 0;
        }
    }

    for(int i = 0; i < 6; i++){
        for(int j = 0; j < 6; j++){
            int v1n = cube[i][j]-1;
            int v2n = cube[i][j]-1;
            if(v1n != -1){
                //v1.push_back(p[v1n]);
                c1[n[i]-1][n[j]-1] = n[v1n];
            }
            
            if(v2n != -1){
                //v2.push_back(p[v2n]);
                c2[m[i]-1][m[j]-1] = m[v2n];
            }
            
            //cout << v1n <<" " << v2n << endl;
        }
    }
/*
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());

    if(v1.size() != v2.size()){
        cout << "No" << endl;
        return 0;
    }
    //cout << v1.size() << endl;
    for(int i = 0; i < v1.size(); i++){
        if(v1[i] != v2[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
*/  
/*
    for(int i = 0; i < 6; i++){
        for(int j = 0; j < 6; j++){
            cout << c1[i][j] << " ";
        }
        cout << endl;
    }
    for(int i = 0; i < 6; i++){
        for(int j = 0; j < 6; j++){
            cout << c2[i][j]<< " ";
        }
        cout << endl;
    }
    */
    for(int i = 0; i < 6; i++){
        for(int j = 0; j < 6; j++){
            if(c1[i][j] != c2[i][j]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

    
}


Measured memory_bytes: 3116
#include<iostream>
#define MAX 105
using namespace std;

int main(){
  int h, w;
  char a[MAX][MAX];
  cin >> h >> w;
  bool hb[h], wb[w];
  for(int i = 0; i < w; i++) wb[i] = false;
  for(int i = 0; i < h; i++){
    hb[i] = false;
    for(int j = 0; j < w; j++){
      cin >> a[i][j];
      if(a[i][j] == '#'){
        hb[i] = true;
        wb[j] = true;
      }
    }
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(hb[i] && wb[j]){
        cout << a[i][j];
      }
    }
    if(hb[i]){
      cout << endl;
    }
  }
}



Measured memory_bytes: 256