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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
//const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

int N;
vector<int> vi;

int main()
{
    cin >> N;
    _for(i,0,N){
        int num;
        cin >> num;
        vi.PB(num);
    }
    sort(ALL(vi));
    printf("%d\n",vi[N/2] - vi[N/2-1]);

    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890

using namespace std;

LLI A[100007];
LLI B[100007];

int main()
{
    int i,j;
    int n;

    scanf("%d",&n);
    for(i=1;i<=n+1;i++)
    {
        scanf("%lld",&A[i]);
    }
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&B[i]);
    }
    LLI counti=0;
    for(i=1;i<=n;i++)
    {
        if(B[i]>=A[i])
        {
            counti+=A[i];
            B[i]-=A[i];
            if(B[i]>=A[i+1])
            {
                counti+=A[i+1];
                A[i+1]=0;
            }
            else
            {
                counti+=B[i];
                A[i+1]-=B[i];
            }
        }
        else
        {
            counti+=B[i];
            B[i]=0;
        }
    }
    printf("%lld\n",counti);

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

int main() {
  int N;
  cin >> N;
  vector<int> A(N - 1), B(N - 1);
  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; i++) {
    cin >> A[i] >> B[i];
    A[i]--, B[i]--;
    G[A[i]].push_back(B[i]);
    G[B[i]].push_back(A[i]);
  }

  map<pair<int, int>, int> color;

  vector<int> vc(N, -1);

  vector<bool> visited(N, false);
  visited[0] = true;

  queue<int> que;
  que.push(0);

  int k = 0;

  while (!que.empty()) {
    int u = que.front();
    que.pop();

    int c = 1;

    for (int v : G[u]) {
      if (visited[v]) continue;
      if (c == vc[u]) c++;
      vc[v] = color[make_pair(u, v)] = color[make_pair(v, u)] = c++;
      que.push(v);
      visited[v] = true;
    }

    k = max(k, c - 1);
  }

  cout << k << endl;
  for (int i = 0; i < N - 1; i++) {
    cout << color[make_pair(A[i], B[i])] << endl;
  }
  return 0;
}


Measured memory_bytes: 19712
import bisect
s=input()
t=input()
jisho={}
alphabets = [chr(ord('a') + i) for i in range(26)]
for moji in alphabets:
    jisho[moji] = [i for i,x in enumerate(s) if x==moji]
lis = [jisho[moji] for moji in t]

if [] in lis:
    print(-1)
else:    
    old=-1
    count=0
    for cand in lis:
        z=bisect.bisect(cand,old)
        if z==len(cand):
            num=min(cand)
        else:
            num=cand[z]
#         tes = [temp for temp in cand if temp>old]
#         if len(tes)==0:
#             num = min(cand)
#         else:
#             num = min(tes)
        if num<=old: count+=1
        old=num
    print(count*len(s)+old+1)

