akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>

using namespace std;

typedef long long ll;

int main(){
	int n;
	ll a[100000], x;
	scanf("%d %lld", &n, &x);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	ll res = max(0LL, a[0] - x);
	if(a[0] > x) a[0] = x;
	for(int i = 0; i < n - 1; i++){
		res += max(0LL, a[i] + a[i + 1] - x);
		if(a[i] + a[i + 1] > x) a[i + 1] = x - a[i];
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 896
// Problem : B - Judge Status Summary
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
 *   ﷽
 * In the name of Allah, the Most Gracious, the Most Merciful
 */

#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <climits>

using namespace std;

int main()
{
	int n;
	cin>>n;
	map<string, int> ss;
	while(n--){
		string sa;
		cin>>sa;
		ss[sa]++;
	}
	cout<<"AC x "<< ss["AC"] << "\n";
	cout<<"WA x "<< ss["WA"] << "\n";
	cout<<"TLE x "<< ss["TLE"] << "\n";
	cout<<"RE x "<< ss["RE"] << "\n";
	 
	return 0;
}

Measured memory_bytes: 3236
import sys;

def gcd(a, b):
	if b == 0:
		return a;
	return gcd(b, a % b);
	
def lcm(a, b):
	return a * b // gcd(a, b);

for line in sys.stdin:
	[a, b] = [int(num) for num in line.split()];
	print(str(gcd(a, b)) + ' ' + str(lcm(a, b)));

Measured memory_bytes: 7664
limit = 100003
import math
def resolve():
    N = int(input())
    for k in range(N, limit+1):
        factor = 0
        if k % 2 == 0 and k != 2:
            continue
        for divisor in range(2, math.floor(math.sqrt(k))+1):
            if k % divisor == 0:
                factor += 1
        if factor == 0:
                return k
print(resolve())

Measured memory_bytes: 3060
N=int(input())
a=[[0 for j in range(N-1)] for i in range(N)]
for i in range(N):
  line=list(map(int,input().split()))
  for j in range(N-1):
    a[i][j]=line[j]-1
  a[i]=a[i][::-1]
    
stack=[]

def addmatch(i):
  if len(a[i])==0:
    return
  j=a[i][-1]
  if a[j][-1]==i:
    stack.append([i,j])

for i in range(N):
  addmatch(i)

day=0
while stack:
  day+=1
  member=set()
  for i in range(len(stack)):
    g=stack.pop()
    y=g[0]
    x=g[1]
    if len(a[y])>0 and a[y][-1]==x:
      a[y].pop()
      a[x].pop()
      member.add(y)
      member.add(x)
  for m in member:
    addmatch(m)

for i in range(len(a)):
  if len(a[i])>0:
    print(-1)
    break
else:
  print(day)

Measured memory_bytes: 35572
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;

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

    int N;
    cin >> N;
    vector<int> A(N);

    long long int two_x1 = 0;
    int sgn = 1;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        two_x1 += sgn * A[i];
        sgn *= -1;
    }

    cout << two_x1 << " ";

    long long int prev_x = two_x1 / 2;
    for (int i = 1; i < N; ++i) {
        const long long int cur_x = A[i - 1] - prev_x;
        cout << 2 * cur_x << " ";
        prev_x = cur_x;
    }
    cout << endl;

    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int>h(n);
	for (int i = 0; i < n; i++)cin >> h.at(i);
	ll cur = h.at(0);
	ll ans = 1;
	for (int i = 1; i < n; i++) {
		if (h.at(i) >= cur) {
			ans++;
			cur = h.at(i);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.ComponentModel;
using System.Xml.XPath;

namespace ARC098D
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            long[] a = Array.ConvertAll(Console.ReadLine().Split(' '), input => long.Parse(input));

            int r = 0;
            long sum = a[0];
            long xorsum = a[0];
            long ans = 0;
            for (int l = 0; l < n; l++)
            {
                if (r < l)
                {
                    r = l;
                    sum = a[l];
                    xorsum = a[l];
                }
                while (true)
                {
                    if (r + 1 < n)
                    {
                        long s = sum + a[r + 1];
                        long x = xorsum ^ a[r + 1];
//                        Console.Write("sx ");
//                        Console.Write(s);
//                        Console.Write(' ');
//                        Console.WriteLine(x);
                        if (s == x)
                        {
                            sum = s;
                            xorsum = x;
                            r++;
                            continue;
                        }
                        sum -= a[l];
                        xorsum ^= a[l];
                    }

//                    Console.Write("lra");
//                    Console.Write(l);
//                    Console.Write(' ');
//                    Console.Write(r);
//                    Console.Write(' ');
                    ans += r - l + 1;
//                    Console.WriteLine(ans);
                    break;
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 29660
N;M=10007;d[9999];main(i,j,k,c){for(d[2]=scanf("%d\n",&N);c=getchar(),c-10;i++)for(j=0;j<8;j++)for(k=0;j&1<<c%4-1&&k<8;j&k++?d[i*8+j]+=d[i*8+k-9],d[i*8+j]%=M:0);for(j=k=0;k<8;j%=M)j+=d[N*8+k++];N=!printf("%d\n",j);}

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

using namespace std;
int n,k;
int main(){
	cin >> n >> k;
	while(k--){
		int a,b;
		cin >> a >> b;
		int ans =  min(min(a,n-a+1),min(b,n-b+1))%3;
		if(ans == 0)ans = 3;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;
 
int k;
ll a[100001];
bool test(ll d){
    rep(i,k){
        if(d<a[i]) return false;
        d-=d%a[i];
    }
    if(d==2) return true;
    else return false;
}
int main(){  
    cin>>k;
    ll mx=2,mn=2;
    rep(i,k) cin>>a[i];
    if(a[k-1]!=2){
        cout<<-1<<endl;
        return 0;
    }
    for(int i=k-1;i>=0;--i){
        mn+=(a[i]-mn%a[i])%a[i];
        mx+=-mx%a[i]+a[i]-1;
    }
    if(!test(mn)||!test(mx)) cout<<-1<<endl;
    else cout<<mn<<" "<<mx<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
static const double pi = 3.141592653589793;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int A,B;

int main(){
  cin >> A >> B;
  if(A<=8 && B <=8)cout<< "Yay!" <<endl;
  else cout<< ":(" <<endl;
}


Measured memory_bytes: 256
a,b,c,d = map(int,input().split())

a_b = abs(b-a)
b_c = abs(c-b)
a_c = abs(c-a)

if max(a_b,b_c) <= d:
  print('Yes')
elif a_c <= d:
  print('Yes')
else:
  print('No')

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

using namespace std;
const int maxn=2e5+5;
typedef long long ll;
int a[maxn];
string s;
int main()
{

    int n;
    cin>>n;
    cin>>s;
    s="+"+s;
    int ans=0;
    for(int i=1;i<s.length();i++)
    {
        if(s[i]!=s[i-1])
            ans++;
    }
    cout<<ans;
    return 0;
}

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

int main() {
  int y,x;
  cin >> y >> x;
  int flag=0;
  
  vector<vector<char>> a(y,vector<char>(x));

  for(int i=0 ; i<y ; i++){
    for(int j=0 ; j<x ; j++){
      cin >> a.at(i).at(j);
    }
  }
  
  vector<int> y_flag(y),x_flag(x);
  
  //横列の出力フラグ
  for(int i=0 ; i<y ; i++){
    int flag=0;

    for(int j=0 ; j<x ; j++){
      if(a.at(i).at(j)=='#'){
        flag++;
        break;
      }
    }
    
    if(flag==1){
    y_flag.at(i)++;
    }
  }

  //縦列の出力フラグ
  for(int j=0 ; j<x ; j++){
    int flag=0;

    for(int i=0 ; i<y ; i++){
      if(a.at(i).at(j)=='#'){
        flag++;
        break;
      }
    }
    
    if(flag==1){
    x_flag.at(j)++;
    }
  }
  
  //出力
  for(int i=0 ; i<y ; i++){
    for(int j=0 ; j<x ; j++){
      if(x_flag.at(j)==1 && y_flag.at(i)==1){
        cout << a.at(i).at(j);
      }
    }
    
    if(y_flag.at(i)==1){
      cout << endl;
    }
  }
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  map<string, int> cnt;
  int ma = 0;
  rep(i, n) {
    string s; std::cin >> s;
    cnt[s]++;
    chmax(ma, cnt[s]);
  }
  for (auto &p : cnt) {
    if (ma == p.se)
      std::cout << p.fi << "\n";
  }
}


Measured memory_bytes: 23808
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 500050;
const int K = 1e18;
const int M = 1e9;
const int mod = 1e9 + 7;
int a[N];
vector <int> b[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string t;
    cin >> t;
    int n = t.length();
    int x = 0;
    int k = 0;
    for (int i = 0; i < n - 1; i++){
        if (t[i] == '1' && t[i + 1] == '1'){
            a[i] = 1;
            a[i + 1] = 1;
            x++;
            i++;
        }
    }
    for (int i = 0; i < n; i++) if (t[i] == '1') k++;
    int ans = 0;
    for (int i = 1; i <= k; i++){
        ans += (i + 1) / 2;
    }
    ans += (n - k) * x;
    vector <int> b;
    int l = 0;
    for (int i = 0; i < n; i++){
        if (a[i]) continue;
        if (t[i] == '0') l++; else
        {
            b.pb(l);
            l = 0;
        }
    }
    b.pb(l);
    ans = 2 * ans - b.size() / 2;
    for (int i = 0; i < t.length(); i++) if (a[i] == 0 && t[i] == '1' && i % 2 == 0) ans++;
    for (int i = 0; i < (int)b.size(); i++){
        ans += b[i] * (2 * i + b.size() - 1 - i);
    }
    cout << ans / 2;
}


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

int main() {
	int A, B, C, X;
	
	cin >> A >> B >> C >> X;
	
	int ans = 0;
	
	for (int i = 0; i <= A; ++i) {
		for (int j = 0; j <= B; ++j) {
			for (int k = 0; k <= C; ++k) {
				if (500 * i + 100 * j + 50 * k == X) {
					ans++;
				}
			}
		}
	}
	
	cout << ans << endl;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k;cin >> n >> k;
    vector<int> h(n);
    rep(i,0,n) cin >> h[i];
    sort(all(h));
    ll ans = abs(h[0]-h[k-1]);
    ll sum = 0;
    rep(i,k,n){
        sum = abs(h[i-k+1] - h[i]);
        ans = min(ans,sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
from collections import deque

K = int(input())

G = [None]*K
for i in range(K):
    G[i] = ((10*i % K, 0), ((i+1) % K, 1))
s = 1

dist = [10**9] * K
que = deque([s])
dist[s] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for w, c in G[v]:
        if d+c < dist[w]:
            dist[w] = d+c
            if c:
                que.append(w)
            else:
                que.appendleft(w)

print(dist[0]+1)

Measured memory_bytes: 30580
//Bismillahir Rahmanir Rahim
//In the name of Allah the Most Merciful
//Astagfirullahil laji Rabbi Minkulli Jamio
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define int   long long  int
#define double  long double
#define rp(i,a,b)  for (int i = a; i <= b; i++)
#define hi ios_base :: sync_with_stdio(false); cin.tie(0);cout.tie(0);
int i,j,k;
main()
{
    int a;
    double d;
    cin>>a>>d;
    int d1=d*a;
    cout<<d1<<endl;
    //cout<<fixed<<setprecision(0)<<d<<endl;
}


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

#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;

void solve()
{
	int n, k;
	cin >> n >> k;
	int a[n];
	ll ans = 0;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < k; i++)
		ans += a[i];
	cout << ans;
}


int main()
{

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

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

	int t = 1;
	// cin >> t;
	while (t--)
	{
		solve();
	}

	return 0;
}




Measured memory_bytes: 3648
#include  <iostream>
#include  <stdio.h>
using namespace std;


int main(){

    string b;
    cin >> b;
    int count;
    int max_c;
    max_c = 0;
    count = 0;
    for (int si = 0; si < (int)b.length(); si++){
        string val = b.substr(si,1);
        if(val == "A" ){
            count = count + 1;
        }else if(val == "T" ){
            count = count + 1;
        }else if(val == "C" ){
            count = count + 1;
        }else if(val == "G" ){
            count = count + 1;
        }else{
            count = 0;
        }
        if(max_c < count){
            max_c = count;
        }

    }
    cout << max_c;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
t,a = map(int,input().split())
H = [t-h*0.006 for h in list(map(int,input().split()))]
min_abs = float('inf')
index = 0
for h in H:
  if abs(h-a) < min_abs:
    min_abs = abs(h-a)
    index = H.index(h)
print(index +1)
  

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

#define pb push_back
#define sp " "
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (unsigned long long a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define bit(i,j) (i&(1<<j))
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=2e5+5,mod=998244353;
ll n,c,s;
ll vs[1000005];
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin>>n;
	if (n==2) { cout<<1; return 0; }
	ll q=n-1;
	for (ll i=2;i*i<=n;i++) {
		if (q%i==0) {
			c+=2;
			if (q/i==i) c--;
		}
	}
	c++;
	for (ll i=2;i*i<=n;i++) {
		if (n%i==0) {
			q=n;
			while (q%i==0) q/=i;
			if (q%i==1) c++;
			q=n;
			if (n/i==i) continue;
			while (q%(n/i)==0) q/=(n/i);
			if (q%(n/i)==1) c++;
		}
	}
	c++;
	cout<<c;
	return 0;
}


Measured memory_bytes: 256
n = int(input())

def plus(k):
    j = 0
    while (2**(j+2) - 1)/3 < k:
        j += 2
    return 10**j,k-2**j

def minus(k):
    j = 1
    while ((-2)**(j+2)-(-2))/3 > k:
        j += 2
    return 10**j,k-(-2)**j

ans = 0    
while n != 0:
    if n > 0:
        a,n = plus(n)
        ans += a
    else:
        a,n = minus(n)
        ans += a

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
int main(){
    int n;cin >> n;
    vector<int> L(n);
    for(int i=0; i<n; i++) cin >> L[i];
    int ans=0;
    sort(L.begin(),L.end());
    for(int a=0; a<n-1; a++){
        for(int b=a+1; b<n; b++){
            int ab=L[a]+L[b];
            int right=lower_bound(L.begin(),L.end(),ab)-L.begin();
            int left=b+1;
            ans+=max(0,right-left);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main{
    
      public static int a,b,c,d;
      
      public static String solve(){
           int tak = 0,aok = 0;
           tak = ((c+b-1)/b);
           aok = ((a+d-1)/d);
           if( tak - aok <= 0 ) return "Yes";
           return "No";
      }
  	  public static void read(){
         Scanner x = new Scanner(System.in);
         a = x.nextInt();
         b = x.nextInt();
         c = x.nextInt();
         d = x.nextInt();   
      }

       public static void main(String []args){

         read();
         System.out.println(solve());
        
      }
}

Measured memory_bytes: 35568
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  string s, t; cin >> s >> t;
  vector<int> A(26, -1), B(26, -1); 

  bool flag = true;
  rep(i, s.length()) {
    int p = s[i]-'a';
    int q = t[i]-'a';

    if(A[p]==-1) A[p] = q;
    if(B[q]==-1) B[q] = p;

    if(A[p]!=-1 && A[p]!=q) flag = false;
    if(B[q]!=-1 && B[q]!=p) flag = false;
  }
  cout << (flag ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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



int main() {
	
	int q;
	cin >> q;
	while(q--){
		string s;
		cin >> s;
		
		int ans = 0;
		while(s.size() != 1){
			int maxi = 0;
			REP(i, 1, s.size()){
				int a = stoi(s.substr(0, i));
				int b = stoi(s.substr(i));
				maxi = max(maxi, a * b);
			}
			s = to_string(maxi);
			ans++;
		}
		
		cout << ans << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3240
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Comparator;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final int n = in.nextInt();
            List<TaskC.Point> pointA = new ArrayList<>();
            List<TaskC.Point> pointB = new ArrayList<>();
            Comparator<TaskC.Point> min = Comparator.comparing(TaskC.Point::getMin);
            Comparator<TaskC.Point> max = Comparator.comparing(TaskC.Point::getMax);

            for (int i = 0; i < n; i++) {
                pointA.add(new TaskC.Point(in.nextInt(), in.nextInt()));
            }
            for (int i = 0; i < n; i++) {
                pointB.add(new TaskC.Point(in.nextInt(), in.nextInt()));
            }

            pointA.sort(max);
            pointB.sort(min);
            int ans = 0;
            int index = pointA.size() - 1;
            while (index >= 0) {
                TaskC.Point ca = pointA.get(index);
                for (int i = 0; i < pointB.size(); i++) {
                    TaskC.Point cb = pointB.get(i);
                    if (ca.getX() < cb.getX() && ca.getY() < cb.getY()) {
                        pointA.remove(ca);
                        pointB.remove(cb);
                        ans++;
                        index--;
                        break;
                    } else if (i == pointB.size() - 1) {
                        index--;
                    }
                }
            }
            out.println(ans);
        }

        static class Point {
            private int x;
            private int y;

            public Point(int x, int y) {
                this.x = x;
                this.y = y;
            }

            public int getX() {
                return this.x;
            }

            public int getY() {
                return this.y;
            }

            public int getMax() {
                return Math.max(x, y);
            }

            public int getMin() {
                return Math.min(x, y);
            }

        }

    }
}



Measured memory_bytes: 26964
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <tuple>

using namespace std;

#define D(x) x
#define REP(i,a,b) for (int i = (a); i < (b); ++i)
#define ll long long

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(12) << fixed;

    int N; ll x; cin >> N >> x;
    ll A[N]; REP(i,0,N) {cin >> A[i];}

    ll price[N];
    REP(i,0,N) {price[i] = A[i];}

    ll result = 1ll << 50;

    REP (shift, 1, N + 1) {
        ll sum = 0;
        REP (i, 0, N) {
            sum += price[i];
        }
        result = min(result, sum + (shift-1) * x);
        REP (i, 0, N) {
            price[i] = min(price[i], A[(i - shift + N) % N]);
        }
    }

    cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	string s;
	cin >> s;
	string ans;
	for(char c : s) {
		if (c != 'B') {
			ans.push_back(c);
		}
		else {
			if (!ans.empty()) {
				ans.pop_back();
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int k = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		while(a<=b) {
			if(a%k == 0) {
				System.out.println("OK");
				System.exit(0);
			}else {
				a += 1;
			}
		}
		
		System.out.println("NG");
		
	}	
	
	
	//最小公約数
	/*
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	*/
	
}

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

using namespace std;

int main() {
	int h1, h2, k1, k2, a, b, c, d, score1, score2;

	cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;

	score1 = h1 * a + h2 * b + h1 / 10 * c + h2 / 20 * d;
	score2 = k1 * a + k2 * b + k1 / 10 * c + k2 / 20 * d;

	if (score1 > score2) {
		cout << "hiroshi" << endl;
	}
	else if (score1 < score2) {
		cout << "kenjiro" << endl;
	}
	else {
		cout << "even" << endl;
	}

	return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
using namespace std;
int main(){
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	while(a>=b && k>0){
		b*=2;
		k--;
	}
	while(b>=c && k>0){
		c*=2;
		k--;
	}
	if(a<b && b<c)cout<<"Yes";
	else cout<<"No";
}


Measured memory_bytes: 3632
#if 0
?????¨?????????1.5h(???????????????)
bfs??????????????¢?´¢???????????°????????§?????????
????????????????´????????????\?????????????????????????????¨????????????????????£??????????????????queue?????????????????¢?????????
main?????§???????????§?§£????????£??\?????????to??£??\??????????????????????????£??????
????????§?????????G????????????cout??§??????(presentation error)?????¨???????????´?????????
#endif

#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int n, D[100];
int G[100][100];
void bfs(int src){
	queue<int> q;
	q.push(src);
	D[src]=0;
	while(!q.empty()){
		int cur=q.front();
		q.pop();
		for(int dst=0;dst<n;dst++){
			if(G[cur][dst]==1&&D[dst]==-1){
				D[dst]=D[cur]+1;
				q.push(dst);
			}
		}
	}
};

int main()
{
	vector<int> v[110];
	cin>>n;
	for(int i=0;i<n;i++){
		int u,k;
		cin>>u>>k;
		for(int j=0;j<k;j++){
			int tmp;
			cin>>tmp;
			v[u].push_back(tmp);
		}
	}
	for(int i=0;i<100;i++){
		D[i]=-1;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			G[i][j]=0;
		}
	}
	for(int i=1;i<n+1;i++){
		for(int j=0;j<v[i].size();j++){
			G[i-1][v[i][j]-1]=1; //
		}
	}
	bfs(0);
	for(int i=0;i<n;i++){
		cout<<(i+1)<<' '<<D[i]<<endl;
	}
}

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

typedef long long ll;
ll hp[100005];
ll N, A, B;

bool enough(int num) {
    ll count = 0;
    for (int i = 0; i < N; i++) {
        if (hp[i] > B * num) {
            count += (hp[i] - B * num + A - B - 1) / (A - B);
        }
    }
    if (count <= num) return true;
    else return false;
}

int main() {
    ll max_hp = 0;
    cin >> N >> A >> B;
    for (int i = 0; i < N; i++) {
        cin >> hp[i];
        max_hp = max(max_hp, hp[i]);
    }
    ll max_num = (max_hp + B - 1) / B;
    ll left = 1, right = max_num, mid = (left + right) / 2;
    while (left <= right) {
        mid = (left + right) / 2;
        if (! enough(mid)) {
            left = mid + 1;
        }
        else {
            right = mid - 1;
        }
    }
    if (enough(mid)) cout << mid << endl;
    else cout << left << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  ll n,q;
  cin>>n;
  vi a(n);
  rep(i,n) cin>>a[i];
  cin>>q;
  vi b(q),c(q);
  rep(i,q) cin>>b[i]>>c[i];
  vi cnt(100005);
  ll nowsum=0;
  rep(i,n){
    cnt[a[i]]++;
    nowsum+=a[i];
  }
  rep(i,q){
    nowsum+=cnt[b[i]]*(c[i]-b[i]);
    cnt[c[i]]+=cnt[b[i]];
    cnt[b[i]]=0;
    out(nowsum);
  }
}

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


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

//?????????????????????????¶????????????????-1???????????????

int main(){
    while(1){
        //??\???
        int h; cin >> h;
        if(!h) break;
        vector<vector<int> >  pu(h, vector<int> (h, 5));
        for(int i = 0; i < h; i++){
            for(int j = 0; j < 5; j++){
                cin >> pu[i][j];
            }
        }


        //??\????????????
        int score = 0;
        bool flag = true;
        while(flag){
            flag = false;
            for(int i = 0; i < h; i++){
                int counter = 1;
                int n = pu[i][0];
                for(int j = 1; j <= 5; j++){
                    if(j == 5){
                        if(counter >= 3 && n != -1){
                            flag = true;
                            score += counter * n;
                            for(int k = j - 1; k >= j - counter; k--){
                                pu[i][k] = -1;
                            }
                        }
                        break;
                    }

                    if(pu[i][j] == n){
                        counter++;
                    }else{
                        if(counter >= 3 && n != -1){
                            flag = true;
                            score += counter * n;
                            for(int k = j - 1; k >= j - counter; k--){
                                pu[i][k] = -1;
                            }
                            break;
                        }else{
                            counter = 1;
                            n = pu[i][j];
                        }
                    }
                }
            }

            //???????????£???????????????
            for(int j = 0; j < 5; j++){
                for(int i = 1; i < h; i++){
                    if(pu[i][j] == -1){
                        for(int k = i - 1; k >= 0; k--){
                            pu[k + 1][j] = pu[k][j];
                        }
                        pu[0][j] = -1;
                    }
                }
            }

            /*cout << "ohana" << endl;
            for(int i = 0; i < h; i++){
                for(int j = 0; j < 5; j++){
                    cout << pu[i][j] << " ";
                }
                cout << endl;
            }
            cout << score << endl;
            int input; cin >> input;*/
        }

        cout << score << endl;
    }

    return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n,x,ans=0;cin>>n;
  	vector<int> a(100000);
  	for(int i=0;i<n;i++){
    	cin>>x;
      	a[x]++;
    }
  	for(int i=2;i<=100000;i++){
     	 ans=max(ans,a[i-2]+a[i-1]+a[i]);
    }
  	cout<<ans<<endl;
}

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

using namespace std;

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

const int MOD = 1000000007;

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

    int ans = 0;
    for(int i = 1; i <= n; i++) {
        int j = i;
        int tmp = 0;
        while(j > 0) {
            tmp++;
            j /= 10;
        }
        if(tmp % 2 == 1) ans++;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    int A, B;

    AtCoder(FastScanner sc) {
        A = sc.nextInt();
        B = sc.nextInt();
    }

    void solve(PrintWriter out) {
        if (A > B) {
            out.println(B != 1 ? "Alice" : "Bob");
        } else if (A < B) {
            out.println(A != 1 ? "Bob" : "Alice");
        } else {
            out.println("Draw");
        }
    }

}

class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21332
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	s := readLine()
	fmt.Println(abc040a(s))
}

func abc040a(s string) int64 {
	result := int64(0)
	combos := []int64{}
	combo := int64(0)
	prev := byte('?')
	for i := range s {
		str := s[i]
		if prev == str {
			combo++
		} else {
			if prev == '>' {
				combos = append(combos, -combo)
			} else {
				combos = append(combos, +combo)
			}
			combo = 1
		}
		prev = str
	}
	if prev == '>' {
		combos = append(combos, -combo)
	} else {
		combos = append(combos, +combo)
	}
	// pp.Print(combos)
	for i, combo := range combos {
		if combo == 0 {
			continue
		}
		c := int64(math.Abs(float64(combo)))
		if combo > 0 {
			if len(combos) == i+1 {
				result += (c + 1) * c / 2
			} else if combo+combos[i+1] < 0 {
				result += (c - 1) * c / 2
			} else {
				result += (c + 1) * c / 2
			}
		} else {
			if combo+combos[i-1] < 0 {
				result += (c + 1) * c / 2
			} else {
				result += (c - 1) * c / 2
			}
		}
	}
	return result
}


Measured memory_bytes: 9728
from itertools import product
A=[2*x-1 for x in range(2,50001)]
primes=[2]
while(1):
    if A[0] > 5000**0.5:
        primes += A
        break
    else:
        t=A[0]
        primes.append(t)
        A = [x for x in A if x%t !=0 ]
while(1):
    b = int(raw_input())*2
    M=b
    if b==0: break
    D=[]
    for a in primes:
        tmp=0
        while b%a == 0:
            tmp+=1
            b/=a
        if tmp!=0:
            D.append( [ a**p for p in range(tmp+1) ] )
    allp =  sorted( [reduce( lambda a,b:a*b ,d ) for d in product(*D) ] , reverse=True)
    for p in allp:
        n=p-1
        if (M/p-n)%2==0 and (M/p-n)/2>0:
            print (M/p-n)/2, p
            break



Measured memory_bytes: 7888
import java.util.Scanner;


public class Main {
	Scanner sc = new Scanner(System.in);
	
	void run(){
		while(sc.hasNext()){
			int sum = 0, n = sc.nextInt();
			for(int a = 0; a < 10; a++){
				for(int b = 0; b < 10; b++){
					for(int c = 0; c < 10; c++){
						for(int d = 0; d < 10; d++){
							if(a + b + c + d == n)
								sum++;
						}
					}
				}
			}
			
			System.out.println(sum);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 18868
#include <stdio.h>
int main(int argc, char const *argv[])
{
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	if(A * C <= B){
		printf("%d\n", C);
	}else{
		printf("%d\n",B / A);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll power(ll x, ll m){
    //繰り返し二乗法
    if(m == 0) return 1;
    if(m == 1) return x;
    if(m % 2 == 0){
        return power(x*x,m/2);
    }else{
        return power(x*x,m/2)*x;
    }
}

int main(){
    ll n; cin >> n;
    vl h(n);
    rep(i,n) cin >> h[i];
    for(ll i=n-1; i>=1; i--){
        if(h[i-1] > h[i]){
            if(h[i-1] - h[i] > 1){
                cout << "No" << endl;
                return 0;
            }else{
                h[i-1]--;
            }
        }
    }
    cout << "Yes" << endl;
}

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

void dfs(int v, vector<bool> &seen) {
    seen[v] = true;
    for (auto nv : G[v]) {
        if (seen[nv])
            continue;
        dfs(nv, seen);
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    rep(i, M) { cin >> A[i] >> B[i]; }
    int res = 0;
    rep(i, M) {
        int s = A[i] - 1;
        G.assign(N, vector<int>());
        rep(j, M) {
            if (j != i) {
                int a = A[j], b = B[j];
                a--, b--;
                G[a].push_back(b);
                G[b].push_back(a);
            }
        }

        vector<bool> seen(N, false);
        dfs(s, seen);
        for (auto b : seen) {
            if (b == false) {
                res++;
                break;
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N = in_n()
    A = in_nl()

    ans = 0
    for i in range(0, N, 2):
        if A[i] % 2 == 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

string inttos(int num)
{
    return to_string(num);
}

int stoint(string sss)
{
    return stoi(sss);
}

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	string s,t;
	cin >> s >> t;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes";
	
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, k, q, a, t[100005];
int main(){
	scanf("%d%d%d", &n, &k, &q);
	rep(i,q){
		scanf("%d", &a);
		t[a-1]++;
	}
	rep(i,n) puts( q-t[i] < k ? "Yes" : "No");
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h = 100, w = 40;
    char c[110][50] = {};
    int a, b;
    cin >> a >> b;
    rep(i, 0, h) rep(j, 0, w) c[i][j] = '.';
    rep(i, 0, h){
        rep(j, 0, w){
            if(i % 2){
                if(j < w / 2) c[i][j] = '#';
            }else{
                if(j % 2) c[i][j] = '#';
            }
        }
    }
    int acnt = 501 - a;
    int bcnt = 501 - b;
    rep(i, 0, h){
        rep(j, 0, w / 2){
            if(c[i][j] == '.'){
                if(acnt != 0){
                    c[i][j] = '#';
                    acnt--;
                }
            }
        }
    }
    rep(i, 0, h){
        rep(j, w / 2, w){
            if(c[i][j] == '#'){
                if(bcnt != 0){
                    c[i][j] = '.';
                    bcnt--;
                }
            }
        }
    }
    cout << h << ' ' << w << endl;
    rep(i, 0, h){
        rep(j, 0, w) cout << c[i][j];
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

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

  vector<ll> mins(n + 1), maxes(n + 1);

  mins[n] = a[n];
  maxes[n] = a[n];
  for (int i = n - 1; i >= 0; --i) {
    mins[i] = (mins[i + 1] + 1) / 2 + a[i];
    maxes[i] = maxes[i + 1] + a[i];
  }

  if (mins[0] > 1) {
    puts("-1");
    return 0;
  }

  ll ans = 1;
  ll pre = 1;
  for (int i = 1; i <= n; ++i) {
    ll minv = min(pre * 2, maxes[i]);
    ans += minv;
    pre = minv;
    pre -= a[i];
  }

  cout << ans << endl;

}

Measured memory_bytes: 5632
#include<algorithm>
#include<iomanip>
#include<iostream>
#include<queue>
#include<string>
#include<unordered_set>
#include<vector>
using namespace std;
typedef long long ll;
const ll INF = 1000000000000000000;

string s;

int main(){
    cin >> s;
    for(int i=0; i<s.size(); i++){
        cout << 'x';
    }
    cout << endl;
}

Measured memory_bytes: 256
from collections import deque
n, q_time = map(int, input().split())
d = deque()
for i in range(n):
    x, y = input().split()
    d.append((x, int(y)))

total = 0
while d:
    name, time = d.popleft()
    if time <= q_time:
        total += time
        print(name, total)
    else:
        total += q_time
        time -= q_time
        d.append((name, time))





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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    ll ans = K;
    REP(i, N - 1) {
        ans *= K - 1;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int lam,gcd,a,b,c,d;
	while(cin>>a>>b)
	{
		c=a;
		d=b;
		if(a<b)
		{
			a=a+b;
			b=a-b;
			a=a-b;
		}
		while(a%b!=0)
		{
			int temp;
			temp=b;
			b=a%b;
			a=temp;
		}
		gcd=b;
		lam=d/gcd*c;
		printf("%d %d\n",gcd,lam);
	}
	return 0;
}

Measured memory_bytes: 3036
#include<bits/stdc++.h>
using namespace std;
int N, L;

int p[21];
int d[21];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    while(true) {
        cin >> N >> L;
        if(N == 0) break;
        int out = 0;
        for(int i = 1; i <= N; i++) {
            char di;
            cin >> di;
            if(di == 'L') d[i] = 0;
            else d[i] = 1;
            cin >> p[i];
            //cerr << d[i] << ' ' << p[i] << endl;
        }
        for(int timer = 1; ; timer++) {
            //cerr << timer << ' ' << out << endl;
            for(int i = 1; i <= N; i++) {
                if(d[i] == -1) continue;
                if(d[i] == 0) p[i]--;
                if(d[i] == 1) p[i]++;
            }
            int ans = -1;
            for(int i = 1; i <= N; i++) {
                if(d[i] == -1) continue;
                for(int j = i + 1; j <= N; j++) {
                    if(d[j] == -1) continue;
                    if(p[i] == p[j]) {
                        d[i] = 1 - d[i];
                        d[j] = 1 - d[j];
                    }
                }
            }
            for(int i = 1; i <= N; i++) {
                if(d[i] == -1) continue;
                if(p[i] == L) {
                    d[i] = -1;
                    ans = i;
                    out++;
                    //cerr << timer << ' ' << i << endl;
                }
            }
            for(int i = 1; i <= N; i++) {
                if (d[i] == -1) continue;
                if (p[i] == 0) {
                    d[i] = -1;
                    ans = i;
                    out++;
                    //cerr << timer << ' ' << i << endl;
                }
            }
            if(out == N) {
                cout << timer << ' ' << ans << endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <cmath>
#include <iomanip> 
using namespace std;
double distance(int x1, int y1, int x2, int y2) 
{ 
    // Calculating distance 
    return sqrt(pow(abs(x2 - x1), 2) +  
                pow(abs(y2 - y1), 2) * 1.0); 
} 
int factorial(int n)
{
    if(n > 1)
        return n * factorial(n - 1);
    else
        return 1;
}
int main(void){
 int n;
 double S=0;
 int a[100][2];
cin >> n;
  for(int i=0;i<n;i++){
      cin >> a[i][0] >> a[i][1];
  }
    for(int i=0;i<n-1;i++)
      for(int j=i+1;j<n;j++)
          S+=2*(n-1)*distance(a[i][0],a[i][1],a[j][0],a[j][1])*factorial(n-2);
      
cout << setprecision(12) << S/factorial(n);


































































































}


Measured memory_bytes: 256