akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A=0;
		int B=0;

		int n = sc.nextInt();
		List<Integer> list=new ArrayList<Integer>();
		for(int i=0;n>i;i++) {
			int b=sc.nextInt();
			list.add(b);
		}
		//System.out.println(list);
        Collections.sort(list, Collections.reverseOrder());
        //System.out.println(list);

        for(int i=0;n>i;i++) {
        	if(i%2==0) {
        		A=A+list.get(i);
        	}
        	else {
        		B=B+list.get(i);
        	}
        }
        System.out.println(A-B);
	}

}


Measured memory_bytes: 21844
<?php
// Your code here!
$day = trim(fgets(STDIN));
$c = explode(' ',trim(fgets(STDIN)));

for ($i = 0; $i < $day; $i++) {
     $scores = explode(' ',trim(fgets(STDIN)));
     arsort($scores);
     echo array_key_first($scores) +1;
     echo "\n";
}
?>


Measured memory_bytes: 16280
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 100005;
int h[maxn], ta, he, Q[maxn], cnte, X[maxn], Y[maxn], Z[maxn];
int clo, vis[maxn], col[maxn], dis[maxn];
struct edge_t {
	int to, next;
} edge[maxn*2];
void ins(int x, int y) {
	edge[++cnte].to = y;
	edge[cnte].next = h[x];
	h[x] = cnte;
}
void bfs(int S, int d, int c) {
	if (d <= dis[S]) return;
	Q[he=ta=1] = S;
	dis[S] = d;
	while (he <= ta) {
		int now = Q[he++];
		if (col[now] == 0) col[now] = c;
		if (dis[now] == 0) continue;
		for (int i = h[now]; i; i = edge[i].next) {
			if (dis[now]-1 <= dis[edge[i].to]) continue;
			dis[edge[i].to] = dis[now]-1;
			Q[++ta] = edge[i].to;
		}
	}
}
int n, m, x, y, z, q;
int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) dis[i] = -999;
	for (int i = 1; i <= m; ++i) {
		cin >> x >> y;
		ins(x, y); ins(y, x);
	}
	cin >> q;
	for (int i = 1; i <= q; ++i) {
		cin >> X[i] >> Y[i] >> Z[i];
	}
	for (int i = q; i >= 1; --i) {
		bfs(X[i], Y[i], Z[i]);
	}
	for (int i = 1; i <= n; ++i) cout << col[i] << endl;
}

Measured memory_bytes: 5376
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
using namespace std;


typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
int gcd (int a, int b){
  while(true){
    if(a < b) swap(a, b);
    if(b == 0) break;
    a = a % b;
  }
  return a;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n){
    cin >> a[i];
  }

  int g = a[0];
  for(int i = 1; i < n; ++i){
    g = gcd(g, a[i]);
  }

  cout << g << endl;



}


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

#define F first
#define S second
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
 
const int Maxn = 52;
const ll Inf = LONG_LONG_MAX >> 2;
const int Log = 23;
const ll Mod = 10133;

ll mul(ll a, ll b){
	return (a * b) % Mod;
}
ll bin_pow(ll b, ll p){
	ll res = 1;
	for(ll pw = b, j = 1; j <= p; j <<= 1, pw = mul(pw, pw)) if(p & j) res = mul(res, pw);
	return res;
}
ll inv(ll x){
	return bin_pow(x, Mod - 2);
}

ll dp[Maxn][Maxn][Maxn * Maxn];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	dp[0][0][0] = 1;
	ll n, a, x;
	cin >> n >> a;
	for(int i = 1; i <= n; i++){
		cin >> x;
		for(int j = 0; j <= i; j++){
			for(int sm = 0; sm <= 50 * i; sm ++){
				dp[i][j][sm] += dp[i - 1][j][sm];
				if( (j >= 1) && (sm >= x) ) dp[i][j][sm] += dp[i - 1][j - 1][sm - x];
			}
		}
	}
	ll ans = 0;
	for(int j = 1; j <= n; j++){
		ans += dp[n][j][a * j];
	}
	cout << ans;
	return 0;
}


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

