akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using usize = std::size_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;

template <class T> void chmin(T &a, const T &b) {
  if (b < a)
    a = b;
}

struct lazyseg {
  usize n;
  std::vector<usize> sum, lazy;

  lazyseg(const usize n_) {
    n = 1;
    while (n < n_) {
      n *= 2;
    }
    sum.assign(n * 2, 0);
    lazy.assign(n * 2, 2);
  }

  void apply(usize i, usize s, usize b) {
    if (b != 2) {
      sum[i] = s * b;
      lazy[i] = b;
    }
  }

  void push(usize i, usize s) {
    apply(i * 2, s / 2, lazy[i]);
    apply(i * 2 + 1, s / 2, lazy[i]);
    lazy[i] = 2;
  }

  void update(usize i, usize ll, usize rr, usize l, usize r, usize b) {
    if (r <= ll || rr <= l) {
      return;
    }
    if (l <= ll && rr <= r) {
      apply(i, rr - ll, b);
      return;
    }
    push(i, rr - ll);
    usize mid = (ll + rr) / 2;
    update(i * 2, ll, mid, l, r, b);
    update(i * 2 + 1, mid, rr, l, r, b);
    sum[i] = sum[i * 2] + sum[i * 2 + 1];
  }

  void update(usize l, usize r, usize b) { update(1, 0, n, l, r, b); }

  usize fold(usize i, usize ll, usize rr, usize l, usize r) {
    if (r <= ll || rr <= l) {
      return 0;
    }
    if (l <= ll && rr <= r) {
      return sum[i];
    }
    push(i, rr - ll);
    usize mid = (ll + rr) / 2;
    return fold(i * 2, ll, mid, l, r) + fold(i * 2 + 1, mid, rr, l, r);
  }

  usize fold(usize l, usize r) { return fold(1, 0, n, l, r); }
};

int main() {

  usize n;
  std::cin >> n;

  lazyseg f(n), g(n - 1);

  std::vector<usize> x(n);
  for (auto &e : x) {
    char c;
    std::cin >> c;
    e = c != '0';
  }

  for (usize i = 0; i != n; ++i) {
    f.update(i, i + 1, x[i]);
  }

  for (usize i = 0; i != n - 1; ++i) {
    g.update(i, i + 1, x[i] * x[i + 1]);
  }

  usize q;
  std::cin >> q;

  for (usize qq = 0; qq != q; ++qq) {
    usize l, r, b;
    std::cin >> l >> r >> b;
    --l;
    f.update(l, r, b);
    if (r - l >= 2) {
      g.update(l, r - 1, b);
    }
    if (l != 0 && l != n) {
      usize c = f.fold(l - 1, l + 1) == 2;
      g.update(l - 1, l, c);
    }
    if (r != 0 && r != n) {
      usize c = f.fold(r - 1, r + 1) == 2;
      g.update(r - 1, r, c);
    }

    usize fq = f.fold(0, n);
    usize gq = g.fold(0, n);
    std::cout << fq - gq << std::endl;
  }

  return 0;
}



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

int main()
{
  int N;
  cin >> N;
  vector<int> d(N);

  for (int i = 0; i < N; i++)
  {
    cin >> d[i];
  }

  sort(d.begin(), d.end());
  int ans = d[N / 2] - d[N / 2 - 1];
  cout << ans << endl;
}

