akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vs s(n);
  rep(i,n){
    cin>>s[i];
    vsort(s[i]);
  }
  
  vsort(s);
  
  ll ans=0;
  ll r=0, l=0;
  while(l<n){
    while(r<n && s[l]==s[r]){
      r++;
    }
    
    ll d=r-l;
    ans+=d*(d-1)/2;
    if(l==r) r++;
    l=r;
  }
  cout<<ans<<endl;
  
}

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

int main (void){
  long long int n = 0,a = 0,r = 0,g = 0, b = 0;
  char d[4005] = "";

  cin >> n;
  cin >> d;

  for(int i = 0;i < n;i++){
    if(d[i] == 'R'){
      r++;
    }else if(d[i] == 'G'){
      g++;
    }else{
      b++;
    }
  }
  a = r*g*b;

    for(int j = 1; j < n - 1;j++){
      for(int k = j + 1;k < n;k++){
        if(2*j - k >= 0){
          if(d[2 * j - k] != d[j] && d[j] != d[k] && d[2 * j - k] != d[k]){
            a--;
          }
        }
      }
    }
  cout << a << "\n";

  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <math.h>

using namespace std;
int main(){
  string s;
  cin >> s;
  int a[4];
  for(int i=0;i<s.length();i++){
    a[i] = s[i]-'0';
  }

  char op[4] = "---";
  int sum;
  for(int i=0;i<pow(2,3);i++){
    sum = a[0]-a[1]-a[2]-a[3];
    for(int j=0;j<3;j++)op[j]='-';
    for(int j=0;j<3;j++){
      if((i & (1<<j)) == (1<<j)){
        sum += 2*a[j+1];
        op[j] = '+';
      }
    }
    if(sum == 7)break;
  }

  for(int i=0;i<3;i++){
    cout << a[i] << op[i];
  }
  cout << a[3] << "=7" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DBG(x) cerr << #x << " = " << x << endl

using namespace std;
typedef long long LL;

string str = ".\n.\n";

void fuck(string &str) {
    string up, down;
    int cnt = 0;
    for(auto c : str) {
        if(c != '\n') {
            if(cnt & 1) down.push_back(c);
            else up.push_back(c);
            ++cnt;
        }
    }
    cout << up << endl;
    cout << down << endl;
}

int main(int argc, char **argv) {
    int n;
    cin >> n;
    int cnt = 1;
    bool toRight = true;
    while(true) {
        fuck(str);
        fflush(stdout);
        string st;
        cin >> st;
        if(st == "end") break;
        else if(st == "F") {
            if(cnt == 4) {
                toRight = !toRight;
                str.erase(str.size() - 4, 4);
                str = ".\n.\n" + str;
                cnt = 1;
            } else {
                if(toRight) {
                    str.erase(str.size() - 4, 4);
                    string add;
                    if(cnt & (1 << 0)) add += '#'; else add += '.'; add += '\n';
                    if(cnt & (1 << 1)) add += '#'; else add += '.'; add += '\n';
                    str += add;
                    ++cnt;
                } else {
                    str.erase(0, 4);
                    string add;
                    if(cnt & (1 << 0)) add += '#'; else add += '.'; add += '\n';
                    if(cnt & (1 << 1)) add += '#'; else add += '.'; add += '\n';
                    str = add + str;
                    ++cnt;
                }
            }
        } else if(st == "T") {
            cnt = 1;
            if(toRight) str += ".\n.\n";
            else str = ".\n.\n" + str;
        }
    }
    return 0;
}


Measured memory_bytes: 724
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>


using namespace std;




int facctorial(long long k) {
	long long sum = 1; 
	for (int i = 1; i <= k; i++){ 
		sum *= i;
		sum = sum % 1000000007;
	}
	return sum;
}

int main() {
	int n, m;
	cin >> n >> m;
	long long nf = facctorial(n);
	long long mf = facctorial(m);
	long long ans = 0;
	if (n == m) {
		ans = nf * mf * 2 %1000000007;
	}
	else if (abs( m - n) <= 1) {
		ans = nf * mf%1000000007;
	}
	else {
		ans = 0;
	}
	
	cout << ans << endl;
	









		return 0;
}

Measured memory_bytes: 256
#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 a,b,c;
  cin >>a >>b >>c;
  for(int i = 1; i<=b; i++){
    if(i*a%b==c){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int main(){
    float ans;
    CIN(N);
    CIN(A);
    COUT(A+(A-N));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int height;
	int max[3] = {0};
	int i;
	
	for (i = 0; i < 10; i++) {
		scanf("%d", &height);
		
		if (max[0] < height) {
			max[2] = max[1];
			max[1] = max[0];
			max[0] = height;
		}
		else if (max[1] < height) {
			max[2] = max[1];
			max[1] = height;
		}
		else if (max[2] < height) {
			max[2] = height;
		}
	}
	
	for (i = 0; i < 3; i++) {
		printf("%d\n", max[i]);
	}
	
	return (0);
}

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

int n, a, c[5];
int main()
{
	int t;
	cin >> n;
	while (n--) scanf("%d", &t), c[t % 4]++;
	c[0] += c[2] == 0;
	if (c[1] + c[3] <= c[0]) cout << "Yes";
	else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env php
<?php
const YES = "Yes";  # type: str
const NO = "No";  # type: str
function solve(int $a, int $b)
{
    $c = (int)((string)$a . (string)$b);
    $s = sqrt($c);
    $r = (int)$s;
    if (($s - $r) > 0) {
        echo NO.PHP_EOL;
    } else {
        echo YES.PHP_EOL;
    }
}

$inputs = [];
while (($item = fgets(STDIN)) !== false) {
    $inputs = array_merge($inputs, explode(' ', $item));
}
$a = (int)array_shift($inputs);
$b = (int)array_shift($inputs);
solve($a, $b);



Measured memory_bytes: 4728
# coding:utf-8                                                        

import bisect

N = int(raw_input())
A = sorted(map(int, raw_input().split()))
B = sorted(map(int, raw_input().split()))
C = sorted(map(int, raw_input().split()))

count = 0

for mid in B:
    lower_bound = bisect.bisect_left(A, mid)
    upper_bound = N - bisect.bisect_right(C, mid)
    count += lower_bound * upper_bound

print count

Measured memory_bytes: 17788
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long D = sc.nextLong();
		sc.close();

		// Cで割り切れる数
		long divideC = (B / C) - ((A - 1) / C);
		// Dで割り切れる数
		long divideD = (B / D) - ((A - 1) / D);
		// CとDの最小公倍数で割り切れる数
		long lcm = calcLcm(C, D);
		long divideLcm = (B / lcm) - ((A - 1) / lcm);
		System.out.println((B - (A - 1)) - (divideC + divideD - divideLcm));
	}

	// 最大公約数を求める。
	public static long calcGcd(long m, long n) {
		if (m < n) {
			long tmp = m;
			m = n;
			n = tmp;
		}
		long remainder = 0;
		while ((remainder = m % n) != 0) {
			m = n;
			n = remainder;
		}
		return n;
	}

	// 最小公倍数を求める。
	public static long calcLcm(long m, long n) {
		return m * n / calcGcd(m, n);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,c=0,d=0,e=INT_MAX,f;
  cin>>a;
  int b[a];
  rep(i,a){
    cin>>b[i];
    c+=b[i];
  }
  rep(i,a){
    d+=b[i];
    c-=b[i];
    if(d-c<0)f=(d-c)*-1;
    else f=d-c;
    e=min(e,f);
  }
  cout<<e;
}

Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;
use std::cmp::max;

fn main(){
    let (_n, _m, k): (i64, i64, i64) = get_triple();
    let xs: Vec<i64> = get_vec();
    let ys: Vec<i64> = get_vec();
    let xcs = cumsum(&xs);
    let ycs = cumsum(&ys);
    let mut ans = 0;

    for i in 0..xcs.len() {
        let cost_x = xcs[i];
        let cost_rem = k - cost_x;
        if let Some(y_n) = upper_bound(&ycs, &|y| *y <= cost_rem) {
            ans = max(ans, i + y_n);
        } 
    }

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

fn cumsum(v: &Vec<i64>) -> Vec<i64> {
    let mut result = vec![0];
    let mut sum = 0;
    for &elm in v.iter() {
        sum += elm;
        result.push(sum);
    }
    result
}

fn upper_bound<T, F>(v: &Vec<T>, f: &F) -> Option<usize>
    where F: Fn(&T) -> bool {
    if v.first().map(f) != Some(true) {
        return None;
    }

    let last_idx = (v.len() as i64 -1) as usize;
    if f(&v[last_idx]) {
        return Some(last_idx);
    }

    return Some(upper_bound(v, f, 0, last_idx));

    fn upper_bound<T, F>(v: &Vec<T>, f: &F, left: usize, right: usize) -> usize 
        where F: Fn(&T) -> bool {
        if left+1 == right {
            return left;
        }
        let m = (left + right) / 2;
        if f(&v[m]) {
            return upper_bound(v, f, m, right);
        } else {
            return upper_bound(v, f, left, m);
        }
    }
}

#[allow(dead_code)]
fn get_line() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn get_vec<T: std::str::FromStr>() -> Vec<T> {
    let line = get_line();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn get_one<T: FromStr + Copy>() -> T {
    let v = get_vec();
    v[0]
}

#[allow(dead_code)]
fn get_pair<T: FromStr + Copy>() -> (T, T) {
    let v = get_vec();
    (v[0], v[1])
}

#[allow(dead_code)]
fn get_triple<T: FromStr + Copy>() -> (T, T, T) {
    let v = get_vec();
    (v[0], v[1], v[2])
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}

#[allow(dead_code)]
fn vec_min(xs: &Vec<i64>) -> i64 {
    xs.iter().map(|&x|x).fold(std::i64::MAX, std::cmp::min)
}

#[allow(dead_code)]
fn vec_max(xs: &Vec<i64>) -> i64 {
    xs.iter().map(|&x|x).fold(std::i64::MIN, std::cmp::max)
}

#[allow(dead_code)]
fn vec_sum(xs: &Vec<i64>) -> i64 {
    xs.iter().fold(0, |acc, &x| acc+x)
}


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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int n; cin >> n;
	map<ll, ll> mp, mn;
	for(int i=0;i<n;i++){
		ll a; cin >> a;
		mp[i+a]++;
		mn[i-a]++;
	}
	ll ans = 0LL;
	for(int i=0;i<n;i++){
		ans += mp[i]*mn[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 46280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	int N;
	cin >> N;
	int a[N];
	for(int i=0; i<N; i++) cin >> a[i];
	vector<int> index;
	int cnt = 1;
	for(int i=1; i<N; i++){
		if(a[i-1] == a[i]) cnt++;
		else{
			index.push_back(cnt);
			cnt = 1;
		}
		if(i == N-1) index.push_back(cnt);
	}
	int ans = 0;
	for(int i=0; i<index.size(); i++){
		ans += index[i]/2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	final int INF = 100000;

	private void doit() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int [][] data = new int[n+1][n+1];
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				if(i !=j){
					data[i][j] = INF;
				}
			}
		}

		for(int i = 1; i <= n; i++){
			int from = sc.nextInt();
			int k = sc.nextInt();
			while(k-- > 0){
				int to = sc.nextInt();
				data[from][to] = 1;
			}
		}

		for(int j = 1; j <= n; j++){
			for(int i = 1; i <= n; i++){
				for(int k = 1; k <= n; k++){
					data[i][k] = Math.min(data[i][k], data[i][j] + data[j][k]);
				}
			}
		}

		int p = sc.nextInt();
		while(p-- > 0){
			int from = sc.nextInt();
			int to = sc.nextInt();
			int ttl = sc.nextInt();
			if(data[from][to] + 1 <= ttl){
				System.out.println(data[from][to] + 1);
			}
			else{
				System.out.println("NA");
			}
		}



	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();

	}

}

Measured memory_bytes: 13000
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    int N,M;
    int[] x,y;
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Read();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int[] Num = new int[N];
        bool[] c = new bool[N];
        for(int i=0;i<N;i++){
            Num[i] = 1;
            c[i] = (i == 0);
        }
        for(int i=0;i<M;i++){
            if(c[x[i]]){
                c[y[i]] = true;
                c[x[i]] = Num[x[i]] != 1;
            }
            Num[x[i]]--;
            Num[y[i]]++;
        }
        int count = 0;
        for(int i=0;i<N;i++){
            if(c[i]){
                count++;
            }
        }
        sb.Append(count+"\n");
    }
    void Read(){
        string[] str = Console.ReadLine().Split(' ');
        N = int.Parse(str[0]);
        M = int.Parse(str[1]);
        x = new int[M];
        y = new int[M];
        for(int i=0;i<M;i++){
            str = Console.ReadLine().Split(' ');
            x[i] = int.Parse(str[0])-1;
            y[i] = int.Parse(str[1])-1;
        }
    }    
}

Measured memory_bytes: 7992
#include<stdio.h>
int main(){
	char a;
	int b,c;
	while(1){scanf("%d %c %d",&b,&a,&c);
	if(a == '+'){
		printf("%d\n",b+c);
	}
		else if(a=='-'){
			printf("%d\n",b-c);
		}
		else if(a=='*'){
			printf("%d\n",b*c);
		}
		else if(a=='/'){
			printf("%d\n",b/c);
		}
		if(a=='?'){
			break;}
	}
	return 0;
}

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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
#define v vector
// Template END

int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}

signed main(){
    int n ; cin >> n ;
    v<pair<int,int>> coords(n) ;
    for( int i = 0 ; i < n ; i++ ) cin >> coords[i].first >> coords[i].second ;
    int pMax = coords[0].first + coords[0].second ;
    int pMin = pMax ;
    int mMax = coords[0].first - coords[0].second ;
    int mMin = mMax ;
    for( int i = 1 ; i < n ; i++ ){
        int temp1 = coords[i].first + coords[i].second ;
        int temp2 = coords[i].first - coords[i].second ;
        pMax = max( pMax, temp1 ) ;
        pMin = min( pMin, temp1 ) ;
        mMax = max( mMax, temp2 ) ;
        mMin = min( mMin, temp2 ) ;
    }
    cout << max( pMax - pMin, mMax - mMin ) ;
    return 0 ;   
}

Measured memory_bytes: 6396
program main
  implicit none
  integer :: HP(2)
  integer :: AT(2)
  
  read(*,*)  HP(1),AT(1),HP(2),AT(2)

  do
     HP(2) = HP(2) - AT(1)
     if (HP(2) <= 0) then
        write(*,'(a)') 'Yes'
        stop
     end if
     HP(1) = HP(1) - AT(2)
     if (HP(1) <= 0) then
        write(*,'(a)') 'No'
        stop
     end if
  end do
  
end program main


Measured memory_bytes: 2852
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <sstream>
#include <stdio.h>
#include<math.h>
#include<unistd.h>
using namespace std;

int main(){

    int N;
    cin >> N;

    int A[N];

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

    int count=0;

    while(true){

        bool exist_odd=false;

        for(int i=0;i<N;i++){
            if(A[i]%2==1){
                exist_odd = true;
            }
        }

        if(exist_odd){
            break;
        }

        for(int i=0;i<N;i++){
            A[i] = A[i] / 2;
        }

        count++;
    }

    cout << count << endl;
    
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 40;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define all(x) ((x).begin(),(x).end())


int main(){
    int a,b,c; cin>> a >> b >> c;
    bool f = false;
    FOR(i,1,b){
        if ((a*i)%b==c) f = true;
    }
    if(f) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
while true do
  n, x = gets.split.map(&:to_i)
  break if n == 0 && x == 0

  h = {}

  1.upto(n) do |i|
    1.upto(n) do |j|
      next if i == j
      t = x - (i + j)
      if t > 0 && t < n && t != i && t != j && h[[i,j,t].sort].nil?
        h[[i,j,t].sort] = 1
      end
    end
  end

  puts h.keys.size
end



Measured memory_bytes: 7120
void main()
{
    long x = rdElem;

    bool op(long len, long cnt)
    {
        if (len <= 2) return cnt <= x;
        return op((len-1)>>1, cnt+1);
    }

    long ok, ng = inf;
    while (ng - ok > 1)
    {
        long m = (ok + ng) >> 1;
        if (op(m, 0)) ok = m;
        else ng = m;
    }

    ok.writeln;
}

enum long mod = 10L^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 256
N = int(input())
W = list(map(int,input().split()))
sum_all = sum(W)
ans = float("INF")
for t in range(N):
  sum = 0
  for i in range(N):
    if t >= i:
      sum += W[i]
  ans = min(ans, abs(sum - (sum_all - sum)))
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N;
    cin >> N;
    int ans = 0;
    int digit = 1;
    rep(i,N) {
        int j = i + 1;
        if (j == 10 || j == 100 || j == 1000 || j == 10000 || j == 100000) digit++;
        if (digit % 2 == 1) ans++;
    }

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

Measured memory_bytes: 256
function main(input) {
  const args   = input.split(' ');
  const a      = parseInt(args[0], 10);
  const p      = parseInt(args[1], 10);
  const total  = a * 3 + p;
  const result = Math.floor(total / 2);
  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

int N;

void solve() {
    REP (i, N+1) {
        if (i * 108/100 == N) {
            cout << i << endl;
            return;
        }
    }
    cout << ":(" << endl;
}

int main() {
    cin >> N;
    solve();
}

Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,w,z;
    char ca,cb,cc;
    cin>>a>>b;
    cout<<(a-1)*(b-1)<<endl;
    return 0;
}


Measured memory_bytes: 3592
using System;
using System.Linq;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;
using static System.Console;

namespace program {
  class Program {
    static string Alp = "abcdefghijklmnopqrstuvwxyz";
    static void Main()
    {
      var input = ScanIntArray();
      int n = input[0];
      int m = input[1];
      bool[] isSolved = new bool[n];
      int[] WA = new int[n];
      for(int i=0; i<m; i++)
      {
        var res = ScanStrArray();
        int p = int.Parse(res[0])-1;
        if(!isSolved[p] && res[1] == "WA") WA[p]++;
        isSolved[p] |= res[1] == "AC";
      }
      
      int pe = 0;
      for(int i=0; i<n; i++){
        if(isSolved[i]) pe += WA[i];
      }
      WriteLine($"{isSolved.Count(_=>_)} {pe}");
    }
  }
  
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 17744
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int mod = 1e9 + 9;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1 ;
	//cin >> t;
	while(t--){
		int n,W;
		cin >> n >> W;
		vector<int> w(n);
		vector<ll> v(n);
		for(int i = 0; i < n; i++){
			cin >> w[i] >> v[i];
		}
		ll dp[n+1][W+1];
		for(int i = 0; i <= n; i++)
			for(int j = 0 ; j <= W; j++){
				if(i == 0 || j == 0)
					dp[i][j] = 0;
				else if(w[i-1] <= j)
					dp[i][j] = max(dp[i-1][j],v[i-1] + dp[i-1][j-w[i-1]]);
				else dp[i][j] = dp[i-1][j];
			}
		cout << dp[n][W] << endl;
	}
	return 0;
}


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

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

    int n;
    cin >> n;

    int a[n];
    int xy[n][n];
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j) xy[i][j] = -1;
    }

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

        for(int j = 0; j < a[i]; ++j) {
            int tmp;
            cin >> tmp;
            cin >> xy[i][tmp-1];
        }
    }

    int res = 0;

    for(int i = 0; i < 1<<n; ++i){
        int honest[n] = {0}; 
        int d = 0;
        for(int j = 0; j < n; ++j){
            if(i & (1<<j)){
                honest[j] = 1;
                d++;
            }
        }

        bool flg = true;
        for(int j = 0; j < n; ++j){

            if(!honest[j])continue;

            for(int k = 0; k < n; ++k){
                if(j==k || xy[j][k] == -1) continue;
                if(xy[j][k] ^ honest[k]) flg = false;
            }
   
        }
        if(flg) res = max(res, d);
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef struct{
  char mark[2];
  int value;
  int moji;
} Card;
 
int partition(Card*, int, int);
void quickSort(Card*,int ,int);
 
 
int main(){
  Card A[100001];
   int n,i,stb = 0;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%s %d",A[i].mark, &A[i].value);
    A[i].moji = i + 1;
  }
  
 quickSort(A, 0, n - 1);
 
  for(i = 0; i < n; i++){
     if(A[i].moji > A[i + 1].moji && A[i].value == A[i + 1].value){
      stb++;
      break;
    }
   }
   if(stb == 0) {
     printf("Stable\n");
   }
   else { 
     printf("Not stable\n");
   }  
   for(i = 0; i < n; i++) {
     printf("%s %d\n",A[i].mark, A[i].value);
   }  
   return 0;
   
   
}
void quickSort(Card *A,int p,int r){
   
  int q;
  if (p < r){
    q = partition(A, p, r);
    quickSort(A, p, q-1);
    quickSort(A, q+1, r);
  }
   
   
 
   
}
 
int partition(Card *A,int p,int r){
  int i, j, a;
  Card x;
   
  a = A[r].value;
  i = p - 1;
  for(j = p; j < r; j++){
    if(A[j].value <= a){
      i++;
      x = A[i];
      A[i] = A[j];
      A[j] = x;
    }
  }
  x = A[i + 1];
  A[i + 1] = A[r];
  A[r] = x;
   
  return i + 1;
}

Measured memory_bytes: 1784
a=[0]*100
a[0]=1
a[1]=1
a[2]=1
def fib(n):
    if a[n]!=0:
        return(a[n])
    elif a[n]==0:
        a[n]=(fib(n-1)+fib(n-2))
        return(a[n])
x=int(input())
print(fib(x+1))


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

const ll MOD = 1e9+7;

ll dp[10100][2][110] = {0};


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

  string K;
  cin >> K;
  int D;
  cin >> D;

  dp[0][0][0] = 1;
  rep(i, K.length()){

    int num = (K[i] - '0');
    for(int j = 0; j < 2; j++){
      for(int m = 0; m < D; m++){
        for(int d = 0; d < 10; d++){
          int ni = i+1, nj = j;
          int nm = (m + d) % D;

          if(j == 0){
            if(d > num) continue;
            if(d < num) nj = 1;
          }
          dp[ni][nj][nm] = (dp[ni][nj][nm] + dp[i][j][m]) % MOD;
        }
      }
    }
  }
  cout << (dp[K.length()][0][0] + dp[K.length()][1][0] + MOD - 1LL) % MOD << endl;

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> b(n);
  for(int i = 0; i < n; i++) cin >> b.at(i);
  
  vector<int> a(n);
  int now;
  for(int i = 0; i < n; i++){
    now = -1;
    for(int j = 0; j < n-i; j++){
      if(j+1 == b.at(j)) now = j+1;
    }
    a.at(i) = now;
    if(now == -1) break;
    b.erase(b.begin()+now-1);
  }
  
  if(now == -1) cout << now << endl;
  else{
    for(int i = n-1; i >= 0; i--){
      cout << a.at(i) << endl;
    }
  }
}

