akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

ll xs[1<<15][15];
ll ys[1<<15][15];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi x(n),y(n),p(n);
    rep(i,n) cin >> x[i] >> y[i] >> p[i];
    rep(bit,1<<15) rep(i,n) {
        xs[bit][i] = abs(x[i]);
        ys[bit][i] = abs(y[i]);
        rep(j,n) if(bit>>j&1) {
            chmin(xs[bit][i],(ll)abs(x[i]-x[j]));
            chmin(ys[bit][i],(ll)abs(y[i]-y[j]));
        }
    }
    vl ans(n+1,linf);
    rep(bit,1<<n) {
        rrep(X,bit+1) {
            X &= bit;
            int Y = bit^X;
            ll sum = 0;
            rep(i,n) sum += min(xs[X][i],ys[Y][i])*p[i];
            chmin(ans[__builtin_popcount(bit)],sum);
        }
    }
    rep(i,n+1) cout << ans[i] << '\n';
}


Measured memory_bytes: 11320
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var D = one[1];
	myout(Math.ceil(N / (D * 2 + 1)));
}


Measured memory_bytes: 29868
#include<stdio.h>

int binarySearch(int,int *,int);

int main(){
  int S[100000],T[50000],n,q;
  int i,res=0;

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

  scanf("%d",&q);
  if (q<=50000){
    for(i=0; i<q; i++){
      scanf("%d",&T[i]);
      res += binarySearch(n,S,T[i]);
    }
  }

  printf("%d\n",res);

  return 0;
}

int binarySearch(int n,int *S,int key)
{
  int left=0,right=n,mid;

  while(left<right){
    mid = (left+right)/2;
    if (S[mid] == key) return 1;
    if (key < S[mid]) right = mid;
    else if (key > S[mid]) left = mid + 1;
  }

  return 0; 
}



Measured memory_bytes: 2300
f=lambda s,y1,x1,y2,x2:s[y2][x2]-s[y2][x1-1]-s[y1-1][x2]+s[y1-1][x1-1]
H,W,N=map(int,raw_input().split())
a=[map(int,raw_input()) for _ in [0]*H]
s,s1,s2=[ [[0]*(W+1) for _ in [0]*-~H] for _ in [0]*3 ]
for h in range(H):
	for w in range(W):
		s[h+1][w+1]=s[h+1][w]+s[h][w+1]-s[h][w]+a[h][w]
		s1[h+1][w+1]=s1[h+1][w]+s1[h][w+1]-s1[h][w]+(a[h][w]*(w+1<W and a[h][w+1]))
		s2[h+1][w+1]=s2[h+1][w]+s2[h][w+1]-s2[h][w]+(a[h][w]*(h+1<H and a[h+1][w]))
for _ in [0]*N:
	y1,x1,y2,x2=map(int,raw_input().split())
	print f(s,y1,x1,y2,x2)-f(s1,y1,x1,y2,x2-1)-f(s2,y1,x1,y2-1,x2)

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

int main() {
  string S[3];
  int w = 0, id[3] = {0, 0, 0}, s[3];
  for (int i=0; i<3; i++) {
    cin >> S[i];
    s[i] = S[i].size();
  }
  while (1) {
    if (id[w] >= s[w])
      break;
    char c = S[w][id[w]];
    id[w]++;
    w = c - 'a';
  }
  cout << (char)('A'+w) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	a = 0;
	string str = "";
	char c2;
	for(int i =0;i<3;i++){
		cin >> c2;
		str.push_back(c2);
	}
	a = stoi(str);
	
	if(a%4 == 0)
		cout<<"YES";
	else
		cout<<"NO";
	
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : GURUTEJA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second


  int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n;
    cin>>n;
     long long int a[n],cons=1000000000+7,s=0,ans=0;
    for(int i=0; i<n; i++){
    	cin>>a[i];
    }
    s=0;
    for(int i=n-1; i>=0; i--){
       ans+=((a[i]%cons)*s)%cons;
       s+=(a[i]%cons);
       s%=cons;
       ans%=cons;
    }
    cout<<ans<<endl;
    return 0;
  }

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