Measured memory_bytes: 640
// ACM-ICPCアジア地区予選2014 C. Shopping

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int N, m;
	while(cin >> N >> m){
		vector< pair<int,int> > p(m);
		for(int i=0;i<m;i++) cin >> p[i].first >> p[i].second;
		sort(p.begin(), p.end());
		int idx = 0;
		int res = N+1;
		while(idx < m){
			int b = p[idx].first, e = p[idx].second;
			while(idx < m && p[idx].first < e){
				e = max(e, p[idx].second);
				++idx;
			}
			res += 2*(e-b);
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 1204
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)
#define INF 1000000
#define all(x) (x).begin(), (x).end()

vector<int> dp;
vector<int> h;

int dfs(int i){
    if(i == 0){
        return 0;
    }
    int ans;
    if(dp.at(i) != -1){
        ans = dp.at(i);
    }else if(i - 2 < 0){
        ans = dfs(i - 1) + abs(h.at(i) - h.at(i - 1));
        dp.at(i) = ans;
    }else{
        ans = min(dfs(i - 1) + abs(h.at(i) - h.at(i - 1)), dfs(i - 2) + abs(h.at(i) - h.at(i - 2)));
        dp.at(i) = ans;
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    h = vector<int>(n);
    rep(i, n){
        cin >> h.at(i);
    }
    dp = vector<int>(n, -1);
    cout << dfs(n - 1) << endl;
}


Measured memory_bytes: 6356
/**
 *    author:  tourist
 *    created: 26.11.2019 09:39:34       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> dp(n);
  for (int i = 0; i < n; i++) {
    dp[i] = a[i];
  }
  vector<long long> new_dp(n);
  vector<int> st(n);
  for (int it = 1; it < k; it++) {
    new_dp[0] = (long long) -1e18;
    int ptr = 0;
    int end = 0;
    for (int i = 0; i < n - 1; i++) {
      while (ptr < end && st[ptr] <= i - m) {
        ++ptr;
      }
      while (ptr < end && dp[st[end - 1]] <= dp[i]) {
        --end;
      }
      st[end++] = i;
      new_dp[i + 1] = dp[st[ptr]] + (it + 1LL) * a[i + 1];
    }
    swap(dp, new_dp);
  }
  cout << *max_element(dp.begin(), dp.end()) << '\n';
  return 0;
}


Measured memory_bytes: 2560
import collections
S=input()
l=len(S)
T,d=0,1
A=[0]*2019
A[0]=1
for i in range(l):
    T+=int(S[l-i-1])*d
    d*=10
    T%=2019
    d%=2019
    A[T]+=1
B=map(lambda x: x*(x-1)//2,A)
print(sum(B))














Measured memory_bytes: 9592
import java.util.*;
class Main{
	
    public static void main(String args[]){
Scanner sc=new Scanner(System.in);
String a=sc.next();
String b =sc.next();
System.out.println(a.charAt(0)==b.charAt(2)&&a.charAt(2)==b.charAt(0)&&a.charAt(1)==b.charAt(1)?"YES":"NO");
    }
}
  

 

   

Measured memory_bytes: 21716
n,m,x=map(int,input().split())
book=[list(i for i in map(int,input().split()))for _ in range(n)]
t=[0]
def dfs(seq, seq2, c):
  judgeSeq(calSkills(seq), c) # 条件を満たすか判定
  if len(seq2)==0: return # 終端条件: n冊目の本を購入したら打ち切り
  for i in range(len(seq2)):
    seq.append(seq2[i])
    dfs(seq, seq2[i+1:], c)
    seq.pop()

def calSkills(seq):
  res = [0]*(m+1)
  for i in seq:
    for j in range(m+1):
      res[j] += book[i][j]
  return res

def judgeSeq(skills, c):
  if all(x<=i for i in skills[1:]):
    t[0]+=1
    c[0] = min(c[0], skills[0])

if __name__ == "__main__":
  c = [sum(book[i][0] for i in range(n))]
  dfs([], [i for i in range(n)], c)
  print(c[0] if t[0]>0 else -1)

Measured memory_bytes: 9288
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n,k;
	cin>>n>>k;
	int p[n];
	int c[n];
	for(int i=0;i<n;i++){
		cin>>p[i];
		p[i]--;
	}
	for(int i=0;i<n;i++)
		cin>>c[i];
	ll maxval=-1e18;
	for(int i=0;i<n;i++)
	{
		ll sum=c[i],period=1;
		int j = p[i];
		vector<ll>c2;
		c2.push_back(c[i]);
		
		while(j!=i)
		{

			sum += c[j];
			c2.push_back(sum);
			j=p[j];
			period++;

		}
		for(int l=0;l<c2.size();l++)
		{
			if(k-l-1<0)
				break;
			int rest = k-l-1;
			if(c2[l] + max(sum,0LL)*(rest/period)>maxval)
				maxval = c2[l]+max(sum,0LL)*(rest/period);
		}
	}
		
		cout<<maxval<<"\n";
}

Measured memory_bytes: 3744
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int k=sc.nextInt();
        int aa=0;
        int bb=0;
        if(a<b){aa=0;}
        else if(a<(2*b)){aa=1;}
        else if(a<(4*b)){aa=2;}
        else if(a<(8*b)){aa=3;}
        for(int i=0;i<aa;i++){
        	b=b*2;
        }
        if(b<c){bb=0;}
        else if(b<(2*c)){bb=1;}
        else if(b<(4*c)){bb=2;}
        else if(b<(8*c)){bb=3;}
        else if(b<(16*c)){bb=4;}
        if(k>=(aa+bb)){System.out.println("Yes");}
        else{System.out.println("No");}
        }

}

Measured memory_bytes: 35668
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 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 _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
A = LI()
B = LI()

"""
左からみていったときの不都合
特になし
"""
all_count = sum(A)
for bidx in range(len(B)):
    diff = min(A[bidx], B[bidx])
    A[bidx] -= diff
    B[bidx] -= diff
    diff = min(A[bidx+1], B[bidx])
    A[bidx+1] -= diff
    B[bidx] -= diff
final_count = sum(A)

#  print(all_count, final_count)
print(all_count - final_count)


Measured memory_bytes: 100192
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,c;
    cin>>n>>m>>c;
    int b[m];
    for(int i=0;i<m;i++)
    cin>>b[i];
    int a[n][m];
    for(int i=0;i<n;i++)
    {
        for(int k=0;k<m;k++)
        cin>>a[i][k];
    }    
    int counter=0;
    for(int i=0;i<n;i++)
    {
        int sum=0;
        for(int j=0;j<m;j++)
        {
            sum+=(a[i][j]*b[j]);
        }
        sum+=c;
        if(sum>0)
        counter++;
    }
    cout<<counter<<endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int A, B, C; cin >> A >> B >> C;
    if (A == B) cout << C << endl;
    else if (B == C) cout << A << endl;
    else cout << B << endl;
}


Measured memory_bytes: 256
a1,b1 = map(int,input().split())
a2,b2 = map(int,input().split())
a3,b3 = map(int,input().split())
l = [a1,b1,a2,b2,a3,b3]

yes = 1
for i in range(1,5):
    if l.count(i)==3:
        yes *= 0

if yes == 1:
    print("YES")
else:
    print("NO")

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

int main() {
  long long Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;

  long long Smin = min({Q * 4, H * 2, S});
  long long Dmin = min({Q * 8, H * 4, S * 2, D});

  if (N == 1)
    cout << Smin << endl;
  else if (N % 2 == 0)
    cout << Dmin * (N / 2) << endl;
  else
    cout << (Dmin * (N / 2)) + Smin << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
// const ll MOD = 1000000007;

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

	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int dp[k+1];
	dp[0] = 0;
	for(int i=1;i<=k;i++){
		dp[i] = 0;
		for(int j=0;j<n;j++){
			if(a[j] > i)
				break;
			if(dp[i-a[j]] == 0){
				dp[i] = 1;
				break;
			}
		}
	}
	
	if(dp[k])
		cout<<"First\n";
	else
		cout<<"Second\n";
}


Measured memory_bytes: 640
import java.util.Comparator;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Arrays;
	/* static int java.util.Arrays.binarySearch(int[] a, int key); */
import java.math.BigDecimal;
	



public class Main {
	Scanner sc = new Scanner(System.in);
	int n;
	String s;
	public void run(){
		n = sc.nextInt();
		s = sc.next();
		solve();
	}
	
	public void solve(){
		int max = 0;
		String[] words = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
				"k", "l","m","n", "o", "p", "q", "r", "s", "t", "u", "v",
				"w", "x", "y", "z"
		};
		for(int i = 0; i < n; i++){
			String s1 = s.substring(0, i);
			String s2 = s.substring(i, n);
			
			int nmax = 0;
			for(int j = 0; j < 26; j++){
				if(s1.contains(words[j]) && s2.contains(words[j])){
					nmax++;
				}
			}
			
			if(max < nmax){
				max = nmax;
			}
			
		}
		System.out.println(max);
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
	static class Pair {
        int first,second;
        public Pair(int a,int b) {
            this.first = a;
            this.second = b;
        }
    }
	static class Edge{
		int to, cost;
		public Edge(int a, int b){
			this.to = a;
			this.cost = b;
		}
	}
	class MyComparator implements Comparator {
		@Override
		public int compare (Object arg0, Object arg1) {
			int x = ((Pair)arg0).first;
			int y = ((Pair)arg1).first;
			
			if (x < y) {
				return 1;
			} else if (x > y) {
				return -1;
			} else{
				return 0;
			}
		}
	}
	static class UnionFind{
		int par[];
		int rank[];
		
		//n要素で初期化
		public UnionFind(int maxn){
			par = new int[maxn];
			rank = new int[maxn];
			
			for(int i = 0; i < maxn; i++){
				par[i] = i;
				rank[i] = 0;
			}
		}
		
		//木の根を求める
		int find(int x){
			if(par[x] == x){
				return x;
			}
			else {
				return par[x] = find(par[x]);
			}
		}
		
		// xとyの属する集合を併合
		void unite (int x, int y){
			x = find(x);
			y = find(y);
			if(x == y){
				return;
			}
			
			if(rank[x] < rank[y]){
				par[x] = y;
			}
			else{
				par[y] = x;
				if(rank[x] == rank[y]) rank[x]++;
			}
		}
		
		// xとyが同じ集合に属するか否か
		boolean same(int x, int y){
			return find(x) == find(y);
		}
	}
	
}


Measured memory_bytes: 23124
n = int(input())
a = list(map(int, input().split(" ")))
a.sort()
ai = a.pop()
aj = a[0]
diff = abs(ai - 2 * aj)


for i in range(1, len(a)):
    if diff > abs(ai - 2 * a[i]):
        aj = a[i]
        diff = abs(ai - 2 * a[i])
print(ai, aj)

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

int main(){
  int N,A;
  cin >> N;
  A=N%10;
  if(A==3){
    cout << "bon" << endl;
  }
  else if(A==0 || A==1 || A==6 || A==8){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
}

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

int calcDigit(long long num) {
  int digit = 0;
  while (num) {
    num /= 10;
    digit++;
  }
  return digit;
}

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

  int res = (1<<29); // 十分大きい値で初期化
  for (long long a = 1; a*a <= n; a++) {
    if (n % a == 0) {
      long long b = n / a;
      int f = max(calcDigit(a), calcDigit(b));
      res = min(res, f);
    }
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s, t;
  cin >> s >> t;
  int e = s.size();
  int b = t.size();
  int c = 0, m = 0;
  for(int i = 0; i <= e - b; i++){
    for(int j = 0; j < b; j++){
    	if(s[j + i] == t[j])
          c++;
    }
    m = max(m, c);
    c = 0;
  }
  cout << b - m ;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                1000000007
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 long double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr(a,n)           for(ll i=0;i<n;i++){ cin>>a[i]; }
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= mod;} b >>= 1; x *= x; x %= mod;} return p % mod;}
using namespace std;
# define INF 1e15
struct lex_compare {
    bool operator() (const pair<db,ll>  p1, const pair<db,ll> p2){
        return (p1.first ==  p2.first) ? p1.ss < p2.ss : p1.first > p2.first;
    }
};
ll fact[2000005];
ll ncr(ll n,ll r){
    ll ans = fact[n];
    ll temp = fact[r]*fact[n-r];
    temp %= mod;
    ans = (ans*power(temp,mod-2));
    ans %= mod;
    return ans;

}

int main(){
    FIO;
    ll k; cin >> k;
    string s; cin >> s;
    ll sizes = s.size();
    ll n = sizes+k;
    ll k2 = sizes;
    fact[0] = fact[1] = 1;
    ll ans = 0;
    for(ll i = 2;i<= n+2;i++){
        fact[i] = (i*fact[i-1])%mod;
    }
    for(ll i = 0;i<=n-k2;i++){
        ll temp = ncr(n,k2+i);
        temp = temp*power(25,n-k2-i);
        temp %= mod;
        ans += temp;
        ans %= mod;
    }

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


Measured memory_bytes: 19796
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end()))
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[4] = {1, 1, -1, -1};
const int dy[4] = {-1, 1, 1, -1};