Measured memory_bytes: 50652
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int cnt = 1;
        for(int i = 1; i < n; i++) {
        	if(s.charAt(i) == s.charAt(i-1)) continue;
        	cnt++;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 26068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll h,w,n,f[3005],inv[200005],fac[200005],mod=1000000007;
struct point{int x,y;}a[3005];
void pre()
{
	inv[0]=inv[1]=fac[0]=fac[1]=1;
	for(ll i=2;i<=200000;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(ll i=2;i<=200000;i++) inv[i]=inv[i-1]*inv[i]%mod,fac[i]=fac[i-1]*i%mod;
}
bool cmp(point x,point y){return x.x==y.x?x.y<y.y:x.x<y.x;}
ll cmn(ll m,ll n){return fac[m]*inv[m-n]%mod*inv[n]%mod;}
int main()
{
    pre();
    scanf("%lld%lld%lld",&h,&w,&n);
    for(int i=1;i<=n;i++) scanf("%d%d",&a[i].x,&a[i].y);
    sort(a+1,a+n+1,cmp);
    a[++n].x=h;a[n].y=w;a[0].x=a[0].y=1;
    f[0]=1;
    for(int i=0;i<n;i++)
    for(int j=i+1;j<=n;j++)
    if(a[i].y<=a[j].y)
    f[j]=(mod+f[j]-f[i]*cmn(a[j].x-a[i].x+a[j].y-a[i].y,a[j].x-a[i].x)%mod)%mod;
    printf("%lld",(mod-f[n])%mod);
    return 0;
}

Measured memory_bytes: 3456
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
vector<int> g[200020];
bool used[200020];
ll cnt1, cnt2;
void dfs(int x){
	used[x]=1;
	if(x<100000) cnt1++;
	else cnt2++;
	for(auto y:g[x]){
		if(!used[y]) dfs(y);
	}
}
int main()
{
    int n; cin>>n;
	for(int i=0; i<n; i++){
		int x, y; cin>>x>>y; x--; y--;
		g[x].push_back(y+100000);
		g[y+100000].push_back(x);
	}
	ll ans=0;
	for(int i=0; i<200000; i++){
		if(!used[i]){
			cnt1=0, cnt2=0;
			dfs(i);
			ans+=cnt1*cnt2;
		}
	}
	ans-=(ll)n;
	cout<<ans<<endl;
    return 0;
}

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

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

  bool ans = true;
  
  for (int i = 0;i < n-1;i++){
    if (h[i] < h[i+1]){
      h[i+1]--;
    }
    if (h[i] > h[i+1]){
      ans = false;
      break;
    }
  }

  if (ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3788
#include <stdio.h>

int main(void){
    int D;
    scanf("%d",&D);
    if(D == 25)
        puts("Christmas");
    else if(D == 24)
        puts("Christmas Eve");
    else if(D == 23)
        puts("Christmas Eve Eve");
    else if(D == 22)
        puts("Christmas Eve Eve Eve");
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	char[] s = sc.next().toCharArray();
      	Arrays.sort(s);
      	if(s[0]==s[1] && s[1]!=s[2] && s[2]==s[3]) System.out.println("Yes");
      	else System.out.println("No");
		//System.out.println(s[0]+""+s[1]+""+s[2]+""+s[3]);	
    }
}

Measured memory_bytes: 35668
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

struct Dice {
    top: u32,
    south: u32,
    east: u32,
    west: u32,
    north: u32,
    bottom: u32,
}

impl Dice {
    fn go_north(&mut self) {
        let tmp = self.top;
        self.top = self.south;
        self.south = self.bottom;
        self.bottom = self.north;
        self.north = tmp;
    }

    fn go_south(&mut self) {
        let tmp = self.top;
        self.top = self.north;
        self.north = self.bottom;
        self.bottom = self.south;
        self.south = tmp;
    }

    fn go_east(&mut self) {
        let tmp = self.top;
        self.top = self.west;
        self.west = self.bottom;
        self.bottom = self.east;
        self.east = tmp;
    }

    fn go_west(&mut self) {
        let tmp = self.top;
        self.top = self.east;
        self.east = self.bottom;
        self.bottom = self.west;
        self.west = tmp;
    }
}

fn main() {
    let v = read_vec::<u32>();
    let mut dice = Dice {
        top: v[0],
        south: v[1],
        east: v[2],
        west: v[3],
        north: v[4],
        bottom: v[5],
    };

    let cs = read::<String>();
    for c in cs.chars() {
        match c {
            'N' => dice.go_north(),
            'E' => dice.go_east(),
            'W' => dice.go_west(),
            _ => dice.go_south(),
        }
    }

    println!("{}", dice.top);
}



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

#define rep(i, n) for(long long i=0;i<n;i++)
using ll = long long;
const ll INF = (1LL<<60);

int main(){

    long double r; cin >> r;

    cout << 2*3.14159265358979*r << endl;

    return 0;
}

Measured memory_bytes: 3768
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))

#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define INF ((1LL<<62)-(1LL<<31))

ll n;
ll ans;
int main(){
	scanf("%lld",&n);
	while(n--){
		ll n,k;
		scanf("%lld%lld",&n,&k);
		while(n>k){
			ll cnt=(n%k)/(n/k+1);
			n-=cnt*(n/k+1);
			if(n%k==0)break;
			n-=n/k+1;
		}
		ans^=n/k;
	}
	puts(ans?"Takahashi":"Aoki");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない


int main() {

	string s;
	cin >> s;
	int ans = INF;

	rep(i, 0, s.size()-2) {
		int a = ((int)s[i] - 48);
		
		a = a * 10 + (int)s[i + 1] - 48;
		
		a = a * 10 + (int)s[i + 2] - 48;
		ans = min(ans, abs(a - 753));
	}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c;
		if(b * 2 > a){
			c = 0;
		}
		else{
			c = a - b * 2;
		}
		System.out.print(c);
	}

}

Measured memory_bytes: 21972
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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; }

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(ll i = 0;i < n;++i)
#define rep1(i, n) for(ll i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define chmin

    

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------
    ll N ,x;
    cin >> N >>x;
    ll a[N];
    rep(i,N) {
        cin >> a[i];
    }
    
    ll ans = 0;
    if (a[0]>x){
        ans += a[0] - x ;
        a[0] = x;
    }
    rep1(k,N){
        if(x < a[k] + a[k-1]){
            ans += a[k] - (x - a[k-1]);
            a[k] = x - a[k-1];
        }
    }
    pri(ans);
    
    return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int n,H,M;
  scanf("%d",&n);
  H=n/3600;
  n=n-H*3600;
  M=n/60;
  n=n-M*60;
  printf("%d:%d:%d\n",H,M,n);
  return(0);
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int main(){
  int l,r,d;
  cin>>l>>r>>d;
  int count=0;
  for(int i=l;i<=r;i++){
     if(i%d==0) count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    while(cin>>s)
    {
        int i,len,cnt=0;
        len= s.size();
        for(i=0;i<len/2;i++)
        {
            if(s[i]!=s[len-i-1])
                cnt++;
               
        }
        cout<<cnt<<endl;
    }
    return 0;
}


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

class Main{
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        final Bug[] A = new Bug[n];
        final boolean[] found = new boolean[n];
        final StringTokenizer in = new StringTokenizer(br.readLine(), " ");
        for(int i = 0; i<n; i++)
            A[i] = new Bug(Integer.parseInt(in.nextToken()), i);
        Arrays.sort(A);
        int cost = 0;
        final int min = A[0].weight;
        for(int i = 0; i<n; i++){
            if(found[i]) continue;
            found[i] = true;
            int m = 0;
            for(int j = A[i].index; j!=i; j = A[j].index){
                found[j] = true;
                cost += A[j].weight;
                m++;
            }
            cost += Math.min(A[i].weight*m, min*(m+2)+A[i].weight*2);
        }
        System.out.println(cost);
    }
}

