akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <queue>//引入队列
using namespace std;

const int SIZE = 50 + 10;//数据规模
char board[SIZE][SIZE];//“.”或“#”
bool vis[SIZE][SIZE];//标记是否到达过
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};//分别代表向上、下、左、右移动一格
int step[SIZE][SIZE];//标示每一步
int H,W;//行数、列数

int check(int x, int y)
{
    if(x<0 || y<0 || x>=H || y>=W || vis[x][y] || board[x][y]=='#')
        return false;
    return true;
}//检查函数，检查当前节点是否可搜

int bfs()
{
    queue<pair<int,int> > q;//声明点队列
    pair<int,int> t;//temp
    q.push(make_pair(0,0));//起点（0，0）入队
    step[0][0]=1;//起点为1
    vis[0][0]=true;//（0，0）点到达过
    while(q.size())//只要队列不为空，一直循环
    {
        t=q.front();//把队列首的元素赋值给临时变量t
        q.pop();//清空队列

//        if(/*搜索成功的条件*/)
//            return t.step;
        for(int i=0; i<4; ++i)//遍历上下左右
        {
            int t_x=t.first+Move[i][0];//t_x是下一个点的横坐标
            int t_y=t.second+Move[i][1];//t_x是下一个点的纵坐标
            if(t_x==H-1&&t_y==W-1)//如果到达终点
            {
                return step[t.first][t.second]+1;//把起点加上
            }
            if(check(t_x,t_y))//如果该点可搜
            {
                vis[t_x][t_y]=true;//标记搜过了
                step[t_x][t_y]=step[t.first][t.second]+1;//可走的白块数加一
                q.push(make_pair(t_x,t_y));//该点入队
            }
        }
    }
    return -1;
}

int main()
{
    cin>>H>>W;
    int cnt=0;
    for(int i=0; i<H; ++i)
    {
        for(int j=0; j<W; ++j)
        {
            cin>>board[i][j];
            if(board[i][j]=='#')
                ++cnt;
        }
    }
    int res = bfs();
    if(res == -1)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<H*W-cnt-res<<endl;//方块总数 减去 黑块数目 再减 走过的白块数目
    }
    return 0;
}


Measured memory_bytes: 504
import java.io.*;

public class Main{
	public static void main(String[] args){
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try{
		String s;
		while((s = reader.readLine()) != null){
			int n = s.length();
			char[] t = new char[n];
			for(int i = 0;i<n;i++){
				int m = n-1;
				t[m-i] = s.charAt(i);
			}
			for(int j = 0;j<n;j++){
				System.out.print(t[j]);
			}
			System.out.println("");
		}
		}catch(IOException e){
			System.exit(0);
		}
	}
}

Measured memory_bytes: 16860
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

ll sq(ll x){
	return x*x;
}

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

bool isvowel(char c){
	int i;
	string v="aeiou";
	for(i = (v.size()-1); i>=0; --i){
		if(c == v[i]){
			return true;
		}
	}
	return false;
}

ll manhattan(ll x1, ll y1, ll x2, ll y2){
	return ((ll)(abs(x1-x2)+abs(y1-y2)));
}

ll digit(ll x){
	ll ans = 0ll;
	if(!x){
		return 0ll;
	}
	while(x>0){
		ans++;
		x /= 10;
	}
	return ans;
}

ll f(ll a, ll b){
	return max(digit(a),digit(b));
}

char ltou(char c){
	c -= 'a';
	c += 'A';
	return c;
}