ll k;
const int SIZE = 8;
vector<string> grid(SIZE);

bool back_track(int n) {
  if (n == 0) return true;

  for (int i = 0; i < SIZE; i++) {
    for (int j = 0; j < SIZE; j++) {

      if (grid[i][j] == 'Q') continue;

      // 行チェック
      int cnt = 0;
      for (int k = 0; k < SIZE; k++) {
        if (grid[i][k] == 'Q') cnt++;
      }
      if (cnt > 0) continue;

      // 列チェック
      cnt = 0;
      for (int k = 0; k < SIZE; k++) {
        if (grid[k][j] == 'Q') cnt++;
      }
      if (cnt > 0) continue;

      // 斜めチェック
      // 右上, 右下, 左下, 左上
      cnt = 0;
      bool ok = true;
      for (int k = 0; k < 4; k++) {
        int ni = i + dy[k];
        int nj = j + dx[k];

        while (ni >= 0 && ni < SIZE && nj >= 0 && nj < SIZE) {
          if (grid[ni][nj] == 'Q') cnt++;
          ni += dy[k];
          nj += dx[k];
        }
        if (cnt > 0) { ok = false; break; }
      }
      if (!ok) continue;

      grid[i][j] = 'Q';

      int snj = j + 1;
      int sni = i;
      if (j == SIZE) { snj = 0, sni++; }
      if (back_track(n-1)) return true;

      grid[i][j] = '.';
    }
  }

  return false;
}