class Bug implements Comparable<Bug>{
    final int weight;
    final int index;
    Bug(int weight, int index){
        this.weight = weight;
        this.index = index;
    }
    @Override
    public int compareTo(Bug o){
        if(weight<o.weight) return -1;
        else if(weight>o.weight) return 1;
        else return 0;
    }
}

Measured memory_bytes: 24972
#include<iostream>
#include<vector>
#include<cstring>
#include<map>
#include<bitset>
#include<assert.h>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<set>
#include<queue>
#define long long long
using namespace std;
const int N=1e6,mod=1e9+7;
int aa[N+2],bb[N+2],rq[N+2],n;
vector<pair<int,int> >ed;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  cin>>n;int tr=(n*(n-1))/2;if(n%2==0)tr--;

  for(int i=1;i<=n;i++)rq[i]=tr;int bad=!(n%2);
  for(int i=n;i>=1;i--)
  {
    for(int j=i-1;j>=1;j--)
    {
      if(j==bad)continue;
        ed.push_back({i,j});
    }
    bad++;
  }
  cout<<ed.size()<<endl;
  for(auto x:ed)cout<<x.first<<" "<<x.second<<endl;
  return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <memory.h>
#include <cmath>
#include <array>

void re(char* c);

void pr(long long x);

void pr(const char *x);

void ps();
template<class T, class... Ts> void ps(const T& t, const Ts&... ts);

#ifdef FFDBG

#else
#define dbg(x...) dsfdsfsdfasd
#endif

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#include <cstring>

char s[210000];

void solve()
{
    re(s);
    int n = strlen(s);

    int as = 0;
    long long ans = 0;

    rep(i,0,n) {
        if (s[i] == 'A') as++;
        if (s[i] == 'C') as=0;
        if (s[i] == 'B') {
            if (i+1 < n && s[i+1] == 'C') {
                ans += as;
                i++;
            }
            else as = 0;
        }
    }    

    ps(ans);
}

int main() {

    solve();
}

void re(char* c) { scanf("%s", c); }

void pr(long long x) { printf("%lld", x); }

void pr(const char *x) { printf("%s", x); }

void ps() { pr("\n"); }
template<class T, class... Ts> void ps(const T& t, const Ts&... ts) { 
    pr(t); if (sizeof...(ts)) pr(" "); ps(ts...); 
}



Measured memory_bytes: 384
#include<stdio.h>
int main(){
int a,b=0,c=0,i,x[101];
scanf("%d\n",&a);
for(i=0;i<102;i++){
x[i]=0;
}
for(i=0;i<a;i++){
scanf("%d ",&x[i]);
}
for(i=0;i<102;i++){
if(x[i]==1){
b++;
if(c<b){
c=b;
}
}
else{
b=0;
}
}
printf("%d\n",c+1);
return 0;
}


Measured memory_bytes: 2108
N = int(input())
a = 100
ans = [0]*N
for x in range(1,a):
    for y in range(1,a):
        for z in range(1,a):
            res = x**2 + y **2 + z**2 + x*y + y*z + z*x
            if res <=N:
                ans[res-1]+=1
for i in ans:
    print(i)



Measured memory_bytes: 69280
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 A, B;
  std::cin >> A >> B;
  std::cout << (A < 10 && B < 10 ? A * B : -1) << std::endl;
  return 0;
}

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

using namespace std;

template <class T>
using lim = numeric_limits<T>;

typedef long long ll;
typedef long double ld;

struct edge {
	int here;
	int there;
	int w;
};

// solve for min-path
// bellman-ford
pair<vector<ll>,vector<bool>> solve(vector<edge> myEdges, int n, int start){
	vector<ll> dist(n, lim<ll>::max());
	vector<bool> cycle(n, false);
	
	dist[start] = 0;
	
	for (int count = 0; count < n - 1; count ++){
		for (int i = 0; i < (int) myEdges.size(); i++){
			int u = myEdges[i].here;
			int v = myEdges[i].there;
			int w = myEdges[i].w;
			if (dist[u] == lim<ll>::max()) continue;
			if (dist[u] + w < dist[v]){
				dist[v] = dist[u]+w;
			}
		}
	}
	
	for (int count = 0; count < n; count++){
		for (int i = 0; i < (int) myEdges.size(); i++){
			int u = myEdges[i].here;
			int v = myEdges[i].there;
			int w = myEdges[i].w;
			if (dist[u] == lim<ll>::max()) continue;
			if (dist[u] + w < dist[v]) cycle[v] = true;
			
			if (cycle[u]) cycle[v] = true;
		}
	}
	
	return make_pair(dist,cycle);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m; cin >> n >> m;
	vector<vector<bool>> isEdge(n, vector<bool>(n,0));
	// grabbing cost matrix
	vector<edge> myEdges(m);
	for (int i = 0; i < m; i++){
		int a, b, c;
		cin >> a >> b >> c;
		isEdge[a-1][b-1] = true;
		myEdges[i].here = a-1;
		myEdges[i].there = b- 1;
		myEdges[i].w = -c;
	}
	
	
	auto ans = solve(myEdges, n, 0);
	if (ans.second[n-1]) cout << "inf" << endl;
	else cout << -ans.first[n-1] << endl;
}