Measured memory_bytes: 256
N = int(input())
Xs = list(map(int, input().split()))
mod = 10**9 + 7
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
NNN = (10**6)
g1 = [1, 1]
inverse = [0, 1]
for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )

mxx = Xs[-1]
r = 0
r2 = 0
for i in range(N-1):
    r = (r+mul(mul(g1[N-1],inverse[i+1]),Xs[N-1]-Xs[i]))%mod
print(r)


Measured memory_bytes: 140360
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
from heapq import *
import copy

N,M=map(int,input().split())
A=list(map(int,input().split()))
XY=[list(map(int,input().split())) for i in range(M)]
data=[[] for i in range(N)]

for x,y in XY:
    data[x].append(y)
    data[y].append(x)
visitedlst=[]

ittenai=set([i for i in range(0,N)])
while ittenai:
    q=ittenai.pop()
    stack=[q]
    visited=set()
    visited.add(q)
    while stack:
        q=stack.pop()
        for p in data[q]:
            if p not in visited:
                visited.add(p)
                ittenai.remove(p)
                stack.append(p)
    visitedlst.append(visited)
lst=[]
value=0
count=0
for visited in visitedlst:
    visited=sorted([A[i] for i in list(visited)])
    for i in visited[1:]:
        lst.append(i)
    value+=visited[0]
    count+=1