void solve() {
  cin >> k;
  rep(i, SIZE) grid[i] = "........";
  rep(i, k) {
    ll ri, ci; cin >> ri >> ci;
    grid[ri][ci] = 'Q';
  }

  if (back_track(8-k)) {
    rep(i, SIZE) outl(grid[i]);
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}



Measured memory_bytes: 3252
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  println {
    sc.next().last.toString.toInt match {
      case 2 | 4 | 5 | 7 | 9 => "hon"
      case 3 => "bon"
      case _ => "pon"
    }
  }
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n, m, x; cin >> n >> m >> x;
    vector<ll> c(n);
    vector<vector<ll>> a(n, vector<ll>(m));

    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        for (int j = 0; j < m; ++j) {
            cin >> a[i][j];
        }
    }

    //bit
    ll ans = LINF;

    for (ll bit = 0; bit < (1 << n); ++bit) {
        vector<ll> score(m, 0);
        ll sum = 0;

        for (int i = 0; i < n; ++i) {
            if (bit & (1 << i)) {
                sum += c[i];

                for (int j = 0; j < m; ++j) {
                    score[j] += a[i][j];
                }
            }
        }

        bool ok = true;
        for (int i = 0; i < m; ++i) {
            if (score[i] < x) ok = false;
        }

        if (ok) {
            ans = min(ans, sum);
        }
    }

    if (ans == LINF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <complex>
#include <cmath>
#include <cstdio>
using namespace std;
typedef complex<double> xy_t;
const double eps = 1e-11;

double dot_product(xy_t a, xy_t b) { return (conj(a) * b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); }
xy_t projection(xy_t p, xy_t b) { return b * dot_product(p, b) / norm(b); }

int main()
{
    int n = 0;
    double x, y;
    xy_t P[4];
    double sum = 0.0;
    cin >> n;
    bool answer[n] = {};
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            cin >> x >> y;
            P[j] = xy_t(x, y);
        }
        xy_t a[2] = {P[1] - P[0], P[3] - P[2]};
        if (abs(cross_product(a[0], a[1])) < eps)
        {
            answer[i] = 1;
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (answer[i])
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
    return 0;
}



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

typedef struct Person {
    ll a, b, c;
} Person;

bool comp(const Person &a, const Person &b) {
    return (a.a - a.b) < (b.a - b.b);
}

const int N = 111111;
int x, y, z, n;
Person per[N];
ll sumy[N], sumx[N];
ll ans;

int main() {
    ios::sync_with_stdio(false);
    cin >> x >> y >> z;
    n = x + y + z;
    for(int i = 1; i <= n; i++) {
        cin >> per[i].a >> per[i].b >> per[i].c;
        per[i].a -= per[i].c;
        per[i].b -= per[i].c;
        ans += per[i].c;
        per[i].c = 0;
    }
    sort(per + 1, per + 1 + n, comp);
    priority_queue<ll, vector<ll>, greater<ll> > q;
    ll sum = 0;
    for(int i = 1; i <= n; i++) {
        sum += per[i].b;
        q.push(per[i].b);
        if(q.size() > y) {
            sum -= q.top();
            q.pop();
        }
        sumy[i] = sum;
    }
    q = priority_queue<ll, vector<ll>, greater<ll> >();
    sum = 0;
    for(int i = n; i >= 1; i--) {
        sum += per[i].a;
        q.push(per[i].a);
        if(q.size() > x) {
            sum -= q.top();
            q.pop();
        }
        sumx[i] = sum;
    }
    ll maxi = -(1LL << 62);
    for(int k = y; k <= y + z; k++) {
        ll cur = sumy[k] + sumx[k + 1];
        maxi = max(maxi, cur);
    }
    cout << ans + maxi << endl;
    return 0;
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
int n;
unsigned long long T[110];
unsigned long long ans1;
unsigned long long gcd(unsigned long long x,unsigned long long y)
{
    if(y==0)return x;
    return gcd(y,x%y);
}
int main() {
     scanf("%d",&n);
     for(int i=1;i<=n;i++)scanf("%llu",&T[i]);
     ans1=T[1];
	 for(int i=2;i<=n;i++)
      ans1=ans1/gcd(ans1,T[i])*T[i];
	printf("%llu",ans1);
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll L,R;
    cin >> L >> R;
    ll out = 2018;
    if(R-L>=2018) out = 0;
    else{
        if(L>2019){
            ll a = L/2019;
            L = L%2019;
            R -= a*2019;
        }
        for(ll i=L;i<=R;i++){
            for(ll j=L;j<=R;j++){
                if(i!=j){
                    ll b = (i*j)%2019;
                    if(b<out) out = b;
                }
            }
        }
    }
    
    cout << out << endl;
    return 0;
}


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

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n, m, c;
   cin >> n >> m >> c;
   vector<int> b(m);
   for (int i = 0; i < m; i++) {
      cin >> b[i];
   }
   int ans = 0;
   vector<vector<int>> a(n, vector<int>(m));
   for (int i = 0; i < n; i++) {
      long long e = c;
      for (int j = 0; j < m; j++) {
         cin >> a[i][j];
         e += a[i][j] * b[j];
      }
      if (e > 0) ans++;
   }
   cout << ans << '\n';
   return 0;
}

Measured memory_bytes: 256
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
3
2 1 2
---+/
/+---test
3
2 2 2
---+/
/+---test
10
3 1 4 1 5 9 2 6 5 3
---+/
/+---test
1
1
---+/

void main(string[] args) {
  const N = readln.chomp.to!long;
  const A = readln.split.map!(to!long).array;

  long next_expect = 1;
  long ans;
  foreach (a; A) {
    if (a == next_expect) {
      ++next_expect;
    } else {
      ++ans;
    }
  }
  (next_expect == 1? -1: ans).writeln;
}


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

struct node {
    node():p(-1),b(-1),c(-1),d(-1){}
    int p;
    int b;
    int c;
    int d;
};

void setdepth(node t[], int id, int d) {
    t[id].d=d;
    if(t[id].c!=-1) setdepth(t, t[id].c, d+1);
    if(t[id].b!=-1) setdepth(t, t[id].b, d);
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    node t[100000];
    cin>>n;
    for(int i=0; i<n; i++) {
        int id, k, ci, cp=-1;
        cin>>id>>k;
        for(int j=0; j<k; j++) {
            cin>>ci;
            t[ci].p=id;
            if(j) t[cp].b=ci;
            else t[id].c=ci;
            cp=ci;
        }
    }
    int root;
    for(root=0; root<n&&t[root].p!=-1; root++);
    setdepth(t, root, 0);
    for(int i=0; i<n; i++) {
        cout<<"node "<<i<<": parent = "<<t[i].p<<", depth = "<<t[i].d;
        if(t[i].p==-1) cout<<", root, [";
        else if(t[i].c==-1) cout<<", leaf, [";
        else cout<<", internal node, [";
        if(t[i].c!=-1) {
            cout<<t[i].c;
            for(int j=t[t[i].c].b; j!=-1; j=t[j].b) cout<<", "<<j;
        }
        cout<<"]\n";
    }
    return 0;
}

Measured memory_bytes: 2764
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }

    val a = readLine()!!.split(' ').map { it.toInt() }
    var sum = 0
    repeat(m) {
        sum += a[it]
    }

    if (n-sum >= 0) {
        println(n-sum)
    } else println(-1)
}