Measured memory_bytes: 512
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)


H, N = list(map(int, input().split()))
a = []
for i in range(N):
    a.append(list(map(int, input().split())))


dp = [0 for i in range(H+1)]

for h in range(1, H+1):
    dp[h] = min([dp[max(0, h-a[i][0])] + a[i][1] for i in range(N)])

print(dp[H])





Measured memory_bytes: 75464
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <tuple>
#include <complex>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define previous fake_previous
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL MAXN = 4001;
const LL MAXK = 2000;

int n;
VLL a;
VLL b;
VLL fact;
VLL revFact;
VVLL DP1;
VVLL DP2;

inline LL power(LL x, LL to)
{
	LL res = 1;
	while (to)
	{
		if (to & 1)
			res = (res * x) % mod;

		x = (x*x) % mod;
		to >>= 1;
	}
	return res;
}

LL solve()
{
	//C(2a, 2b);
	LL res = 0, add;

	FOR(i, 0, n)
	{
		add = (fact[a[i] * 2 + b[i] * 2]) * revFact[a[i] * 2] % mod;
		add *= revFact[b[i] * 2];
		add %= mod;
		res += add;
	}

	res %= mod;
	return res;
}

LL calculate()
{
	DP1.assign(MAXN, VLL(MAXN, 0));
	DP2.assign(MAXN, VLL(MAXN, 0));
	FOR(i, 0, n)
		DP2[a[i] + MAXK][b[i] + MAXK]++, DP1[MAXK - a[i]][MAXK - b[i]]++;

	FOR(i, 0, MAXN)
		FOR(j, 0, MAXN)
	{
		if (i)
			DP1[i][j] = (DP1[i][j] + DP1[i - 1][j]) % mod;

		if (j)
			DP1[i][j] = (DP1[i][j] + DP1[i][j - 1]) % mod;
	}

	LL ans = 0;

	FOR(i, 0, MAXN)
		FOR(j, 0, MAXN)
	{
		ans += (DP1[i][j] * DP2[i][j]) % mod;
		ans %= mod;
	}

	ans %= mod;
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	fact.assign(MAXN*2, 0);
	revFact.assign(MAXN * 2, 0);
	fact[0] = 1;
	FOR(i, 1, MAXN*2)
		fact[i] = (fact[i - 1] * i) % mod;

	FOR(i, 1, MAXN*2)
		revFact[i] = power(fact[i], mod - 2);

	cin >> n;
	a.assign(n, 0);
	b.assign(n, 0);
	FOR(i, 0, n)
		cin >> a[i] >> b[i];

	LL ans = calculate();	
	ans += mod;
	ans -= solve();
	ans %= mod;
	ans *= power(2, mod - 2);
	ans %= mod;
	cout << ans << endl;
	cin >> n;
	return 0;
}

Measured memory_bytes: 253952
def main():

    N, M = map(int, input().split())

    lights = []
    for _ in range(M):
        ary = [int(v) - 1 for v in input().split()]
        lights.append(ary[1:])

    P = [int(v) for v in input().split()]

    def is_on(state):
        for i, sw in enumerate(lights):
            on = 0
            for j in sw:
                if state & (1 << j) != 0:
                    on += 1
            if (on % 2) != P[i]:
                return False
        return True

    def search(i, state):
        if i == N:
            ok = 1 if is_on(state) else 0
            return ok

        c = 0
        c += search(i+1, state)
        c += search(i+1, state | (1 << i))
        return c

    print(search(0, 0))


main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

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

    int n, k; cin >> n >> k;
    // int cnt = 0;
    // FOR(a, 1, n+1) FOR(b, 1, n+1) FOR(c, 1, n+1) {
    //     if ((a+b)%k==0 && (b+c)%k==0 && (a+c)%k==0) {
    //         cnt++;
    //         debug(a, b, c, a+b+c);
    //     }
    // }
    // debug(cnt);
    ll ans;
    if (k%2!=0) {
        ans = pow(n/k, 3);
    } else {
        int h = k/2;
        for(int i=h; i<n+1; i+=k) {
            ans += pow((n-h)/k+1, 2);
        }
        ans += pow(n/k, 3);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll n; cin>>n;
	vector<ll> a(n);
	FOR(i,1,n) cin>>a[i];
	vector<ll> m(n);
	FOR(i,1,n){
		m[a[i]-1]++;
	}
	REP(i,n){
		cout<<m[i]<<endl;
	}
	return 0;
}


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

const ll INF = 1e+18;