int main(void){
	int i;
	string s[3];
	for(i=0; i<3; ++i){
		cin >> s[i];
		cout << (ltou(s[i][0]));
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define pii pair<int, int>
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
typedef long long ll;
typedef long double ld;
using namespace std;
template<class T> using minheap = priority_queue<T, vector<T>, greater<T>>;

const int mod = 1e9 + 7;
const int N = 1e6 + 10;
ll fac[N], ifac[N];

ll powmod(ll a, ll b) {
  if (b == 0) return 1;
  ll c = powmod(a, b / 2);
  c = c * c % mod;
  if (b & 1) c = c * a % mod;
  return c;
}

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

  fac[0] = ifac[0] = 1;
  for (int i = 1; i < N; i++) {
    fac[i] = fac[i - 1] * i % mod;
  }

  ifac[N - 1] = powmod(fac[N - 1], mod - 2);
  for (int i = N - 2; i >= 1; i--) {
    ifac[i] = ifac[i + 1] * (i + 1) % mod;
  }

  int x, y;
  cin >> x >> y;

  ll cnt = 0;
  for (int a = 0; a <= x && 2 * a <= y; a++) {
    int d = x - a;
    if (d & 1) continue;
    int b = d / 2;
    if (a + 2 * b != x) continue;
    if (2 * a + b != y) continue;
    ll cur = fac[a + b];
    cur = cur * ifac[a] % mod;
    cur = cur * ifac[b] % mod;
    cnt += cur;
    cnt %= mod;
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 15872
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define value0(a) prime[(a)-1]
#define value1(b) prime[(b)+749]
using namespace std;
inline char gc() {
	return getchar();
	static char buf[100000],*l=buf,*r=buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void rd(T &x) {
	x=0; int f=1,ch=gc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=gc();}
	x*=f;
}
typedef long long ll;
const int maxn=500+5;
const int dx[]={0,0,1,-1},dy[]={1,-1,0,0};
int n;
int val0[maxn<<1],val1[maxn<<1];
ll an[maxn][maxn];
bool mark[10005];
vector<int> prime; 
ll gcd(ll a,ll b) {return b==0?a:gcd(b,a%b);}
void init(int n) {
	for(int i=2;i<=n;++i) {
		if(!mark[i]) {
			prime.push_back(i);
		}
		for(int j=0;j<prime.size();++j) {
			int x=i*prime[j]; if(x>n) break;
			mark[x]=1;
			if(i%prime[j]==0) break; 
		}
	}
}
int main() {
	rd(n);
	if(n==2) {puts("4 7\n23 10"); return 0;} 
	init(10000);
	for(int i=1;i<=n;++i) for(int j=1;j<=n;++j) if((i+j)%2==0) {
		an[i][j]=value0((i+j)/2)*value1((i-j)/2);
	}
	for(int x=1;x<=n;++x) for(int y=1;y<=n;++y) if((x+y)&1) {
		an[x][y]=1;
		for(int k=0;k<4;++k) {
			int _x=x+dx[k],_y=y+dy[k];
			if(_x<1||_x>n||_y<1||_y>n) continue;
			an[x][y]=an[x][y]/gcd(an[x][y],an[_x][_y])*an[_x][_y];
		}
		++an[x][y]; 
	}
	for(int i=1;i<=n;++i) {
		for(int j=1;j<=n;++j) {
			if(j!=1) printf(" ");
			printf("%lld",an[i][j]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 5544
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double n = sc.nextInt();
        double k = sc.nextInt();
        System.out.println((int) Math.ceil(n / k));
    }


    public static int log2(long x) {
        return (int) (Math.log(x) / Math.log(2));
    }
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define ll  long long int
#define fr(i,n) for(ll i=0; i<n; i++)
#define fre(i,n) for(ll i=1; i<=n; i++)
#define pb push_back
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define pii pair<ll,ll>
#define ve vector
#define piii pair<pii, ll>
#define FAST ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;

ll power(ll x, ll n, ll m)
{
    if(n==0)
        return 1;
    if(n==1)
        return x;
    x%=m;
    if(n%2)
        return (x*(power((x*x)%m, n/2, m)%m))%m;
    return power((x*x)%m, n/2, m)%m;
}

int main(){
  
    FAST;
    string s,t,ans="";
    cin>>s>>t;

    int n=s.length(), m = t.length();
    int lcs[n+1][m+1], x=n, y = m;

    for(int i=0; i<=n; i++){
      for(int j=0; j<=m; j++){
        lcs[i][j] = 0;
      }
    }

    for(int i=1; i<=n; i++){
      for(int j=1; j<=m; j++){
        if( s[i-1] == t[j-1] )
          lcs[i][j] = 1+lcs[i-1][j-1];
        else
          lcs[i][j] = max( lcs[i-1][j], lcs[i][j-1] );
      }
    }

    while( x > 0 && y > 0){
        if( s[x-1] == t[y-1] ){
          // cout<<x<<" "<<y<<" "<<s[x-1]<<" "<<t[y-1]<<endl;  
          ans += t[y-1];
          x--,y--;
        }
        else if( lcs[x][y-1] < lcs[x-1][y])
          x--;
        else
          y--;
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;



}

Measured memory_bytes: 38808
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;


public class Main
{
	static class Company
	{
		int no;
		int count;
		boolean is_trade;
	};
	
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		ArrayList<Company> comp = new ArrayList<>();
		for(; ;)
		{
			String input = scanner.nextLine();
			if(input.equals(""))
			{
				break;
			}
			String[] word = input.split(",");
			
			boolean is_add = true;
			for(int i=0; i<comp.size(); i++)
			{
				if(comp.get(i).no == Integer.parseInt(word[0]))
				{
					comp.get(i).count++;
					is_add = false;
					break;
				}
			}
			
			if(is_add)
			{
				Company c = new Company();
				c.no = Integer.parseInt(word[0]);
				c.count = 1;
				c.is_trade = false;
				comp.add(c);
			}
		}
		
		Collections.sort(
				comp,
				new Comparator<Company>()
				{
					@Override
					public int compare(Company o1, Company o2)
					{
						return o1.no<o2.no ? -1: 1;
					}
				});
		
		for(; scanner.hasNext();)
		{
			String input = scanner.next();
			String[] word = input.split(",");
			
			for(int i=0; i<comp.size(); i++)
			{
				if(comp.get(i).no == Integer.parseInt(word[0]))
				{
					comp.get(i).count++;
					comp.get(i).is_trade = true;
				}
			}
		}
		
		for(int i=0; i<comp.size(); i++)
		{
			if(comp.get(i).is_trade)
			{
				System.out.println(comp.get(i).no +" "+ comp.get(i).count);
			}
		}
	}
}

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

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    if(s.at(n-1) == '0'){
        s += '1';
    }else{
        s += '0';
    }
    vector<vector<int>> a(0, vector<int>(2));
    rep(i, n){
        if(s.at(i+1) != s.at(i)){
            a.push_back({i+1, s.at(i) - '0'});
        }
    }
    int cou = 0;
    rep(i, a.size()){
        if(a.at(i).at(1) == 0) cou++;
    }
    int sum = 0;
    int ans = 0;
    int asi = a.size();
    k = min(k, cou);
    if(n != 1){
        if(asi != 1){
            rep(i, asi){
                if(a.at(i).at(1) == 1) continue;
                if(i+(k-1)*2 > asi-1) break;
                int st = max(0, i-1);
                int fi = min(asi-1, i+(k-1)*2+1);
                if(st == 0){
                    sum = a.at(fi).at(0);
                }else{
                    sum = a.at(fi).at(0) - a.at(st-1).at(0);
                }
                if(ans < sum) ans = sum;
            }
        }else{
            ans = n;
        }
    }else{
        ans = 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6964
/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc172/A
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000



int main() {
    int a;
    cin >> a;
    cout << (a + a*a + a*a*a) << endl;
}


Measured memory_bytes: 3584
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


L, R, d = map(int, input().split())

res = 0
for i in range(L, R+1):
    if i % d == 0:
        res += 1
print(res)


Measured memory_bytes: 9832
import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();
        sc.close();
        for (int i=0;i<N+1;i++){
            for (int j=0;j<N+1-i;j++){
                if (10000*i+5000*j+1000*(N-i-j) == Y){
                    System.out.println(i+" "+j+" "+ (N-i-j));
                    System.exit(0);
                }
            }
        }
        System.out.println(-1+" "+-1+" "+ -1);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    int mid = 0;
    if(s.size() % 2 == 0){
        mid = s.size()/2 -1;
    }else{
        mid = (s.size()-1)/2;
    }
    int ans = 0;
    for(int i = 0; i <= mid ; i++){
        if(s[i] == s[s.size()-1-i]) continue;
        else ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	auto distance = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
	cout << fixed << setprecision(17) << distance << endl;
}


Measured memory_bytes: 3216
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
const int maxn = 10005;
int a[maxn]={0};
int main()
{
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		if(a[i]==a[i-1]) a[i]=0,ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
//https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#5-%E4%BA%8C%E9%A0%85%E4%BF%82%E6%95%B0-ncr
#include <iostream>
using namespace std;

const int MAX = 1000005; //適当に変更する
const long long MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();

    int x,y;
    cin >> x >> y;
    long long ans=0;
    if((x+y)%3==0 && x<=2*y && y<=2*x){
        int p=(2*y-x)/3;
        int q=(2*x-y)/3;
        ans=COM(p+q,p);
        }
  cout << ans << endl;
}

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

int main()
{
  ll n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  for (int i=1; i<n; i++) {
    a[i] += a[i-1];
  }
  ll ans = 1LL<<60;
  for (int i=0; i<n; i++) {
    ans = min(ans, abs(a[i]-(a[n-1]-a[i])));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
using System;

public class Test
{
	public static void Main()
	{
		string[] inputs = Console.ReadLine().Split(' ');
		int a = int.Parse(inputs[0]);
		int b = int.Parse(inputs[1]);
		
		string output = "";
		if (a < b)		output = "a < b";
		else if (a > b)	output = "a > b";
		else			output = "a == b";
		
		Console.WriteLine(output);
	}
}

Measured memory_bytes: 9028
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n, m, l;
    cin >> n >> m >> l;
    ll a[n][m], b[m][l], c[n][l];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            int a_ij;
            cin >> a_ij;
            a[i][j] = a_ij;
        }
    }
    for(int i=0; i<m; i++){
        for(int j=0; j<l; j++){
            int b_ij;
            cin >> b_ij;
            b[i][j] = b_ij;
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<l; j++){
            c[i][j] = 0;
            for(int k=0; k<m; k++) c[i][j] += a[i][k]*b[k][j];
            cout << c[i][j];
            if(j != l-1) cout << " ";
        }
        cout << endl;
    }
}


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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		long n = stdIn.nextLong(); //sの個数
		long m = stdIn.nextLong(); //cの個数
		long ans = 0;
		long ns = n;
		long mc = m;
		
		if(n>=1 && m == 1){
			ans = 0;
		}else {
			
			if(n*2 <= m) { //sの2倍の個数よりcが多い場合
				ans += n;
				mc -= 2*n;
				if(mc>=4) {
					ans += mc/4;
				}
				
			}else if(n <= m){
				ans += mc/2;
			}else { //m < n
				ans += mc/2;
			}
			
			
			
			
		}
		
		
		
		if(ans == 0) {
			System.out.println(ans);
		}else {
			System.out.println(ans);
		}
		
		
	}

}


Measured memory_bytes: 21716
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
  int n, x;
  while(cin >> n, n){
	   x = n;
	   int cnt = 0;
	   while(x > 0){
		    cnt += x / 5;
		    x /= 5;
		  }
	  cout << cnt << endl;
	}	
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3160
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int Maxn = 100010;
typedef long long ll;
int f[110][20],p[110][20],ans,cnt,res,n;
int main()
{
    cin>>n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < 10; j++)
            cin>>f[i][j];
    for (int i = 0; i < n; i++)
        for (int j = 0; j <= 10; j++)
            cin>>p[i][j];
    res = -(1<<30);
    for (int k = 1; k < 1024; k++)
    {
        ans = 0;
        for (int i = 0; i < n; i++)
        {
            cnt = 0;
            for (int j = 0; j < 10; j++)
            {
                if(k>>j&1 && f[i][j])
                    cnt++;
            }
            ans += p[i][cnt];
        }
        if(ans > res)
            res = ans;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

vector<pair<ll, int> > vv;
int n;

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		ll a;
		cin >> a;
		vv.push_back(make_pair(a, i));
	}
	sort(vv.begin(), vv.end());
	int now = 0;
	ll sum = 0;
	int ans = 0;
	for (int i = 0; i < vv.size(); ++i) {
		if (now == i) {
			sum += vv[i].first;
			++now;
		}
		while (now < vv.size() && vv[now].first <= sum * 2) {
			sum += vv[now].first;
			++now;
		}
		if (now == vv.size())
			++ans;
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 2420
#include<iostream>

using namespace std;

int n;
int count;

int main()
{
	while(cin>>n)
	{
		for(int i=0;i<=9;++i)
		{
			for(int j=0;j<=9;++j)
			{
				for(int k=0;k<=9;++k)
				{
					for(int l=0;l<=9;++l)
					{
						if(i+j+k+l==n)
						{
							++count;
						}
					}
				}
			}
		}
		cout<<count<<endl;
		count = 0;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define MOD (ll)(1e9 + 7)
#define MAX (ll)(1e6 + 4)
#define INF (ll)(1e17)
using namespace std;
using ll =  long long;
using ld = long double;
bool ch[MAX];
vector<pair<ll, ll>> pri[MAX];
ll cnt[MAX];
void seive () {
	for (ll i = 2; i < MAX; i++) {
		if (!ch[i]) {
			for (ll j = i; j < MAX; j += i) {
				ll xx = j, cc = 0;
				while (xx % i == 0) {
					cc++;
					xx /= i;	
				}
				pri[j].push_back (make_pair (i, cc));
				ch[j] = 1;
			}
		}
	}
}
		
ll mult (ll a, ll b) {
	return (a * b) % MOD;
}

ll add (ll a, ll b) {
	return (a + b) % MOD;
}

ll pw (ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1) {
			res = mult (res, a);
		}
		b >>= 1;
		a = mult (a, a);
	}
	return res;
}

int main () {
	seive ();
	ll n;
	cin >> n;
	ll ar[n], pr = 1, dr = 1;
	for (ll i = 0; i < n; i++) {
		cin >> ar[i];
		pr = mult (ar[i], pr);
	}
	for (ll i = 0; i < n; i++) {
		ll pp = 1;
		for (pair<ll, ll> x : pri[ar[i]]) {
			ll mm = min (cnt[x.first], x.second);
			cnt[x.first]  = max (cnt[x.first], x.second);  
			dr = mult (dr, pw (x.first, mm));
		}
	}
	pr = mult (pr, pw (dr, MOD - 2));
	ll su = 0;
	for (ll i = 0; i < n; i++) {
		su = add (su, mult (pr, pw (ar[i], MOD - 2)));
	}
	cout << su << "\n";
}
	



Measured memory_bytes: 102912
#include <iostream>
#include <queue>
#define MAX_N 500
#define WHITE 0
#define BLACK 1
#define INF 100000
using namespace std;

int l[MAX_N + 1][MAX_N + 1];
int status[MAX_N + 1];
int d[MAX_N + 1];
int sum;

void bfs(int n) {
  queue<int> q;
  int temp = 1;
  q.push(temp);
  d[temp] = 0;
  while (q.empty() == false) {
    temp = q.front();
    q.pop();
    if (d[temp] == 2) break;
    for (int i = 2; i <= n; i++) {
      if (l[temp][i] == 1 && status[i] == WHITE) {
	status[i] = BLACK;
	q.push(i);
	d[i] = d[temp] + 1;
	sum++;
      }
    }
  }
}

void init(int n) {
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      l[i][j] = 0;
    }
  }
  for (int i = 0; i <= n; i++) {
    status[i] = WHITE;
    d[i] = INF;
  }
  sum = 0;
}

int main() {
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n == 0 && m == 0) return 0;
    init(n);
    for (int i = 0; i < m; i++) {
      int a, b;
      cin >> a >> b;
      l[a][b] = 1;
      l[b][a] = 1;
    }

    bfs(n);
    cout << sum << endl;
  }
}

Measured memory_bytes: 3916
N=int(input())

t,x,y=0,0,0
s=0

for i in range(N):
    tn,xn,yn=map(int,input().split())
    
    if ((tn-t)-(xn-x+yn-y))%2==1 or ((tn-t)-(xn-x+yn-y))<0:
        s=1

if s==0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

import sys
from operator import itemgetter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
SP=[]
for i in range(N):
    s,p=input().split()
    SP.append((i, s, int(p)))

SP.sort(key=itemgetter(2), reverse=True)
SP.sort(key=itemgetter(1))

for i in range(N):
    print(SP[i][0]+1)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
typedef pair<P, int> PP;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	if (n == 0) return 1;
	if (n % 2) return (x * modpow(x * x % mod, n / 2) % mod + mod) % mod;
	return (modpow(x * x % mod, n / 2) + mod) % mod;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

int n, k;
vector<int>g[114514];
int ans = 1;
queue<int>que;
int d[114514];
signed main() {
	cin >> n >> k;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
		d[i] = inf;
	}
	d[n - 1] = inf;
	que.push(0);
	d[0] = k;
	while (!que.empty()) {
		int p = que.front(); que.pop();
		int cnt;
		if (p == 0) cnt = k - 1;
		else cnt = k - 2;
		int w = 0;
		rep(i, g[p].size()) {
			if (d[g[p][i]] != inf) continue;
			d[g[p][i]] = cnt - w;
			if (cnt - w < 1) {
				cout << 0 << endl;
				return 0;
			}
			que.push(g[p][i]);
			w++;
		}
	}
	rep(i, n) {
		ans *= d[i];
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 8948
#include <stdio.h>
int main () {
    int n, build, floor, room, b, f, r, v;
    int inf[4][3][10];
    scanf("%d", &n);
    
    for (build = 0; build < 4; build++) {
        for (floor = 0; floor < 3; floor++) {
            for (room = 0; room < 10; room++) {
                inf[build][floor][room] = 0;
            }
        }
    }
    
    for (int i = 0; i < n; i++) {
        scanf("%d %d %d %d", &b, &f, &r, &v);
        inf[b-1][f-1][r-1] = inf[b-1][f-1][r-1] + v;
    }
    
    for (build = 0; build < 4; build++) {
        for (floor = 0; floor < 3; floor++) {
            for (room = 0; room < 10; room++) {
                printf(" %d",inf[build][floor][room]);
            }
            printf("\n");
        }
        if (build < 3) {
            for (int i = 0; i < 20; i++) printf("#");
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2048
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include <ctime>
#include<list>
#include <numeric>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include <array>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(int i = 0; i < n; i++)
#define FORAB(i, a, b) for(int i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))
#define AIN(A, B, C) assert(IN(A, B, C))

typedef long long int LL;
//typedef __int128 LLL;
typedef long long LLL;

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PLL> VPL;
typedef vector<PII> VP;
typedef vector<double> VD;
typedef vector<vector<int>> VVI;
typedef vector<string> VS;
typedef long double ld;

#define MAXN 1000006
//#define MAXN 1006

const LL MOD = 1000000007;
//const LL MOD = 998244353;
const LL INF = 2000000000000000001LL; //2e18 + 1

void solve(int ks) {
	int h1, m1, h2, m2, k;
	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
	int t1 = h1 * 60 + m1;
	int t2 = h2 * 60 + m2;
	if (t2 < t1) t2 += 60 * 24;
	int t = t2 - t1 - k;
	printf("%d\n", t);
}

void gen() {
}

int main()
{
	double start_time = clock();
#ifdef LOCAL
	freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin);
	// freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin);
	//	freopen("out.out", "w", stdout);
#endif

	gen();

	if (0) {
		int T;
		scanf("%d", &T);
		//AIN(T, 1, 5000);
		for (int ks = 1; ks <= T; ks++) {
			solve(ks);
			if (ks % 1 == 0) fprintf(stderr, "%d done\n", ks);
		}
	}
	else {
		solve(0);
	}

	double end_time = clock();
	fprintf(stderr, "Time = %lf\n", (end_time - start_time) / CLOCKS_PER_SEC);

	return 0;
}


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

namespace ConsoleApp15
{
    class Class219
    {
        static void Main()
        {
            long x = long.Parse(Console.ReadLine());
            
            long x2 = x / 11*2;
            long y = x % 11;
            if (y > 6) y = 2;
            else if (y != 0) y = 1;
            else y = 0;

            Console.WriteLine(x2+y);
        }
    }
}


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

using namespace std;

class Solution {
public:
	int tenki(const string& S, const string& T) {
		const int n = S.size();
		int ans = 0;
		for (int i = 0; i < n; ++i) {
			if (S[i] == T[i])
				++ans;
		}
		return ans;
	}
};

int main() {
	int a;
	string S, T;
	cin >> S >> T;

	Solution sol;
	int ans = sol.tenki(S, T);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main(){
  long long int a,e=0;
  cin>>a;
  vector<int>b(a);
  vector<int>c(a);
  vector<int>d(a);
  rep(i,a)cin>>b[i];
  rep(i,a)cin>>c[i];
  rep(i,a)cin>>d[i];
  sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    sort(d.begin(),d.end());
	for(int i=0;i<a;i++){
		long long A=(lower_bound(b.begin(),b.end(),c[i])-b.begin());
		long long B=a-(upper_bound(d.begin(),d.end(),c[i])-d.begin());
		e+=A*B;
	}
  cout<<e;
}


Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<ctype.h>
#include<vector>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
	int a;
	cin >> a;
	int b;
	cin >> b;

	if (a + b >= 24)
		cout << a + b - 24 << endl;
	else
		cout << a + b << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int N,M;
	int *c;

	cin >> N >> M;

	c = new int[N+1];

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

	for(int i=0;i<M;i++)
	{
		int t,s;

		cin >> t >> s;
		c[t]++;
		c[s]++;
	}

	for(int i=1;i<N+1;i++)
	{
		cout << c[i] << endl;
	}

	delete(c);

	return 0;
}

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

int main() {
	int S;
	cin >> S;
	int h, m, s;
	s = S % 60;
	m = S / 60 % 60;
	h = S / 60 / 60;
	cout << h << ":" << m << ":" << s << endl;
	
	return 0;
}

Measured memory_bytes: 3056
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    a,b = map(int, input().split())
    t = a + b
    if t%2 != 0:
        print("IMPOSSIBLE")
    else:
        print(t//2)

if __name__ == '__main__':
    main()


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

using namespace std;

int mex(set<int> x)
{
    int r = 0;
    while(x.count(r))
        r++;
    return r;
}

const int maxn = 6e5;
vector<int> G[maxn], Gt[maxn];

void add_edge(int u, int z1, int v, int z2)
{
    int U = 2 * u + z1;
    int V = 2 * v + z2;
    G[U].push_back(V);
    Gt[V].push_back(U);
}

int used[maxn];

void dfs(int v, vector<int> *G, vector<int> &st)
{
    if(used[v])
        return;
    used[v] = 1;
    for(auto u: G[v])
        dfs(u, G, st);
    st.push_back(v);
}

void try2sat()
{
    vector<int> top_sort;
    for(int i = 0; i < maxn; i++)
        dfs(i, G, top_sort);
    reverse(begin(top_sort), end(top_sort));
    memset(used, 0, sizeof(used));
    for(auto v: top_sort)
    {
        if(used[v])
            continue;
        vector<int> comp;
        dfs(v, Gt, comp);
        set<int> lol;
        for(auto u: comp)
        {
            lol.insert(u);
            if(lol.count(u ^ 1))
            {
                cout << "IMPOSSIBLE\n";
                exit(0);
            }
        }
    }
    cout << "POSSIBLE\n";
}

signed main()
{
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int p[n], cnt[n] = {0};
    set<pair<int, int>> vrt;
    for(int i = 0; i < n; i++)
    {
        cin >> p[i];
        p[i]--;
        cnt[p[i]]++;
    }
    for(int i = 0; i < n; i++)
        vrt.insert({cnt[i], i});
    set<int> banned[n];
    while(begin(vrt)->first == 0)
    {
        int v = begin(vrt)->second;
        vrt.erase(begin(vrt));
        vrt.erase({cnt[p[v]], p[v]});
        cnt[p[v]]--;
        vrt.insert({cnt[p[v]], p[v]});
        banned[p[v]].insert(mex(banned[v]));
    }
    int m[n][2];
    for(auto it: vrt)
    {
        int v = it.second;
        m[v][0] = mex(banned[v]);
        banned[v].insert(m[v][0]);
        m[v][1] = mex(banned[v]);
    }
    for(auto it: vrt)
    {
        int v = it.second;
        int u = p[v];
        for(int z1 = 0; z1 <= 1; z1++)
            for(int z2 = 0; z2 <= 1; z2++)
                if(m[u][z1] == m[v][z2])
                {
                    add_edge(u, z1, v, !z2);
                    add_edge(v, z2, u, !z1);
                }
        if(m[u][0] == m[v][0])
        {
            add_edge(u, 1, v, 0);
        }
        else if(m[u][0] == m[v][1])
        {
            add_edge(u, 1, v, 1);
        }
        else
        {
            add_edge(u, 1, u, 0);
        }
    }
    try2sat();
}


Measured memory_bytes: 85744
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	scanf("%d",&n);
	int arr[n];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&arr[i]);
	}
	int mark[8]={0};int temp=0;int count=0;
	for(int i=0;i<n;i++)
	{
		if(arr[i]<=3199)
			mark[arr[i]/400]=1;
		else
			temp++;
	}
	for(int i=0;i<8;i++)
	{
		if(mark[i]==1)
			count++;
	}
	printf("%d %d\n",count+(count>0?0:1),count+temp);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int m,n,q;
	vector<int> res;
	cin>>n>>m>>q;
	int a[500][500],temp1,temp2,b[500][500];
	for(int i=0;i<m;i++){
		cin>>temp1>>temp2;
		temp2--;
		temp1--;
		a[temp1][temp2]++;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n-i;j++){
			if(i==0){
				b[j][i+j]=a[j][i+j];
			}else if(i==1){
				b[j][i+j]=(a[j][i+j]+b[j][i+j-1]+b[j+1][i+j]);
			}else{
				b[j][i+j]=(a[j][i+j]+b[j][i+j-1]+b[j+1][i+j]-b[j+1][i+j-1]);
			}
		}
	}
	for(int i=0;i<q;i++){
		cin>>temp1>>temp2;
		temp2--;
		temp1--;
		res.push_back(b[temp1][temp2]);
	}
	for(int i=0;i<q;i++){
		cout<<res[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3448
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  char ans[3] = {'A', 'B', 'C'};
  vector<string> s(3);
  vector<int> rest(3, 0);
  REP(i,3) cin >> s[i];
  int turn=0;
  while(rest[turn]!=(int)s[turn].size()){
    char next = s[turn][rest[turn]];
	rest[turn]++;
    if(next=='a') turn = 0;
    else if(next=='b') turn = 1;
    else turn = 2;
  }
  cout << ans[turn] << '\n';

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int H = Integer.valueOf(s.next());
		int N = Integer.valueOf(s.next());
		int[] A = new int[N+1];
		int[] B = new int[N+1];
		for(int i = 0; i < N; i++) {
			A[i] = Integer.valueOf(s.next());
			B[i] = Integer.valueOf(s.next());
		}
		
		long[] dp = new long[20000];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;
		
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < 10000; j++) {
				dp[j+A[i]] = Long.min(dp[j+A[i]], dp[j] + B[i]);
			}
		}
		for(int i = 10001; i >= 0; i--) {
			dp[i] = Long.min(dp[i], dp[i+1]);
		}
		
		System.out.println(dp[H]);
	}
}