Measured memory_bytes: 39700
#!/usr/bin/env python3
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

ans = 0

for i in range(n):
    num = sum(a1[: i + 1]) + sum(a2[i:])
    ans = max(ans, num)

print(ans)


Measured memory_bytes: 9092
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> T INF = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i), i--;
    vector<vector<int>> cnt(m, vector<int>(n+1, 0));
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            cnt[i][j+1] = cnt[i][j]+(v[j] != i);
        }
    }
    vector<int> dp1(1<<m), dp2(1<<m, INF<int>);
    for (int i = 0; i < (1 << m); ++i) {
        for (int j = 0; j < m; ++j) {
            if(i & (1 << j)){
                dp1[i] = dp1[i^(1<<j)] + n-cnt[j][n];
                break;
            }
        }
    }
    dp2[0] = 0;
    for (int i = 0; i < (1 << m); ++i) {
        for (int j = 0; j < m; ++j) {
            if(i & (1 << j)){
                dp2[i] = min(dp2[i], dp2[i^(1 << j)] + cnt[j][dp1[i]]-cnt[j][dp1[i-(1<<j)]]);
            }
        }
    }
    cout << dp2.back() << "\n";
    return 0;
}


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

#define ll long long
#define pb push_back

const int maxn = 2e5 + 20;