typedef long long ll;

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

    int n; cin >> n;
    vector<string> s(n);
    set<string> st;
    for(int i=0;i<n;i++){
        cin >> s[i];
        st.insert(s[i]);
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 25112
#include<stdio.h>
int main(void){
  int k,x;
  scanf("%d %d",&k,&x);
  long int l=x-k+1,r=x+k-1,i;
  for(i=l;i<=r;i++){
    if(i>=-1000000&&i<=1000000){
      printf("%ld ",i);
    }
  }
  return 0;
}
  


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

int main() {
  int a, b;
  string op;

  cin >> a >> op >> b;

  if (op[0] == '+') {
    cout << a + b << endl;
  }
  else {
    cout << a - b << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int64_t x; cin>>x;

    int64_t ans=2*(x/11);
    if(x%11){
        ans++;
        if(x%11>6) ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int n;
    multiset<int> ms;
    vector<int> v;
    while(1){
    	cin>>s;
    	if(s=="end")break;
    	if(s=="extract"){
    		auto itr=ms.end();
    		itr--;
    		v.pb(*itr);
    		ms.erase(itr);
    	}else{
    		cin>>n;
    		ms.insert(n);
    	}
    }
    for(auto& i:v){
    	cout <<i<<endl;
    }
    return 0;
}



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

using namespace std;

int main()
{
    int m1, m2, d1, d2;
    scanf("%d %d %d %d", &m1, &d1, &m2, &d2);

    if(m1 <= m2 and d1 >= d2)
    {
        printf("1\n");
    }
    else
    {
        printf("0\n");
    }
    return 0;
}


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

int main(){

  int n;
  cin>>n;

  int num[4][3][10] = {};
  for(int i=0;i<n;i++){
    int b, f, r, v;
    cin>>b>>f>>r>>v;
    num[b-1][f-1][r-1] += v;
  }  

  for(int i=0;i<4;i++){
    if(i) cout<<"####################"<<endl;

    for(int j=0;j<3;j++){
      for(int k=0;k<10;k++){
        cout<<" "<<num[i][j][k];
      }
      cout<<endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 3104
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		String line = sc.nextLine();
		String[] inputs = line.split(" ");
		double ans = 0;

		for(int i = 0; i < num; i++){
			double money = sc.nextDouble();
			String currency = sc.next();

			if(currency.equals("BTC"))money *= 380000;
			ans += money;
		}

		System.out.println(ans);
	}
}




Measured memory_bytes: 24532
#include<bits/stdc++.h>
#define int long long 

using namespace std ;

int a , b ;
const int hell = 1e9 + 7 ;
int fact[1000001];

int binpower(int a, int b){
        int res = 1;
        while(b){
                if(b&1)
                        (res *= a)%=hell;
                b/=2;
                (a*=a)%=hell;
        }
        return res;
}

int modinverse(int n){
        return binpower(n,hell-2);
}

int ncr(int n , int r){
        if(r==0) return 1 ;
        fact[0] = 1;
        for(int i = 1 ; i <= n ; i++ ){
                fact[i] = fact[i-1]*i%hell;
        }
        return ((fact[n]*modinverse(fact[r]))%hell*modinverse(fact[n-r])%hell)%hell;       
}

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

        cin >> a >> b ;

        if((a+b)%3!=0){
                cout << 0 << endl; 
                return 0 ;
        }

        int n = (2*a-b)/3 , m = (2*b-a)/3;

        if(n < 0 or m < 0 ){
                cout << 0 << endl ;
                return 0;
        }
        //cout << n <<' ' << m << endl ;
        cout << ncr(n+m,m) << endl; 
        
        for(int i = 0 ; i < 1000000 ; i++ ){
                for(int j = 0 ; j < 1000 ; j++ )
                        true;
        }
        return 0;
        
}

Measured memory_bytes: 6400
import itertools
n,m,x = list(map(int,input().split()))
Text =[list(map(int,input().split())) for i in range(n)]

mini_cash=12*10**5+2

for alllist in list(itertools.product([0,1], repeat=n)):
    #print(alllist)
    temp_mini_cash=0
    knowledge = [0]*m
    j = 0
    for i in alllist:
        if i==1:
            for k in range(m):
                knowledge[k]+=Text[j][1+k]
                #print(Text[j][1+k])
            temp_mini_cash +=Text[j][0]
        j+=1
    #print(temp_mini_cash)
    #print(knowledge)
    if all([i >= x for i in knowledge]):
        if temp_mini_cash<mini_cash:
            mini_cash=temp_mini_cash
if mini_cash!=12*10**5+2:
    print(mini_cash)
else:print("-1")

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

#define ll long long
const int MOD = 1e9+7;


void solve()
{
    int row,col;
    cin >> row >> col;
    int dp[row][col],up = 1,right = 1;
    for(int i=0;i<row;i++)
    {
        for(int j=0;j<col;j++)
        {
            char k;
            cin >> k;
            if(!i && !j)
                dp[i][j] = 1;
            else if(!i)
            {
                if(k=='#'||!up)
                {
                    dp[i][j] = 0;
                    up = 0;
                }
                else dp[i][j]=1;
            }
            else if(!j)
            {
                if(k=='#'||!right)
                {
                    dp[i][j] = 0;
                    right = 0;
                }
                else dp[i][j]=1;
            }
            else
            {
                if(k == '#')
                    dp[i][j] = 0;
                else dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
            }
        }
    }
    cout << dp[row-1][col-1];
}




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


Measured memory_bytes: 7480
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//各ルートの最短だす
//二点間が最短じゃなかったらカウントだなも
int main(){
  ll N,M; cin>>N>>M;
  vector<vector<ll>> path(N+1, vector<ll>(N+1,1e6)), graph(N+1, vector<ll>(N+1,1e6));
  for(int i=0; i<M; i++){
    ll a,b,c; cin>>a>>b>>c;
    graph[a][b]=c;
    graph[b][a]=c;
  }
  for(int i=0; i<=N; i++) graph[i][i]=0;
  path=graph;
  for(int k=1; k<=N; k++){
    for(int i=1; i<=N; i++){
      for(int j=1; j<=N; j++){
        path[i][j]=min(path[i][j],path[i][k]+path[k][j]);
      }
    }
  }
  ll ans=0;
  for(int i=1; i<=N; i++){
    for(int j=1; j<=N; j++){
//      cout<<"i:"<<i<<" j:"<<j<<" path:"<<path[i][j]<<" graph:"<<graph[i][j]<<endl;
      if(path[i][j]==graph[i][j] || graph[i][j]==1e6) continue;
      ans++;
    }
  }
  cout<<ans/2<<endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

struct UnionFind {
  vector<int> par, s; 
  UnionFind(int N) : par(N), s(N) { rep(i,N) { par[i] = i; s[i] = 1; } }
  int root(int x) { return par[x]==x ? x : par[x] = root(par[x]); }
  int size(int x) { return par[x]==x ? s[x] : s[x] = size(root(x)); }
  void unite(int x, int y) { int rx=root(x), ry=root(y); if (rx!=ry) { s[rx] += s[ry]; par[ry] = rx; } }
  bool same(int x, int y) {  int rx=root(x), ry=root(y); return rx==ry; }
};

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  ll N, Q; cin >> N >> Q;
  UnionFind uf(N);
  rep(i,Q) {
    ll t, u, v; cin >> t >> u >> v;
    if (t==0) uf.unite(u,v);
    else cout << uf.same(u,v) << endl;
  }
  return 0;
}

Measured memory_bytes: 4640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main(void)
{
  int k;
  cin >> k;
  ll s = 0;
  for(int i = 1;i<=k;i++) s+=i;
  for(int i = 1;i<=k;i++)
  {
      for(int j=i+1;j<=k;j++)
      {
          s += gcd(i,j) * 6;
      }
  }
  for(int i = 1;i<=k;i++)
  {
      for(int j=i+1;j<=k;j++)
      {
          for(int l = j+1;l<=k;l++)
          {
              int g = gcd(i,j);
              s += gcd(g,l) * 6;
          }
      }
  }
  cout << s << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  
  for(int i = 0; i < n; i++) {
  	cin >> a.at(i);
  }
  
  int first = 0, second = 0, count = 0;
  
  for(int i = 0; i < n; i++) {
  	first = max(first, a.at(i));
  }
  
  for(int i = 0; i < n; i++) {
  	if(first != a.at(i)) {
    	count++;
    }
  	else {
    	break;
    }
  }
  
  for(int i = 0; i < n; i++) {
  	if(i != count) {
    	second = max(second, a.at(i));
    }
  }
  
  for(int i = 0; i < n; i++) {
  	if(a.at(i) == first) {
    	cout << second << endl;
    }
  
  	else {
    	cout << first << endl;
    }
  }
}


Measured memory_bytes: 2432
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 100011

int n, i;
ll A[maxN], B[maxN];
ll ans, cnt;

int main()
{
   // freopen("test.in","r",stdin);

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

    for (i = n; i > 0; i--) {
        A[i] += ans;

        cnt = B[i] * (A[i] / B[i]);
        while (cnt < A[i]) cnt += B[i];
        ans += cnt - A[i];
    }

    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 1920
use std::io::{BufRead, BufReader};

fn main(){
    // init
    let lines = read::<String>();

    let amat: Vec<Vec<i32>> =
        lines.iter().take(3)
        .map(|l| 
             l.split(' ')
             .map(|k| k.parse::<i32>().unwrap()).collect())
        .collect();

    let _n: i32 = lines[3].parse().unwrap();

    let bb: Vec<i32> = lines.iter().skip(4).map(|k| k.parse().unwrap()).collect();

    // bingo
    let mut result_mat = vec![[false,false,false]; 3];
    for (i, line) in amat.iter().enumerate() {
        for (j, val) in line.iter().enumerate(){
            if bb.iter().any(|b| b == val) {
                result_mat[i][j] = true;
            };
        }
    }

    // before check
    let mut result = false;
    let mut flat_results: Vec<bool> = Vec::new();
    for (_i, line) in result_mat.iter().enumerate() {
        for (_j, val) in line.iter().enumerate() {
            flat_results.push(*val);
        }
    }
    
    // yoko
    if result_mat.iter().map(|line| line.iter().all(|r| r == &true)).any(|r| r ) {
        result = true;
    }

    // tate
    if flat_results[0] && flat_results[3] && flat_results[6] {
        result = true;
    }

    if flat_results[1] && flat_results[4] && flat_results[7] {
        result = true;
    }

    if flat_results[2] && flat_results[5] && flat_results[8] {
        result = true;
    }

    // naname
    if flat_results[0] && flat_results[4] && flat_results[8] {
        result = true;
    }
    
    if flat_results[2] && flat_results[4] && flat_results[6] {
        result = true;
    }

    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T>() -> Vec<T>
where
  T: std::str::FromStr,
  T::Err: std::fmt::Debug,
{
    let lines: Vec<T> =
        BufReader::new(std::io::stdin())
        .lines()
        .map(|l| l.unwrap().parse::<T>().unwrap())
        .collect();
    lines
}


Measured memory_bytes: 4476
while True:
    b=[]
    a,c,ans,f,g=0,0,0,0,0
    try:
        for i in range(5):
            f,g=map(int,input().split())
            if f==0 and g==0:
                break
            a=f+g
            b.append(a)
        if a==0 and b==0:
            break
        c=max(b)
        if c==b[0]:
            ans="A"
        if c==b[1]:
            ans="B"
        if c==b[2]:
            ans="C"
        if c==b[3]:
            ans="D"
        if c==b[4]:
            ans="E"
        print(ans,c)
    except:break


Measured memory_bytes: 5600
#include <iostream>
using namespace std;
#define MAX 100000

int L[MAX];
int R[MAX];

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

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

	int lmax = 0;
	for (int i = 0; i < m; i++) {
		if (lmax < L[i]) {
			lmax = L[i];
		}
	}

	int rmin = MAX;
	for (int i = 0; i < m; i++) {
		if (rmin > R[i]) {
			rmin = R[i];
		}
	}

	if (lmax > rmin) {
		cout << 0 << endl;
	}
	else
	{
		cout << (rmin - lmax + 1) << endl;
	}
	return 0;
}

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

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(n+1);
    vector<ll> b(m);
    //それぞれで累積和をとる
    a[0]=0;
    for(int i=1;i<n+1;i++){
        int x;
        cin>>x;
        a[i]=a[i-1]+x;
    }
    rep(i,m){
        int y;
        cin>>y;
        if(i==0) b[i]=y;
        else b[i]=b[i-1]+y;
    }
    int ans=0;
    //aでどこまでよむか
    for(int s=0;s<n+1;s++){
        //最初にaで読む本分引いておく、残り時間でbから読む
        if(a[s]>k) break;
        int tmp=k-a[s];
        //二分探索
        int left=0;
        int right=m-1;
        while(left<=right){
            int mid=(right+left)/2;
            if(tmp<b[mid]) right=mid-1;
            else left=mid+1;
        }
        ans=max(ans,s+left);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
int lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}

int main()
{
	cout<<48-read()<<endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)  (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define mod 1000000007
typedef long long LL;
#define int long long
typedef long double LD;
typedef vector<int> VI;
inline LL add(LL x, LL y) { x += y; if (x >= mod) x -= mod; return x; }
inline LL moduloMultiplication(LL x, LL y) {
	return (x%mod * 1LL * y%mod) %mod;
}
inline LL power(LL a, LL b) {
	LL x = 1 % mod;
	while (b) {
		if (b & 1) x = moduloMultiplication(x, a);
		a = moduloMultiplication(a, a);
		b >>= 1;
	}
	return x % mod;
}

inline LL inv(LL a) { return power(a, mod - 2) % mod; }
LL gcd(LL a, LL b)
{
	if (!a)
		return b % mod;
	return gcd(b%a, a) % mod;
}

signed main()
{
	fastio;
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(a *b, c) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

const double EPS=(1e-10);
typedef long long ll;
typedef pair<int,int> pii;
bool EQ(double a,double b){
  return abs((a)-(b))<EPS;
}
void fast_stream(){
	std::ios_base::sync_with_stdio(0);
}

short dp[5002][5002];
void dfs(int x,int y,int depth){
    if(dp[y][x]>=depth)return;
    dp[y][x]=depth;
    if(depth==0)return;
    int ny=y+1;
    int nx=x+1;
    dfs(nx,ny,depth-1);
    ny=y;
    dfs(nx,ny,depth-1);
}

void solve(){
    memset(dp,-1,sizeof(dp));
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y,a;
        cin>>x>>y>>a;
        dp[x][y]=a;
        //dfs(x,y,a);
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            dp[i+1][j+1]=max(dp[i+1][j+1],(short)(dp[i][j]-1));
            dp[i+1][j]=max(dp[i+1][j],(short)(dp[i][j]-1));
        }
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            if(dp[i][j]>=0)cnt++;
        }
    }
    cout<<cnt<<endl;
}

int main(){

    solve();

    return 0;
}

Measured memory_bytes: 48000
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int d,x;
cin>>d>>x;
int ans=0;
while(n--)
{
    int a;
    cin>>a;
    ans+=(d-1)/a+1;
}
ans+=x;
cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdint>
#include <string>

using namespace std;

int main() {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cout << fixed << setprecision(4) << hypot(x2 - x1, y2 - y1) << endl;
}

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

using namespace std;

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s, t;
    int ans = 0;
    cin >> s >> t;
    for (int i = 0; i < 3; ++i) if (s[i] == t[i]) ans++;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int answer, temp;
        System.out.println(Math.max(Math.max((answer = (temp = 0) + scanner.nextInt()) - temp, (answer = (temp = answer) + scanner.nextInt()) - temp), (answer = (temp = answer) + scanner.nextInt()) - temp) * 9 + answer);
    }
}

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

int main() {
  string A,B;
  cin >> A >> B;
  if (A.size() > B.size()) {
    cout << "GREATER" << endl;
  }
  if (A.size() < B.size()) {
    cout << "LESS" << endl;
  }
  if (A.size() == B.size()) {
    int N = A.size();
    for (int i=0; i<N; i++) {
      if (A[i] > B[i]) {
        cout << "GREATER" << endl;
        break;
      }
      if (A[i] < B[i]) {
        cout << "LESS" << endl;
        break;
      }
      if (i == N-1) {
        cout << "EQUAL" << endl;
      }
    }
  }
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A.at(i).at(j);
    }
  }
  
  vector<int> dx(8);
  dx = {1, 0, -1, 0, 1, -1, -1, 1};
  vector<int> dy(8);
  dy = {0, 1, 0, -1, 1, 1, -1, -1};
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (A.at(i).at(j) == '#') continue;
      int num = 0;
      for (int d = 0; d < 8; d++) {
        int ni = i + dx.at(d);
        int nj = j + dy.at(d);
        
        if (ni < 0 || H <= ni) continue;
        if (nj < 0 || W <= nj) continue;
        if (A.at(ni).at(nj) == '#') num++;
      }
      
      A.at(i).at(j) = char('0' + num);
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << A.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := makeScanner(8192)
	s := eGetChars(scanner)
	t := eGetChars(scanner)

	match := 0
	for i := 0; i < len(s); i++ {
		if s[i] == t[i] {
			match++
		}
	}
	fmt.Println(match)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long n,m,i,j;
