akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(20)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int A, B, K;
    cin >> A >> B >> K;
    for(int i = 0; i < K; i++){
        if(i % 2 == 0){
            A /= 2;
            B += A;
        }else{
            B /= 2;
            A += B;
        }
    }
    cout << A << " " << B << endl;
}


Measured memory_bytes: 256
n =int(input())
a =list(int(input()) for i in range(n))

dict = {}
for i in range(n):
  if str(a[i]) in dict:
    dict.pop(str(a[i]))
    continue
    
  if not(str(a[i]) in dict):
    dict[str(a[i])] =1
    continue
  
    
print(len(dict))

Measured memory_bytes: 21844
<?php
fscanf(STDIN, '%d %d', $N, $K);
$V = array_map('intval', explode(' ', trim(fgets(STDIN))));

$max = 0;
for($i = 0; $i <= min($K, $N); $i++) { // 全部で$i個取る場合を考える
    for($left = 0; $left <= $i; $left++) { // 左から$left個取る
        $have = [];
        $right = $i - $left; // 右から$right個取る
        for($j = 0; $j < $left; $j++) {
            $have[] = $V[$j];
        }
        for($j = 0; $j < $right; $j++) {
            $have[] = $V[$N - 1 - $j];
        }
        for($j = 0; $j < $K - $i; $j++) {
            if (empty($have)) break;
            $min = min($have);
            if ($min < 0) array_splice($have, array_search($min, $have), 1);
            else break;
        }
        $max = max($max, array_sum($have));
    }
}
echo $max . PHP_EOL;

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	string s;
	cin >> s;
	VL count(2,0);

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') {
			count[0]++;
		}
		else {
			count[1]++;
		}
	}
	cout << min(count[0], count[1]) * 2 << endl;
	return 0;
}


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

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

struct Edgenode{
  int x;
  int y;
};