vector<int> adj[maxn];

pair<int , int> dfs(int v , int p = -1)
{
	pair<int , int> mx = {1 , v};
	for(auto u : adj[v])
		if(u != p)
		{
			auto tmp = dfs(u , v);
			tmp.first++;
			mx = max(mx , tmp);
		}

	return mx;
}

bool res[maxn];

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

	int n;
	cin >> n;

	for(int i = 0; i < n - 1; i++)
	{
		int a , b;
		cin >> a >> b;
		a-- , b--;

		adj[a].pb(b);
		adj[b].pb(a);
	}

	int k = dfs(dfs(0).second).first;
	res[0] = 0, res[1] = 1 , res[2] = 0;

	for(int i = 3; i <= k; i++)
		res[i] = !res[i - 1] | !res[i - 2];

	cout << (res[k]? "First" : "Second") << endl;
}



















Measured memory_bytes: 27008
#include <iostream>
#include <vector>
using namespace std;
// https://atcoder.jp/contests/abc157/submissions/10486180

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N,Q;
  string S;
  cin >> N >> S >> Q;
  vector<int> A(N);
  for(int i=0;i<N;++i){
    A[i] = 1 << (S[i]-'a');
  }

  int x,l,r,i;
  char c;
  while(Q--){
    cin >> x;
    if(x==1){
      cin >> i >> c;
      i--;
      A[i] = 1<<(c-'a');
    }else{
      cin >> l >> r;
      int ans = 0;
      for(int i=l-1;i<r;i++)ans|=A[i];
      cout << __builtin_popcount(ans) << '\n';
    }
  }
}

Measured memory_bytes: 2936
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

const LL mod = 1e9 + 7;
LL n, k;


int main(){
    cin >> n >> k;
    vector<pair<int, int>> vp;
    LL i = 1;
    while(i <= n / i){
        vp.emplace_back(make_pair(i, n / i));
        i++;
    }
    int n = (int)vp.size();
    REP(i, n){
        if(vp[i].first == vp[i].second)continue;
        vp.emplace_back(vp[i].second, vp[i].first);
    }
    n = (int)vp.size();
    sort(ALL(vp));
    vector<LL> dp(n, 0);
    dp[0] = 1;
    REP(_, k){
        vector<LL> dp_new(n, 0);
        REP(i, n){
            (dp_new[n - 1 - i] += dp[i]) %= mod;
        }
        for(int i = n - 2;i >= 0;i--){
            (dp_new[i] += dp_new[i + 1]) %= mod;
        }
        REP(i, n){
            dp_new[i] = (dp_new[i] * (i == 0 ? 1 : vp[i].first - vp[i - 1].first)) % mod;
        }
        swap(dp, dp_new);
    }
    LL ans = 0;
    REP(i, n)(ans += dp[i]) %= mod;
    cout << ans << endl; 
}

Measured memory_bytes: 1912
#include <iostream>
#include <cstdio>

using namespace std;

int nums[100000];

int main()
{
    int n , num , res = 0;
    scanf("%d" , &n);
    for(int i = 0; i < n; i ++){
        scanf("%d" , &num);
        nums[num] ++;
        nums[num + 1] ++;
        nums[num - 1] ++;
    }
    for(int i = 0; i < 100000; i ++){
        if(nums[i] > res){
            res = nums[i];
        }
    }
    printf("%d" , res);
    return 0;
}


Measured memory_bytes: 640
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 808;
char s[N][N];
int n , m , K , _ , dis[N][N];
pii q[N*N];

