akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  int n;
  while (cin >> n) {
    string s;
    cin >> s;
    int r = count(ALL(s), 'R');
    int b = count(ALL(s), 'B');
    cout <<  (r > b ? "Yes" : "No") << endl;
  }
}


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

using namespace std;

int n;
long long ans, t[100];

long long gcd(long long a, long long b){
	return (!b ? a : gcd(b, a%b));
}

long long lcm(long long a, long long b){
	return max(a, b)/gcd(a, b)*min(a, b);
}

int main(){
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> t[i];
	ans = t[0];
	for(int i = 1; i < n; ++i) ans = lcm(ans, t[i]);
	cout << ans << endl;
}

Measured memory_bytes: 256
//import java.io.FileNotFoundException;
//import java.io.FileReader;
import java.util.Scanner;



public class Main {
	public static void main(String[] args) {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
				
		int[][] a;
		int[] b;
		int []c;
		try{Scanner sc =new Scanner(System.in);
			int n=sc.nextInt();
			int m=sc.nextInt();
			a=new int[n][m];
			b=new int[m];
			c=new int[n];
			for(int i=0;i<n;i++){
				for(int l=0;l<m;l++){
					a[i][l]=sc.nextInt();
				}
			}
			for(int i=0;i<m;i++){
				b[i]=sc.nextInt();
			}sc.close();
			//////////////////////////////////////////////////////////
		    //ここまで入力部
		    //////////////////////////////////////////////////////////
		    //↓より計算部
			
			for(int i=0;i<n;i++){
				for(int l=0;l<m;l++){
					c[i]+=b[l]*a[i][l];
					}System.out.println(c[i]);
				}
			
			}//catch(FileNotFoundException ee){}
		catch(ArrayIndexOutOfBoundsException e){System.out.println("配列エラーです");}
		
		}
	}

Measured memory_bytes: 31860
=begin
愚直に足す
=end

while (n, x = gets.split.map(&:to_i)) != [0, 0]
  cnt = 0
  (1..n).each do |i|
    ((i+1)..n).each do |j|
      k = x - (i+j)
      cnt += 1 if k <= n && k > j
    end
  end
  puts cnt
end


