akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w,n;
    cin>>h>>w>>n;
    int tate[h]={},yoko[w]={};
    map<pair<int,int>,int>m;
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        x--,y--;
        tate[x]++;
        yoko[y]++;
        m[{x,y}]=1;
    }
    int maxtate=*max_element(tate,tate+h),maxyoko=*max_element(yoko,yoko+w);
    int ans=maxtate+maxyoko;
    vector<int>mx;
    vector<int>my;
    for(int i=0;i<h;i++)if(tate[i]==maxtate)mx.push_back(i);
    for(int i=0;i<w;i++)if(yoko[i]==maxyoko)my.push_back(i);
    for(int i=0;i<mx.size();i++){
        for(int j=0;j<my.size();j++){
            if(m[{mx[i],my[j]}]==0){
               cout<<ans<<endl;
               return 0;
            }
        }
    }
    cout<<ans-1<<endl;
    return 0;
}

Measured memory_bytes: 28432
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


//////////////////////////////////////
using namespace std;
#define dp(arg) do { cout << #arg << ":"; dprint(arg); } while(0)

template <typename T> void dprint(T arg) { cout << arg << "\n"; }
template <typename T> void dprint(const vector<T>& arg) { for_each(begin(arg), end(arg), [](T value){ cout << value << " "; }   ); cout << "\n";  }
template <typename T> void dprint(const vector<vector<T>>& arg) { for_each(begin(arg), end(arg), [=](vector<T> arg2){ dprint(arg2); cout << "\n";} );  }

// #define dprint(arg) ;
//////////////////////////////////////

using namespace std;
int main() {
    string str;
    stack<int> st;
    int x, y;

    while (cin >> str) {
        if(str == "+") {
            x = st.top(); st.pop();
            x+= st.top(); st.pop();
            st.push(x);
        } else if(str == "*") {
            x = st.top(); st.pop();
            x*= st.top(); st.pop();
            st.push(x);
        } else if(str == "-") {
            x = st.top(); st.pop();
            y = st.top(); st.pop();
            st.push(y-x);
        } else {
            st.push(stoi(str));
        }
    }
    cout << st.top() << "\n";
}



Measured memory_bytes: 3148
n, x = gets.chomp.split(" ").map(&:to_i)
l = gets.chomp.split(" ").map(&:to_i)
l.unshift(0)

d = 0
cnt = 0
1.upto(n + 1) do |i|
  d = d + l[i - 1]
  break if d > x
  cnt += 1
end
puts cnt


Measured memory_bytes: 1788
import sys
a = input()
l = ['+', '-']
for i in l:
  for j in l:
     for k in l:
        eq = a[0] + i + a[1] + j + a[2] + k + a[3] 
        if eval(eq) == 7:
          print(eq, '=7', sep='')
          sys.exit()

Measured memory_bytes: 3060
arr = str(input())
arr = list(arr)
arr = list(map(int,arr))
a = arr[0]
b = arr[1]
c = arr[2]
d = arr[3]
a1 = str(arr[0])
b1 = str(arr[1])
c1 = str(arr[2])
d1 = str(arr[3])

if a+b+c+d == 7:
    print(a1+'+'+b1+'+'+c1+'+'+d1+'=7')
elif a+b+c-d == 7:
    print(a1+'+'+b1+'+'+c1+'-'+d1+'=7')
elif a+b-c+d == 7:
    print(a1+'+'+b1+'-'+c1+'+'+d1+'=7')
elif a-b+c+d == 7:
    print(a1+'-'+b1+'+'+c1+'+'+d1+'=7')
elif a+b-c-d == 7:
    print(a1+'+'+b1+'-'+c1+'-'+d1+'=7')
elif a-b+c-d == 7:
    print(a1+'-'+b1+'+'+c1+'-'+d1+'=7')
elif a-b-c+d == 7:
    print(a1+'-'+b1+'-'+c1+'+'+d1+'=7')
elif a-b-c-d == 7:
    print(a1+'-'+b1+'-'+c1+'-'+d1+'=7')


Measured memory_bytes: 3064
from fractions import gcd

A,B,C,D = map(int, input().split())

lcm = (C*D) // gcd(C,D)