if count==1:
    print(0)

elif len(lst)<(count//2-1)*2+count%2:
    print("Impossible")
else:
    lst.sort()
    value+=sum(lst[:(count//2-1)*2+count%2])
    print(value)


Measured memory_bytes: 126612
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int H,W;

	while(1){
		cin>>H>>W;
		if (H==0 && W==0)break;
		for (int i=0; i<H; i++){
			for (int j=0; j<W; j++){
				if ((i+j)%2==0){
					cout<<"#";

				}
				else cout<<".";
			}
			cout<<"\n";
		}
		cout<<endl;
	}

	return 0;
}

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

void chmax(ll &a, ll b){ if(a < b) a = b; return; }
ll n, a[16][16], dp[1<<16];

int main(){
    cin >> n;
    rep(i,n) rep(j,n) cin >> a[i][j];
    loop(i,1,1<<n){
        rep(j,n) rep(k,j) if(i>>j & i>>k & 1) dp[i] += a[j][k];
        for(int j = i; j > 0; j = (j-1)&i) chmax(dp[i], dp[j]+dp[i^j]);
    }
    cout << dp[(1<<n)-1] << endl;
    return 0;
}

Measured memory_bytes: 4120
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n,a,sum=0;
    cin>>m>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        sum+=a;
    }
    if(m-sum<0)
        cout<<-1<<endl;
    else
        cout<<m-sum<<endl;

    return 0;
}


Measured memory_bytes: 3624
import numpy as np

a = [list(map(int,input().split())) for _ in range(3)]

n = int(input())

b = list([int(input()) for _ in range(n)])

c = np.zeros(9).reshape(3,3)

for k in b:
    for i in range(3):
        for j in range(3):
            if k == a[i][j]:
                c[i,j]=1

if (max(c.sum(axis=0))==3) or (max(c.sum(axis=1))==3) or \
    (sum([c[i,i] for i in range(3)])==3) or (c[2,0]+c[1,1]+c[0,2]==3):
    print("Yes")
else:
    print("No")

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

int mp[4] = {0, 3, 2, 1};

int main() {
    int x, y; cin >> x >> y;
    if(x == 1 && y == 1) cout << 1000000 << endl;
    else {
        int ans = 0;
        if(x < 4) ans += mp[x];
        if(y < 4) ans += mp[y];
        cout << ans*100000 << endl;
    }
}

Measured memory_bytes: 256
x,k,d = gets.chomp.split(' ').map(&:to_i)
x = x.abs

# 場合分け
#if (x >= d)
  hoge = x / d
  if (hoge >= k)
    puts x - k*d
    exit
  else
    x -= d * hoge
    k -= hoge
    if (k.even?)
      puts x
      exit
    else
      puts [(x + d).abs, (x - d).abs].min
      exit
    end
  end
#end

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

int main()
{
	int n, mini, res, R;
	cin >> n >> mini >> R;
	res = R - mini;
	mini = min(mini, R);
	for (int i = 2; i < n; i++) {
		cin >> R;
		res = max(res, R - mini);
		mini = min(mini, R);
	}
	cout << res << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a, ans = 1000000000, cnt = 10000000;
    for (int i = 0; i < n; i++) {
        cin >> a;
        ans = min(cnt, ans);
        cnt = 0;
        while (a % 2 == 0) {
            a /= 2;
            cnt++;
        }
        
    }
    cout << ans << endl;
}

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

// 分解するコードを書くのは面倒なので以下を使ってください
std::vector<std::string>	split(std::string&string, std::regex&&pattern)
{
	return std::vector<std::string>(
		std::sregex_token_iterator(string.begin(), string.end(), pattern, -1),
		std::sregex_token_iterator()
		);
}

int main(int argc, char *argv[])
{
	std::string	line;
	std::getline(std::cin, line);

	auto splitStrings = split(line, std::regex("\\s+"));	// c/c++の場合は文字列内で\を使用する際は\\と二つ続ける。
	if (splitStrings.size() != 1) {
		return	-1;
	}

	auto input = std::atoi(splitStrings[0].c_str());		// あまりc++っぽくない。cの文字列を渡して整数にする。
	auto cubic = input*input*input;
	std::cout << cubic << std::endl;

	return 0;
}


Measured memory_bytes: 3272
#include<bits/stdc++.h>
#define ll                      long long int
#define pb                      push_back
#define mp                      make_pair
#define in                      insert
#define all(x)                  (x).begin(),(x).end() 
#define rep(i,a,n)              for(int i=0;i<n;++i)
#define per(i,a,n)              for(int i=n-1;i>=0;--i)
#define mod                     1000000007
using namespace std;

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

    int n,m;
    cin>>n>>m;
    cout<<(n*(n-1)/2)+(m*(m-1)/2)<<'\n';
    
    return 0;
}


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

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

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

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

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int n,m;
  scanf("%d%d",&n,&m);
  int A[n];
  int B[n];
  for(int i=0;i<n;i++){
    A[i]=0;
    B[i]=0;
  }

  for(int i=0;i<m;i++){
    int p;
    scanf("%d",&p);
    p--;
    char s[20];
    scanf("%s",s);

    if(s[0]=='W'){
      if(A[p]==0){
        B[p]++;
      }
    }
    else{
      A[p]++;
    }
  }

  int ac=0;
  int pe=0;
  for(int i=0;i<n;i++){
    if(A[i]!=0){
      ac++;
      pe+=B[i];
    }
  }

  printf("%d %d\n",ac,pe);
  
  return 0;
}