Measured memory_bytes: 6860
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstring>
#include <string>
#include <string.h>
#include <cmath>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <list>
#include <stack>
#include <bitset>
#include <fstream>
#include <sstream>
#include <assert.h>
#define eps 1e-7
#define SIZE 1000100
#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define pi acos(-1.0)
#define mp make_pair
#define ll long long
#define int long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
const int mod = 998244353;
int n, inv[SIZE], cnt[SIZE], tp, maxx = 0, ans[SIZE], res = 0;
inline int qpow(int a, int b, int m) {	//快速幂，求a ^ b mod m
	int res = 1;
	while (b) {
		if (b & 1) res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
signed main() {
	io(); cin >> n;
	rep(i, 1, n) {
		cin >> tp;
		cnt[tp]++;
		maxx = max(maxx, tp);
	}
	for (int i = maxx; i; --i) {
		int s1 = 0, s2 = 0;
		for (int j = i; j <= maxx; j += i) {
			s1 = (s1 + cnt[j] * j % mod) % mod;
			s2 = (s2 + cnt[j] * j % mod * j % mod) % mod;
		}
		ans[i] = (s1 * s1 % mod - s2 + mod) % mod;
		for (int j = i + i; j <= maxx; j += i) {
			ans[i] = (ans[i] - ans[j] + mod) % mod;
		}
	}
	rep(i, 1, maxx) {
		res = (res + ans[i] * qpow(i, mod - 2, mod) % mod) % mod;
	}
	cout << res * qpow(2, mod - 2, mod) % mod;
}

Measured memory_bytes: 16640
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	parseProblem()
}

func parseProblem() {
	n := scanInt(sc)
	as := nextIntSlice(sc, n)
	q := scanInt(sc)
	answers := make([]bool, q)
	for i := 0; i < q; i++ {
		m := scanInt(sc)
		answers[i] = resolve(as, m)
	}
	for i := 0; i < len(answers); i++ {
		if answers[i] {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}

func resolve(as []int, m int) bool {
	sum := 0
	for i := 0; i < len(as); i++ {
		sum += as[i]
	}
	if sum < m {
		return false
	} else if sum == m {
		return true
	}
	for j := 0; j < 1<<uint(len(as)); j++ {
		if match(as, j, m) {
			return true
		}
	}
	return false
}

func match(as []int, j, m int) bool {
	sum := 0
	for i := 0; i < len(as); i++ {
		if j&(1<<uint(i)) != 0 {
			sum += as[i]
		}
		if sum == m {
			return true
		}
	}
	return false
}

// package: gocom
// packed src of [/Users/masumi/dev/src/github.com/masu-mi/gamemo/lib/gocom/next.go] with goone.

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

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

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}



Measured memory_bytes: 1104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int N = S.size();
  int A_min;
  int Z_max;
  int check_A = 0;
  for(int i = 0; i < N; i++){
    char a = S.at(i);
    if(a == 'A' && check_A == 0){
      A_min = i;
      check_A = 1;
    }else if(a == 'Z'){
      Z_max = i;
    }
  }
  cout << Z_max - A_min +1 << endl;
}

Measured memory_bytes: 3760
a=[1,9,30,76,141,267,400,624,885,1249,1590,2208,2689,3411,4248,5248,6081,7485,8530,10248,11889,13687,15228,17988,20053,22569,25242,28588,31053,35463,38284,42540,46581,50893,55362,61824,65857,71247,76884,84388,89349,97881,103342,111528,120141,128047,134580,146316,154177,164817,174438,185836,194157,207927,218812,233268,245277,257857,268182,288216,299257,313635,330204,347836,362973,383709,397042,416448,434025,456967,471948,499740,515581,536073,559758,583960,604833,633651,652216,683712,709065,734233,754734,793188,818917,846603,874512,909496,933081,977145,1006126,1041504,1073385,1106467,1138536,1187112,1215145,1255101,1295142,1342852,1373253,1422195,1453816,1502376,1553361,1595437,1629570,1691292,1726717,1782111,1827492,1887772,1925853,1986837,2033674,2089776,2145333,2197483,2246640,2332104,2379085,2434833,2490534,2554600,2609625,2693919,2742052,2813988,2875245,2952085,3003306,3096024,3157249,3224511,3306240,3388576,3444609,3533637,3591322,3693924,3767085,3842623,3912324,4027884,4102093,4181949,4270422,4361548,4427853,4548003,4616104,4718640,4812789,4918561,5003286,5131848,5205481,5299011,5392008,5521384,5610705,5739009,5818390,5930196,6052893,6156139,6239472,6402720,6493681,6623853,6741078,6864016,6953457,7094451,7215016,7359936,7475145,7593865,7689630,7886244,7984165,8130747,8253888,8403448,8523897,8684853,8802826,8949612,9105537,9267595,9376656,9574704,9686065,9827097,9997134,10174780,10290813,10493367,10611772,10813692]
x=int(input())
print(a[x-1])

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

int main() {
  int n,k,q; cin>>n>>k>>q;
  vector<int> l(n,0);
  for (int i=0; i<q; i++){
    int a; cin>>a;
    a-=1;
    l[a]+=1;
  }
  for (auto t : l){
    cout<<(k-q+t>0 ? "Yes" : "No")<<endl;
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <unordered_map>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    unordered_map<string, ll> m;
    for(int i = 0; i < n; ++i){
        string tmp;
        cin >> tmp;
        sort(tmp.begin(), tmp.end());
        m[tmp]++;
    }
    ll ans = 0;
    for(auto it = m.begin(); it != m.end(); ++it){
        ans += it->second * (it->second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7328
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
   int a,b;
   cin >> a >> b;
   
   int so=1;
   int ans =0;
   
   while(so < b){
      so += a-1;
      ans++;
   }
   
   cout << ans << endl;
   
   return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll w, a, b, result;
  cin >> w >> a >> b;
  if(a < b) result = b - (a + w);
  if(a > b) result = a - (b + w);
  if(result < 0) result = 0;
  cout << result << endl;
	return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    pair<int,int> w[1000];
    vector<pair<int,int> > block;
    cin>>n;
    for(int i=0; i<n; i++) {
        cin>>w[i].first;
        w[i].second=i;
    }
    sort(w, w+n);
    int cost=0;
    for(int i=0; i<n; i++) {
        if(w[i].first!=-1) {
            int m=0;
            for(int c=w[i].second; c!=i; c=w[c].second) {
                m++;
                cost+=w[c].first;
                w[c].first=-1;
            }
            block.push_back(make_pair<int,int>(w[i].first, m));
        }
    }
    for(int i=0; i<block.size(); i++) cost+=min(block[i].first*block[i].second, block[i].first*2+w[0].first*(block[i].second+2));
    cout<<cost<<'\n';
    return 0;
}

Measured memory_bytes: 1228
#define ll long long
#define ld long double
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set2d(array, val, m, n) memset(array, val, sizeof(array[0][0]) * m * n);
#include <bits/stdc++.h>
using namespace std;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x %= p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll po(ll base, ll powerRaised)
{
    if (powerRaised != 0)
        return (base * po(base, powerRaised - 1));
    else
        return 1;
}
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 //*/
    ld l;
    cin >> l;
    l /= 3;
    cout << setprecision(20) << l * l * l;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
ll N;
signed main(){
    cin>>N;
    vector<P> T(N);
    REP(i, N){
        ll a, b; cin>>a>>b;
        T[i] = P(b, a);
    }
    sort(ALL(T));
    bool res =true;
    ll t=0;
    REP(i, N){
        t += T[i].second;
        if(t>T[i].first){
            res=false;
            break;
        }
    }
    if(res) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3328
A,B,C,D = map(int, input().split())

import fractions

g = fractions.gcd(C, D)
E = C*D//g
num = (B//C-(A-1)//C) + (B//D-(A-1)//D) - (B//E-(A-1)//E)
print(B-A+1-num)

Measured memory_bytes: 5304
import sys

s = sys.stdin.buffer.readline().rstrip().decode()
MOD = 2019
ans = [1] + [0 for i in range(MOD)]
t = 1
r = 0
for i in reversed(s):
    r = (r + int(i)*t) % MOD
    t = t*10%2019
    ans[r] += 1
print(sum([m*(m-1)//2 for m in ans]))


Measured memory_bytes: 9344
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        if(n % 10 == 0){
        	System.out.println(10);
        }else{
        	String s = Integer.toString(n);
            int ans = 0;
            for(int i = 0; i < s.length(); i++){
            	int a = Integer.parseInt(s.substring(i, i + 1));
                ans += a;
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 35716
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	int h[n]; rep(i,n) cin >> h[i];
	int ans = 0, now = 0;
	for(int i = n - 2; i >= 0; --i) {
		if(h[i] >= h[i + 1]) {
			now++;
		} else {
			now = 0;
		}
		ans = max(ans, now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
  int a,b,c,d;
  scanf("%d",&d);
  a=d/1000;
  b=(d/100)%10;
  c=(d/10)%10;
  d=d%10;
  if(a+b+c+d==7)printf("%d+%d+%d+%d=7",a,b,c,d);
  else if(a+b+c-d==7)printf("%d+%d+%d-%d=7",a,b,c,d);
  else if(a+b-c+d==7)printf("%d+%d-%d+%d=7",a,b,c,d);
  else if(a+b-c-d==7)printf("%d+%d-%d-%d=7",a,b,c,d);
  else if(a-b+c+d==7)printf("%d-%d+%d+%d=7",a,b,c,d);
  else if(a-b+c-d==7)printf("%d-%d+%d-%d=7",a,b,c,d);
  else if(a-b-c+d==7)printf("%d-%d-%d+%d=7",a,b,c,d);
  else if(a-b-c-d==7)printf("%d-%d-%d-%d=7",a,b,c,d);
  return 0;
}

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

int main(){
int A,c=0;
  cin >> A;
  
  rep(i,10){
    rep(j,10){
      if(i*j==A && c!=1){
        cout << "Yes" << endl;
        c=1;
      }
      
    }
  }
 
  if(c==0)
    cout<< "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int a, b;
    cin >> a >> b;
    vector<int> A(1000), B(999);
    A[0] = 0;
    rep(1, i, 1001)
    {
        A[i] = A[i - 1] + i;
        B[i] = A[i] - A[i - 1];
        if (B[i] == b - a)
        {
            cout << A[i] - b;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

H,W,K=LI()
MP=[input() for i in range(H)]

res = 0
for bits in range(1 << (H+W)):
    k = 0
    for i in range(H):
        for j in range(W):
            if not (((bits >> i) & 1) or ((bits >> H+j) & 1)):
                k += (MP[i][j] == "#")
    res += (k == K)

print(res)


Measured memory_bytes: 68248
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        String s = inp.next();
        System.out.println(s.contains("7") ? "Yes" : "No");
    }
}


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

signed main() {
    int H, W;
    cin >> H >> W;

    const int inf = 1e18;
    vector<vector<int>> dist(H, vector<int> (W, inf));

    vector<string> vs(H);
    queue<pair<int, int>> qp;
    for (int i = 0; i < H; i++) {
        cin >> vs[i];
        for (int j = 0; j < W; j++) {
            if (vs[i][j] != '#') continue;
            qp.push({i, j});
            dist[i][j] = 0;
        }
    }

    const int dy[] = {0, 1, 0, -1};
    const int dx[] = {1, 0, -1, 0};
    int ans = 0;
    while (qp.size()) {
        auto p = qp.front();
        qp.pop();
        for (int i = 0; i < 4; i++) {
            int y = p.first + dy[i];
            int x = p.second + dx[i];
            if (y < 0 || x < 0 || y >= H || x >= W) continue;
            if (dist[y][x] < inf) continue;
            dist[y][x] = dist[p.first][p.second] + 1;
            ans = max(ans, dist[y][x]);
            qp.push({y, x});
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 25524
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
 
int main(){
  int n,m;
  cin>>n>>m;
  vector<int>broken(n+1);
  rep(i,m){
    int a;
    cin>>a;
    broken[a]=1;
  }
  vector<int>dp(n+2);
  const int mod=1000000007;
  dp[n]=1;
  for(int i=n-1;i>=0;i--){
    if(broken[i]){
      dp[i]=0;
      continue;
    }else{
      dp[i]=(dp[i+1]+dp[i+2])%mod;
    }
  }
  cout<<dp[0]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll N; cin >> N;
	ll A = sqrt(N);
	cout << A * A << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(string, a, b);
	a += b;

	auto num = [=](string s) {
		int ret = 0;
		REP(i, s.size()) {
			ret *= 10;
			ret += (s[i] - '0');
		}
		return ret;
	};
	
	int t = num(a);
	debug(t);
	bool ok = false;
	REP(i, 1010) {
		ok |= (i * i == t);
	}
	OUT(ok ? "Yes" : "No")BR;
	
  return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto nm = readints;
    int n = nm[0], m = nm[1];

    auto xs = readints;
    auto uf = new UnionFind(n + 1);
    for (int i = 0; i < m; i++) {
        auto xy = readints;
        uf.unite(xs[xy[0] - 1], xs[xy[1] - 1]);
    }

    int x = 0;
    foreach (i; 1 .. n + 1) {
        if (!uf.isSame(xs[i - 1], i)) {
            x++;
        }
    }

    writeln(n - x);
}

class UnionFind {
    private int[] _data;
    private int[] _nexts; // 次の要素。なければ -1
    private int[] _tails; // 末尾の要素

    this(int n) {
        _data  = new int[](n + 1);
        _nexts = new int[](n + 1);
        _tails = new int[](n + 1);

        _data[] = -1;
        _nexts[] = -1;
        for (int i = 0; i < _tails.length; i++)
            _tails[i] = i;
    }

    int root(int a) {
        if (_data[a] < 0) return a;
        return _data[a] = root(_data[a]);
    }

    bool unite(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) return false;
        // ra に rb を繋げる
        _data[ra] += _data[rb];
        _data[rb] = ra;

        // ra の末尾の後ろに rb を繋げる
        _nexts[_tails[ra]] = rb;
        // ra の末尾が rb の末尾になる
        _tails[ra] = _tails[rb];
        return true;
    }

    bool isSame(int a, int b) {
        return root(a) == root(b);
    }

    /// a が属する集合のサイズ
    int groupSize(int a) {
        return -_data[root(a)];
    }

    /// a が属する集合の要素全て
    void doEach(int a, void delegate(int) fn) {
        auto node = root(a);
        while (node != -1) {
            fn(node);
            node = _nexts[node];
        }
    }
}


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

using namespace std;

#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;

int main(){
	cin.sync_with_stdio(false);
	ll n,h;
	cin>>n>>h;
	vi a(n);
	vi b(n);
    rep(i,0,n) cin>>a[i]>>b[i];
    sort(all(a));
    reverse(all(a));
    sort(all(b));
    reverse(all(b));
    ll ans = 0;
    rep(i,0,n){
        if(a[0]>b[i]||h<=0) break;
        h-=b[i];
        ans++;
    }
    if(h>0)
    ans += h/a[0] + (h%a[0]!=0);
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for ai in range(a+1):
    for bi in range(b+1):
        for ci in range(c+1):
            if 500*ai+100*bi+50*ci==x:
                cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
using namespace std;
const int mod=1e9+7;

ll solve(){
    int n,m;
    cin>>n>>m;
    vector<vector<int> > grp(n);
    vector<int> a(n);
    for(int i=0;i<n;i++) a[i]=i,grp[i].push_back(i);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;u--,v--;
        if(a[u]==a[v]) continue;
        vector<int> &x=grp[a[u]],&y=grp[a[v]];
        if(x.size() > y.size()){
            for(int i:y) x.push_back(i),a[i]=a[u];
            y.clear();
        }
        else{
            for(int i:x) y.push_back(i),a[i]=a[v];
            x.clear();
        }
    }
    ll ans=0;
    for(auto v:grp) ans=max(ans,(ll)v.size());
    return ans;  

}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while(t--) cout<<solve()<<'\n';
    //while(t--) solve(),cout<<'\n';
    return 0;
}


Measured memory_bytes: 18740
n = int(input())
s = [input() for i in range(n)]
u = set(s)
dic = dict(zip(u, [0]*len(u)))
for i in range(n):
    dic[s[i]] += 1
m = max(dic.values())
res = []
for k, v in dic.items():
    if v == m:
        res.append(k)
res.sort()
print(*res, sep="\n")

Measured memory_bytes: 50960
def resolve():
    Nyens, Mtypes = map(int, input().split())  # N円をM種類のコインで最小枚数で払うという問題
    types = list(map(int, input().split()))  # 何円玉があるかのリスト

    def knapsack(Nyens, Mtypes, types):
        # dp[i][j]:i種類目までのコイン限定でj円払うのに必要な最小枚数
        # 最小で無限枚必要として初期化
        dp = [[float('inf')] * (Nyens + 1) for _ in range(Mtypes + 1)]

        # 0円は0枚で払える
        for ii in range(Mtypes):
            dp[ii][0] = 0

        for i in range(Mtypes):
            for j in range(Nyens + 1):
                if j >= types[i]:  # 最小枚数更新の可能性
                    dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - types[i]] + 1)
                else:  # 可能性なし
                    dp[i + 1][j] = dp[i][j]

        return dp[Mtypes][Nyens]

    print(knapsack(Nyens, Mtypes, types))

resolve()


Measured memory_bytes: 43788
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int a,b,k;
    int i,c,num=0;
    scanf("%d %d %d",&a,&b,&k);
    c=min(a,b);
    for(i=c;i>=1;i--)
    {
        if(a%i==0&&b%i==0)
        {
            num++;
        }
        if(num==k)
        {
            printf("%d\n",i);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{

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

        int n = sc.nextInt();

        int[] arr = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            sum += arr[i];
        }

        if (sum % 10 != 0) System.out.println(sum);
        else {
            Arrays.sort(arr);
            for (int i : arr) {
                if (i % 10 != 0) {
                    System.out.println(sum - i);
                    return;
                }
            }

            System.out.println(0);
        }
    }
}




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

int main()
{
  string s;
  int i;

  cin >> s;
  int ans=0, cnt = 0, prev = s[0];

  for(i=0;i<s.size();i++)
  {
    if(s[i]=='R'){
      cnt++;
    }
    else{
      cnt  =0;
    }
    ans = max(cnt, ans);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 驍ｨ・ｶ陝・ｽｾ陋滂ｽ､雎弱ｅ・∫ｹｧ繝ｻ笆ｽ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
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 che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;

int main(){
  int n ;cin>>n;
  int odd = (n+1)/2;//奇数の数
  double ans;
  ans = odd *10000000000/ n;

  cout<<ans/10000000000.0000000000000<<endl;
}


Measured memory_bytes: 256
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let mut a: Vec<i32> = s.take(1 << n).map(|a| a.parse().unwrap()).collect();
	while a.len() > 1 {
		let mut next = vec![];
		for a in a.chunks(2) {
			if a[0] > a[1] {
				next.push(a[0] - a[1]);
			} else if a[0] == a[1] {
				next.push(a[0]);
			} else {
				next.push(a[1] - a[0]);
			}
		}
		a = next;
	}
	println!("{}", a[0]);
}


Measured memory_bytes: 6036
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	string s;
	int n,a,b;
	int cnt = 0,bb = 0;;
	
	cin >> n >> a >> b>> s;

	for(int i = 0;i<s.size(); i++){
		if(s[i] == 'a'){
			if(cnt < a+b){
				cnt++;
				cout << "Yes" <<endl;
			}else{
				cout << "No" <<endl;
			}
		}else if(s[i] == 'b'){
			if(cnt < a+b && bb < b){
				cnt++;
				bb++;
				cout << "Yes" <<endl;
			}else{
				cout << "No" <<endl;
			}
		}else{
			cout << "No" <<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

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

    map<int, int> A;
    for( int i = 0; i < N; ++i ){
        int tmp;
        cin >> tmp;
        if( A.find(tmp) != A.end() ) A[tmp] += 1;
        else A[tmp] = 1;
    }

    int M = A.size();
    int ans = 0;

    if( K < M ){
        vector<int> AA(M);
        int cnt = 0;
        for( auto itr = A.begin(); itr != A.end(); ++itr )
            AA[cnt++] = itr->second;

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

        for( int i = 0; i <  M-K; ++i )
            ans += AA[i];
    }


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x,y;cin>>x>>y;
  if(x%y){
    cout<<x*(y-1)<<endl;
  }
  else{
    cout<<-1<<endl;
  }

  return 0;

}


Measured memory_bytes: 256
h,w,k=map(int,input().split())
cnt=1
ss=[input() for i in range(h)]
ans=[[0 for i in range(w)]for f in range(h)]
misyori=0
for ok in range(h):
    s=ss[ok]
    if set(s)!=set("."):
        v=[gg for gg in range(w) if s[gg]=="#"]
        l=[0]*w
        for k in v[:-1]:
            l[k+1]=1
        l[0]=cnt
        for i in range(1,w):
            l[i]+=l[i-1]
        for tate in range(misyori,ok+1):
            ans[tate]=l
        misyori=ok+1
        cnt+=len(v)
for t in range(misyori,h):
    ans[t]=l
for i in range(h):
    print(*ans[i],sep=" ")

Measured memory_bytes: 7580
// abc048_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string s;
    cin >> s;

    int n = s.size();

    // 最終状態で残る文字列の数の遇奇は、先頭と末尾が同じかどうかのみで決まる
    int end_num = (s[0] == s.back()) ? 1 : 2;

    // 消せる文字の数が奇数だったら、先手の勝ち
    if ((n - end_num) % 2 == 1){
        print("First");
    } else {
        print("Second");
    }

//    s = "";
//    random_device rd;
//    mt19937 mt(rd());
//
//    char p = '?';
//    REP(i, 4){
//        char c;
//        do {
//            c = mt() % 3 + 'a';
//        } while(c == p);
//        p = c;
//        s += c;
//        s += ' ';
//    }
//    print(s);



    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define INF 1000000

/*void solve(vector<vector<int>> &d, int N) {
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                d.at(i).at(j) = min(d.at(i).at(j), d.at(i).at(k) + d.at(k).at(j));
            }
        }
    }
}*/

int main(){
  int N, X, Y;
  cin >> N >> X >> Y;
  X--;
  Y--;
  /*vector<vector<int>> d (N, vector<int>(N, INF));
  d.at(X).at(Y) = 1;
  d.at(Y).at(X) = 1;
  d.at(N - 1).at(N - 1) = 0;
  for (int i = 0; i < N - 1; i++) {
      d.at(i).at(i + 1) = 1;
      d.at(i + 1).at(i) = 1;
      d.at(i).at(i) = 0;
  }
  solve(d, N);
  vector<int> ans(N, 0);
  for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
          ans.at(d.at(i).at(j))++;
      }
  }*/
  vector<int> ans(N, 0);
  for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
          if (i <= X && j >= Y)
              ans.at((j - i) - (Y - X) + 1)++;
          else if (i <= X && j < Y && Y - j + 1 < j - X)
              ans.at((X - i) + (Y - j) + 1)++;
          else if (i > X && j >= Y && i - X + 1 < Y - i)
              ans.at((i - X) + (j - Y) + 1)++;
          else if (i > X && j < Y && (Y - j) + (i - X) + 1 < j - i)
              ans.at((i - X) + (Y - j) + 1)++;
          else
              ans.at(j - i)++;
      }
  }
  for (int i = 1; i < N; i++) cout << ans.at(i) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int a = in.nextInt();
		int b = in.nextInt();
		long r = solve(a, b);
		System.out.println(r);
	}

	private static long solve(int a, int b) {
		long r = cm(a, b);
		a /= r;
		return (long) a * (long) b;
	}

	private static int cm(int a, int b) {
		if (a == b)
			return a;
		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}
		if (a % b == 0)
			return b;
		else
			return cm(a % b, b);
	}
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD ((int)1e9 + 7)
#define atoi(x) ((x)-'0')
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

const int MAX = 3010;
int n, m, k, a, b, c, dp[MAX][MAX][4], ans;
vi arr[MAX][MAX];

signed main() {
	fastio;
	cin >> n >> m >> k;
	FOR(i, k) {
		cin >> a >> b >> c;
		arr[a][b].pb(c);
	}
	for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) {
		FOR(x, 4) dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][x]);
		FOR(x, 4) dp[i][j][x] = max(dp[i][j][x], dp[i][j - 1][x]);
		sort(all(arr[i][j]), greater<int>());
		FOR(x, min(3LL, sz(arr[i][j]))) {
			for (int y = 3; y >= 1; y--) dp[i][j][y] = max(dp[i][j][y], dp[i][j - 1][y - 1] + arr[i][j][x]),
										dp[i][j][y] = max(dp[i][j][y], dp[i][j][y - 1] + arr[i][j][x]);
		}
		FOR(x, 4) ans = max(ans, dp[i][j][x]);
	}
	cout << ans;
}



Measured memory_bytes: 504320
//use std::io::{stdout, Write, BufWriter}
use std::ops::Range;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        a: i64,
        b: i64,
        c: i64,
        d: i64,
    }

    let gcd = gcd(c, d);
    let lcm = gcd * (c / gcd) * (d / gcd);
    println!("{}",
         (b - a + 1) - multiples(a..b, c) - multiples(a..b, d) + multiples(a..b, lcm)
    );
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
// 区間r(両端含む)に含まれるnの倍数の個数を求める
fn multiples(r: Range<i64>, n: i64) -> i64 {
    (r.end / n) - (((r.start + n - 1)/ n) - 1)
}


Measured memory_bytes: 4352
def main():
    """
    1 <= N  <= 10^5
    1 <= M  <= 10^5
    0 <= Pi <= N
    0 <= Yi <= 10^9
    Yi != Yj
    """
    N, M = map(int, input().split())
    P, Y = zip(*(
        map(int, input().split())
        for _ in range(M)
    ))

    ans = f(N, M, P, Y)
    print(*ans, sep="\n")


def f(N, M, P, Y):
    piy = [[] for _ in range(N)]
    for i, (p, y) in enumerate(zip(P, Y), 1):
        piy[p-1].append((p, i, y))

    ns = []
    for vs in piy:
        sorted_vs = sorted(vs, key=lambda x: x[2])
        for k, (p, i, _) in enumerate(sorted_vs, 1):
            n = "{:06d}{:06}".format(p, k)
            ns.append((i, n))

    ans = [n for _, n in sorted(ns, key=lambda x: x[0])]

    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 58328
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> V;
V A[10],U;
string S;

V Union(V a,V b){
  for(int i=0;i<(int)b.size();i++) a.push_back(b[i]);
  sort(a.begin(),a.end());
  a.erase(unique(a.begin(),a.end()),a.end());
  return a;
}

V Inter(V a,V b){
  V res;
  int n =a.size(),m=b.size();
  for(int i=0;i<n;i++){
    int flg = 0;
    for(int j=0;j<m;j++) flg |= a[i] == b[j];
    if(flg)res.push_back(a[i]);
  }

  sort(res.begin(),res.end());
  return res;
}

V Diff(V a,V b){
  V res;
  int n = a.size();
  int m = b.size();
    for(int i=0;i<n;i++){
    int flg =1;
    for(int j=0;j<m;j++)flg &=a[i]!=b[j];
    if(flg)res.push_back(a[i]);
  }
  
  sort(res.begin(),res.end());
  return res;
}

V Sdiff(V a,V b){return Union(Diff(a,b),Diff(b,a));}

V Comp(V a){
  V res;
  int n = U.size(),m = a.size();
  for(int i=0;i<n;i++){
    int flg = 1;
    for(int j=0;j<m;j++)flg &= U[i]!=a[j];
    if(flg) res.push_back(U[i]);
  }
  sort(res.begin(),res.end());
  return res;
}

int p;
V bnf();
V getV(){
  char ch = S[p];
  V res;
  if(ch == '(')p++,res = bnf(),p++;
  else if(isupper(ch))p++,res = A[ch-'A'];
  else if(ch=='c')p++,res = Comp(getV());
  else assert(isupper(ch));
  return res;
}

V bnf(){
  V res = getV();
  while(1){
    char ch = S[p];
    if(ch=='(')p++,res = bnf(),p++;
    else if(ch=='c')p++,res = Comp(getV());
    else if(ch=='u')p++,res = Union(res,getV());
    else if(ch=='i')p++,res = Inter(res,getV());
    else if(ch=='d')p++,res = Diff(res,getV());
    else if(ch=='s')p++,res = Sdiff(res,getV());
    else if(p<S.size()&&ch!=')')assert(ch==')');
    else break;
  }
  return res;
}

int main(){

  while(1){
    U.clear();
    while(1){
      char ch;
      int n;
      if(!(cin>>ch>>n))exit(0);
      if(ch == 'R' && n == 0) break;
      int idx = ch-'A';
      A[idx].resize(n);
      for(int i=0;i<n;i++)cin>>A[idx][i],U.push_back(A[idx][i]);
      sort(A[idx].begin(),A[idx].end());
      A[idx].erase(unique(A[idx].begin(),A[idx].end()),A[idx].end());
    }

    sort(U.begin(),U.end());
    U.erase(unique(U.begin(),U.end()),U.end());
    cin >> S;
    p = 0;
    V ans = bnf();
    
    for(int i=0;i<ans.size();i++){
      if(i)cout<<" ";
      cout<<ans[i];
    }
    if(ans.size()==0)cout<<"NULL";
    cout<<endl;
  }
 

  return 0;
}

Measured memory_bytes: 3092
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	cout << (((a*b*c)/max(max(a,b),c))/2) << endl;
	return 0;
}


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

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

	unordered_set<string> cache;
	string temp;
	for(int i = 0; i< n; i++){
		cin >> temp;
		if(cache.count(temp) == 0){
			cache.insert(temp);
		}
	}
	cout << cache.size() << endl;
}

Measured memory_bytes: 17612
N,Y = map(int, input().split())

Flag=False
for x in range(N+1):
    for y in range(N+1):
        z=N-x-y
        if 10000*x+5000*y+1000*z==Y and z>=0:
            print(str(x)+' '+str(y)+' '+str(z))
            Flag=True
            break
    if Flag:
        break

if Flag==False:
    print('-1 -1 -1')

Measured memory_bytes: 3060
using System;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            string n;
            n = Console.ReadLine();
            if (n == "a")
                Console.WriteLine("b");
            if (n == "b")
                Console.WriteLine("c");
            if (n == "c")
                Console.WriteLine("d");
            if (n == "d")
                Console.WriteLine("e");
            if (n == "f")
                Console.WriteLine("g");
            if (n == "g")
                Console.WriteLine("h");
            if (n == "h")
                Console.WriteLine("i");
            if (n == "i")
                Console.WriteLine("j");
            if (n == "j")
                Console.WriteLine("k");
            if (n == "k")
                Console.WriteLine("l");
            if (n == "l")
                Console.WriteLine("m");
            if (n == "m")
                Console.WriteLine("n");
            if (n == "n")
                Console.WriteLine("o");
            if (n == "o")
                Console.WriteLine("p");
            if (n == "p")
                Console.WriteLine("q");
            if (n == "q")
                Console.WriteLine("r");
            if (n == "r")
                Console.WriteLine("s");
            if (n == "s")
                Console.WriteLine("t");
            if (n == "t")
                Console.WriteLine("u");
            if (n == "u")
                Console.WriteLine("v");
            if (n == "v")
                Console.WriteLine("w");
            if (n == "w")
                Console.WriteLine("x");
            if (n == "x")
                Console.WriteLine("y");
            if (n == "y")
                Console.WriteLine("z");
            if (n == "e")
                Console.WriteLine("f");

        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+7;
int a[N], b[N], c[N], dp[N][2][2][2];
int n;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    memset(dp, 0, sizeof dp);
    for (int i = 0; i <= n; i++) {
        dp[i+1][1][0][0] = max({dp[i+1][1][0][0], a[i+1]+dp[i][0][1][0], a[i+1]+dp[i][0][0][1]});
        dp[i+1][0][1][0] = max({dp[i+1][0][1][0], b[i+1]+dp[i][1][0][0], b[i+1]+dp[i][0][0][1]});
        dp[i+1][0][0][1] = max({dp[i+1][0][0][1], c[i+1]+dp[i][1][0][0], c[i+1]+dp[i][0][1][0]});
    }
    int ans = max({dp[n+1][1][0][0], dp[n+1][0][1][0], dp[n+1][0][0][1]});
    cout << ans << endl;

    return 0;
}

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

int main() {
	string s;
	long long int n, all_a = 0, over;
	cin >> s >> n;
	for (unsigned i = 0; i < s.size(); i++) {
		if (s[i] == 'a')continue;
		all_a += 123 - s[i];
		if (n < all_a)over = i - 1;
	}
	if (n <= all_a) {
		long long temp = n;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == 'a')continue;
			if (123 - s[i] > temp);
			else {
				temp -= 123 - s[i];
				s[i] = 'a';
			}
		}
		if (temp != 0) {
			s[s.size() - 1] += temp;
		}
	}
	else {
		long long temp = n - all_a;
		while (temp > 26 * s.size()) {
			temp -= 26 * s.size();
		}
		for (unsigned i = 0; i < s.size(); i++) {
			s[i] = 'a';
		}
		s[s.size() - 1] += temp % 26;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 512
let () =
  Scanf.scanf "%d\n" @@ fun n ->
  let d = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun n -> n in
  let ans = ref 0 in
  for i = 0 to n - 2 do
    for j = i + 1 to n - 1 do
      ans := !ans + d.(i)*d.(j)
    done;
  done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 3784
while True:
	H, W = map(int, input().split())
	if H == 0 and W == 0:
		break
	for i in range(H):
		for j in range(W):
			if (i + j) % 2 == 0:
				print("#", end = '')
			else:
				print(".", end = '')
		print()
	print()



Measured memory_bytes: 7000
import math
from decimal import Decimal, ROUND_DOWN
def main():
    a,b = list(input().split())
    a = Decimal(a)
    b = Decimal(b)
    ans = a * b
    print(Decimal(ans).quantize(Decimal(1), rounding=ROUND_DOWN))

if __name__=='__main__':
    main()


Measured memory_bytes: 9952
x, y, a, b, c = map(int,input().split())
p = sorted(list(map(int,input().split())), reverse=True)
q = sorted(list(map(int,input().split())), reverse=True)
r = sorted(list(map(int,input().split())), reverse=True)

li = []
for i in range(x):
    li.append(p[i])
for i in range(y):
    li.append(q[i])

sm = 0
v = 0
for e in sorted(li):
    if v < c and r[v] > e:
        sm += r[v]
        v += 1
    else:
        sm += e

print(sm)


Measured memory_bytes: 23200
N, M = map(int, input().split())
P, Y = zip(*(map(int, input().split()) for _ in range(M)))
ans = ['' for _ in range(M)]
c = [1 for _ in range(N + 1)]

for i, t in sorted(enumerate(zip(P, Y)), key=lambda x: x[1][1]):
  ans[i] = '{:06}{:06}'.format(t[0], c[t[0]])
  c[t[0]] += 1
  
print('\n'.join(ans))

Measured memory_bytes: 58328