int main() {
	ll H,N;
	cin >> H >> N;
  vector<ll> A(N);
	rep(i,N) cin >> A[i];
	if(accumulate(all(A),0) >= H){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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

#define ll long long

using namespace std;

int n, d[100];
int main() {
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> d[i];

    ll sol = 0;
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j) {
            sol += d[i] * d[j];
        }

    cout << sol;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	static int MOD=10007;
	static int[][] dp;
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int days=sc.nextInt();
		dp=new int[days][8];
		String s=sc.next();
		for(int i=0; i<days; i++) {
			for(int j=0; j<8; j++) {
				dp[i][j]=0;
			}
		}
		/*
		 * 0 000
		 * 1 001 I
		 * 2 010 O
		 * 3 011 IO
		 * 4 100 J
		 * 5 101 JI
		 * 6 110 JO
		 * 7 111 JOI
		 */
		if(s.charAt(0)=='J') {
			dp[0][4]=1;
			dp[0][5]=1;
			dp[0][6]=1;
			dp[0][7]=1;
		}
		else if(s.charAt(0)=='O') {
			dp[0][6]=1;
			dp[0][7]=1;
		}
		else if(s.charAt(0)=='I') {
			dp[0][5]=1;
			dp[0][7]=1;
		}
		for(int i=1; i<days; i++) {
			if(s.charAt(i)=='J') {
				J(i);
			}
			else if(s.charAt(i)=='O') {
				O(i);
			}
			else if(s.charAt(i)=='I') {
				I(i);
			}
		}
		int sum=0;
		for(int i=0; i<8; i++) {
			sum+=dp[days-1][i];
		}
		pl(sum%MOD);
	}
	public static void J(int day) {
		for(int i=0; i<8; i++) {
			if(i>=4) {
				dp[day][4]+=dp[day-1][i];
			}
			if(i!=2) {
				dp[day][5]+=dp[day-1][i];
			}
			if(i!=1) {
				dp[day][6]+=dp[day-1][i];
			}
			dp[day][7]+=dp[day-1][i];
		}
		for(int i=0; i<8; i++) {
			dp[day][i]%=MOD;
		}
	}
	public static void O(int day) {
		for(int i=0; i<8; i++) {
			if(i!=1 && i!=4 && i!=5) {
				dp[day][2]+=dp[day-1][i];
			}
			if(i!=4) {
				dp[day][3]+=dp[day-1][i];
			}
			if(i!=1) {
				dp[day][6]+=dp[day-1][i];
			}
			dp[day][7]+=dp[day-1][i];
		}
		for(int i=0; i<8; i++) {
			dp[day][i]%=MOD;
		}
	}
	public static void I(int day) {
		for(int i=0; i<8; i++) {
			if(i%2==1) {
				dp[day][1]+=dp[day-1][i];
			}
			if(i!=4) {
				dp[day][3]+=dp[day-1][i];
			}
			if(i!=2) {
				dp[day][5]+=dp[day-1][i];
			}
			dp[day][7]+=dp[day-1][i];
		}
		for(int i=0; i<8; i++) {
			dp[day][i]%=MOD;
		}
	}

	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 24340
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    int N;
    cin >> N;
    vector<char> S(N);
    rep(i, N) cin >> S[i];
    int K;
    cin >> K;
    --K;
    rep(i, N) {
        if (S[i] != S[K]) S[i] = '*';
    }
    rep(i, N) cout << S[i];
    cout << "\n";
    return 0;
}


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

	#include <set>
	#include <iterator>
	using namespace std;
	// using namespace __gnu_pbds;


	#define f first
	#define s second
	#define pb push_back
	#define all(x) x.begin(),x.end()

	#define ll long long int
	#define vi vector<int>
	#define vii vector<pair<int,int> >
	#define pii pair<int,int>
	#define plii pair<pair<ll, int>, int>
	#define piii pair<pii, int>
	#define viii vector<pair<pii, int> >
	#define vl vector<ll>
	#define vll vector<pair<ll,ll> >
	#define pll pair<ll,ll>
	#define pli pair<ll,int>
	#define mp make_pair
	#define ms(x, v) memset(x, v, sizeof x)
	#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

	#define f_in(st) freopen(st,"r",stdin)
	#define f_out(st) freopen(st,"w",stdout)

	#define INF (ll)1e17
	#define matrix vector<vector<ll> >

	#define fr(i, a, b) for(i=a; i<=b; i++)
	#define fb(i, a, b) for(i=a; i>=b; i--)
	#define ASST(x, l, r) assert( x <= r && x >= l )
	#define maxbits 9
	#define maxmask (1ll<<maxbits)
	// typedef tree<pll, null_type, less<pll>, rb_tree_tag,
	//              tree_order_statistics_node_update>
	//     new_data_set;
	const int  N=(ll)2e3 +10, M=(ll)1e9+1 ;
	const int mod =(ll)1e9+7 , MAX=(ll)1e6+10;
	string fir="Monocarp",sec="Bicarp";

	void work(){
		ll a,b,c,k;
		cin >> a >> b >> c >> k;
		if(k<a){
			cout << k << "\n";
		}
		else if(k<a+b){
			cout << a << "\n";
		}
		else if(k<= a+b+c){
			ll rem=k-a-b;
			cout << a-rem << "\n";
		}
		return;
			
		
	}

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

		

		// to avoid printing in Scientific Notation like 2.14748e+09 and instead print: 2147483648.000000
		cout << fixed ;
		
		// precomp();
		ll t,z;
		// cin >> t;
		t=1;
		// z=t;
		while(t--){
				// cout << "Case #" << z-t << ": " << "\n";
		        work();
		
		}

		return 0;
	}
		

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; ++i)
    cin >> s[i];

  int ret = 0;
  int xa = 0, bx = 0, bxa = 0;
  for (auto& t : s) {
    for (int i = 0; i < t.size() - 1; ++i) {
      if (t[i] == 'A' && t[i + 1] == 'B')
        ++ret;
    }
    if (t.front() == 'B') {
      if (t.back() == 'A')
        ++bxa;
      else
        ++bx;
    } else if (t.back() == 'A')
      ++xa;
  }
  ret += bxa + min(bx, xa);
  if (bx == 0 && xa == 0 && bxa)
    --ret;

  cout << ret << "\n";

  return 0;
}