Measured memory_bytes: 38972
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007
int main(){
	fast;
	string s;
	cin>>s;
	if(s[0]==s[2])
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}



Measured memory_bytes: 3640
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N, M;
  cin >> N;
  vec<ll> T(N);
  REP(i, N) cin >> T[i];
  cin >> M;

  REP(j, M) {
    ll P, X, acc = 0;
    cin >> P >> X;
    REP(i, N) acc += (i + 1 == P) ? X : T[i];
    cout << acc << endl;
  }
  return 0;
}


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

int n, del = -1; 
queue <int> q;

int main()
{
    scanf( "%d", &n );
    
    if( n == 3 )
    {
    	printf( "2 5 63\n" ); 
    	return 0;
	}

    int now = 0, p2 = 0, p3 = -3; 
    while( now + 3 < n && p2 +6 <= 30000 )
    {
        p2 += 2; q.push( p2 );
        p2 += 2; q.push( p2 );
        p2 += 2; q.push( p2 );
        now += 3;
    } 

    if( ( n - now ) %2 )
        del = 6, now --;
//    printf( "now:%d\n", now );
    
    while( now < n )
    {
        p3 += 6; q.push( p3 );
        p3 += 6; q.push( p3 );
        now += 2;
    }

    while( !q.empty() )
    {
        if( q.front() != del )
            printf( "%d ", q.front() );
        q.pop();
    } 
    printf( "\n" );
    
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
int main(void){
	float a, b;
	cin >> a >> b;
	cout << ceil((a + b) / 2);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename T>
class hashmap64 {
	std::vector<std::pair<uint64, T>> map;
	uint64 mask, count, temp;
	uint64 hash64(uint64 key) {
		key = ~key;
		key ^= key << 13;
		key ^= key >> 19;
		return key ^ (key << 17);
	}
public:
	hashmap64() :map(8192, std::make_pair(~static_cast<std::uint_fast64_t>(0), T())) {
		mask = 8191; count = 0;
	}
	hashmap64(size_t s) {
		s |= s << 1;
		s |= s >> 2;
		s |= s >> 4;
		s |= s >> 8;
		s |= s >> 16;
		s |= s >> 32;
		mask = s;
		count = 0;
		map.resize(s + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
	}
	T &operator[](uint64 suf) {
		temp = mask&hash64(suf);
		while (map[temp].first != suf) {
			temp = mask&(temp + 1);
		}
		return map[temp].second;
	}
	void insert(uint64 key, const T &value) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				map[temp].second = value;
				return;
			}
			temp = mask&(temp + 1);
		}
		map[temp] = std::make_pair(key, value);
		++count;
		if ((count << 1) > mask) {
			std::pair<uint64, T> mkey;
			mask = mask << 1 | 1;
			map.resize(mask + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
			for (uint64 t = 0;t <= mask >> 1;++t) {
				if (!~map[t].first) {
					mkey = map[t];
					map[t].first = ~0;
					temp = mask&hash64(mkey.first);
					while (~map[temp].first) {
						temp = mask&(temp + 1);
					}
					map[temp] = mkey;
				}
			}
		}
		return;
	}
	bool find(uint64 key) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				return true;
			}
			temp = mask&(temp + 1);
		}
		return false;
	}
	bool empty(void) {
		return !count;
	}
	size_t size(void) {
		return count;
	}
};

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	hashmap64<uint32> map(32000);
	uint32 n;
	std::cin >> n;
	int64 a, sum = 1e15;
	uint32 ans = 0;
	map.insert(sum, 0);
	rep(i, 0, n) {
		std::cin >> a;
		sum += a;
		if (map.find(sum)) {
			ans = std::max(ans, i + 1 - map[sum]);
		}
		else {
			map.insert(sum, i + 1);
		}
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 15060
use std::io::BufRead;

fn main() {
    let handle = std::io::stdin();
    let mut buf = String::new();
    handle.lock().read_line(&mut buf).unwrap();
    let new_buf: String= buf.chars().map(|a| {
        if a == '1' {
           '9'
        } else if a == '9' {
            '1'
        } else {
            ' '
        }
    }).collect();
    println!("{}", new_buf)
}

Measured memory_bytes: 4352
N = int(input())
A = list(map(int,(input().split())))

UP = 1
DOWN = -1

state = 0
cnt = 1
last = None
for x in A:
	if last == None:
		last = x
	elif state == 0:
		if x - last > 0:
			state = UP
		elif x - last < 0:
			state = DOWN
		last = x
	else:
		if (x-last) * state >= 0:
			last = x
		else:
			last = x
			state = 0
			cnt += 1

print(cnt)

Measured memory_bytes: 14252
from collections import defaultdict
N = int(input())
a = [int(i) for i in input().split()]
d = defaultdict(int)
for x in a:
    d[x] += 1
#print(d)
ans = []
for x in d.keys():
    sum = d[x]
    if x-1 in d:
        sum += d[x-1]
    if x+1 in d:
        sum += d[x+1]
    ans.append(sum)
print(max(ans))

Measured memory_bytes: 14564
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N,M = getNM()
data = [[] for i in range(8)]
for _ in range(N):
    x,y,z = getNM()
    data[0].append(x + y + z)
    data[1].append(x + y - z)
    data[2].append(x - y + z)
    data[3].append(x - y - z)
    data[4].append(- x + y + z)
    data[5].append(- x + y - z)
    data[6].append(- x - y + z)
    data[7].append(- x - y - z)

ans = -mod
for i in range(8):
    data[i].sort(reverse = True)
    ans = max(ans,sum(data[i][:M]))
print(ans)

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int INF=1<<29;

template<class T>
class binary_heap{
	const static int N_MAX=30000;
	int n;
	T a[N_MAX+1];
public:
	binary_heap():n(0){}
	const T &find_min()const{ return a[1]; }
	void insert(const T &x){
		int u=++n;
		a[u]=x;
		while(u!=1 && a[u/2]>a[u]) swap(a[u/2],a[u]), u/=2;
	}
	void delete_min(){
		a[1]=a[n--];
		for(int u=1;2*u<=n;){
			int v=2*u;
			if(2*u+1<=n && a[2*u]>a[2*u+1]) v++;
			if(a[v]<a[u]) break;
			swap(a[v],a[u]);
			u=v;
		}
	}
	bool empty()const{ return n==0; }
	int size()const{ return n; }
};

struct edge{ int v,cost1,cost2; };

int main(){
	for(int m,n;scanf("%d%d",&m,&n),n;){
		vector<edge> G[100];
		rep(i,m){
			int u,v,cost1,cost2; scanf("%d%d%d%d",&u,&v,&cost1,&cost2); u--; v--;
			G[u].push_back((edge){v,cost1,cost2});
			G[v].push_back((edge){u,cost1,cost2});
		}

		int q; scanf("%d",&q);
		while(q--){
			int s,t,type; scanf("%d%d%d",&s,&t,&type); s--; t--;

			int d[100];
			rep(u,n) d[u]=(u==s?0:INF);
			static binary_heap< pair<int,int> > H; H.insert(make_pair(0,s));
			while(!H.empty()){
				int d_now=H.find_min().first,u=H.find_min().second;
				H.delete_min();

				if(d[u]<d_now) continue;

				rep(i,G[u].size()){
					const edge &e=G[u][i];
					int d2=d_now+(type==0?e.cost1:e.cost2);
					if(d[e.v]>d2){
						d[e.v]=d2;
						H.insert(make_pair(d2,e.v));
					}
				}
			}

			printf("%d\n",d[t]);
		}
	}

	return 0;
}

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

int N,a,b;
vector<pair<int,int>> v[100005];
int c[100005],K=0;

void root(int x, int p,int cp){
    int color=1;
    for(auto i : v[x]){
        K=max(K,(int)v[x].size());
        if(i.second==p) continue;
        if(color==cp) color++;
        cerr << i.first << endl;
        c[i.first]=color;
        root(i.second,x,color);
        color++;
    }
}

int main(){
    cin>>N;
    for(int i=0;i<N-1;i++){
        cin>>a>>b;
        a--,b--;
        v[a].push_back(make_pair(i,b));
        v[b].push_back(make_pair(i,a));
    }
    root(0,-1,-1);
    cout<<K<<endl;
    for(int i=0;i<N-1;i++){
        cout<<c[i]<<endl;
    }
}


Measured memory_bytes: 10240
#include<iostream>
#include<fstream>
#include<algorithm>
#include<string>
using namespace std;
long long n,h,zd=0;
string st;
int main()
{
    cin>>n>>st;
    for(int i=0;i<st.size();i++)
    {
        if(st[i]=='I')h++;
        else h--;
        if(h>zd)zd=h;
    }
    cout<<zd<<endl;
    return 0;
}

Measured memory_bytes: 256