Measured memory_bytes: 2488
n=int(input())
if n<2**1:
  print(1)
elif n<2**2:
  print(2)
elif n<2**3:
  print(4)
elif n<2**4:
  print(8)
elif n<2**5:
  print(16)
elif n<2**6:
  print(32)
elif n<2**7:
  print(64)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
#define ll long long
int main(){
    int i,j;
    int n,a;
    int ans;
    bool f;
    cin >> n ;
    ans =n;
    char s[n][n];
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            cin >> s[i][j];
        }
    }
    for(a=0;a<n;a++){
        f=true;
        for(i=0;i<n;i++){
            for(j=0;j<n;j++){
                if(s[i][(j+n-a)%n]!=s[j][(i+n-a)%n]){
                    ans--;
                    f=false;
                    break;
                }
            }
            if(!f){
                break;
            }
        }
    }
    cout << ans*n << endl;
    return 0;
}

Measured memory_bytes: 384
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
low, high = 2, 2

for a in A[::-1]:
    low += (-low) % a
    high -= high % a
    high += (a-1)

if low > high:
    print(-1)
else:
    print(low, high)

Measured memory_bytes: 14252
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>
#include <memory>
#include <cassert>

#include <map>
#include <vector>
#include <queue>


using namespace std;

typedef long long LL;