b_sum = B - ((B//C) + (B//D) - (B//lcm))

a = A-1
a_sum = a - ((a//C) + (a//D) - (a//lcm))

print(b_sum - a_sum)

Measured memory_bytes: 5048
#include<bits/stdc++.h>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <stdlib.h>
#include<string>
#define mp make_pair
#define ss second
#define ff first
#define pb push_back
#define io ios_base::sync_with_stdio;cin.tie(0);cout.tie(0)
#define READ freopen("input.txt","r", stdin)
#define mem(a,b)     memset(a, b, sizeof(a))
#define snd(a) scanf("%d",&a)
#define snl(a) scanf("%lld",&a)
#define snul(a) scanf("%ull",&a)
#define rep(i,k,n) for(int i=k;i<n;i++)
#define rev(j,n,k) for(int j=n;j>=k;j--)
#define TC int tc;cin>>tc;while(tc--)
#define FastRead ios_base::sync_with_stdio(false);cin.tie(NULL);

#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a / __gcd(a, b) ) * b)

#define PI 2*acos(0.0)
#define MAX 1000000000
#define inf 1e18
#define MOD 1000000007
#define case(i) "Case "<<i++<<": "
#define nscase(i) "Case "<<i++<<":"
#define base(n,b) floor(log(n)/log(b))+1
#define onecnt(x) __builtin_popcount(x)
#define to_binary(n) bitset<8>(n).to_string()
#define endl '\n'
#define esc cout<<"\n"

/*------------------------------Graph Moves----------------------------*/
///const int fx[]= {+1,-1,+0,+0};
///const int fy[]= {+0,+0,+1,-1};
///const int fx[]= {+0,+0,+1,-1,-1,+1,-1,+1};  // Kings Move
///const int fy[]= {-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
///const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
///const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef std::map<long long,int> mli;
typedef std::map<long long,long long> mll;
typedef std::map<int,int> mii;
using namespace __gnu_pbds;
typedef tree<
ll,
null_type,//set to another type while using map
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;

template <typename T>
std::string toString( T Number )
{
    std::ostringstream ss;
    ss << Number;
    return ss.str();
}


const ll ten5=100000;
const ll ten6 =1000000;
const ll ten7 =10000000;
const ll ten8 =100000000;
const ll ten9 =1000000000;
const ll mod=1000000007;


int main()
{
    io;

    int n,i,j,k=0;
    cin>>n;
    string s,t;
    map<string,int>m;
    rep(i,0,n)
    {
        cin>>s;
        m[s]++;
        if(k<m[s])k=m[s];
    }
    map<string,int>::iterator it;
    for(it=m.begin();it!=m.end();it++)
    {
        if(it->ss==k)cout<<it->ff<<endl;
    }

    return 0;
}


Measured memory_bytes: 19144
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if (a==b)
    {
        cout <<c;
    }
    else if (a==c)
    {
        cout <<b;
    }
    else
    {
        cout <<a;
    }
    return 0;
}


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

struct edge{
    int to,cost;
};

int main(){
    int N;
    cin >> N;
    vector<int> c(N+1,-1);
    vector<edge> v[N+1];
    rep2(i,1,N){
        int a,b,c;
        cin >> a >> b >> c;
        v[a].push_back({b,c});
        v[b].push_back({a,c});
    }
    c[1]=0;
    queue<int> que;
    que.push(1);
    while(!que.empty()){
        int  v_cur =que.front();
        que.pop();

        for(auto v_next : v[v_cur] ){
            if(c[v_next.to]!=-1) continue;
            c[v_next.to]=(c[v_cur]+v_next.cost)%2;
            que.push(v_next.to);
        }
    }

    rep2(i,1,N+1){
        cout << c[i]<<endl;

    }
    
}

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

int main() {
    string s;
    cin >> s;
    if (s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 3628
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn readu() -> usize {
    read::<usize>()
}

#[allow(dead_code)]
fn readi() -> i32 {
    read::<i32>()
}

fn main() {
    input! {
        mut s: chars,
    }
    let M = 1000_000_007;
    s.reverse();
    let mut dp = [[0; 15]; 100010];
    dp[0][0] = 1;
    let mut keta = 1;
    for i in 0..s.len() {
        let c = s[i];
        for j in 0..13 {
            if c == '?' {
                for k in 0..10 {
                    let m = (j + k * keta) % 13;
                    dp[i + 1][m] += dp[i][j];
                    dp[i + 1][m] %= M;
                }
            } else {
                let digit = c as usize - 48;
                let m = (j + digit * keta) % 13;
                dp[i + 1][m] += dp[i][j];
                dp[i + 1][m] %= M;
            }
        }
        keta = (keta * 10) % 13;
    }
    println!("{}", dp[s.len()][5]);
}


Measured memory_bytes: 10108
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
//これは、頭が悪く競プロが世界で一番できないHIR180が
//IOI2014日本代表になるまでのN日間の記録である。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define f first
#define s second
#define rep(i,x) for(int i=0;i<x;i++)
bool used[100005]={};
int num[100005];
int main()
{
	srand((unsigned int)time(NULL));
	int n,m; scanf("%d%d",&n,&m);
	num[0]=num[n+1]=-INF;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&num[i]);
	}
	priority_queue<P,vector<P>,greater<P> >que;
	for(int i=1;i<=n;i++)
	{
		if(num[i]>num[i-1] && num[i]>num[i+1])
		{
			que.push(mp(m-num[i],i));
		}
	}
	int cur,id;
	while(!que.empty())
	{
		P p=que.top();
		que.pop();
		cur=p.f;
		id=p.s;num[id]=-INF;
		if(id>1 && num[id-1]>num[id-2] && num[id-1]>num[id])
		{
			que.push(mp(m-num[id-1]+cur,id-1));
		}
		if(id<n && num[id+1]>num[id+2] && num[id+1]>num[id])
		{
			que.push(mp(m-num[id+1]+cur,id+1));
		}
	}
	printf("%d\n",cur);
}

Measured memory_bytes: 2044
#include<stdio.h>

static const int N = 1000;

int main(){
  int n,i,j,flag;
  int A[N+1];
  int swap,sort=0;

  scanf("%d",&n);

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

  flag=1;
  i=0;
  while(flag){
  flag=0;
    for(j=n-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	swap=A[j];
        A[j]=A[j-1];
        A[j-1]=swap;
        flag=1;
        sort++;
      }
     }
    i++;
   }
    for(i=0;i<n;i++){
      if(i<n-1) printf("%d ",A[i]);
      else printf("%d\n",A[i]);
    }
    printf("%d\n",sort);

    return 0;
   } 

Measured memory_bytes: 604
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d, e, k int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&d)
	fmt.Scan(&e)
	fmt.Scan(&k)
	s := "Yay!"
	if e-a > k {
		s = ":("
	}
	fmt.Println(s)
}


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

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n; i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    int ali=0,bob=0;

    for(int i=0;i<n; i++){
        if(i%2==0){
            ali+=a[i];
        }
        else if(i%2==1){
            bob+=a[i];
        }
    }
    cout<<ali-bob<<endl;
    

}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define int long long
#define pii pair<int,int>
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans; 
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	int c[n+1]={0};
	for(int i=0;i<n;i++){
		int j=lower_bound(b,b+n,a[i])-b;
		int k=upper_bound(b,b+n,a[i])-b;
		if(j==k)continue;
		k--;
		j-=i;
		k-=i;
		//cout<<j<<" "<<k<<" "<<endl;
		if(j<0){
			c[(j+n)%n]++;
			if(k<0){
			    if(k+1!=0)
			    c[(k+1-n)%n]--;
			}
			else{
			    c[0]++;
			    c[k+1]--;
			}
		}
		else{
			c[j]++;
			c[k+1]--;
		}
	}
	int x=0;
	for(int i=0;i<n;i++){
		x+=c[i];
		//cout<<x<<" ";
		if(x==0){
		    
			cout<<"Yes"<<endl;
			for(int j=0;j<n;j++){
			    //assert(b[(j+i)%n]!=a[j]);
				cout<<b[(j+i)%n]<<" ";
			}
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 9800
#include <iostream>
#include <limits.h>
using namespace std;

int main() {
	int a, b, c, ans = 0;
	cin >> a >> b >> c;
	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
	    int aa = (b + c) / 2;
	    int bb = (c + a) / 2;
	    int cc = (a + b) / 2;
	    a = aa, b = bb, c = cc;
	    ans++;
	    if (ans > 10000) break;
	}
	if (ans > 10000) cout << -1;
	else cout << ans;
	return 0;
}


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

signed
main(){
		int b;
		while(cin >> b && b!=0)
		{
				int l=1,r=2;
				int sum = 1;
				while(1)
				{
						if(sum < b)
						{
						sum += r;
						r++;
						}
						else if(b < sum)
						{
						sum -= l;
						    l++;
						}else
						{
						break;
						}
				}
				cout << l << " " << r-l << endl;
		}
}


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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, y;
  cin >> x >> y;
  int ans = 2 * (int)1e9;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      int a = x, b = y, cnt = 0;
      if (i && j) {
        a = -a;
        b = -b;
        cnt = 2;
      } else if (i) {
        a = -a;
        cnt = 1;
      } else if (j) {
        b = -b;
        cnt = 1;
      }
      if (b - a >= 0) {
        ans = min(ans, cnt + b - a);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3652
H,W,K=map(int,input().split())
x1,y1,x2,y2=map(lambda x:int(x)-1,input().split())

pond=[list(input()) for _ in range(H)]

inf=float("inf")
cost=[[inf]*W for _ in range(H)]
cost[x1][y1]=0
from heapq import heappop,heappush
hq=[(0,x1,y1)]

while hq:
    t,x,y=heappop(hq)
    if x==x2 and y==y2:
      print(t)
      exit()
    #北へ
    for i in range(1,K+1):
        if x-i<0 or pond[x-i][y]=="@" or cost[x-i][y]<t+1:
            break
        if cost[x-i][y]>t+1:
            cost[x-i][y]=t+1
            heappush(hq,(t+1,x-i,y))
    #東へ
    for i in range(1,K+1):
        if y+i>W-1 or pond[x][y+i]=="@" or cost[x][y+i]<t+1:
            break
        if cost[x][y+i]>t+1:
            cost[x][y+i]=t+1
            heappush(hq,(t+1,x,y+i))
    #南へ
    for i in range(1,K+1):
        if x+i>H-1 or pond[x+i][y]=="@" or cost[x+i][y]<t+1:
            break
        if cost[x+i][y]>t+1:
            cost[x+i][y]=t+1
            heappush(hq,(t+1,x+i,y))
    #西へ
    for i in range(1,K+1):
        if y-i<0 or pond[x][y-i]=="@" or cost[x][y-i]<t+1:
            break
        if cost[x][y-i]>t+1:
            cost[x][y-i]=t+1
            heappush(hq,(t+1,x,y-i))

print(-1)



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

int main() {

    string N;
    cin >> N;

    ll sum = 0;
    rep(i, N.length()) {
        sum += (N[i] - '0');
    }

    if (sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005
#define PI 3.14159265358979323846264338327950
int main()
{
    _FastIO;
    cout.precision(20);
    int a , b , h , m;
    cin >> a >> b >> h >> m;
    long double rad = PI * 2 * ( (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);

    long double ans = (long double)(a * a + b * b) - (long double)(2 * a * b * cos(rad));
    cout << fixed << sqrtl(ans) << endl;
    return 0;
}


Measured memory_bytes: 4172
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int subsum[][] = new int[n][n];
		int max = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				int k = sc.nextInt();
				max = Math.min(max, k);
				if (i == 0 && j == 0) {
					subsum[i][j] = k;
				} else if (i == 0) {
					subsum[i][j] = subsum[i][j - 1] + k;
				} else if (j == 0) {
					subsum[i][j] = subsum[i - 1][j] + k;
				} else {
					subsum[i][j] = subsum[i - 1][j] + subsum[i][j - 1] - subsum[i - 1][j - 1] + k;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = i; k < n; k++) {
					for (int l = j; l < n; l++) {
						int tmp1, tmp2, tmp3;
						tmp1 = tmp2 = tmp3 = 0;
						if (0 < i && 0 < j) {
							tmp1 = subsum[i - 1][j - 1];
						}
						if (0 < i) {
							tmp2 = subsum[i - 1][l];
						}
						if (0 < j) {
							tmp3 = subsum[k][j - 1];
						}
						max = Math.max(max, subsum[k][l] - tmp2 - tmp3 + tmp1);
					}
				}
			}
		}
		System.out.println(max);
	}

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

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

int c[20];
int a[20][20];
int s[20];

int main(){
    int n,m,x; cin >> n >> m >> x;
    for(int i=0;i<n;i++){
        cin >> c[i];
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    int sm=(1<<n);
    int ans=1e9;
    for(int i=0;i<sm;i++){
        int cost=0;
        for(int j=0;j<n;j++) s[j]=0;
        for(int j=0;j<n;j++){
            if(i & (1<<j)){
                cost+=c[j];
                for(int k=0;k<m;k++){
                    s[k]+=a[j][k];
                }
            }
        }
        bool f=true;
        for(int j=0;j<m;j++){
            if(s[j]<x) f=false;
        }
        if(f) ans=min(ans,cost);

    }
    if(ans==1e9) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
   
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	static final long MOD = 1000000007L;
	static long modpow(long n, long y){
		if(y == 0){
			return 1;
		}else if(y == 1){
			return n % MOD;
		}else{
			if(y % 2 == 0){
				long r = modpow(n , y / 2);
				return (r * r) % MOD;
			}else{
				long r = modpow(n , y / 2);
				long r2 = (r * r) % MOD;
				return (r2 * n) % MOD;				
			}
		}
	}
	static long modinv(long n){
		return modpow(n , MOD - 2);
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);				
		int N = sc.nextInt();
		long A[] = new long[N];
		long S = 0;
		for(int i = 0 ; i < N ; ++i){
			A[i] = sc.nextLong();
			S = (S + A[i]) % MOD;
		}
		long ret = S * S;
		for(int i = 0 ; i < N ; ++i){
			long A2 = A[i] * A[i];
			A2 = A2 % MOD;
			ret = (ret + MOD - A2) % MOD;
		}
		ret = (ret * modinv(2)) % MOD;
		System.out.println(ret);
	}
}


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

int main() {
    int N; cin >> N;
    vector<int> ans(N+1);

    for (int i = 1; i < 101; i++){
        for (int j = 1; j < 101; j++){
            for (int k = 1; k < 101; k++){
                int x = i*i + j*j + k*k + i*j + j*k + k*i;
                if(x <= N){
                    ans[x]++;
                }
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    string s,t; cin >> s >> t;
    cout << t + s << endl;

}

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


#define ll long long
#define MOD 1000000007
#define PI 3.1415


int main(){
    int n;
    cin>>n;
    
    set<string> a;
    string d;
    for(int i=0;i<n;i++){
        cin>>d;
        a.insert(d);
    }
    
    cout<<a.size()<<endl;
}



Measured memory_bytes: 19212
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String O = sc.next();
		String E = sc.next();

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < O.length(); i++) {
			sb.append(O.charAt(i));
			if (i < E.length()) {
				sb.append(E.charAt(i));
			}
		}

		System.out.println(sb.toString());
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


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

int main() {
int N; cin >> N; // 配列サイズ
  bool flag = true;
  int ret;
vector<int> a(N);
for (int i = 0; i < N; ++i) cin >> a[i]; // a の入力

// 累積和
vector<int> s(N+1, 0); // s[0] = 0 になる
for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

  for(int i = 0;i < N+1;i++){
    if(flag == true){
      ret = abs(s[i] - s[N]);
      flag = false;
    }
    else
      if(ret >= abs(s[i] -(s[N] - s[i])))
        ret = abs(s[i]-(s[N]-s[i]));
  }
  cout << ret << endl;
  
}


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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  
  int cnt = 0;
  for(int i = 1, j = 1; i <= s.size() && j <= t.size(); ++i, ++j) {
    if(s[i - 1] != t[j - 1]) {
      ++cnt;
    }
  }
  
  cout << cnt << "\n";
  return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s; cin >> s;
    int k; cin >> k;
    int rest = k;
    string ans;
    for(int i=0;i<s.size();i++){
        if(s[i] == 'a'){
            ans += 'a';
        }else if((26 - (s[i] - 'a')) <= rest){
            rest -= (26 - (s[i] - 'a'));
            ans += 'a';
        }else{
            ans += s[i];
        }
    }
    // cout << ans << endl;
    ans[ans.size()-1] = char(ans[ans.size()-1] + (rest % 26));
    cout << ans << endl;
}

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

bool checkPali(string s){
   int p1 = 0, p2 = s.length() - 1;
   while(p1 < p2){
      if(s[p1] != s[p2]){
         return false;
      }
      p1 ++, p2 --;
   }
   if(s.length() % 2 == 0){
      if(s[p1] != s[p2]){
         return false;
      }
   }
   return true;
}

int main(){
 string s;
 cin >> s;
 int n = s.length();
 int endFirstCond = (n - 1)/2;
 int startSecondCond = (n + 3)/2;
 if(checkPali(s) and checkPali(s.substr(0, endFirstCond)) and checkPali(s.substr(startSecondCond - 1,  n - startSecondCond + 1))){
    cout << "Yes" << endl;
 }else{
    cout << "No" << endl;
 }
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int n,m;

int main(){
    cin >> n >> m;
    vector<int> w(n,1);
    w[0]=0;
    vector<int> r(n,0);
    r[0]=1;
    vector<int> x(m);
    vector<int> y(m);
    Rep(i,m){
        cin >> x[i] >> y[i];
    }
    Rep(i,m){
        if(r[x[i]-1]>0){
            r[y[i]-1]+=w[y[i]-1]+1;
            r[x[i]-1]--;
            w[y[i]-1]=0;
        }else if(r[y[i]-1]>0){
            r[y[i]-1]++;
            w[x[i]-1]--;
        }else{
            w[y[i]-1]+=1;
            w[x[i]-1]--;
        }
    }
    int res=0;
    Rep(i,n){
        if(r[i]>0){
            res++;
        }
    }
    put(res);
    return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  string s, t;
  cin >> N >> s >> t;
  int ans = (s[0] == t[0] ? 3 : 6);
  int i = (s[0] == t[0] ? 1 : 2);
  while(i < N) {
    if(s[i] == t[i]) {
      if(s[i-1] == t[i-1]) {
	(ans *= 2) %= mod;
      } else {
	(ans *= 1) %= mod;
      }
      i++;
    } else {
      if(s[i-1] == t[i-1]) {
	(ans *= 2) %= mod;
      } else {
	(ans *= 3) %= mod;
      }
      i += 2;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int N,D;
  cin >> N >> D;

  int d = 2*D+1;
  if (N % d == 0) {
    cout << N / d << "\n";
  } else {
    cout << N / d + 1 << "\n";
  }

  return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  int yoko = W + 2;
  vector<string> strVec(H);
  for(int i = 0 ; i < H ; i++) {
    string str = "";
    cin >> str;
  	strVec.at(i) = "#" + str + "#"; 
  }
  string ue = "";
   for(int i = 0 ; i < yoko ; i++) {
     ue += "#";
  }
  cout << ue << endl;
  for(int i = 0 ; i < H ; i++) {
     cout << strVec.at(i) << endl;
  }
  cout << ue << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  string s;
  cin >> s;
  ll n = sz(s)+1;
  vl a(n, 0);
  rep(i,sz(s)){
    if(s[i]=='<'){
      a[i + 1] = a[i] + 1;
    }
  }
  for(ll i=sz(s)-1;i>=0;i--){
    if(s[i]=='>'){
      a[i] = max(a[i + 1] + 1,a[i]);
    }
  }
  ll ans = 0;
  rep(i, n){
    ans += a[i];
  }
  print(ans);
}


Measured memory_bytes: 7720
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

x = inint()

ans = 0

for i in range(1,33):
    for j in range(2,10):
        if ans < i**j <= x:
            ans = i**j

print(ans)


Measured memory_bytes: 61548
#include <stdio.h>

int main(void)
{
	double l[20], sum, mid, v[4];
	int i, j;
	char cm;
	
	while (scanf("%lf%c%lf%c%lf%c%lf%c%lf%c%lf%c%lf%c%lf%c%lf%c%lf%c%lf%c%lf"
	, &l[0], &cm, &l[1], &cm, &l[2], &cm, &l[3], &cm, &l[4], &cm, &l[5], &cm, &l[6], &cm, &l[7], &cm, &l[8], &cm, &l[9], &cm, &v[1], &cm, &v[2]) != EOF){
		sum = 0;
		for (i = 0; i < 10; i++)sum += l[i];
		
		mid = sum * v[1] / (v[1] + v[2]);
		sum = 0;
		for (i = 0; i < 10; i++){
			sum += l[i];
			if (sum >= mid){
				printf("%d\n", i + 1);
				break;
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 624
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin>>n;
  ll x,y;
  cin>>x>>y;
  n -= 2;
  ll z = 0;
  REP(i,n) {
    ll a;
    cin>>a;
    z ^= a;
  }
  ll p220 = 1 << 20;
  ll mask = p220 - 1;
  vecll mn(4, p220);
  REP(i,p220) {
    if (i >= x) break;
    int idx = 0;
    ll xl = x & mask;
    if (i > xl) ++idx;
    ll yl = y & mask;
    if (yl + i >= p220) idx+=2;
    ll bits = (xl + p220 - i) ^ (yl + i);
    bits &= mask;
    if (bits == (z & mask)) {
      mn[idx] = min(mn[idx], (ll)i);
    }
  }
  REP(i,p220) {
    ll ih = ((ll)i) << 20;
    if (ih >= x) break;
    ll mnj = p220;
    REP(j,4) {
      if (mn[j] == p220) continue;
      ll nx = x - ih - mn[j];
      ll ny = y + ih + mn[j];
      if (nx <= 0) continue;
      if ((nx ^ ny) == z) {
        mnj = mn[j];
      }
    }
    if (mnj < p220) {
      cout<<(ih+mnj)<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int n;
	while(scanf("%d",&n),n) {
		for(int i=0;i<n;i++) {
			int pm,pe,pj;
			scanf("%d %d %d",&pm,&pe,&pj);
			if(max(pm,max(pe,pj))==100||(pm+pe)>=180||(pm+pe+pj)>=240) {
				printf("A\n");
			}else if((pm+pe+pj)>=210||((pm+pe+pj)>=150&&max(pm,pe)>=80)) {
				printf("B\n");
			}else {
				printf("C\n");
			}
		}
	}
}

Measured memory_bytes: 1012
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define FLOAT setprecision(16)
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
#define INSIDE(i,j,H,W) ((i) >= 0 && (i) < (H) && (j) >= 0 && (j) < (W))
#define YesNo(b) (b ? "Yes" : "No")
#define YESNO(b) (b ? "YES" : "NO")
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const double EPS = 1.0e-9;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }

// all_of
// partial_sum, adjacent_difference

#if _DEBUG
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#endif

#if 1234567891
#include <array>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

string s, t;
int main() {
	cin >> s >> t;
	REPM(i, s.size() - t.size() + 1, 0) {
		bool ok = true;
		REP(k, 0, t.size()) {
			if (s[i + k] != '?' && s[i + k] != t[k]) ok = false;
		}
		if (ok) {
			copy(t.begin(), t.end(), s.begin() + i);
			for (auto& c : s) {
				if (c == '?') c = 'a';
			}
			cout << s << endl;
			return 0;
		}
	}
	cout << "UNRESTORABLE" << endl;
	return 0;
}


Measured memory_bytes: 256
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)    
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=1000000, INF=20000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }


int dp[3002][3002];
int32_t main()
{
    IOS;
    int n,s;
    cin>>n>>s;
    int ar[n+1];
    for(int i=1;i<=n;i++)
    cin>>ar[i];
    //dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=s;j++)
        {
            dp[i][j]=(dp[i-1][j])%mod;
        }
        for(int j=0;(j+ar[i])<=s;j++)
        dp[i][j+ar[i]]=(dp[i][j+ar[i]]+(dp[i-1][j]))%mod;
        dp[i][0]++;
        dp[i][ar[i]]++;
    }
    int ans=0;
    //print2d(dp,n,s);
    for(int i=1;i<=n;i++)
    ans=(ans+dp[i][s])%mod;
    cout<<ans;
}

Measured memory_bytes: 73900
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

 int main() {
   int N, M; cin >> N >> M;
   vector<pii> AB(N);
   rep(i, 0, N) cin >> AB.at(i).first >> AB.at(i).second;

   sort(AB.begin(), AB.end());

   priority_queue<int> pq;
   int ans = 0, tmp = 0;

   rep(i, 1, M + 1) {
     rep(j, tmp, N) {  //i日後にもらえる仕事のBiをpush
       if (AB.at(j).first == i) pq.push(AB.at(j).second);
       else if (AB.at(j).first > i) {
         tmp = j;
         break;
       }
     }
     if (!pq.empty()) {
       ans += pq.top();
       pq.pop();
     }
   }

   cout << ans << endl;
 }


Measured memory_bytes: 1660
require 'set'
X,N = gets.split.map(&:to_i)
px = Set.new((N > 0) ? gets.split.map(&:to_i) : []) 
x0 = x1 = X
while true 
  (puts x0; break) if !px.member?(x0)
  (puts x1; break) if !px.member?(x1)
  x0 -= 1; x1 += 1
end

Measured memory_bytes: 14412
#include<stdio.h>


int main() 
{
	int i;
	char str[10] = {0};

	while (scanf("%s",str)!=EOF)
	{
		//printf("%s\n", str);
		if (str[0]!='s' && str[0] == str[1] && str[1] == str[2])
		{
			i = 0;
		}
		else if (str[0] != 's' && str[0] == str[3] && str[3] == str[6])
		{
			i = 0;
		}
		else if (str[0] != 's' && str[0] == str[4] && str[4] == str[8])
		{
			i = 0;
		}
		else
		{
			if (str[1] != 's' && str[1] == str[4] && str[4] == str[7])
			{
				i = 1;
			}
			else
			{
				if (str[2] != 's' && str[2] == str[5] && str[5] == str[8])
				{
					i = 2;
				}
				else if (str[2] != 's' && str[2] == str[4] && str[4] == str[6])
				{
					i = 2;
				}
				else
				{
					if (str[3] != 's' && str[3] == str[4] && str[4] == str[5])
					{
						i = 3;
					}
					else
					{
						if (str[6] != 's' && str[6] == str[7] && str[7] == str[8])
						{
							i = 6;
						}
						else
						{
							i = 9;
						}
					}
				}
			}
		}
		if (i == 9)
		{
			printf("d\n");
		}
		else
		{
			if (str[i] == 'o')
			{
				printf("o\n");
			}
			else
			{
				printf("x\n");
			}
		}
		
	}

	
		
	
	
	return 0;
}


Measured memory_bytes: 524
n = int(input())
Ans = 0
num = [0] * 100000
an = list(map(int, input().split()))
for i in range(n):
    num[an[i]-1] += 1
    Ans += an[i]
q = int(input())
for i in range(q):
    bici = list(map(int, input().split()))
    Ans += num[bici[0]-1]*(bici[1]-bici[0])
    num[bici[1]-1] += num[bici[0]-1]
    num[bici[0]-1] = 0
    print(Ans)


Measured memory_bytes: 21664
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <numeric>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1ll<<60;
const double EPS = 1e-8;
const int MOD = 1000000007;


int n, m, l;

int main(){
	while(~scanf("%d%d%d", &n, &m, &l)){
		vector<ll> K(n), S(m), sum(m+1);
		REP(i, n) scanf("%lld", &K[i]), K[i]--;
		REP(i, m) scanf("%lld", &S[i]);
		sort(ALL(K));
		K.push_back(K.back()); ++n;
		partial_sum(ALL(S), sum.begin()+1);
		vector<vector<ll>> dp(n+1, vector<ll>(n+1, INF));
		dp[0][0] = 0;
		REP(i, n)REP(j, i){
			dp[i][j]   = min(dp[i][j]  , dp[i-1][j] + (sum[K[i]+1] - sum[K[i-1]])/l);
			dp[i][i-1] = min(dp[i][i-1], dp[i-1][j] + (sum[K[i]+1] - sum[K[j]])/l);
		}
		printf("%lld\n", dp[n-1][n-2]);
	}
	return 0;
}

Measured memory_bytes: 33992
#include <bits/stdc++.h>
using namespace std;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

typedef long long ll;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define DBGV(v,n) forn(i,n) cout << v[i] << " "; cout << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl

int main()
{
	FIN;
	
	int n;
	cin >> n;
	multiset <string> s;
	forn(i,n) 
	{
		string aux;
		cin >> aux;
		s.insert(aux);
	}
	int a = s.count("WA");
	int b = s.count("RE");
	int c = s.count("AC");
	int d = s.count("TLE");
	
	cout << "AC x " << c << "\n";
	cout << "WA x " << a << "\n";
	cout << "TLE x " << d << "\n";
	cout << "RE x " << b << "\n"; 
	
    return 0;
}


Measured memory_bytes: 11428
#include<stdio.h>

int main()
{

  int x,a,b;

  scanf("%d %d %d",&x,&a,&b);

  if(b-a<=0)printf("delicious\n");
  else{
    if(b-a<=x)printf("safe\n");
    else printf("dangerous\n");
      }

  return 0;
}

Measured memory_bytes: 128
import copy

n = int(input())
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
dis = copy.deepcopy(a)

def warshall_floyd(dis):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j])
    return dis

data = warshall_floyd(dis)
flag = True
for i in range(n):
    for j in range(i + 1, n):
        if data[i][j] < a[i][j]:
            flag = False
            break
    if flag == False:
        break
if flag == False:
    print(-1)
else:
    count = 0
    for i in range(n):
        for j in range(i + 1, n):
            for k in range(n):
                if k == i or k == j:
                    continue
                if data[i][k] + data[k][j] == data[i][j]:
                    break
            else:
                count += data[i][j]
    print(count)

Measured memory_bytes: 76952
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    int a[q];
    rep(i,q)cin >> a[i];

    // 全部1つの配列でやる
    int f_[m+1] = {};
    srep(i,1,m+1)f_[i] = 1001001 + i;
    rep(i,q)f_[a[i]] = -i;
    vector<P> v_;
    srep(i,1,m+1)v_.push_back(P(f_[i], i));
    sort(v_.begin(), v_.end());
    int flag_ = 1;
    rep(i,m)if(v_[i].second != i+1)flag_ = 0;
    if(flag_){
        cout << "Yes" << endl;
        return 0;
    }

    // 後ろから貪欲
    vector<P> v;
    map<int,int> mp;
    drep(i,q){
        int aa = a[i];
        if(mp.find(aa) == mp.end()){
            v.push_back(P(aa, 1));
            mp[aa] = v.size() - 1;
        }else{
            int ite = mp[aa];
            if(ite == 0){
                v[ite].second++;
                if(v[ite].second > n)v[ite].second = n;
            }else{
                v[ite].second++;
                if(v[ite].second > v[ite-1].second)v[ite].second = v[ite-1].second;
            }
        }
    }

    /*
    cout << v.size() << endl;
    rep(i,v.size())cout << v[i].first << ' ' << v[i].second << endl;
    */
    int flag = 1;

    int mex = 1;
    int cnt[m+1] = {};
    rep(i,v.size()){
        cnt[v[i].first] = v[i].second;
    }
    srep(i,1,m+1){
        if(cnt[i] >= n)mex++;
        else break;
    }

    int last = -1;
    drep(i,v.size()){
        if(v[i].first <= mex){
            last = i;
            break;
        }
    }

    /*
    drep(i,v.size()){
        // if(i == last)break;
        if(i == v.size() - 1 && v[i].first <= mex)continue;
        if(v.size() == m && i == v.size() - 1)continue;
        if(v[i].second != n)flag = 0;
    }
    */

    int use[m+1] = {};
    int mex2 = 1;
    rep(i,v.size()){
        if(v[i].second == n){
            use[v[i].first] = 1;
            continue;
        }else{
            while(use[mex2] == 1)mex2++;
            if(v[i].first == mex2){
                use[mex2] = 1;
            }else{
                flag = 0;
                break;
            }
        }
    }

    if(flag)yn;
    return 0;
}




Measured memory_bytes: 11036
Scanf.scanf "%d" (fun n ->
    let conv s =
        let arr = Array.make 26 0 in
        String.iter (fun c -> let q = int_of_char c - 97 in arr.(q) <- arr.(q) + 1) s;
        arr
    in
    let s = Array.init n (fun _ -> Scanf.scanf " %s" conv) in
    Array.sort compare s;

    let rec loop i cur prev acc =
        if i = n then acc + cur * (cur - 1) / 2 else
            if s.(i) = prev then loop (i + 1) (cur + 1) prev acc
                else loop (i + 1) 1 s.(i) (acc + cur * (cur - 1) / 2)
    in
    loop 1 1 s.(0) 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 28816