void lj(long long u,long long v){
	pus(u,1);
	pus(v,2);
	return;
}
int main(){
    n=read();
    m=n;
    while((m&1)==0)
    	m>>=1;
    if(m==1){
    	printf("No\n");
    	return 0;
    }
    printf("Yes\n");
    for(i=3;i<=n;i+=2){
    	lj(i-1,i);
    	lj(i,1);
    	lj(1,i-1+n);
    	lj(i-1+n,i+n);
    }
    lj(n+1,2);
    if((n&1)==0){
    	for(i=1;i<n;i++)
    		if((i^1^n)<n){
    			j=(i^1^n);
    			if((i&1)==0)
    				i+=n;
    			if((j&1)==0)
    				j+=n;
    			lj(i,n);
    			lj(j,n<<1);
    			return 0;
    		}
    }
    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  string S,T;ll i,j,ans;cin>>S>>T;ans=T.size();
  REP(i,S.size()-T.size()+1){
    ll co=0;
    REP(j,T.size())if(S[i+j]!=T[j])co++;
    ans=min(ans,co);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int a,b;
    cin>>a>>b;
    if(a==1)a=INF;
    if(b==1)b=INF;
    if(a>b)cout<<"Alice"<<endl;
    else if(a<b)cout<<"Bob"<<endl;
    else cout<<"Draw"<<endl;
}


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

int main() {
  int a,b;
  cin >> a >> b;
 
  if(a==b){
    cout << 0 << endl;
  }else if( (a+b)%2 == 1){
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }else{
    cout << (a+b)/2 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
	int N, K, S;
	cin >> N >> K >> S;
	for (int i = 1; i <= K; i++) {
		cout << S << " ";
	}
	for (int i = K+1; i <= N; i++) {
		if (S==1000000000) {
			cout << 1 << " ";
		} else {
			cout << S+1 << " ";
		}
	}
	return 0;
}


Measured memory_bytes: 1280
n=int(input())
x=[]
x.append(input())
last_char=x[0][-1]
f_l_checker=True
for i in range(1,n):
    x.append(input())
    if f_l_checker:
        first_char=x[i][0]
        if first_char==last_char:
            f_l_checker=True
            last_char=x[i][-1]
        else:
            f_l_checker=False
            
set_x=set(x)
if len(set_x)==n and f_l_checker==True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
from collections import defaultdict
a = [list(map(int, s.split()))[0] for s in open(0)][0]
cnt = 0 
di = defaultdict(int)
for i in range(1, a + 1):
    if len(str(i)) == 1:
        cnt += 1 
        di[str(i)] += 1
    elif str(i) != 0:
        if str(i)[0] == str(i)[-1]:
            cnt += di[str(i)[-1]] * 2 + 1
            cnt += di[str(i)[0] + str(i)[-1]]*2
            di[str(i)[0] + str(i)[-1]] += 1
        else:
            cnt += di[str(i)[-1] + str(i)[0]]*2
            di[str(i)[0] + str(i)[-1]] += 1

print(cnt)

Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
using namespace std;

struct Node {
	int key;
	Node* right, * left, * parent;
};

Node* root, * NIL;

Node* find(Node* u, int k) {
	while (u != NIL && k != u->key) {
		if (k < u->key) u = u->left;
		else u = u->right;
	}
	return u;
}

void insert(int k) {
	Node* y = NIL;
	Node* x = root;
	Node* z;

	z = (Node*)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NIL) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
}

void inorder(Node* u) {
	if (u == NIL) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node* u) {
	if (u == NIL) return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}

int main() {
	int n, x;
	string com;

	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		cin >> com;
		if (com[0] == 'f') {
			scanf("%d", &x);
			Node* t = find(root, x);
			if (t != NIL) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
		else if (com == "insert") {
			scanf("%d", &x);
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;

}


Measured memory_bytes: 22028
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	int n;
	map<string, int> s;
	cin >> n;
	string st;
	rep(i,n) {
		cin >> st;
		s[st]++;
	}
	int count = 0;
	for(auto f : s) {
		count++;
	}
	cout << count << endl;

  return 0;
}


Measured memory_bytes: 19204
# coding: utf-8

list = [int(i) for i in input().rstrip().split(" ")]

matsu_count = list[0]
require = sorted(list[1:])

matsu_list = sorted([int(input().rstrip()) for i in range(matsu_count)])

def get_mp(matsu:list):
    ans = 0
    for i in range(3):
        ans += abs(matsu[i] - require[i])
    return ans
mp = {}

def get_ans(matsu:list):
    if len(matsu) == 3:
        return get_mp(matsu)
    key = "#".join(map(str, matsu))
    if key in mp:
        return mp[key]
    ans = 80000
    for i in range(len(matsu) - 3 + 1):
        for j in range(i + 1, len(matsu) - 2 + 1):
            for k in range(j + 1, len(matsu) - 1 + 1):
                ans = min(ans, get_mp([matsu[i],matsu[j], matsu[k]]))
    if ans > 0:
        for i in range(len(matsu)):
            for j in range(i + 1, len(matsu)):
                sub_matsu = []
                for k in range(len(matsu)):
                    if k == i or k == j:
                        continue
                    else:
                        sub_matsu.append(matsu[k])
                sub_matsu.append(matsu[i] + matsu[j])
                ans = min(ans, get_ans(sorted(sub_matsu)) + 10)

    mp[key] = ans
    return ans

ans = get_ans(matsu_list)
print(ans)



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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};

int calc(int a){
    int cnt = 0;
    while(a) {
        ++cnt;
        a /= 10;
    }
    return cnt;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        ans += calc(i) % 2;
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

typedef long long ll;

int n, m;

ll x, sk[maxn], top;
ll f[maxn], a[maxn];

void solve(ll d, ll w){
	int i = upper_bound(sk + 1, sk + 1 + top, d) - (sk + 1);
	if(!i) a[1] += w, a[d + 1] -= w;
	else f[i] += d / sk[i] * w, solve(d % sk[i], w);	
}

int main(){
	scanf("%d%d", &n, &m);
	sk[++top] = n;
	while(m--){
		scanf("%lld", &x);
		while(top && sk[top] >= x) --top;
		sk[++top] = x;
	}
	f[top] = 1;
	for(int i = top - 1;i;i--){
		f[i] += sk[i + 1] / sk[i] * f[i + 1];
		solve(sk[i + 1] % sk[i], f[i + 1]);
	}
	a[1] += f[1], a[sk[1] + 1] -= f[1];
	for(int i = 1;i <= n;i++) printf("%lld\n", a[i] += a[i - 1]);
}

Measured memory_bytes: 6088
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000

typedef long long ll;

int n;
double v, x, y;
double l[50], b[50], r[50], t[50];
double g = 9.8;

double cmp(double l, double u, double a) {
    return a-1e-9 < l ? -1 : a+1e-9 > u ? 1 : 0;
}

double height(double vy, double t) {
    return vy * t - g * t * t / 2;
}

bool solve(int bx, int by) {
    int i, j;
    double a = g*g/4, bb = by*g-v*v, c = bx*bx+by*by;
    double d = bb*bb - 4 * a * c;
    if (d < 0)
        return false;
    for (int i = -1; i <= 1; i+=2) {
        double t2 = (-bb+i*sqrt(d))/(2*a);
        if (t2 <= 0)
            continue;
        double t1 = sqrt(t2);
        double vx = bx / t1;
        double vy = by/t1 + g*t1/2;
        if (height(vy,x/vx) < y-1e-9) continue;
        bool ok = true;
        rep (j,n) {
            if (l[j] >= x) continue;
            if (r[j] == x && height(vy,x/vx) >= b[j] && y <= t[j]) ok = false;
            int yL = cmp(b[j],t[j],height(vy,l[j]/vx));
            int yR = cmp(b[j],t[j],height(vy,r[j]/vx));
            int xH = cmp(l[j],r[j],vx*vy/g);
            int yH = cmp(b[j],t[j],height(vy,vy/g));
            if (yL*yR <= 0) ok = false;
            if (yR < 0 && xH == 0 && yH >= 0) ok = false;
        }
        if (ok) return true;
    }
    return false;
}

int main() {
    int i;
    bool ans;
    cin >> n >> v >> x >> y;
    rep (i,n) cin >> l[i] >> b[i] >> r[i] >> t[i];
    rep (i,n) r[i] = min(r[i],x);
    ans = solve(x,y);
    rep (i,n) {
        ans |= solve(l[i],t[i]);
        ans |= solve(r[i],t[i]);
    }
    if (ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
    int x,y;
    cin >> x >> y;
    if((x+y)%3){
        cout << 0 << endl;
        return 0;
    }
    int n = (x+y)/3;
    x -= n;y -= n;
    if(x<0 || y<0){
        cout << 0 << endl;
        return 0;
    }
    combination c(x+y);
    mint ans = c(x+y,x);
    cout << ans.x << endl;
}


Measured memory_bytes: 10624
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
	
	io
	
	ll k,n;
	cin>>k>>n;
	std::vector<ll> dist(n);
	ll mx=0;
	rep(i,0,n)
	{
		cin>>dist[i];

	}
	rep(i,0,n)
	{
		if(i!=n-1)
			mx=max(mx,abs(dist[i]-dist[(i+1)%n]));
		else
			mx=max(mx,k-abs(dist[i]-dist[(i+1)%n]));

	}
	cout<<k-mx;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ll k, a, b; cin >> k >> a >> b;
    ++k;
    ll ans = 0;
    ans += min(a, k);
    k -= min(a, k);
    if (a <= ans && a + 2 < b) {
        ans += k / 2 * (b - a);
        k %= 2;
    }
    ans += k;
    cout << ans << "\n";
}

Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,i=INTM()
    print(n-i+1)
if __name__ == '__main__':
    do()

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

int main(){
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  a=a+b;
  b=c+d;
  if(a<=b){
    if(a<b){
    cout <<"Right"<<endl;
    }
    else{
      cout <<"Balanced"<<endl;
  }
  }
    else{
      cout <<"Left"<<endl;
    }
  }

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i,n,m,t,data[1000],data2[1000],data3[1000],max,u,r=1;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        scanf("%d",&data[i]);
    }
    for(i=0;i<m;i++){
        scanf("%d",&data2[i]);
    }
    for(i=0;i<n;i++){
        data3[i]=0;
    }
    for(i=0;i<m;i++){
        for(t=0;t<n;t++){
            if(data[t]<=data2[i]){
                data3[t]++;
                break;
            }
        }
    }
    max=data3[0];
    for(u=0;u<n;u++){
        if(max<data3[u]){
            max=data3[u];
            r=u+1;
        }
    }
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 608
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> d(N); for(auto& in:d) cin >> in;
    sort(d.begin(),d.end()); d.erase(unique(d.begin(),d.end()),d.end());
    cout << d.size() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int main(){
	
	int N;
	std::cin >> N;
	std::map<int64_t, int> map;
	for(int i=0;i<N;++i){
		int64_t A;
		std::cin >> A;
		map[A]++;
	}
	for(auto itr=map.begin();itr!=map.end();){
		if(itr->second<2)map.erase((itr++)->first);
		else ++itr;
	}
	
	int64_t ans = 0;
	
	if(!map.empty()){
		auto front = map.rbegin();
		if(front->second>=4)
			ans = front->first*front->first;
		else if(std::next(front)!=map.rend()){
			auto next = std::next(front);
			ans = front->first*next->first;
		}
	}
	
	std::cout << ans << std::endl;
	
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
int arr[400006];
int a[400006],b[400006];
        int brr[200005];

signed main()
{
    int x;
    cin>>x;
    int y=x/500;
    x%=500;
    int z=x/5;
    cout<<y*1000+z*5;
}


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

int main()
{
	int n, m;
	cin >> n >> m;
	long long ans = 1;
	if (abs(n-m) > 1){
		cout << 0 << endl;
		return 0;
	}

	for (int i = 1; i < n+1; i++){
		ans *= i;
		ans %= 1000000007;
	}
	for (int i = 1; i < m+1; i++){
		ans *= i;
		ans %= 1000000007;
	}
	if (abs(n-m) == 0){
		ans *= 2;
		ans %= 1000000007;
	}
	cout << ans << endl;

}


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

int main() {
  string S;
  cin>>S;
  int Z=0;
  int a=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='A'||S.at(i)=='C'||S.at(i)=='G'||S.at(i)=='T'){
      a++;
    }
    else{
      Z=max(Z,a);
      a=0;
    }
  }
  Z=max(Z,a);
  cout<<Z<<endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

int main()
{
    int A,B;
    cin >> A >> B;
    string s;
    cin >> s;

    for(int i = 0; i < A; ++i){
        if(s[i] > '9' || s[i] < '0'){
            cout << "No" << endl;
            return 0;
        }
    }

    if(s[A] != '-'){
        cout << "No" << endl;
        return 0;
    }

    for(int i = A + 1; i < A + B + 1; ++i){
        if(s[i] > '9' || s[i] < '0'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
def solve(H, W, field):
    ret = []
    for y in range(0, H):
        for x in range(0, W):
            if field[y][x] % 2 == 1:
                for (xi, yi) in [(x + 1, y), (x, y + 1)]:
                    if 0 <= xi < W and 0 <= yi < H:
                            ret.append(" ".join([str(y + 1), str(x + 1), str(yi + 1), str(xi + 1)]))
                            field[y][x] -= 1
                            field[yi][xi] += 1
                            break
    return [len(ret)] + ret


if __name__ == "__main__":
    l = input()
    H, W = int(l.split()[0]), int(l.split()[1])
    field = [[int(c) for c in input().split(" ")] for _ in range(0, H)]
    [print(l) for l in solve(H, W, field)]


Measured memory_bytes: 17288