int a, b, c;

int main() {
    
    cin >> a >> b;
    cout << a + b / 2 << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int N = 1e3+5;
const int INF = 0x3f3f3f3f;

int dp[50][N],v[50];
int h,w,k;

//void print(int n,int cnt){
//	printf("%d    ",n);
//	for(int i = 1;i < cnt;++i) printf("%d ",ss[i]);
//	printf("\n");
//}

inline int check(int cnt){
	int res = 0,lastline = 0;
	for(int i = 1;i <= w;++i){
		int Max = 0;
		for(int j = 1;j < cnt;++j){
			int t = dp[v[j]][i]-dp[v[j-1]][i]-dp[v[j]][lastline]+dp[v[j-1]][lastline];
			//if(t > k) return INF;
			Max = max(Max,dp[v[j]][i]-dp[v[j-1]][i]-dp[v[j]][lastline]+dp[v[j-1]][lastline]);
		}
		
		if(Max > k){
			if(i == 1) return INF;
			else{
				res++;
				lastline = i-1;
			}
		}
	}
	return res;
}

int main()
{
	scanf("%d%d%d",&h,&w,&k);
	for(int i = 1;i <= h;++i)
		for(int j = 1;j <= w;++j)
			scanf("%1d",&dp[i][j]),dp[i][j] += dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];		
	
	int ans = h+w-2,cnt;
	for(int i = 0;i < (1 << (h-1));++i){
		cnt = 0;
		v[cnt++] = 0;
		for(int j = 0;j < h-1;++j)
			if((1 << j) & i) v[cnt++] = j+1;
		v[cnt++] = h;
		
		//for(int j = 0;j < cnt;++j) printf("%d ",v[j]);
		//printf("\n");
		if(cnt-2 >= ans) continue;
		
		ans = min(ans,check(cnt)+cnt-2);
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n,c[1000],s[1000],f[1000];
int depart (int x){
    int t = 0;
    for(int i=x;i<n;i++){
        if(t<=s[i]){
            t = s[i]+c[i];
        }
        else{
            int temp = t - s[i];
            int need = f[i] - (temp % f[i]);
            if(need==f[i])need=0;
            t += (need+c[i]);
        }
    }
    return t;
}
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<n;i++){
        cin>>c[i]>>s[i]>>f[i];
    }
    for(int i=1;i<=n;i++){
        cout<<depart(i)<<newl;
    }

}