Measured memory_bytes: 768
import java.util.*;

public class Main {
    public static int solve() {
        return -1;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a, b, w;
        w = sc.nextInt();
        a = sc.nextInt();
        b = sc.nextInt();

        if ((a <= b && b <= a+w) || (b <= a && a <= b+w))
            System.out.println(0);
        else if (a+w < b) {
            System.out.println(b-(a+w));
        } else if (b+w < a) {
            System.out.println(a-(b+w));
        }
    }
}


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

int asc(const void *a, const void *b){
    return *(int *)a - *(int *)b;
}

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

    if(n>=m){
        printf("0\n");
        return 0;
    }

    qsort(x,m,sizeof(int),asc);

    int dif[m-1];
    for(i=0;i<m-1;i++){
        dif[i]=x[i+1]-x[i];
    }

    qsort(dif,m-1,sizeof(int),asc);

    for(i=0;i<m-n;i++){
        sum += dif[i];
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 1268
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

var sc = newScanner()

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

func main() {
	a, b := scanInt(), scanInt()
	answer := a * b
	fmt.Println(answer)
}

func debug(a ...interface{}) {
	fmt.Println(a...)
}


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

int main()
{
    int n; cin>>n;
    if(n==1 || n<10) return cout<<"Yes",0;
    if(n>81) return cout<<"No",0;
    int d;
    for(int i=9;i>=1;i--)
    {
        if(n%i==0)
        {
            d=n/i;
            break;
        }
    }
    if(d>=10) cout<<"No";
    else cout<<"Yes";
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int INF_INT = 1e9;

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

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

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N,W;
    cin >> N >> W;
    ll wei[N],value[N];
    for(int i = 0; i < N ; i++){
        cin >> wei[i] >> value[i];
    }
    ll dp[N+1][W+1];
    for(int i = 0; i <= N; i++){
        for(int j = 0; j < W+1; j++) dp[i][j] = 0;
    }
    for(int i = 1; i <= N; i++){
        for(int j = 0 ; j < W+1; j++){
            dp[i][j] = dp[i-1][j];
            if(j - wei[i-1] >= 0) chmax(dp[i][j],dp[i-1][j-wei[i-1]]+value[i-1]); 
        }
    }
    ll res = 0;
    for(int i = 0; i < W+1; i++) res = max(res,dp[N][i]);
    cout << res << endl;
    return 0;
}


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

int main(){
  string s,t,s_sort,t_sort;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<char>());
  if(s < t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	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;
	}

	// for prime MOD
	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;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b>>1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;


//////////////////////////

int main() {
	ll A, B;
	cin >> A >> B;

	vvll d(A + 1, vll(B + 1));
	repn(i, A)repn(j, B) cin >> d[i][j];

	vll a, b, c;

	ll k = 1;
	rep(x, 101)rep(y, 101) {
		ll k = -1;

		repn(i, A)repn(j, B) {
			k = max(d[i][j] - x * i - y * j, k);
		}
		
		if (k >= 0) { a.push_back(x); b.push_back(y); c.push_back(k);}
	}

	ll M = a.size();

	bool tf = 1;

	repn(i, A)repn(j, B) {
		ll dis = INF;
		rep(l, M) {
			dis = min(dis, a[l] * i + b[l] * j + c[l]);
		}
		if (dis != d[i][j]) { tf = 0; }
	}

	if (tf == 0) { cout << "Impossible" << endl; return 0; }

	cout << "Possible" << endl;

	cout << 202 << " " << 200 + M << endl;

	repn(i, 100) {
		cout << i << " " << i + 1 << " " << "X" << endl;
	}
	repn(i, 100) {
		cout << 101 + i << " " << 101 + i + 1 << " " << "Y" << endl;
	}
	rep(i, M) {
		cout << a[i] + 1 << " " << 202 - b[i] << " " << c[i] << endl;
	}
	cout << 1 << " " << 202 << endl;
	
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main() {
	int n;
	cin >> n;
	map<int,int> mp[n+10];
	rep(i,n-1){
		int a,b;
		cin >> a >> b;
		mp[a].insert(P(b,i));
		mp[b].insert(P(a,i));
	}

	queue<P> que;
	int color[n+10] = {};
	que.push(P(1,-1));
	while(que.size()){
		P p = que.front(); que.pop();
		int c = 1;
		for(auto x : mp[p.first]){
			if(color[x.second]) continue;
			if(c == p.second) c++;
			color[x.second] = c;
			que.push(P(x.first,c));
			c++;
		}
	}

	int ma = 0;
	for(int i = 0; i < n; i++) ma = max(ma,color[i]);
	cout << ma << endl;
	for(int i = 0; i < n-1; i++) cout << color[i] << endl;

	return 0;
}

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


ll MAX =  2000007LL;

const ll MOD = (ll)1e9 + 7;

vector<ll> fac(MAX + 1);
vector<ll> finv(MAX + 1);
vector<ll> inv(MAX + 1);

void fact() {

	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;

	for (ll i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

ll comb(ll n, ll k) {

	if (n < k) {
		return 0;
	}

	if (n < 0 || k < 0) {
		return 0;
	}

	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	fact();

	ll r1, r2, c1, c2;

	cin >> r1 >> c1 >> r2 >> c2;


	ll ans = 0;

	ans += comb(r1 + c1, r1);

	for (ll i = r1 + 1; i <= r2; ++i) {
		ans += comb(c2 + i, i);
		ans %= MOD;
	}

	for (ll i = c1 + 1; i <= c2; ++i) {
		ans += comb(r2 + i, i);
		ans %= MOD;
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 50104
// 

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

char s[55][55];

bool left(int i, int k){
	if(s[i][k] == s[i][k-1]) return true;
	else return false;
}
bool right(int i, int k){
	if(s[i][k] == s[i][k+1]) return true;
	else return false;
}
bool up(int i, int k){
	if(s[i][k] == s[i-1][k]) return true;
	else return false;
}
bool bottom(int i, int k){
	if(s[i][k] == s[i+1][k]) return true;
	else return false;
}

int main(){
  int h, w;
  bool f1 = true, f2 = true;

  cin >> h >> w;
  for(int i = 0; i <= h+1; i++){
  	for(int k = 0; k <= w+1; k++){
  	  if(i == 0 || k == 0 || i > h || k > w){
  	  	s[i][k] = '1'; // 外堀
  	  	continue;
  	  }
  	  cin >> s[i][k];
  	}
  }

  /*
  // debug
  for(int i = 0; i <= h+1; i++){
  	for(int k = 0; k <= w+1; k++){
  	  cout << s[i][k] << " ";
  	}
  	cout << endl;
  }*/

  for(int i = 1; i <= h; i++){
  	for(int k = 1; k <= w; k++){
  	  if(s[i][k] == '.'){
	  	if(left(i,k) || right(i,k) || up(i,k) || bottom(i,k)) continue;
	  	else f1 = false;
  	  }
	  else{
	    if(left(i,k) || right(i,k) || up(i,k) || bottom(i,k)) continue;
	  	else f2 = false;
	  }
	  if(!(f1) && !(f2)){
	  	cout << "No" << endl;
	  	return 0;
  	  }
  	}
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
$result = 0;

while (!feof(STDIN) ) {
	$arg[] = trim(fgets(STDIN));
}

/*for ($i=0; $i<5; $i++) {
	$arg[] = trim(fgets(STDIN));
}*/

foreach ($arg as $minutes) {
	$trim = intval(substr(strval($minutes), -1, 1));
	if ($trim == 0) {
		$trims[] = 10;
	} else {
		$trims[] = $trim;
	}
}

$min = min($trims);
$min_key = array_keys($trims, $min);

foreach ($arg as $key => $value) {
	if ($key != $min_key[0]) {
		$value = ceil((intval($value)/10))*10;
	}
	$result = $value + $result;
}

echo $result;

Measured memory_bytes: 4856
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  ll x = 1, y = 1;
  rep(i, 0, n) {
    ll t, a;
    cin >> t >> a;
    ll max_val = max((x + t - 1) / t, (y + a - 1) / a);
    x = max_val * t;
    y = max_val * a;
  }
  cout << x + y << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

const int MOD = 1e9+7;

signed main() {
    int N;
    cin >> N;
    int res = 1;
    FOR(i, 1, N+1) {
        res *= i;
        res %= MOD;
    }
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import combinations
n=int(input())
if n == 1:
    print(1)
else:
    xs = []
    for _ in range(n):
        x,y=map(int,input().split())
        xs.append((x,y))
    
    def func(c):
        p,q=(xs[c[0]][0]-xs[c[1]][0],xs[c[0]][1]-xs[c[1]][1])
        ys=[(x,y) for x,y in xs if (x-p,y-q) not in xs]
        return len(ys)
    
    c = combinations(range(n),2)
    print(min(map(func, c)))

Measured memory_bytes: 3188
import sys
from decimal import Decimal
N = int(input())
A = list(map(int,input().split()))
A.sort()
cnt = Decimal('1')
for i in range(N):
  if cnt*Decimal(str(A[i]))>Decimal(10**18):
    print(-1)
    sys.exit()
  cnt = Decimal(cnt)*Decimal(A[i])


print(cnt)


Measured memory_bytes: 22612
# coding: utf-8
# Your code here!
N,x=map(int,input().split())
A=list(map(int,input().split()))

count=0
for i in range(N-1):
    if A[i]+A[i+1]>x:
        count+=(A[i+1]+A[i]-x)
        A[i+1]=max(0,A[i+1]-(A[i+1]+A[i]-x))

print(count)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
 
 string S,T,U;
  int a,b;
  cin >> S >> T >> a >> b >> U;
  if(U==S){
  	cout << a-1 << " " << b << endl;
  }else if(U==T){
  	cout << a << " " << b-1 << endl;
  }
}

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

short table[1005][1005];

int match_length(char* a, char* b) {
	int len_a = strlen(a);
	int len_b = strlen(b);
	int i, j;
	
	for(i=0;i<=len_a;i++) {
		for(j=0;j<=len_b;j++) {
			table[i][j] = 0;
		}
	}

	for(i=1;i<=len_a;i++) {
	    for(j=1;j<=len_b;j++) {
	        if (a[i-1] == b[j-1]) {
	            table[i][j] = table[i-1][j-1] + 1;
	        } else {
	        	if(table[i][j-1] > table[i-1][j]) {
	        		table[i][j] = table[i][j-1];
	        	} else {
	        		table[i][j] = table[i-1][j];
	        	}
	        }
	    }
	}
	
	return table[len_a][len_b];
}

int main(void) {
	int i,n;
	char buff1[1005];
	char buff2[1005];
	
	scanf("%d\n", &n);
	for(i=0;i<n;i++) {
		scanf("%s\n", buff1);
		scanf("%s\n", buff2);
		printf("%d\n", match_length(buff1, buff2));
	}
	
	return 0;
}

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

int main() {
  int64_t a;
  string b;
  cin >> a >> b;
  
  int b100 = (b.at(0) - '0')*100 + (b.at(2) - '0')*10 + (b.at(3) - '0');
  
  int64_t ans = (a * b100) / 100;
  
  cout << ans << endl;
}



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

inline int sg1(int n,int k){
	if(n<k)return 0;
	if(n%k==0)return n/k;
	return sg1(n-n/k-1,k);
}
inline int sg2(int n,int k){
	if(n<k)return 0;
	if(n%k==0)return n/k;
	int t=n/k;
	t=(n-t*k+t)/(t+1)*(t+1);
	return sg2(n-t,k);
}

int main(){
	int n,a,k,fl=0;
	scanf("%d",&n);
	while(n--){
		scanf("%d%d",&a,&k);
		int t=n/log(n);
		fl^=k<=t?sg1(a,k):sg2(a,k);
	}
	puts(fl?"Takahashi":"Aoki");
	return 0;
}

Measured memory_bytes: 384
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vc vector<char> 
#define vll vector< pair<ll,ll> > 
#define mps map<string ,ll>
#define mpc map<char ,ll>
#define mpl map<ll, ll>
#define pr pair<ll,ll>
#define tpl tuple<ll,ll,ll>
ll containsDigit(ll number, ll digit){while (number != 0){int curr_digit = number % 10;if (curr_digit == digit) return 1;number /= 10;}return 0;}
ll soltn(ll x, ll n) {if(x>=0) return x%n;    else return n+x%n;}
ll pd(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}
ll coda(ll n,ll d){ll count=0;while(n!=0){if(n%10==d)count++;n/=10;}return count;}
ll mdls(ll x){return max(x,-x);}
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x%MOD*x%MOD)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
ll isSubstr(string s1, string s2) {   ll M = s1.length();    ll N = s2.length();  for (ll i = 0; i <= N - M; i++) { ll j; for (j = 0; j < M; j++) if (s2[i + j] != s1[j])  break;         if (j == M) return i;   } return -1; } 
//s2>s1;if(not) rtrn -1;
// Driver Program to test above function 
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll tt=1;
//int N=1000001;

//SieveOfEratosthenes
	//   cin>>tt;
	      while(tt--)
{
	char c;
	cin>>c;
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
	cout<<"vowel";
	else
	cout<<"consonant";
	ee;
	
}
return 0;
}















Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int h, w;
vector<string> field;

int main() {
    cin >> h >> w;
    int ans = h*w;
    field.resize(h);
    vector<vector<int>> matrix(h, vector<int>(w, -1));

    rep(i, h) {
        cin >> field[i];
    }

    rep(i, h) {
        rep(j, w) {
            if(field[i][j] == '#') {
                matrix[i][j] = 0;   //黒マスは0
                ans--;
            }
        }
    }
    matrix[0][0] = 1;   //スタートは1

    queue<pair<int, int>> next;

    next.push(make_pair(0, 0)); //queueにスタートを入れる

    while(next.size() != 0) {
        int x = next.front().first;
        int y = next.front().second;
        rep(i, 4) { //4方向調べる
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx < 0 || h <= nx || ny < 0 || w <= ny) {
                continue;   //field外はダメ
            }
            if(matrix[nx][ny] >= 0) {
                continue;   //探索したマスもダメ
            }
            matrix[nx][ny] = matrix[x][y] + 1;  //隣マスに1足す
            next.push(make_pair(nx, ny));   //隣マスをqueueに入れる
        }
        next.pop(); //探索したマスをqueueから出す
    }

    ans -= matrix[h-1][w-1];

    if(matrix[h-1][w-1] == -1) {
        cout << -1;
    }
    else {
        cout << ans;
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
const int BUF = 100005;


int nVal, M;
int val[BUF];

void read() {
    cin >> nVal >> M;
    val[0] = 0;
    for (int i = 1; i <= nVal; ++i) cin >> val[i];
    ++nVal;
}


void work() {
    int sum[BUF];
    sum[0] = 0;
    for (int i = 1; i < nVal; ++i) {
        sum[i] = (sum[i - 1] + val[i]) % M;
    }

    long long ans = 0;
    map<int, int> sum2cnt;

    for (int i = 0; i < nVal; ++i) {
        if (sum2cnt.count(sum[i])) {
            ans += sum2cnt[sum[i]];
        }
        if (!sum2cnt.count(sum[i])) {
            sum2cnt[sum[i]] = 0;
        }
        ++sum2cnt[sum[i]];
    }

    cout << ans << endl;
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 3968
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int n,k;cin>>n>>k;
	vector<vector<bool>> dpf, dpb;
	vector<ll> A;
	rep(i,n){
		ll a;cin>>a;
		A.push_back(a);
	}

	rep(i, n+2){
		dpf.push_back(vector<bool>(k+1, false));
		dpb.push_back(vector<bool>(k+1, false));
	}

	dpf[0][0] = true;
	dpb[n+1][0] = true;
	rep(i,n){
		rep(j,k+1){
			dpf[i+1][j] = dpf[i][j];
			dpb[n+1-i-1][j] = dpb[n+1-i][j];
		}

		rep(j,k+1){
			if(A[i]+j > k) break;
			if(!dpf[i][j]) continue;
			dpf[i+1][A[i]+j] = true;
		}

		rep(j,k+1){
			if(A[n-i-1]+j > k) break;
			if(!dpb[n+1-i][j]) continue;
			dpb[n+1-i-1][A[n-i-1]+j] = true;
		}
	}
/*
	rep(i,n+1){
		rep(j,k+1){
			cerr<<j<<" ";
		}
		cerr<<endl;
		rep(j,k+1){
			cerr<<dpf[i][j]<<" ";
		}
		cerr<<endl;
		rep(j,k+1){
			cerr<<dpb[i][j]<<" ";
		}
		cerr<<endl;
	}*/

	ll ans = n;
	reps(i, n){
		vector<ll> front,back;
		rep(j,k+1){
			if(dpf[i-1][j]){
				front.push_back(j);
			}
			if(dpb[i+1][j]){
				back.push_back(j);
			}
		}
		reverse(all(back));
		int fi=0, bi=0;
		while(fi < front.size() && bi < back.size()){
			ll l = k - A[i-1];
			ll r = k;
			if(front[fi] + back[bi] < l){
				fi++;
			}else if(front[fi] + back[bi] >= r){
				bi++;
			}else{
				ans--;
				cerr<<i<<" "<<front[fi]<<" "<<back[bi]<<endl;
				break;
			}
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 7096
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0; i < n; i++)
#define REPR(i, n) for(long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(long long i = m; i <= n; i++)
#define FORR(i, m, n) for(long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;



int main(){FIN

    ll a,b;cin>>a>>b;
    vll v(4);
    v[0] = a; v[1] = b; v[2] = a-1; v[3] = b-1;
    VSORTR(v);
    cout<<v[0]+v[1]<<endl;
    return 0;
}

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

struct book{
    int score,id;
    string city;
    bool operator<(book x){
        if(city==x.city){
            return score > x.score; //同名の町なら得点を昇順ソート
        }else{
            return city < x.city; //都市名を降順ソート
        }
    }
};

int main(){
    int N;
    cin >> N;
    book res[N];
    for(int i=0;i<N;i++){
        string s;
        int p;
        cin >> s >> p;
        res[i].city=s;
        res[i].score=p;
        res[i].id=i+1;
    }
    sort(res,res+N);
    for(int i=0;i<N;i++) cout << res[i].id << endl;
}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, A);
    IN(string, B);
    ll x = B[0] - '0';
    ll y = stoi(B.substr(2));
    OUT(A * (100 * x + y) / 100);
}

Measured memory_bytes: 3628
H, W = map(int, input().split())
table = []
for i in range(H):
    table.append(input())

dxs = [0, 1, 0, -1, 1, 1, -1, -1]
dys = [1, 0, -1, 0, 1, -1, 1, -1]
output = []
for i in range(H):
    row = []
    for j in range(W):
        if table[i][j] == "#":
            row.append("#")
        else:
            cnt = 0
            for d in range(8):
                ni = i + dxs[d]
                nj = j + dys[d]
                if 0 <= ni and ni < H and 0 <= nj and nj < W:
                    if table[ni][nj] == "#":
                        cnt += 1
            row.append("{}".format(cnt))
    output.append(row)
for row in output:
    print("".join(row))


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;

int MOD=1000000007;


int main(){
    ll N,A,B,ans=0;
    cin >> N >> A >> B;
    if(A==0){
        cout << 0 << endl;
        return 0;
    }
    ans=N/(A+B); ans=A*ans; 
    if(N%(A+B)>A) ans+=A;
    else ans+=N%(A+B);
    cout << ans << endl;
}


Measured memory_bytes: 256
[h, w] = input().split()

h = int(h)
w = int(w)

if h == 1 or w == 1:
    print(1)
else:
    if(h * w % 2 == 0):
        print(int(h * w / 2))
    else:
        print(int(h * w / 2 + 1))


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

vector<ll> m(1001,0);

int main(){
    long long s;
    cin>>s;

    const int v=1000000000;

    int x=(v-s%v)%v;
    int y=(s+x)/v;

    // 0 0 1000000000 1 435958503 311114771

    cout<<"0 0 1000000000 1 "<<x<<" "<<y<<endl;
}

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

namespace AGC004_B3
{
    class Program
    {
        static long N, x;
        static void Main(string[] args)
        {
            var t = scan;
            N = t[0]; x = t[1];
            var a = scan;
            var b = new long[N];

            
            for (long i = 0; i < N; i++)
            {
                b[i] = a[i];
            }

            long ans = a.Sum();

            for (long k = 1; k < N; k++)
            {
                long time = k * x;

                for (long i = 0; i < N; i++)
                {
                    long p = (i - k < 0) ? i - k + N : i - k;
                    b[i] = Math.Min(b[i], a[p]);
                    time += b[i];
                }
                ans = Math.Min(ans, time);
            }
            Console.WriteLine(ans);
        }

        static long[] scan { get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); } }
    }
}


Measured memory_bytes: 3032
<?php

const MAX_X = 1000;
const MAX_Y = 1000;
const COMPUTATIONAL_ERROR = 0.000001;

list($n) = explode(' ', trim(fgets(STDIN)));
$points = [];

for ($i = 0; $i < $n; ++$i) {
    $points[] = explode(' ', trim(fgets(STDIN)));
}

$max_r = sqrt(MAX_X ** 2 + MAX_Y ** 2) / 2;
$upper_r = $max_r;
$lower_r = 0;
while ($upper_r - $lower_r > COMPUTATIONAL_ERROR) {
    $radius = ($upper_r + $lower_r) / 2;
    $intersections = getIntersections($points, $radius);
    $filtered_intersections = filterIntersection($intersections, $points, $radius);
    if (empty($filtered_intersections)) {
        $lower_r = $radius;
    } else {
        $upper_r = $radius;
    }
}

echo $radius;

function getIntersections(array $points, float $radius): array
{
    $point_num = count($points);
    $intersections = [];
    for ($i = 0; $i < $point_num; ++$i) {
        for ($j = $i + 1; $j < $point_num; ++$j) {
            $x_diff = $points[$i][0] - $points[$j][0];
            $y_diff = $points[$i][1] - $points[$j][1];
            $distance = sqrt($x_diff ** 2 + $y_diff ** 2);

            if ($distance - $radius * 2 > COMPUTATIONAL_ERROR) {
                continue;
            }

            $median = [($points[$i][0] + $points[$j][0]) / 2, ($points[$i][1] + $points[$j][1]) / 2];
            $h = sqrt($radius ** 2 - ($distance / 2) ** 2);

            $intersections[] = [$median[0] - $h * $y_diff / $distance, $median[1] + $h * $x_diff / $distance];
            $intersections[] = [$median[0] + $h * $y_diff / $distance, $median[1] - $h * $x_diff / $distance];
        }
    }

    return $intersections;
}

function filterIntersection(array $intersections, array $points, float $radius): array
{
    return array_filter($intersections, function ($intersection) use ($points, $radius) {
        foreach ($points as $point) {
            $distance = sqrt(($intersection[0] - $point[0]) ** 2 + ($intersection[1] - $point[1]) ** 2);
            if ($distance - $radius > COMPUTATIONAL_ERROR) {
                return false;
            }
        }

        return true;
    });
}


Measured memory_bytes: 6776
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(long long i=0; i<x;i++)
#define mod 1000000007
#define INF 10000000000000000
typedef long long ll;
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; }


struct UnionFind {
	vector<int> par;
  
  UnionFind(int N): par(N){
  	for(int i=0;i<N;i++) par[i] =i;
  }
};





int main(){
  ios::sync_with_stdio(false);
  
 
  ll N,W;
  cin>>N>>W;
  ll w[N],v[N];
  rep(i,N) cin>>w[i]>>v[i];
  
  ll mx_size = 100*1000;
  
  ll dp[mx_size+1];
  rep(i,mx_size+1) dp[i]=INF;
  
  rep(i,N){
  	for(ll j=mx_size; j>=v[i];j--){
    	if(j==v[i]){
        	dp[j]=min(w[i],dp[j]);
        }else if(dp[j-v[i]]!=INF){
        	dp[j] = min(dp[j],dp[j-v[i]]+w[i]);
        } 
    }
  }
  
 
  for(ll i=mx_size;i>=0;i--){
 	if(dp[i] <=W){
      cout<<i;
      return 0;
    }
    //cout<<dp[i]<<' ';
  }
  
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
const int MAX = 500000;

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

void COMinit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++)
	{
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

long long COM(int n, int k)
{
	if (n < k)
		return 0;
	if (n < 0 || k < 0)
		return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main()
{
	int n;
	cin >> n;
	map<ll, ll> _map;
	vecll a(n);
	rep(i, n)
	{
		cin >> a[i];
		_map[a[i]]++;
	}
	ll sum = 0;
	for (auto [x, c] : _map)
	{
		sum += c * (c - 1) / 2;
	}
	for (auto i = 0; i < n; i++)
	{
		cout << sum - _map[a[i]] + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 12760