bool check(vector<vector<Edgenode>> G, vector<int> v){
  rep(i, G.size()){
    rep(j, G[i].size()){
      if(v[i]==1 && v[G[i][j].x] != G[i][j].y)return false;
    }
  }
  return true;
}
int main(){
  int n;
  cin >> n;
  vector<vector<Edgenode>> G;

  rep(i,n){
    int a;
    cin >> a;
    vector<Edgenode> g;
    rep(j,a){
      Edgenode edge;
      //int x,y;
      cin >> edge.x >> edge.y;
      edge.x--;

      g.push_back(edge);
    }
    G.push_back(g);
  }

  vector<int> v(n);
  for(int i=n ; i>=0; i--){
    rep(j,n-i)v[j]=0;
    for(int j=n-i; j<n; j++)v[j]=1;
      
    do{
      //rep(j,n)cout << v[j] << " ";
      //cout << endl; 
      if(check(G,v)){
        cout << i << endl;
        return 0;
      }
    }while(next_permutation(v.begin(), v.end()));
  }

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

Measured memory_bytes: 256
/*
Author: Srinjoy
Language: C++ 17
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define fileinput(s) freopen(s,"r",stdin)
#define MINUS(a) memset(a,0xff,sizeof(a))
typedef long long ll;
const ll mod = 1000000007;


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

	ll p1 = abs(B-A);

	if(p1%2==0) cout<< (p1/2) <<endl;

	else{
		ll p2 = min( abs(A -1) , abs(N-B) );

		ll p3 = (B-A-1)/2;



		cout<< p2 + p3 + 1 <<endl;
	} 
	
}

Measured memory_bytes: 256
num = gets.chop
line = gets
num_array = line.split(" ")

class Test 
    def partition(a, pp,r)
        x = a[r].to_i
        i = pp - 1
        j = pp
        while true do
            if j == r then
                break
            end
            if a[j].to_i <= x then
                i += 1
                buf = a[i]
                a[i] = a[j]
                a[j] = buf
            end
            j += 1
        end
        buf2 = a[i + 1]
        a[i + 1] = a[r]
        a[r] = buf2
        a.each_with_index{|value, index|
            if index == i + 1 then
                print "["
                print value.to_i 
                print "] "
            else
                if index == a.length - 1 then
                    p value.to_i
                else
                    print value.to_i
                    print " "
                end
            end
        }
        return i + 1
    end
end
test = Test.new
test.partition(num_array,0,num_array.length - 1)

Measured memory_bytes: 15888
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(pos,mp) for(ll pos=mp.begin();pos!=mp.end();pos -++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

struct idx{
    ll ap, bp, cp;
};

int main(){
    ll x, y, z, k;
    cin >> x >> y >> z >> k;

    vector<ll> a(x), b(y), c(z);
    rep(i, x)cin >> a[i];
    rep(i, y)cin >> b[i];
    rep(i, z)cin >> c[i];

    vector<ll> a_b;
    rep(i, x)rep(j, y){
        a_b.push_back(a[i]+b[j]);
    }

    sort(ALL(a_b), greater<ll>());
    vector<ll> ans;
    rep(i, min(k, (ll)a_b.size()))rep(j, z){
        ans.push_back(a_b[i]+c[j]);
    }

    sort(ALL(ans), greater<ll>());
    rep(i, k)cout << ans[i] << endl;
}

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

#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
int powmod(int a,int l, int md){a%=md; int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
int invmod(int a, int md){return powmod(a,md-2,md);}
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector< ii > vii;
#define pb push_back
int __set(int b, int i) {return b|(1LL<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1LL<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return (((a%md)*(b%md))%md+md)%md;}
int addmod(int a, int b, int md) {return ((a%md+b%md)%md+md)%md;}
int submod(int a, int b, int md) {return (((a%md-b%md)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


signed main(void)
{
	IOS;
	string s; cin>>s;
	int no=1;
	if(s[0]=='7' || s[1]=='7' || s[2]=='7')
		no=0;
	if(no) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 3664
// ========================================================================================================
// Library
// ========================================================================================================
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ========================================================================================================
// ========================================================================================================

int main()
{
	fastIOS();

    int n; cin >> n;
    int indexMax = -1;
    int max1 = INT_MIN , max2 = INT_MIN;
    
    for(int i = 0; i< n; i++)
    {
        int tmp; cin >> tmp;
        
        if(tmp > max1)
        {
            max2 = max1;
            max1 = tmp;
            indexMax = i;
        }
        
        else if(tmp > max2)
        {
            max2 = tmp;
        }
    }
    
    for(int i = 0; i< n; i++)
    {
        if(i != indexMax)
        {
            cout << max1 << endl;
        }
        else{
            cout << max2 << endl;
        }
    }
    
    return 0;
}

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

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

    string s;
    cin >> s;
    map<long long, long long> mp;
    mp[0] = 1;
    reverse(s.begin(), s.end());

    long long now = 0, ten = 1;
    int n = s.size();
    for(int i = 0; i < n; i++){
        now = (now + (long long)(s[i] - '0') * ten) % 2019;
        ten *= 10;
        ten %= 2019;
        mp[now]++;
    }

    long long ans = 0;
    for(auto x: mp){
        ans += x.second * (x.second - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3760
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int f = 0;
		for(int i=0;i<n.length();i++){
			f += (int)n.charAt(i) - (int)'0';
		}
		int x = Integer.parseInt(n);
		if(x%f==0){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24020
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//https://atcoder.jp/contests/dp/tasks/dp_a


int main(){
    ll n;
    cin >> n;
    vector <ll> h(n);
    REP(i,n)
    {
        cin >> h.at(i);
    }

    ll dp[n];

    REP(i,n)
    {
        dp[i] = INF;
    }

    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    
    for(ll i = 2; i <n; ++i)
    {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    ll res = dp[n-1];

    cout << res << endl;

    return 0;    
}



Measured memory_bytes: 1792
from collections import Counter
N, A = int(input()), list(map(int, input().split()))
temp = [0] * N
for i in range(1, N+1):
    temp[i-1] = i + A[i-1]
temp = Counter(temp)
result = 0
for j in range(1, N+1):
    s = temp.get(j - A[j-1])
    if s != None:
        result += s
print(result)

Measured memory_bytes: 42920
N, D = map(int, input().strip().split())
X = [[int(n) for n in input().strip().split()] for _ in range(N)]
c = 0
for i in range(N):
    for j in range(i+1, N):
        n = 0
        for k in range(D):
            x = abs(X[i][k] - X[j][k])
            n += x * x 
        b = False
        for k in range(n+1):
            if k * k == n:
                b = True
        if b:
            c += 1
print(c)

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	// Input
	var d int
	fmt.Scan(&d)

	// Solve
	fmt.Println(solve(d))
}

func solve(d int) string {
	ans := "Christmas"
	for i := 0; i < 25-d; i++ {
		ans += " Eve"
	}
	return ans
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;
int main(void) {

    int x;
    cin >> x;
    
    int h = x / 3600;
    int remaining = x % 3600;
    int m = remaining / 60;
    int s = remaining % 60;
    
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}



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

l_0 = 2
l_1 = 1
N_array = [2,1]
l_2 = l_0+ l_1  
l_3 = l_1+ l_2
a,b = 2,1
for i in range(N-1):
  c = a+b
  N_array.append(c)
  a = c -a
  b = c 
  #a = 
#  N_array.append(b)
  
  
print(N_array[-1])  
  
  
  

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

#define vi vector<int> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vl vector<ll>
#define pii pair<int, int>

void bfs(vi adj[], int src, bool vis[], int level[])
{
	queue<pii> q;
	q.push(mp(src,0));
	vis[src]=true;
	level[src]=0;

	while(!q.empty())
	{
		pii vpair=q.front();
		q.pop();
		int v=vpair.ff;
		int lvl=vpair.ss;

		for(int i=0;i<adj[v].size();i++)
		{
			int next=adj[v][i];
			if(!vis[next])
			{
				q.push(mp(next,lvl+1));
				vis[next]=true;
				level[next]=lvl+1;
			}
		}
	}
}

void dfs(vi adj[], int src, bool vis[])
{
	vis[src]=true;
	for(int i=0;i<adj[src].size();i++)
	{
		int next=adj[src][i];
		if(!vis[next])
		{
			dfs(adj,next,vis);
		}
	}
}




void solve()
{
	// bool vis[6]={false};
	// int level[6];
	// dfs(adj,0,vis);
	// bfs(adj,0,vis,level);
	ll a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	ll d=max(a-b,b-a);
	// cout<<(v+w)*t<<" "<<d<<endl;
	if((v-w)*t>=d)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3644
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<string> S;
  int mid = S.length() / 2;
  for (int i = 0; i <= mid; i++)
    if (S[mid - i] != S[mid + i])
      return "No";
  int qmid = S.length() / 2;
  for (int i = 0; i < mid/2; i++)
    if (S[i] != S[mid-1 - i])
      return "No";
  for (int i = 0; i < mid/2; i++)
    if (S[mid+1+i] != S[S.length()-1-i])
      return "No";



  return "Yes";
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int n=scan.nextInt();
String s=scan.next();
int max=0;
int x=0;
for(int i=0;i<n;i++){
if(s.charAt(i)=='I'){
x++;
max=Math.max(x,max);
}else{x--;}
}
System.out.println(max);
}
}


Measured memory_bytes: 10192
N, M, C = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
A = []
for i in range(N):
    A.append([int(x) for x in input().split()])

count = 0
for a in A:
    tmp = 0
    for i, j in zip(a,B):
        tmp += i*j
    tmp += C
    if tmp > 0:
        count += 1

print(count)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#define ll long long int
ll min(ll x, ll y){return x<y?x:y;}
int main(void){
	ll n,m,ans;
	scanf("%lld%lld",&n,&m);
	ans = min(n,m/2);
	if(ans==m/2){
	}else{
		ll x = m-n*2;
		ans+=x/4;
	}
	printf("%lld",ans);
	
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector <int64_t> l(2);
    l[0] = 2;
    l[1] = 1;
    int64_t ori_l;
    for(int i=2; i<=N; i++){
        ori_l = l[1];
        l[1] = l[0] + l[1];
        l[0] = ori_l;
    }
    cout << l[1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>
using namespace std;
int main(){
	set<string, greater<string> > unique;
  	int num;
  	cin>>num;
  	string dum;
  	for(int i=0; i < num ;i++){
      	cin>>dum;
    	unique.insert(dum);
    }
  	cout<<unique.size()<<endl;
  	return 0;
}

Measured memory_bytes: 15688
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
p = l()
count = 0
i = 0

while i < N:
    if p[i] == i+1:
        count += 1
        i += 1
    i += 1

print(count)


Measured memory_bytes: 21272
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

void dfs(string s, char c, vector<string>& ans) {
    int l = count(s.begin(), s.end(), '?')  - 1;
    if (l == -1) {ans.push_back(s); return;}
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '?') { s[i] = c; break; }
    }

    for (int bit = 0; bit < 1 << l; ++bit) {
        string t(s);
        int j = 0;
        for (int i = 0; i < l; ++i) {
            for (; j < t.size(); ++j) {
                if (t[j] == '?') {
                    if (bit >> i & 1) 
                        t[j] = c;
                    ++j;
                    break;
                }
            }
        }
        dfs(t, c + 1, ans);
    }
}

int main() {
    int n; cin >> n;
    vector<string> ans;
    dfs(string(n, '?'), 'a', ans);
    sort(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); ++i) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 7796
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
using namespace std;
int ok=0;
char c[10][10];
int h,w;
int a=0;
void dfs(int x,int y,int step){
	if(step==a)
	ok=1;
	if(c[x+1][y]=='#')
	dfs(x+1,y,step+1);
	if(c[x][y+1])
	dfs(x,y+1,step+1);
}
int main(){
	scanf("%d %d\n",&h,&w);
	for(int i=0;i<h;i++)
	for(int j=0;j<w;j++){
	while(scanf("%c",&c[i][j])&&c[i][j]=='\n');
	if(c[i][j]=='#')
	a++;
	}
	dfs(0,0,1);
	if(c[0][0]=='.')
	ok=0;
	printf("%s",ok?"Possible":"Impossible");
}

Measured memory_bytes: 128
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))

if len(X) == 1:
    print(0)
    exit()

d = []
for i in range(M - 1):
    d.append(X[i + 1] - X[i])

d = sorted(d, reverse=True)
ans = abs(X[-1] + (X[0] * -1)) - sum(d[:N - 1])
print(ans)

Measured memory_bytes: 13968
#include<iostream>
#include<algorithm>
using namespace std;
int n,cnt;
int a[200],s[200];
int main()
{
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin >> a[i];
    if(a[i]%2==1)
    {
      cout << 0;
      return 0;
    }
  }
  for (int i = 0;i<n;)
  {
    a[i] /= 2;
    s[i]++;
    if(a[i]%2==1)
      i++;
  }
  sort(s, s + n);
  cout << s[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
using ld = long double;
int main()
{
    auto out = [](const ld y, const ld x, const ld sp) {
        const ld PI = 3.141592653589793;
        const ld F = 0.22451398828979266;
        const ld r1 = sqrt(sp / F / 5);
        const ld r2 = r1 * F / 0.5877852522924731;
        const ld theta = 0.1 * PI;
        for (int i = 0; i < 10; i++) {
            const ld s = theta * i * 2;
            const ld r = i % 2 == 0 ? r1 : r2;
            cout << fixed << setprecision(15) << x + r * cos(s) << " " << y + r * sin(s) << endl;
        }
    };
    int N;
    cin >> N;
    vector<ld> S(N);
    for (int i = 0; i < N; i++) { cin >> S[i]; }
    for (int i = 0; i < N; i++) {
        const ld y = (2 * (i / 10) + 1) * 500 - 5000;
        const ld x = (2 * (i % 10) + 1) * 500 - 5000;
        cout << i + 1 << endl;
        out(y, x, S[i]);
        // out(y, x, (i == 0 ? S[i] : (S[i] + S[i - 1]) * 0.5));
    }
    return 0;
}



Measured memory_bytes: 3596
#include<iostream>
#include<vector>

using namespace std;

int M=1000000007;

int f(vector<int> v,int s){
  int dp[823][223]={};
  dp[0][0]=1;
  for(int i=0;i<4;i++){
    for(int j=0;j<v[i];j++){
      for(int k=800;k>=i+1;k--){
	for(int l=200;l>0;l--){
	  dp[k][l]=(dp[k][l]+dp[k-(i+1)][l-1]*1LL*l)%M;
	}
      }
    }
  }
  int head[223]={1};
  for(int i=1;i<=200;i++){
    head[i]=(head[i-1]*1LL*i+1)%M;
  }
  int ans=0;
  int n=v[0]+v[1]+v[2]+v[3];
  int t=1;
  for(int i=0;i<=800;i++,t=(t*10LL)%M){
    for(int j=0;j<=n;j++){
      ans=(ans+dp[i][j]*1LL*head[n-j]%M*s%M*t%M)%M;
    }
  }
  return ans;
}

int solve(vector<int> a){
  int nd[4]={};
  int ds[4]={};
  for(auto e:a){
    int x=(e>=10)+(e>=100)+(e>=1000);
    nd[x]++;
    ds[x]=(ds[x]+e)%M;
  }
  int r=0;
  r=(r+(nd[0]?f({nd[0]-1,nd[1],nd[2],nd[3]},ds[0]):0))%M;
  r=(r+(nd[1]?f({nd[0],nd[1]-1,nd[2],nd[3]},ds[1]):0))%M;
  r=(r+(nd[2]?f({nd[0],nd[1],nd[2]-1,nd[3]},ds[2]):0))%M;
  r=(r+(nd[3]?f({nd[0],nd[1],nd[2],nd[3]-1},ds[3]):0))%M;
  return r;
}

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> nz;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]){
      nz.push_back(a[i]);
    }
  }
  int ans=solve(a);
  if(nz.size()<n){
    ans=(ans-solve(nz)+M)%M;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1940
#include<bits/stdc++.h>
using namespace std;
int ans[55][55];
int main()
{
	int m,n;
	char read1;
	scanf("%d%d",&m,&n);
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin>>read1;
			read1=='.'?ans[i][j]=0:ans[i][j]=-1;
		}
	}
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(ans[i][j]==-1)
			    continue;
			if(ans[i-1][j-1]==-1)
			    ans[i][j]++;
			if(ans[i-1][j]==-1)
			    ans[i][j]++;
			if(ans[i-1][j+1]==-1)
			    ans[i][j]++;
			if(ans[i][j-1]==-1)
			    ans[i][j]++;
			if(ans[i][j+1]==-1)
			    ans[i][j]++;
			if(ans[i+1][j-1]==-1)
			    ans[i][j]++;
			if(ans[i+1][j]==-1)
			    ans[i][j]++;
			if(ans[i+1][j+1]==-1)
			    ans[i][j]++;
		}
	}
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)	
			ans[i][j]==-1?printf("#"):printf("%d",ans[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  string X;
  cin >> X;
  ll ans_s=0;
  ll ans_t=0;
  for(int i=0;i<X.size();i++){
    if(X[i]=='S'){
      ans_s++;
    }else{
      if(ans_s==0){
        ans_t++;
      }else{
        ans_s--;
      } 
    }
  }
  cout<<ans_s+ans_t<<endl;
  return 0;
}

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


int main() {
int a,b;cin >> a>>b;
if(a%3==0||b%3==0||(a+b)%3==0){
cout << "Possible" << endl;
}
else cout << "Impossible" << endl;
}

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

using namespace std;

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

    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // ONLINE_JUDGE

    int k, n; cin>>k>>n;
    vector <int> distancias(n);
    for(int i = 0; i < n; ++i){
        cin>>distancias[i];
//        if(distancias[i] > k/2) distancias[i] = k - distancias[i];
    }
    int ans = distancias[n-1] - distancias[0];
    for(int i = 1; i < n; i++){
        int partida = distancias[i];
        int fin = distancias[(i + n - 1)%n];
        if(fin < partida) fin += k;
        ans = min(ans, fin - partida);
    }
//    sort(distancias.begin(), distancias.end());
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1024
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())


N = int(input())
pp = inpl()
tmp = 0
ans = 0
for i,p in enumerate(pp):
	if i+1 == p:
		tmp += 1
	else:
		ans += (tmp-1)//2 + 1
		tmp = 0

ans += (tmp-1)//2 + 1
print(ans)

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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;
int score=0;
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	string s;
	cin>>s;
	int l=s.size();
	int p=((l&1)?(l/2+1):(l/2));
	rep0(i,p){
		if(s[i]=='p')score--;
	}
	for(int i=p;i<l;i++){
		if(s[i]=='g')score++;
	}
	cout<<score;
	return 0;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  string s;
  cin>>s;
  ll N = s.size();
  vector<ll> ans(N, 0);
  set<ll> se;

  // "RL" の組を見つける
  // 入ったら抜け出せない
  rep(i,0,N-1){
    if (s[i]=='R' && s[i+1]=='L') {
      se.insert(i);
      se.insert(i+1);
      ans[i] = ans[i+1] = 1;
    }
  }
  
  // 偶数回移動して "RL" の組にくっつける
  rep(i,0,N){
    if (se.find(i) != se.end())
      continue;
    if (s[i] ==  'R') {
      auto it = se.lower_bound(i);
      if ((*it - i)%2 == 1)
        it++;
      ans[*it]++;
    } else {
      auto it = se.lower_bound(i);
      it--;
      if ((i - *it)%2 == 1)
        it--;
      ans[*it]++;
    } 
  }
  rep(i,0,N){
    cout<<ans[i];
    if (i==N-1){
      cout<<endl;
    } else {
      cout<<" ";
    }
  }
  return 0;
}


Measured memory_bytes: 6016
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    vector<int> dp(N, 0);
    int ans = 0;
    for(int i = N; i >= 1; i--){
        int sum = 0;
        for(int j = i; j <= N;){
            sum += dp[j - 1];
            j += i;
        }
        if(sum % 2 != A[i - 1]) {
            dp[i - 1] = 1;
            ans++;
        }
    }
    cout << ans << endl;
    for(int i = 0; i < N; i++){
        if(dp[i] == 1) cout << i + 1 << endl;
    }

}

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

enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };
template <class T>
class dice { 
	public:
		dice() {
			id[TOP] = 0; id[FRONT] = 1; id[LEFT] = 2;
			id[RIGHT] = 3; id[BACK] = 4; id[BOTTOM] = 5;
		}
		T& operator[] (FACE f) { return var[id[f]]; }
		const T& operator[] (FACE f) const { return var[id[f]]; }
		bool operator==(const dice<T>& b) const {
			const dice<T> &a = *this;
			return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
				a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
				a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
		}
		void roll_x() { roll(TOP, BACK, BOTTOM, FRONT); }
		void roll_y() { roll(TOP, LEFT, BOTTOM, RIGHT); }
		void roll_z() { roll(FRONT, RIGHT, BACK, LEFT); }
		vector<dice> all_rolls() {
			vector<dice> ret;
			for (int k = 0; k < 6; (k&1?roll_y():roll_x()),++k)
				for (int i = 0; i < 4; roll_z(), ++i)
					ret.push_back(*this);
			return ret;
		}
		bool equivalent_to(const dice& di) {
			for (int k = 0; k < 6; (k&1?roll_y():roll_x()),++k)
				for (int i = 0; i < 4; roll_z(), ++i)
					if (*this == di) return true;
			return false;
		}
	protected:
		void roll(FACE a, FACE b, FACE c, FACE d) {
			T tmp = id[a];
			id[a] = id[b]; id[b] = id[c];
			id[c] = id[d]; id[d] = tmp;
		}
		T var[6];
		int id[6];
};

template <class T>
class mydice : public dice<T> {
	public:
		mydice(T top, T front, T right, T left, T back, T bottom) {
			this->var[this->id[TOP]] = top;
			this->var[this->id[FRONT]] = front;
			this->var[this->id[RIGHT]] = right;
			this->var[this->id[LEFT]] = left;
			this->var[this->id[BACK]] = back;
			this->var[this->id[BOTTOM]] = bottom;
		}
		void roll_n() { this->roll(TOP, FRONT, BOTTOM, BACK); }
		void roll_e() { this->roll(TOP, LEFT, BOTTOM, RIGHT); }
		void roll_w() { this->roll(TOP, RIGHT, BOTTOM, LEFT); }
		void roll_s() { this->roll(TOP, BACK, BOTTOM, FRONT); }
};

main () {
	int n[6];
	for (int i=0; i<6; i++) cin >> n[i];
	mydice<int> a(n[0], n[1], n[2], n[3], n[4], n[5]);
	for (int i=0; i<6; i++) cin >> n[i];
	mydice<int> b(n[0], n[1], n[2], n[3], n[4], n[5]);
	cout << (a.equivalent_to(b) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((int)(a).size())
 
template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcountll(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define eps 1e-6
typedef pair<int, int> II;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI 2 * acos(0)
#define maxn 100005

int n,m,x;

void sol(){
  cin >> n >> m >> x;
  cout << x / max(n,m) + (x % max(n, m) != 0) << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  sol();
  return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
int a[200001],b[200001];
vector<int>sol;
void solve()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	for (int i = n; i >= 1; i--)
	{
		int x = 0;
		for (int j = i+i; j <= n; j = j + i)
		{
			x = x + b[j];
		}
		if (x % 2 != a[i] % 2)
		{
			b[i] = 1;
			sol.pb(i);
		}
	}
	cout << sol.size() << endl;
	for (int i = 0; i < sol.size(); i++)
	{
		cout << sol[i]<<" ";
	}
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
	return 0;
}


Measured memory_bytes: 2936
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(int i=0;i<p;i++)
#define ll long long

using namespace std;

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

for(int i=1;i<=9;i++){
	for(int j=i;j<=9;j++){
		if(i*j==N){
			cout << "Yes";
			return 0;
		}
	}
}
cout << "No";










	return 0;

}



Measured memory_bytes: 256
n,m=gets.split.map(&:to_i)
b,d,p =[],[],[]
n.times do |i|
  b[i], d[i], p[i] = gets.chomp.split.map(&:to_i)
end  
ans=0
[-1,1].each do |bx|
  [-1,1].each do |dx|
    [-1,1].each do |px|
      result = n.times.map{|i|bx*b[i]+dx*d[i]+px*p[i]}.sort.reverse[0, m].inject(0, :+)
      ans = result if ans < result
    end
  end
end  
puts ans
 
## 他の方のコードを参考にしました。

Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10,mod=1e9+7;
int n,x,y,mn1,mn2,c[N],w[N],f[N],cnt[N],mn[N],fac[N],ifac[N];
vector<int>v[N];
int pw(int a,int b){int r=1;for(;b;b>>=1,a=1ll*a*a%mod)if(b&1)r=1ll*r*a%mod;return r;}
int fnd(int x){return f[x]==x?x:f[x]=fnd(f[x]);}
void uni(int u,int v){u=fnd(u);v=fnd(v);f[v]=u;}
int main()
{
	scanf("%d%d%d",&n,&x,&y);
	for(int i=fac[0]=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n]=pw(fac[n],mod-2);
	for(int i=n;i>=1;i--)ifac[i-1]=1ll*ifac[i]*i%mod;
	w[0]=1<<30;
	for(int i=1;i<=n;i++)scanf("%d%d",&c[i],&w[i]);
	for(int i=1;i<=n;i++)if(w[i]<w[mn[c[i]]])mn[c[i]]=i;
	for(int i=1;i<=n;i++)if(mn[i]){if(w[mn[i]]<w[mn1])mn2=mn1,mn1=mn[i];else if(w[mn[i]]<w[mn2])mn2=mn[i];}
	for(int i=1;i<=n;i++)f[i]=i;
	for(int i=1;i<=n;i++)
	{
		if(w[mn[c[i]]]+w[i]<=x)uni(mn[c[i]],i);
		if(mn1&&c[mn1]!=c[i]&&w[mn1]+w[i]<=y)uni(mn1,i);
		if(mn2&&c[mn2]!=c[i]&&w[mn2]+w[i]<=y)uni(mn2,i);
	}
	int ans=1;
	for(int i=1;i<=n;i++)v[fnd(i)].push_back(c[i]);
	for(int i=1;i<=n;i++)if(f[i]==i)
	{
		int sz=v[i].size();ans=1ll*ans*fac[sz]%mod;
		for(int j=0;j<sz;j++)cnt[v[i][j]]++;
		for(int j=0;j<sz;j++)if(cnt[v[i][j]])ans=1ll*ans*ifac[cnt[v[i][j]]]%mod,cnt[v[i][j]]=0;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 16256
exchange_cnt = 0

def insertion_sort(w_list, g):
    """一般化した Insertion ソート

    通常の Insertion ソートは gap が 1 固定だが、ここでは、
    gap を引数 g で指定できる。

    当然、g < len(w_list) でないといけない。
    """
    global exchange_cnt
    N = len(w_list)
    for i in range(g, N):
        v = w_list[i]
        j = i - g
        while j >= 0 and w_list[j] > v:
            w_list[j+g] = w_list[j]
            j -= g
            exchange_cnt += 1
        w_list[j+g] = v


def make_gap_sequence(n):
    """gap sequence を作成

    とりあえず、Wiki にのっていたやり方のひとつを採用。
    N ^ 1.5 のオーダーになるという。
    """
    seq = []
    k = 1
    while True:
        gap = 2 ** k - 1
        if gap > n:
            break
        seq.append(gap)
        k += 1
    seq.reverse()   # in place なので効率が良い。
    return seq

def make_gap_sequence_2(n):
    """もうひとつの gap sequence の作成方法

    Wiki にのっていた Shell によるオリジナルの方法。
    これだと最悪の場合、N ^ 2 のオーダーになってしまうようだ。
    """
    seq = []
    k = 1
    while True:
        gap = n // (2 ** k)
        if gap <= 1:
            break
        seq.append(gap)
        k += 1
    seq.append(1)
    return seq



def shell_sort(w_list):
    N = len(w_list)

    # N から gap sequence を決める。
    # どう決めるかで効率が変わってくるのだが、どう決めるかは難問。
    # gap_sequence = make_gap_sequence(N)
    gap_sequence = make_gap_sequence_2(N)

    for g in gap_sequence:
        insertion_sort(w_list, g)
    
    return gap_sequence


n = int(input())
w_list = []
for _ in range(n):
    w_list.append(int(input()))

gap_seq = shell_sort(w_list)

print(len(gap_seq))
print(*gap_seq)
print(exchange_cnt)
for i in w_list:
    print(i)



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

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

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

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

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

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

    int a;
    cin >> a;
    string S;
    cin >> S;

    if (a >= 3200){
        print(S);
    } else {
        print("red");
    }

    return 0;
}


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

typedef unsigned long long LL;

int main() {
    int Q;
    LL A, B, C;
    double c;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        cin >> A >> B;
        if (A == B) {
            cout << 2 * A - 2 << endl;
        }
        else {
            c = sqrt(A * B);
            C = LL(c);
            if (C * (C + 1) < A * B){
                cout << 2 * C - 1 << endl;
            }
            else if (C == c) cout << 2 * C - 3 << endl;
            else cout << 2 * C - 2 << endl;
        }
    }
    return 0;
}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	ll a,b;
	cin>>a>>b;
	ll g=__gcd(a,b);
	cout<<a/g*b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  //aは+1
  //bは0
  //cは-1
  if(k<=a)
    cout<<k<<endl;
  else if(a<k&&k<=a+b)
    cout<<a<<endl;
  else
    cout<<2*a-k+b;

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long int
#define ff first
#define ss second
#define u128 __int128
#define pb push_back
 
#define N 200010
#define MOD 1000000007


int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	int ans = 0;
	for(int i = 0; i < n; ++i)
	{
		int sum = 0;
		while(i + 1 < n && a[i + 1] <= a[i])
			sum++, i++;
		ans = max(sum, ans);
	}
	cout << ans;
 	return 0;
}

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

using namespace std;

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

    int tmp = max(H, W);
    for(int i = 0; i <= min(H, W); ++i){
        if(tmp * i >= N){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

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

string list[32];
int res=0;
int sa[1000];

int main(){
	int n,max,k,min;
	int r[200000];
	cin >> n;
	for(int i=0;i<n;i++) cin >> r[i];
	max=r[1]-r[0];
	min=r[0];
		for(int j=1;j<n;j++){
			k=r[j]-min;
			if(min>r[j]) min=r[j];
			if(max<k) max=k;
		}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 1944
#include "bits/stdc++.h"

#include <unordered_map>

//#include <iostream>//POJ
//#include <vector>
//#include <string>
//#include <iomanip>
//#include <math.h>
//#include <algorithm>
//#include <cstring>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define dd(n) cout<<fixed<<setprecision(n)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define repir(i,a,b) for(int i=(a)-1, i##_first=(b); i>=i##_first; --i)
#define repr(i,n) repir(i,n,0)
#define repir_(i,a,b) for(int i=(a), i##_first=(b); i>=i##_first; --i)
#define repr_(i,n) repir_(i,n,0)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
//template<typename T> T vpop(vector<T> *v) {
//	T res = v->back();
//	v->pop_back();
//	return res;
//}
//char vpop(string *v) {
//	char res = v->back();
//	v->pop_back();
//	return res;
//}
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define pi 3.14159265358979
#define co(x) cout<<x<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

//#define lint long long
typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<lint> lvec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

const int
dx8[8] ={ 0,1,1,1,0,-1,-1,-1 },
dy8[8] ={ 1,1,0,-1,-1,-1,0,1 },
dx4[4] ={ 0,1,0,-1 },
dy4[4] ={ 1,0,-1,0 };

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

int main(){
	setc;

	lint a,b;cin>>a>>b;
	if(a==b)co("Draw");
	else{
		if(a==1)a+=13;
		if(b==1)b+=13;
		if(a<b)co("Bob");
		else co("Alice");
	}
	gc();
}

Measured memory_bytes: 256
a = input()
l = []

for i in range(a):
	l.append(input())

l.sort()
i = 0
# l = l[::-1]
s = sum(l)
while s % 10 == 0 and i < len(l):
	if l[i] % 10 != 0:
		s -= l[i]
	i += 1

if s % 10 == 0:
	s = 0
print s

Measured memory_bytes: 2568
INF = 1000000000

h, w = map(int, input().split())
S = [list(input()) for i in range(h)]

dx = (1, 0, -1, 0)
dy = (0, 1, 0, -1)

dist = [[INF for i in range(w)] for j in range(h)]

dist[0][0] = 1

que = [[0, 0]]

while len(que) > 0:
    p = que.pop(0)

    if p == [h-1, w-1]:
        break

    for x, y in zip(dx, dy):
        nx = p[0] + x
        ny = p[1] + y

        if 0 <= nx < h and 0 <= ny < w and S[nx][ny] == '.' and dist[nx][ny] == INF:
            que.append([nx, ny])
            dist[nx][ny] = dist[p[0]][p[1]] + 1

if dist[h-1][w-1] == INF:
    print(-1)
else:
    ans = 0
    for s in S:
        ans += s.count('.')
    ans -= dist[h-1][w-1]
    print(ans)


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

int main() {
  string S;
  cin >> S;

  int l = (S[0] - '0') * 10 + (S[1] - '0');
  int r = (S[2] - '0') * 10 + (S[3] - '0');

  if ((l > 12 || l == 0) && (r < 13 && r > 0))
    puts("YYMM");
  else if ((l < 13 && l > 0) && (r > 12 || r == 0))
    puts("MMYY");
  else if ((l < 13 && l > 0) && (r < 13 && r > 0))
    puts("AMBIGUOUS");
  else
    puts("NA");
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

/**
 * ZAKIREN第5章
 *
 * @author K.Yamauchi
 *
 */
public class Main {

	/** 入力用 */
	private static Scanner scan = new Scanner(System.in);

	/** 出力用 */
	private static StringBuilder stringBuilder = new StringBuilder();

	/**
	 * メイン。
	 * @param args
	 */
	public static void main(String[] args) {

		// １行目の読み込み
		String[] firstLine = scan.nextLine().split(" ");
		int size = Integer.parseInt(firstLine[0]);

		// 2行目以降（プロセスとクオンタム）の読み込み
		String[] processes = new String[size];
		for (int i = 0; i < size; i++) {
			processes[i] = scan.nextLine();
		}

		// 読み込み終了
		scan.close();
		scan = null;

		// 計算を実行
		calculation(size, Integer.parseInt(firstLine[1]), processes);

		// 結果出力
		System.out.print(stringBuilder.toString());

	}

	/**
	 *
	 * @param size
	 * @param quantum
	 * @param processes
	 */
	private static void calculation(int size, int quantum, String[] processes) {

		// 計算用キュー
		Queue<String> queue = new ArrayDeque<>();

		// キューにプロセスを設定
		for (int i = 0; i < size; i++) {
			queue.add(processes[i]);
		}

		// 経過時間
		int elapsedTime = 0;

		// キューの中身がなくなるまで計算
		while (!queue.isEmpty()) {
			// キューからプロセスを一つ取得
			String[] process = queue.poll().split(" ");
			// 取得したプロセスの残り時間
			int remainedTime = Integer.parseInt(process[1]);

			if (remainedTime <= quantum) {
				// プロセスの残り時間がクオンタム以下であれば、そのプロセスは終了
				stringBuilder.append(process[0] + " " + (elapsedTime + remainedTime) + "\n");
				elapsedTime -= (quantum - remainedTime);
			} else {
				// プロセスの残り時間がクオンタムより大きければ、クオンタム分残り時間を減らし、再度キューに登録
				remainedTime -= quantum;
				queue.add(process[0] + " " + remainedTime);
			}
			elapsedTime += quantum;
		}

	}

}



Measured memory_bytes: 113048
N, K = map(int, input().split())
A = list(map(int, input().split()))

l = 1
r = max(A)
while l != r:
    mid = (r + l) // 2
    count = 0
    for log in A:
        count += (log - 1) // mid
    if count <= K:
        r = mid
    else:
        l = mid + 1

print(r)


Measured memory_bytes: 30848