Measured memory_bytes: 256
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main()
{
    int n, x, t;
    cin >> n >> x >> t;

    int y = (n + x- 1) / x;

    cout << (t * y) << endl;
    return 0;
}


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

using namespace std;

#define allof(x) (x).begin(), (x).end()

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

const int MAXN = 1e5 + 5;

int N;

vector<int> adj[MAXN];
int edges[MAXN];
char col[MAXN];
bool removed[MAXN];
int remain;

//if we changed the parity of (# times going into x), how does the value change?
int fixval(int x){
    return (edges[x] % 2 == 0 && col[x] == 'W') || (edges[x] % 2 == 1 && col[x] == 'B') ? 1 : -1;
}

int reduce = 0;

pii bestup[MAXN][2];
pii bestdown[MAXN][2];

void insert_pii(pii arr[2], pii to_ins){
    if(to_ins > arr[0]){
        arr[1] = arr[0];
        arr[0] = to_ins;
    } else if (to_ins > arr[1]){
        arr[1] = to_ins;
    }
}

void dfs(int pos, int par){
    bestup[pos][0] = pii(-1e9, -1);
    bestup[pos][1] = pii(-1e9, -2);

    bestdown[pos][0] = pii(-1e9, -1);
    bestdown[pos][1] = pii(-1e9, -2);

    for(int i : adj[pos]){
        if(i == par || removed[i]){
            continue;
        }
        dfs(i, pos);

        insert_pii(bestup[pos], pii(bestup[i][0].first + 1 + fixval(pos), i));
        insert_pii(bestdown[pos], pii(bestdown[i][0].first + 1 + fixval(pos), i));
    }
    
    reduce = max(reduce, bestup[pos][0].first - fixval(pos));
    reduce = max(reduce, bestdown[pos][0].first);

    if(bestup[pos][0].second == bestdown[pos][0].second){
        reduce = max(reduce, bestup[pos][0].first + bestdown[pos][1].first - fixval(pos));
        reduce = max(reduce, bestup[pos][1].first + bestdown[pos][0].first - fixval(pos));
    } else {
        reduce = max(reduce, bestup[pos][0].first + bestdown[pos][0].first - fixval(pos));
    }

    insert_pii(bestup[pos], pii(fixval(pos), pos));
    insert_pii(bestdown[pos], pii(0, pos));
}

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

    cin >> N;

    remain = N;
    for(int a = 1; a <= N - 1; a++){
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);

        edges[u]++;
        edges[v]++;
    }

    cin >> (col + 1);

    queue<int> q;
    for(int a = 1; a <= N; a++){
        if(edges[a] == 1 && col[a] == 'B'){
            q.push(a);
        }
    }

    while(!q.empty()){
        int fr = q.front();
        q.pop();

        remain--;
        removed[fr] = true;

        for(int i : adj[fr]){
            edges[i]--;
            if(edges[i] == 1 && col[i] == 'B'){
                q.push(i);
            }
        }
    }

    if(remain == 0){
        cout << 0;
        return 0;
    }

    int start = -1;
    int ans = 2 * (remain - 1);
    for(int a = 1; a <= N; a++){
        if(!removed[a]){
            start = a;
            ans += (fixval(a) == 1);
        }
    }

    if(start == -1){
        cout << 0;
    } else if (remain == 1){
        cout << (col[start] == 'W');
    } else if (remain == 2){
        cout << 2;
    } else {
        dfs(start, -1);
        cout << ans - reduce;
    }
}


Measured memory_bytes: 18304