int main(){
    scanf("%d%d%d",&n,&m,&K);
    rep(i,1,n+1) scanf("%s",s[i] + 1);
    rep(i,1,n+1) rep(j,1,m+1) dis[i][j] = N * N;
    rep(i,1,n+1) rep(j,1,m+1) if(s[i][j] == 'S')
        q[_++]=mp(i,j),dis[i][j]=0;
    int ans=N*N;
    rep(i,0,_){
        int x=q[i].fi,y=q[i].se;
        ans=min(ans,1+(min(min(x-1,n-x),min(y-1,m-y))+K-1)/K);
        if(dis[x][y]==K) continue;
        rep(d,0,4) {
            int nx=x+(d==2)-(d==0);
            int ny=y+(d==3)-(d==1);
            if(1<=nx&&nx<=n&&1<=ny&&ny<=m&&s[nx][ny]=='.')
                if(dis[nx][ny]>dis[x][y]+1)
                    dis[nx][ny]=dis[x][y]+1,q[_++]=mp(nx,ny);
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 8576
N,K = map(int,input().split())
tmp = 1
num_cnt = 0
while K > tmp :
  tmp *= 2
  num_cnt +=1
nums_list = []
for i in range(1,N+1):
  for j in range(num_cnt+1):
    if i*(2**j) >= K:
      nums_list.append(((1/2)**j))
      break
print(sum(nums_list)*(1/N))

Measured memory_bytes: 12872
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N;
  cin >> N;
  vec<ll> A(N);
  REP(i, N) cin >> A[i];

  ll res = 1;
  optional<int> global_grad;
  FOR(i, 1, N) {
    optional<int> local_grad;
    if (A[i - 1] < A[i]) {
      local_grad = 1;
    } else if (A[i - 1] > A[i]) {
      local_grad = -1;
    }
    if (!global_grad) {
      global_grad = local_grad;
    } else if (global_grad && local_grad && global_grad != local_grad) {
      res++;
      global_grad = nullopt;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3976
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    string s, t;
    ll r = 0, p = -1;
    cin >> s >> t;
    vector< set<ll> > d(26);
    for (ll i = 0; i < ll(s.size()); ++i) d.at(s.at(i) - 'a').insert(i);
    for (ll i = 0; i < ll(t.size()); ++i) {
        if (!d.at(t.at(i) - 'a').size()) {
            printf("-1\n");
            return 0;
        }
        auto np = d.at(t.at(i) - 'a').upper_bound(p);
        if (np == d.at(t.at(i) - 'a').end()) {
            ++r;
            p = *d.at(t.at(i) - 'a').begin();
        } else {
            p = *np;
        }
    }
    printf("%lld\n", r * ll(s.size()) + p + 1);
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> buka(n);
  for(int i=1;i<=n-1;i++) {
    int a;
    cin >> a;
    a--;
    buka[a].emplace_back(i);
  }
  for(int i=0;i<n;i++) {
    cout << buka[i].size() << endl;
  }
  return 0;
}


Measured memory_bytes: 13976
#include<bits/stdc++.h>
using namespace std;
char str[200001];
int main(void){
	int i,len,ans=0;scanf("%s",str+1);len=strlen(str+1);
	for(i=1;i<=len;++i)ans=(ans+str[i]-'0')%9;
	puts((!ans)?"Yes":"No");
	return 0;
}


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

int main()
{
    int h, w, n;
    cin >> h >> w >> n;

    //一次元の配列F1に格納
    vector<int> F1;
    rep(i, n)
    {
        int a;
        cin >> a;
        rep(j, a) F1.push_back(i + 1);
    }

    //２次元配列F2に格納
    vector<vector<int>> F2;
    rep(i, h)
    {
        vector<int> f;
        for (int j = i * w; j < (i + 1) * w; j++)
            f.push_back(F1[j]);
        F2.push_back(f);
    }

    rep(i, h)
    {
        if (i % 2 == 1)
        {
            reverse(F2[i].begin(), F2[i].end());
            rep(j, w) cout << F2[i][j] << " ";
        }
        else
        {
            rep(j, w) cout << F2[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head=0, tail=0, n;

void enqueue(P Que){
  strcpy(Q[tail].name,Que.name);
  Q[tail].t=Que.t;
  if (tail+1==LEN) tail=0;
  else tail++;
}

P dequeue(){
  P Que;
  strcpy(Que.name,Q[head].name);
  Que.t=Q[head].t;
  if(head+1==LEN) head=0;
  else head++;

  return Que;
}


int main(){
  int elaps = 0;
   int i,q;
   P u;
  scanf("%d %d", &n, &q);
  
  for ( i = 0; i <n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  
  tail=i;

  while(head!=tail){
   
    u=dequeue();

    if(u.t>q){
      u.t=u.t-q;
      elaps=elaps+q;
      enqueue(u);
    }

    else {
      elaps=elaps+u.t;
      printf("%s %d\n",u.name,elaps); 
    }
  }
      

  
  return 0;
}



Measured memory_bytes: 11860
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <math.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;

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

  ll ans=0;

  for (int i = 0; i <= min(K, S); i++)
  {
    for (int j = i; j <= min(K, S-i); j++)
    {
      for (int k = j; k <= min(K, S-i-j); k++)
      {
        if((ll)(i+j+k) == S)
        {
          if (i==j && j==k) ans+=1;
          else if (i==j || j==k || k==i) ans+=3;
          else ans += 6;
        }
      }
    }
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 256
N = int(input())
hlist = list(map(int, input().split())) 
# 最初のマスは,単調非現象にするには必ず１低くするのが最適
hlist[0]-=1
for i in range(N-1):
    if hlist[i] < hlist[i+1]:
        # 右側i+1のマスが高ければ必ず１低くする
        hlist[i+1] -= 1
    elif hlist[i] > hlist[i+1]:
        # 左側が高くなれば　単調非現象は成立しない
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  

void solve(){
	int a ;
	ld b ; 
	cin >> a >> b; 
	int c = b*100 + .5;
	int ans = (a*c)/100 ;
	cout << ans << endl;
}
signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

int main(){
    ll a,b,k;
    cin>>a>>b>>k;
    if(a>=k){
        cout<<a-k<<" "<<b<<endl;
    }
    else{
        cout<<"0 "<<max(0LL,b-(k-a))<<endl;
    }
}

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

vector<string> v;

void make(string str , long m){
    if(stoll(str) > m ){
        return;
    }
    v.push_back(str);
    make(str + '3' , m);
    make(str + '5' , m);
    make(str + '7' , m);
    return;
}

int main(){
  long n ;
  cin >> n ;
  long ans = 0;
  string str;
  
  make("3" , n);
  make("5" , n);
  make("7" , n);
  
  for(long i = 0; i < v.size() ; i++ ){
      str = v[i];
      if(count(str.cbegin(), str.cend(), '3') > 0
      && count(str.cbegin(), str.cend(), '5') > 0
      && count(str.cbegin(), str.cend(), '7') > 0){
          ans += 1;
      }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2172
import sys

l = raw_input().split()
N = int(l[0])
K = int(l[1])

a = raw_input().split()

like={}

for i in range(10):
    if str(i) in a:
        like.setdefault(i,False)
    else:
        like.setdefault(i,True)
    

while(True):
    ok = True
    num_str = str(N)
    for s in num_str:
        if like[int(s)] is False:
            if(ok): N += 1
            ok = False
            continue

    if(ok):
        print N
        sys.exit()

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


using namespace std;


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

#define maxN 100011

int n, i, p1, p2;
char s[maxN], c;

int main() {
    
    scanf("%s", s + 1);
    n = strlen(s + 1);
    
    if (n & 1) {
        p1 = p2 = (n + 1) / 2;
    } else {
        p1 = n / 2;
        p2 = p1 + 1;
    }
    
    c = s[p1];
    
    while (s[p1] == s[p2] && s[p1] == c && p1 != 0) p1--, p2++;
    if (p1 == 0) {
        cout << n;
    } else {
        cout << n - p1;
    }
    
    
    
    return 0;
}

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

int main() {
	
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, n) cin >> p.at(i);
	
	int diff = 0;
	rep(i, n){
		if(i+1 != p.at(i)){
			diff++;
		}
	}
	if(diff <= 2) puts("YES");
	else puts("NO");
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using     ll=long long;
using    vll=vector<   ll>;
using   vvll=vector<  vll>;
using  vvvll=vector< vvll>;
using vvvvll=vector<vvvll>;
constexpr ll INF = 1LL << 60;
struct Fast{ Fast(){ cin.tie(0); ios::sync_with_stdio(false); cout<<fixed<<setprecision(numeric_limits<double>::max_digits10); } } fast;
#define REPS(i, S, E) for (ll i = (S); i <= (E); i++)
#define REP(i, N) REPS(i, 0, (N)-1)
#define DEPS(i, S, E) for (ll i = (E); i >= (S); i--)
#define DEP(i, N) DEPS(i, 0, (N)-1)
#define rep(i, S, E)  for (ll i = (S); i <= (E); i++)
#define dep(i, E, S)  for (ll i = (E); i >= (S); i--)
#define each(e, v) for (auto&& e : v)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }
template<class T> inline T MaxE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmax(m,v[i]); return m; }
template<class T> inline T MinE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmin(m,v[i]); return m; }
template<class T> inline T MaxE(vector<T> &v) { return MaxE(v,0,(ll)v.size()-1); }
template<class T> inline T MinE(vector<T> &v) { return MinE(v,0,(ll)v.size()-1); }
template<class T> inline T Sum(vector<T> &v,ll S,ll E){ T s=T(); rep(i,S,E)s+=v[i]; return s; }
template<class T> inline T Sum(vector<T> &v) { return Sum(v,0,v.size()-1); }
template<class T> inline ll sz(T &v){ return (ll)v.size(); }
inline ll CEIL(ll a,ll b){ return (a<0) ? -(-a/b) : (a+b-1)/b; }
inline ll FLOOR(ll a,ll b){ return -CEIL(-a,b); }

#if 1
#include <atcoder/all>
#endif
using namespace atcoder;


void solve()
{
	string s;  cin >> s;
	ll n=sz(s);
	auto sa=suffix_array(s);
	auto lcp=lcp_array(s,sa);
	ll ans=0;
	rep(j,0,n-1){
		ll i=sa[j];
		ans+=n-i;
	}
	rep(i,0,n-2){
		ans-=lcp[i];
	}
	cout << ans << '\n';
}


int main(){
#if 1
	solve();
#else
	ll t;  cin >> t;
	rep(i, 0, t-1){
		solve();
	}
#endif
	return 0;
}


Measured memory_bytes: 15676
/* ITP1_1_C */

import java.io.*;
import java.util.*;

public class Main {
    public static void main (String[] args) throws java.lang.Exception {
    
    BufferedReader input = new BufferedReader (new InputStreamReader(System.in));
    String txt = input.readLine();
    String[] text = txt.split(" ");
    int A = Integer.parseInt(text[0]);
    int B = Integer.parseInt(text[1]);
    System.out.println( (A * B) + " " + (( A + B ) * 2) );
    
    }
}



Measured memory_bytes: 24124