int main(){
    int n;
    cin >> n;
    int x[n];
    rep(i, n) cin >> x[i];
    
    ll ans = INF;
    rep(k, 101){
        ll res = 0;
        rep(i, n) {
            res += ll(pow(x[i] - k, 2));
        }
        ans = min(res, ans);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#define ll long long
#define INF 0x3f3f3f3f
#define SIS std::ios::sync_with_stdio(false)
using namespace std;
struct node
{
    string s;
    ll cnt;
};
bool cmp(node a,node b) {return a.s<b.s;}
int main()
{
    SIS;
    int n;
    while(cin>>n)
    {
        vector <string> s;
        vector <node> x;
        node b;
        string a;
        for(int i=0;i<n;i++)
        {
            cin>>a;
            s.push_back(a);
        }
        sort(s.begin(),s.end());
        ll maxx=1;
        b.cnt=1,b.s=s[0];
        for(int i=1;i<n;i++)
        {
            if(s[i]==s[i-1])
            {
                b.cnt++;
                maxx=max(maxx,b.cnt);
            }
            else
            {
                x.push_back(b);
                b.cnt=1;
                b.s=s[i];
            }
        }
        x.push_back(b);
        maxx=max(maxx,b.cnt);
        sort(x.begin(),x.end(),cmp);
        for(int i=0;i<x.size();i++)
        {
            if(x[i].cnt==maxx)
                cout<<x[i].s<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 16496
from collections import Counter
N = int( input())
A = Counter(list( map( int, input().split())))
Q = 10**9 + 7
ans = 1
for i in range(N-1, 0, -2):
    if A[i] == 1:
        ans = 0
        break
if N%2 == 1:
    if A[0] != 1:
        ans = 0
print(ans*pow(2,N//2,Q))

Measured memory_bytes: 14820
def poker(a, b)
  if a == b
    puts "Draw"
  elsif a == 1
    puts "Alice"
    exit
  elsif b == 1
    puts "Bob"
    exit
  elsif a > b
    puts "Alice"
  else
    puts "Bob"
  end
end

a, b = gets.chomp.split(" ").map(&:to_i)
poker(a, b)

Measured memory_bytes: 1788
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long
#define ld double
#define ull unsigned long long
#define PI pair < int, int > 

const int N = 5e5 + 123;
const int M = 123;
const ld Pi = acos(-1);
const ll Inf = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const int Sz = 501;
const int MOD = 1e9 + 7;

void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mult(int a, int b) {
  return 1ll * a * b % mod;
}
int sum(int a, int b) {
  add(a, b);
  return a;
}

int n, a[N], ans;
ll p[N];

void solve() { 
  cin >> n;
  for (int i = 1;i <= n;i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  for (int i = 1;i <= n;i++) p[i] = p[i - 1] + a[i];
//  for (int i = 1;i <= n;i++) cout << a[i] << " "; cout << endl;
  ll now = 0;
  for (int i = 1;i <= n;i++) {
    now += a[i];
    int pos = i + 1;
    bool fail = 0;
   // cout << "i = " << i << endl;
    ll old = now;
    while(pos <= n) {
     // cout << "pos = " << pos << endl;
      int l = pos, r = n, nxt = -1;
      while(l <= r) {
        int mid = (l + r) / 2;
        if (a[mid] <= 2 * now) {
          nxt = mid;
          l = mid + 1;
        } else r = mid - 1;
      }
      if (nxt == -1) {
        fail = 1;
        break;
      }
      now += p[nxt] - p[pos - 1];
      pos = nxt + 1;
    }
    if (!fail) ans++;
    now = old;
  }
  cout << ans << endl;
}

int main() {
  #ifdef wws
   freopen("in", "r", stdin);
   // freopen("in", "w", stdout);
  #endif 
  ios_base::sync_with_stdio(0);
  int tt = 1; 
  while(tt--) solve();
  return 0;
}

Measured memory_bytes: 3328
N = int(input())
C = [int(input()) for _ in range(N)]
MOD = 10**9 + 7

if N <= 2:
    print(1)
    exit()

dp = [1,1]
last_idx = [-1]*(2*10**5 + 1)
last_idx[C[0]] = 0
last_idx[C[1]] = 1

for i in range(2, N):
    if C[i-1] == C[i] or last_idx[C[i]] == -1:
        dp.append(dp[-1] % MOD)
    else:
        dp.append((dp[-1] + dp[last_idx[C[i]]]) % MOD)
    last_idx[C[i]] = i

print(dp[-1])

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


void solve(long long x){

  if (x >= 400 && x <= 599 ) {
      cout << "8"  << endl;
      return ;
  }
  if (x >= 600 && x <= 799 ) {
      cout << "7"  << endl;
      return ;
  }
  if (x >= 800 && x <= 999 ) {
      cout << "6"  << endl;
      return ;
  }
  if (x >= 1000 && x <= 1199 ) {
      cout << "5"  << endl;
      return ;
  }
  if (x >= 1200 && x <= 1399 ) {
      cout << "4"  << endl;
      return ;
  }
  if (x >= 1400 && x <= 1599 ) {
      cout << "3"  << endl;
      return ;
  }
  if (x >= 1600 && x <= 1799 ) {
      cout << "2"  << endl;
      return ;
  }
  if (x >= 1800 && x <= 1999 ) {
      cout << "1"  << endl;
      return ;
  }

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


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

int main()
{
	int N;

	cin >> N;

	if (N <= 111) {
		printf("111");
	}
	else if (N <= 222) {
		printf("222");
	}
	else if (N <= 333) {
		printf("333");
	}
	else if (N <= 444) {
		printf("444");
	}
	else if (N <= 555) {
		printf("555");
	}
	else if (N <= 666) {
		printf("666");
	}
	else if (N <= 777) {
		printf("777");
	}
	else if (N <= 888) {
		printf("888");
	}
	else if (N <= 999) {
		printf("999");
	}

	return 0;
}







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

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

  map<int, int> a;
  int temp;
  for (int i = 0; i < N; i++) {
    cin >> temp;
    a[temp]++;
  }

  // // for (auto itr = a.begin(); itr != a.end(); ++itr) {
  // //   cout << itr->first << ":" << itr->second <<  ' ';
  // // } cout << endl;

  int count = 0;
  for (auto itr = a.begin(); itr != a.end(); ++itr) {
    if (itr->first > itr->second) count += itr->second;
    else if (itr->first < itr->second) count += (itr->second - itr->first);
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 4736
# 合成数 x は p ≤ √x を満たす素因子 p をもつ
# x が素数かどうかは，2~√xまでの範囲を調べればよい

def is_Prime(x): #xが素数かどうかを調べる
   if x == 2: # 2なら素数
      return x
   if x < 2 or x % 2 == 0: # 2未満or偶数ならFalse
      return False
   for i in range(3, x, 2): # 3からxまでステップ2で
      if i * i > x: # √xまで調べる
         break
      if x % i == 0: # 合成数ならFalse
         return False
   return x

N = int(input())
num_list = [int(input()) for _ in range(N)] # 1つの数字をN行入力
count = 0
for i in num_list: # 各数字について調べる
   prime = is_Prime(i)
   if prime != False: # 素数だった数字のみカウントする
      count+=1
print(count)


Measured memory_bytes: 5988
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end())
#define pb push_back
#define mp make_pair
#define MODP(A,B) A=(A+B)%mod
typedef pair<ll,ll> P;
typedef pair<double,double> Pd;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
    ll N,M; cin>>N>>M;
    cout<<(N*(N-1)+M*(M-1))/2<<endl;
}

Measured memory_bytes: 256
from math import factorial
def comb(n,r):
  if n-r<0:
    return 0
  return factorial(n)//(factorial(r)*factorial(n-r))
n,a,b=map(int,input().split())
v=list(map(int,input().split()))
mod=10**9+7
v.sort(reverse=True)
x=v[a-1]
cnt=0
s=0
for i in range(n):
  if x==v[i]:
    cnt+=1
  if x<v[i]:
    s=i+1
ans=0
print(sum(v[:a])/a)
if v[0]==v[a-1]:
  for i in range(a,min(cnt+1,b+1)):
    ans+=comb(cnt,i)
  print(ans)
else:
  ans=comb(cnt,a-s)
  print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,ans,sum;
string a[50];
int b[50],c[50];
vector<string> d[50];
vector<int> e[50];
map<string,int> m;
map<int,int> memo[40];
void dfs(int x,int p,int q,int t){
  if(sum-q<=ans) return;
  ans=max(ans,p);
  if(x==n) return;
  //cout<<x<<" "<<p<<" "<<q<<":"<<sum<<" "<<ans<<endl;
  if(memo[x].count(t>>x)&&p<=memo[x][t>>x]) return;
  memo[x][t>>x]=p;
  if(!((t>>x)&1)){
    int np=p,nq=1,nt=t;
    np+=b[x];
    for(int i=0;i<c[x];i++){
      if((nt>>e[x][i])&1) continue;
      nt+=1LL<<e[x][i];
      nq+=b[e[x][i]];
    }
    dfs(x+1,np,nq,nt);
  }
  dfs(x+1,p,q,t);
}
signed main(){
  while(cin>>n,n){
    m.clear();
    for(int i=0;i<40;i++) memo[i].clear();
    for(int i=0;i<n;i++){
      cin>>a[i]>>b[i]>>c[i];
      m[a[i]]=i;
      d[i].clear();
      d[i].resize(c[i]);
      for(int j=0;j<c[i];j++) cin>>d[i][j];
    }
    for(int i=0;i<n;i++){
      e[i].clear();
      e[i].resize(c[i]);
      for(int j=0;j<c[i];j++) e[i][j]=m[d[i][j]];
    }
    ans=sum=0;
    for(int i=0;i<n;i++) sum+=b[i];
    int t=0;
    int p=b[0],q=0;
    for(int i=0;i<c[0];i++){
      if((t>>e[0][i])&1) continue;
      t+=1LL<<e[0][i];
      q+=b[e[0][i]];
    }
    dfs(1,p,q,t);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 18044
N = int(input())
Ln = list(map(int, input().split()))
Ln.sort()
# Lc = collections.Counter(Ln)
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        if (Ln[i] == Ln[j]):
            continue
        for k in range(j+1, N):
            if (Ln[i] == Ln[k] or Ln[j] == Ln[k]):
                continue
            if Ln[i] + Ln[j] > Ln[k]:
                ans += 1
print(ans)



Measured memory_bytes: 9132
#include<iostream>
using namespace std;
int a[100005];
int Parttion(int a[],int l,int r)
{
    int x=a[r];
    int i=l-1;
    for(int j=l;j<=r-1;j++)if(a[j]<=x)swap(a[++i],a[j]);
    swap(a[++i],a[r]);
    return i;
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=Parttion(a,0,n-1);
    for(int i=0;i<n;i++)
    {
        if(i)cout<<' ';
        if(ans==i)cout<<"["<<a[i]<<"]";
        else cout<<a[i];
    }
    cout<<endl;
    return 0;
}

/*
5
5 4 1 2 3

1 4 5 2 3

1 2 5 4 3

1 2 3 4 5


12
13 19 9 5 12 8 7 4 21 2 6 11

*/



Measured memory_bytes: 3484
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, p;
    while (1)
    {
        cin >> n >> p;
        if (n == 0)
            break;
        vector<int> cnt(n);
        int pos = 0, x = p;
        while (1)
        {
            if (p > 0)
            {
                cnt[pos++]++;
                if (cnt[pos - 1] == x)
                {
                    cout << pos - 1 << endl;
                    break;
                }
                p--;
                pos %= n;
            }
            else
            {
                p += cnt[pos++];
                cnt[pos - 1] = 0;
                pos %= n;
            }
        }
    }
}


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

void dfs(int pos, vector< vector< int > > &v, vector< bool > &visit){
  if(visit[pos]) return;
  else{
    visit[pos] = true;
    for(auto x: v[pos]){
      dfs(x,v,visit);
    }
  }
}

int main(){
  int n, m; cin >> n >> m;
  int ans = 0;
  int a, b, c;
  vector< bool > v(n + 1,0);
  vector< vector< int > > look(n + 1);
  for(int i = 0; i < m; ++i){
    cin >> a >> b >> c;
    look[a].push_back(b);
    look[b].push_back(a);
  }
  for(int i = 1; i < (n + 1); ++i){
    if(!v[i]){
      ans++;
      dfs(i,look,v);
    }
  }
  cout << ans << '\n';
}


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

signed main(void)
{
	int x, y, i;
	cin >> x >> y;
	if (x % y == 0)
		cout << -1 << endl;
	else
		cout << x << endl;
	return 0;
}


Measured memory_bytes: 256
S = input()

plus = [i for i in range(1, len(S))]

import itertools

ans = int(S)
for c in range(1, len(S)):
    for l in itertools.combinations(plus, c):
        l_ = list(l)
        formula = ""
        for i, s in enumerate(S):
            if i in l_:
                formula += "+"
            formula += s
        ans += sum([int(num) for num in formula.split("+")])
print(ans)

Measured memory_bytes: 42476
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

from collections import defaultdict

H, W, N = map(int, input().split())

dic = defaultdict(int)
lst = [0] * (10)
lst[0] = (H - 2) * (W - 2)

for _ in range(N):
    a, b = map(int, input().split())
    for i in range(-1, 2):
        for j in range(-1, 2):
            if 2 <= (a + i) <= (H - 1):
                if 2 <= (b + j) <= (W - 1):
                    tmp = dic[(a + i, b + j)]
                    lst[tmp] -= 1
                    lst[tmp + 1] += 1
                    dic[((a + i, b + j))] += 1

print (*lst, sep = '\n')
    



Measured memory_bytes: 166868
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P	  = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n;
	cin >> n;
	ll ans = INF;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ans = min(ans, i + n / i - 2);
		}
	}
	dump(ans);
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int from, to;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == 'A'){
      from = i;
      break;
    }
  }
  for(int i = s.size() - 1; i >= 0; i--){
    if(s.at(i) == 'Z'){
      to = i;
      break;
    }
  }

  cout << to - from + 1 << endl;
}

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

results = [0] * N

def g(x, y, z):
  return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x

for x in range(1, 100):
  for y in range(1, 100):
    for z in range(1, 100):
      w = g(x,y,z)
      if w > N:
        break
      else:
        results[w - 1] += 1

for result in results:
  print(result)

Measured memory_bytes: 9364
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

#pragma GCC target("avx,avx2")
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ll=long long ;
#define Whats(x)// cout<<#x<<" is "<<(x)<<endl

int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
int memo[52][52][4][8];

int H, W;
bool ok=false;
bool dfs(int x, int y, const vector<string>&field, vector<vector<int>>&comes,int way,int flag) {
	if(memo[x][y][way][flag]!=-1)return false;
	else memo[x][y][way][flag]=0;
	if(y!=H||x!=1)comes[y][x]=true;

	if(x==1&&y==1)flag^=1;
	if(x==W&&y==1)flag^=2;
	if(x==W&&y==H)flag^=4;
	if (x == 1 && y == H && flag == 7) {
		ok=true;
		throw(false);
	}
	Whats(x);
	Whats(y);
	for (int nway = way - 1; nway <= way + 1; ++nway) {
		int away=(nway+4)%4;
		int nx=x+dx[away];
		int ny=y+dy[away];
		
		if (field[ny][nx] == '.'&&comes[ny][nx]==false) {
			dfs(nx,ny,field,comes,away,flag);
		}
	}
	comes[y][x]=false;
	return false;
}

int main() {
	while (true) {
		cin>>H>>W;
		if(!H)break;
		ok=false;
		for (int i = 0; i < 52; ++i) {
			for (int j = 0; j < 52; ++j) {
				for (int way = 0; way < 4; ++way) {
					for (int x = 0; x < 8; ++x) {
						memo[i][j][way][x]=-1;
					}
				}
			}
		}
		vector<string>field(H+2);
		field[0]=string(W+2,'#');
		field[H+1]=string(W+2,'#');
		for (int i = 0; i < H; ++i) {
			string st; cin >> st;
			st.insert(st.begin(), '#');
			st.insert(st.end(), '#');
			field[i + 1] = st;
		}

		vector<vector<int>>comes(H+2,vector<int>(W+2));
		try {
			dfs(1,H,field,comes,2,0);
		}
		catch (...) {
		}
		if (ok) {
			cout<<"YES"<<endl;

		}
		else {
			cout<<"NO"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3716
<?php
fscanf(STDIN, '%s', $s);
$ans = '';
if($s[0] == $s[1] && $s[1] != $s[2] && $s[2] == $s[3]) $ans = 'Yes';
elseif($s[0] == $s[2] && $s[2] != $s[1] && $s[1] == $s[3]) $ans = 'Yes';
elseif($s[0] == $s[3] && $s[0] != $s[1] && $s[1] == $s[2]) $ans = 'Yes';
else {
    $ans = 'No';
}
echo $ans, PHP_EOL;

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
long long cnt,sum;
long long a[200005],b[200005];
vector<long long>v;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++) 
		cin>>a[i];
	for(int i=0;i<n;i++)
		cin>>b[i];
	for(int i=0;i<n;i++)
	{
		if(a[i]>=b[i])
			v.push_back(a[i]-b[i]);
		else
		{
			sum+=(b[i]-a[i]);
			cnt++;
		}
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
	{
		if (sum>0)
		{
			sum-=v[i];
			cnt++;
		}
	}
	if(sum>0)
		cnt=-1;
	cout<<cnt;

	return 0;
}

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

int INF = 1 << 20;
int main(){
  int n;
  while(1){
    cin >> n;
    if(n == 0) break;
    vector<int> student;
    for(int i = 0; i < n; i++){
      int tmp;
      cin >> tmp;
      student.push_back(tmp);
    }

    int ans = INF;
    for(int i = 0; i < n - 1; i++){
      for(int j = i + 1; j < n; j++){
        int sub = abs(student[i] - student[j]);
        if(sub < ans) ans = sub;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int a, b, c; cin >> a >> b >> c;
  cout << min(c, b/a) << endl;
  system("pause");
}


Measured memory_bytes: 504
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Integer[] l = new Integer[m];
        Integer[] r = new Integer[m];
        for (int i = 0; i < m; i++) {
            l[i] = Integer.parseInt(sc.next());
            r[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        // 主処理
        int max = Arrays.stream(l).mapToInt(i -> i).max().getAsInt();
        int min = Arrays.stream(r).mapToInt(i -> i).min().getAsInt();
        int result = Math.max(0, min - max + 1);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 65180
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LLI long long int
#define LI long int 
const LI MOD=1e9+7;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//            When something is important enough, you do it even if the odds are not in your favor.

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    int t1=1;//cin>>t;
    while(t1--){
      string s,t;cin>>s>>t;
      LI sl=s.length(),tl=t.length(),i;
      std::vector<LI> v[26];
      fo(i,0,sl){
        v[s[i]-'a'].pb(i);
      }
      LI num=0,prev=INT_MAX;
      fo(i,0,tl){
        if(v[t[i]-'a'].size()==0) {cout<<-1;return 0;}
        LI in=lower_bound(v[t[i]-'a'].begin(), v[t[i]-'a'].end(),prev)-v[t[i]-'a'].begin();
        if(in<v[t[i]-'a'].size()&&v[t[i]-'a'][in]==prev) in++;
        if(in>=v[t[i]-'a'].size()) in=0,num++;
        prev=v[t[i]-'a'][in];
      }
      num--;
      cout<<num*sl+prev+1;
    }
    return 0;
}

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

const int MAXN = 15;

int N, M, k[MAXN], s[MAXN][MAXN], p[MAXN];
int main(){
	scanf("%d %d", &N, &M);
	for(int i = 0; i < M; i++){
		scanf("%d", &k[i]);
		for(int j = 0; j < k[i]; j++){
			scanf("%d", &s[i][j]);
			s[i][j]--;
		}
	}
	for(int i = 0; i < M; i++)
		scanf("%d", &p[i]);
		
	int res = 0;
	for(int mask = 0; mask < (1 << N); mask++){
		bool ok = true;
		for(int i = 0; i < M; i++){
			int st = 0;
			for(int j = 0; j < k[i]; j++)
				if(mask & (1 << s[i][j]))st ^= 1;
			
			if(st != p[i])ok = false;
		}
		if(ok)res++;
	}
	printf("%d\n", res);
	
	return 0;
}


Measured memory_bytes: 256