akhauriyash/Code-Regression huggingface dataset:
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

rest=[]
minussum=0
minuscnt=0
for i in range(N):
  diff=A[i]-B[i]
  if diff<0:
    minussum+=diff*(-1)
    minuscnt+=1
  elif diff==0:
    continue
  else:
    rest.append(diff)

rest=sorted(rest)[::-1]
if minussum>sum(rest):
  print(-1)
  exit(0)
if minuscnt==0:
  print(0)
  exit(0)

ind=0
while minussum>0:
  if minussum>rest[ind]:
    minussum-=rest[ind]
    ind+=1
  else:
    break
print(minuscnt+ind+1)

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

int main(){
	int r, d, x2000;
	cin >> r >> d >> x2000;
	for (int i = 0; i < 10; ++i){
		x2000 = r*x2000 - d;
		cout << x2000 << endl;
	}
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  s[5] = ' ';
  s[13] = ' ';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    long long l,a,b,n,ans,i;
    cin>>l;
    a=l*l*l;
    b=3*3*3;
	n=12;
	ans=a/b;
    cout<<ans<<".";
	a%=b; 
	for(i=1;i<=n;i++)
	{
	ans=(a*10)/b;
    cout<<ans;
    a=(a*10)%b;
	}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n;
	
	cin>>n;
	
	vector<int> used(n);
	int x = 0;
	int ans = -1;
	for(int i=1;;++i){
		x = (x*10+7)%n;
		if(used[x]) break;
		used[x] = 1;
		if(!x){
			ans = i;
			break;
		}
	}
	
	cout<<ans<<endl;
	
	
	
	return 0;
}


Measured memory_bytes: 7112
import sys
input = sys.stdin.readline

n = int(input())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
def f(n):
  dp = list(range(n+1))
  for a, b in zip(A, B):
    if b <= a:
      continue
    for i in range(n+1):
      if i-a >= 0:
        dp[i] = max(dp[i], dp[i-a]+b)
  return max(dp)
m = f(n)
A, B = B, A
ans = f(m)
print(ans)

Measured memory_bytes: 260252
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{n:usize, m:usize, p:[(i64,i64); m]};
    let mut map = HashMap::new();
    for i in 0..m {
        {
            let mut count = map.entry(p[i].0).or_insert(0);
            *count += 1;
        }
        {
            let mut count = map.entry(p[i].1).or_insert(0);
            *count += 1;
        }
    }
    for i in 1..n+1 {
        println!("{}", match map.get(&(i as i64)) {
            Some(v) => *v,
            None => 0,
        });
    }
}


Measured memory_bytes: 4352
def solve(n, S):
    for i in range(4):
        ans = list()
        t = i
        for j, s in enumerate(S):
            f0 = t // 2
            f1 = t % 2
            f2 = f0 ^ (0 if s == 'o' else 1)
            ans.append('S' if f2 == 0 else 'W')
            t = ((f1 ^ f2) << 1) | f2

        if (i == t) :
            x = ans[:-1]
            x.insert(0, ans[-1])
            return "".join(x)
    return "-1"

if __name__ == '__main__':
    print(solve(int(input()), input()))


Measured memory_bytes: 4836
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int sum,n;
  
  cin>>sum>>n;
  
  int a[n];
  
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    
    sum-=a[i];
  }
  
  if(sum>=0)
    cout<<sum;
  else
    cout<<"-1";
  
  return 0;
}

Measured memory_bytes: 3624
use std::io;

fn main() {
  let mut line = String::new();
  io::stdin().read_line(&mut line).expect("");
  let v: Vec<i32> = line.split(' ').map(|s| s.trim().parse().unwrap()).collect();
  let a = v[0] + v[1];
  if a % 2 == 0 {
    print!("{}\n", a / 2);
  } else {
    print!("IMPOSSIBLE\n");
  }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, x, y) for (ll i = x; i < y; i++)

int main()
{
  int a, b, c;
  cin >> a >> b;

  for (int i = 1;; i++)
  {
    c = 1 + (a - 1) * i;
    if ((b - 1) % (a - 1) == 0)
    {
      cout << (b - 1) / (a - 1) << endl;
      break;
    }
    else if (c > b)
    {
      cout << i << endl;
      break;
    }
  }

  return 0;
}

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

using namespace std;

int main() {

	vector<string> strings;
	int n, l;
	cin >> n >> l;

	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		strings.push_back(s);
	}

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

	string output = "";

	for (int i = 0; i < n; i++) {
		output += strings[i];
	}

	cout << output;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <bitset>
#include <fstream>
#include <iomanip>

#define ll long long
#define scani(x) scanf("%i", &x)
#define scanll(x) scanf("%I64d", &x)
#define scanfl(x) scanf("%f", &x)
#define scanch(x) scanf("%c", &x)
#define scans(x) scanf("%s", x);
#define printi(x) printf("%i", x);
#define printll(x) printf("%I64d", x);
#define printfl(x) printf("%f", x);
#define printch(x) printf("%c", x);
#define prints(x) printf("%s", x);
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define INFI (1 << 29)
#define INFL (1LL << 62)
#define sz(x) int(x.size())
#define fi first
#define se second
#define forn(i, n) for(ll i = 0; i < n; i++)
#define for1(i, n) for(ll i = 1; i <= n; i++)
#define ford(i, n) for(ll i = (n - 1); i >= 0; i--)
#define fori(i, n) for(ll i = n; i >= 1; i--)
#define fore(i, l, r) for(ll i = l; i <= r; i++)
#define get_bit(mask, x) (bool)(mask & (1LL << x))
#define set_bit(mask, x) (mask |= (1LL << x))
#define reset_bit(mask, x) (mask &= ~(1LL << x))
#define toggle_bit(mask, x) (mask ^= (1LL << x))

using namespace std;

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

    ll r = 1, ul = (-1);
    string s, t;
    vector < set < ll > > v(26);
    vector < ll > f(26);

    cin >> s >> t;

    forn(i, sz(s))
        v[s[i] - 'a'].insert(i);

    forn(i, sz(t))
        f[t[i] - 'a']++;

    forn(i, 26)
    {
        if(f[i] && !sz(v[i]))
        {
            cout << "-1\n";

            return 0;
        }
    }

    forn(i, sz(t))
    {
        auto it = v[t[i] - 'a'].upper_bound(ul);

        if(it == v[t[i] - 'a'].end())
        {
            auto it2 = v[t[i] - 'a'].begin();

            r += ((sz(s) - ul) + (*it2));

            ul = (*it2);
        }
        else
        {
            r += ((*it) - ul);

            ul = (*it);
        }
    }

    cout << (r - 1) << "\n";

    return 0;
}


Measured memory_bytes: 5200
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;
using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}

void solve()
{
	string s;
	
	cin >> s;
	
	cout << s[0] << s.size()-2 << s[s.size()-1];
}

signed main() {
    fast;
    
    int t = 1;
    
	//cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


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



int main() {
    int d;
    cin >> d;
    
    vector<int> c(26);
    rep(i,26) {
        cin >> c[i];
    }
    
    vector<vector<int>> s(d, vector<int>(26));
    rep(i,d) {
        rep(j,26) {
            cin >> s[i][j];
        }
    }
    
    vector<int> t(d);
    rep(i,d) {
        cin >> t[i];
    }
    
    vector<int> last(26);
    
    // 計算する
    int v = 0;
    rep(i,d) {
        v += s[i][t[i]-1];
        //cout << v << endl;
        
        last[t[i]-1] = i+1;
        rep(j,26) {
            v -= c[j] * (i+1 - last[j]);
        }
        
        cout << v << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3680
#include <stdio.h>
int main(void){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a==b && b==c && c==a && a%2==0 && b%2==0 && c%2==0){
        printf("-1\n");
        return 0;
    }
    int ans=0;
    while(a%2==0 && b%2==0 && c%2==0){
        int _a=a, _b=b, _c=c;
        a=_b/2+_c/2;
        b=_a/2+_c/2;
        c=_a/2+_b/2;
        ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1728
A, B, C, X, Y = map(int, input().split())
minimum = max(A, B, C) * 3 * (X + Y)
for c in range(2 * max(X, Y)+1):
    a = max(0, int(X - c/2 + 1/2))
    b = max(0, int(Y - c/2 + 1/2))
    minimum = min(minimum, a * A + b * B + c * C)
print(minimum)

Measured memory_bytes: 3064
N = input()

Nketa = len(N)

if Nketa % 2 == 0:
    total = 0
    for i in range(1, Nketa, 2):
        idai = int('9' + '0'*(i-1))
        total += idai
    
elif Nketa % 2 == 1:
    total = 0
    for i in range(1, Nketa, 2):
        idai = int('9' + '0'*(i-1))
        total += idai
    
    Nstart = int('1' + '0'*(Nketa-1))
    total += int(N) - Nstart + 1

print(total)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
typedef pair<int,int> P;
#define mp make_pair
#define f first
#define s second
int main(){
while(1){
int n,m,p,q,r;
queue<P>que;
scanf("%d",&n);
if(!n) break;
scanf("%d",&m);
scanf("%d %d %d",&p,&q,&r);
que.push(mp(1,r));
for(int i=0;i<m;i++){
	int x,y;
	scanf("%d %d",&x,&y);
	int e=que.size();
	for(int j=0;j<e;j++){
		P pp=que.front(); que.pop();
		int a=pp.f,b=pp.s;
		if(b<=x){
			que.push(mp(n-x+a,n-x+b));
		}else if(b>x && b<=y){
			if(a<=x){
				que.push(mp(n-x+a,n));
				que.push(mp(n-y+1,n+b-x-y));
			}else{
				que.push(mp(n-y+a-x,n+b-x-y));
			}
		}else{
			if(a<=x){
				que.push(mp(1,b-y));
				que.push(mp(n-x+a,n));
				que.push(mp(n-y+1,n-x));
			}else if(a>x && a<=y){
				que.push(mp(1,b-y));
				que.push(mp(n-y-x+a,n-x));
			}else{
				que.push(mp(a-y,b-y));
			}
		}
	}
}
int ans=0;
while(que.size()){
P pp=que.front(); que.pop();
if(pp.s<p || pp.f>q){
}else{
ans+=min(q,pp.s)-max(p,pp.f)+1;
}
}
printf("%d\n",ans);
ans=0;
}
return 0;
}

Measured memory_bytes: 1092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<long long, long long> P;
typedef long long ll;
int main(){
    int m;
    cin >> m;
    ll s = 0;
    vector<P> v(m);
    ll ans = 0;
    ll keta = 0;
    rep(i,m){
        cin >> v[i].first >> v[i].second;
        keta+=v[i].first*v[i].second;
        s+=v[i].second;
    }
    cout << (keta-1)/9 + s-1<<endl;
    return 0;
}

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

vector<int> input(int N){
    int i;
    vector<int> output(N);
    for(i=0;i<N;i++)cin>>output[i];
    return output;
}

int main(){
    int N,i,result,x_min,x_max;
    vector<int> X;

    cin>>N;
    X=input(N);
    x_min=*min_element(X.begin(),X.end());
    x_max=*max_element(X.begin(),X.end());
    
    result=(x_max-x_min)/2+(x_max-x_min)%2;

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


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s;
    cin >> s;
    int ans = 0;
    int now = 0;
    rep(i, s.size()) {
        if (s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T') now++;
        else {
            ans = max(ans, now);
            now = 0;
        }
    }
    ans = max(ans, now);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
using namespace std;
typedef long long unsigned int llui_t;
typedef long long int lli_t;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

/* inputs */
struct data{
    lli_t t;
    lli_t x;
    lli_t y;
};
llui_t N;
vector<data> X;

int main() {
    cin >> N;

    data d = {0, 0, 0};
    X.push_back(d);
	for(llui_t i=0; i<N; i++) {
		cin >> d.t >> d.x >> d.y;
		X.push_back(d);
	}

    sort(X.begin(), X.end(), [](data d1, data d2){return d1.t < d2.t;});

    bool ans = true;
    for(llui_t i=0; i<X.size()-1; i++) {
        lli_t a = (X[i+1].t - X[i].t) - (abs(X[i].x - X[i+1].x) + abs(X[i].y - X[i+1].y));
        if( a < 0 || a % 2 == 1 ) {
            ans = false;
            break;
        }
    }

	cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 4724
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoderbeginner161
{
    class Program
    {
        static void Main(string[] args)
        {
            var input1 = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            var X = input1[0];
            var Y = input1[1];
            var Z = input1[2];
            Console.WriteLine($"{Z} {X} {Y}");
        }
    }
}


Measured memory_bytes: 13268
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
var lines = input.split('\n');

var line;
while (line = lines.shift()) {
    var arr = line.split(' ').map(function(n){return +n;});
    var year = arr[0];
    var month = arr[1];
    var day = arr[2];
    var era = '';

    var today = new Date(year, month - 1, day);
    if (today < new Date(1868, 8, 8)) {
        era = 'pre-meiji';
    } else if (today < new Date(1912, 6, 30)) {
        era = 'meiji';
        year -= 1867;
    } else if (today < new Date(1926, 11, 25)) {
        era = 'taisho';
        year -= 1911;
    } else if (today < new Date(1989, 0, 8)) {
        era = 'showa';
        year -= 1925;
    } else {
        era = 'heisei';
        year -= 1988;
    }

    if (era == 'pre-meiji') {
        console.log('pre-meiji');
        continue;
    }
    console.log(era, year, month, day);
}

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

using namespace std;

typedef long long ll;
#define int long long
const int maxn = 1e6+10;
inline int read()
{
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) w|=ch=='-',ch=getchar();
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}

int n,m,q;
int da[maxn];

signed main()
{
  int n = read();
  int ans = 0;
	for(int i = 1;i<=n;i++){
    	ans += (n-1)/i;
    }
  cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    set<int> s;
    int d;
    rep(i, 0, N)
    {
        cin >> d;
        s.insert(d);
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 256
package main

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

var n = int(1e5)
var k int
var runs = make([]int, 0, 2*n)

func main() {
	k = readInt()

	for i := 1; i < 10; i++ {
		runs = append(runs, i)
	}

	start := 0
	for len(runs) < k {
		preRuns := runs[start:]
		for i := range preRuns {
			pre := preRuns[i] % 10
			for j := max(0, pre-1); j <= min(9, pre+1); j++ {
				runs = append(runs, preRuns[i]*10+j)
			}
		}
		start += len(preRuns)
	}

	sort.Ints(runs)
	fmt.Println(runs[k-1])
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 3444
import math
a, b, h, m = map(int, input().split())
ang = abs(2 * h / 12  +  2 * m / 12 / 60  - 2 * m / 60) * math.pi
distsq = a ** 2 + b ** 2 - 2 * a * b * math.cos(ang)
dist = math.sqrt(distsq)
print(dist)

Measured memory_bytes: 9568
#include<stdio.h>
int main()
{
	int m, f, r, i, j;
	char s;

	while (1)
	{
		scanf("%d %d %d", &m, &f, &r);
		if ((m == -1) && (f == -1) && (r == -1))
			break;

		if ((m == -1) || (f == -1))
			s = 'F';
		else if (m + f >= 80)
			s = 'A';
		else if ((m + f >= 65) && (m + f < 80))
			s = 'B';
		else if ((m + f >= 50) && (m + f < 65))
			s = 'C';
		else if ((m + f >= 30) && (m + f < 50)){
			if (r >= 50)
				s = 'C';
			else if (r < 50)
				s = 'D';
		}
		else if (m + f < 30)
			s = 'F';

		printf("%c\n", s);
	}

	return(0);

}

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

using namespace std;

long long int ara[200100];

int main()
{
    vector<long long int>a;
    long long int n,x,mx=0;
    long long int res,tmp;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        mx=max(mx,x);
        a.push_back(x);
        ara[x]++;
    }
    res=0;
    for(int i=0;i<=mx;i++){
        res+=(ara[i]*(ara[i]-1))/2;
    }
    for(int i=0;i<n;i++){
        tmp=res-ara[a[i]]*(ara[a[i]]-1)/2+(ara[a[i]]-1)*(ara[a[i]]-2)/2;
        cout<<tmp<<endl;
    }
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    if (a[0] == a[1] && a[0] == 5 && a[2] == 7) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}


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

//-----------------------------------------------

//------------------------------------------------
int main(){
  int n,l,answer;
  cin>>n>>l;
  if(l+n-1>=0 &&l<=0) answer=n*l+((n*(n+1))/2)-n;
  if(l>0) answer=n*l+((n*(n+1))/2)-n-l;
  if(l+n-1<0) answer=n*l+((n*(n+1))/2)-n-l-n+1;



  cout<<answer<<endl;
}


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

int main() {
  stack<int> S1;
  stack<pair<int, int> > S2;
  char ch;
  int sum = 0;
  for (int i = 0; cin >> ch; i++) {
    if (ch == '\\') S1.push(i);
    else if (ch == '/' && S1.size() > 0) {
      int j = S1.top();
      S1.pop();
      sum += i - j;
      int a = i - j;
      while (S2.size() > 0 && S2.top().first > j) {
        a += S2.top().second;
        S2.pop();
      }
      S2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  while (S2.size() > 0) {
    ans.push_back(S2.top().second);
    S2.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for (int i = 0; i < ans.size(); i++) {
    cout << " ";
    cout << ans[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3148
if __name__ == '__main__':
    n = int(input())
    val = input()
    a = val.split()
    a = [int(s) for s in a]
    enter = True
    for i in a:
        if i % 2 == 0:
            if not (i % 3 == 0 or i % 5 == 0):
                enter = False
    if enter:
        print('APPROVED')
    else:
        print('DENIED')

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
bool isOk(const i32 &a, const i32 &b) {
    bool ret = 1;
    for (i32 i = 0; i <= 21; ++i) {
        if(( a>>i&1 ) + (b>>i&1) > 1) ret = 0;
    }
    return ret;
}

/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i32 n; cin >> n;
    vi a(n); rep(i,n) cin >> a[i];

    /*
     * 全てのbit桁について、立っているbitの数が0か1つ
     * というような区間が該当する。
     * 尺取りする
     */

    i32 cond = 0;
    i32 cnt = 0;
    for(i32 l = 0, r = 0; l < n; ++l) {
//        r = l;
        while(isOk(cond, a[r]) && r < n) {
            cond |= a[r];
            ++r;
//            debug(r);
        }
        cnt += r-l;

        if(r==l) ++r;
        else cond ^= (a[l]);
//        debug(cnt);
//        debug(l);debug(r);
//        cout << "--------" << '\n';
    }

    cout << cnt << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		int n,min=0,a,p=0;
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		for (int i=0;i<n;i++){
			a=sc.nextInt();
			if (i>=2){
				if (a-min>p){p=a-min;}
				if (a<min){min=a;}
			}else if (i==0){
				min=a;
			}else if (i==1){
				p=a-min;
				if (a<min){min=a;}
			}
		}
		System.out.println(p);
	}
}

Measured memory_bytes: 99740
n,m=map(int,input().split())
a=[]
for i in range(n):
  ai=list(input())
  a.append(ai)
b=[]
for i in range(m):
  bi=list(input())
  b.append(bi)

frag='No'
for i in range(n-m+1):
  for j in range(n-m+1):
    for k in range(m):
      if a[i+k][j:j+m]!=b[k]:
        break
    else:
      frag="Yes"
      break
  continue
print(frag)

Measured memory_bytes: 39024
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};




int main(){
    LL a,b;cin >> a >> b;
    cout << a * b / __gcd(a,b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int n,k,a[200000];
    int distant = 0;
    int distance;
    cin >> k >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    for(int i=0; i<n; i++){
        distance = min( abs(a[i]-a[(i+1)%n]), k-abs(a[i]-a[(i+1)%n]) );
        distant = max( distant, distance);
    }
    cout << k-distant;

}

Measured memory_bytes: 4360
n=int(input())
l=sorted([list(map(int,input().split())) for i in range(n)],key=lambda x:x[0]-x[1],reverse=1)
now=float("INF")
ans=0
for i in l:
    if sum(i)<=now:
        now=i[0]-i[1]
        ans+=1
print(ans)

Measured memory_bytes: 68056
#include<stdio.h>
int main(){
	int a,b,c = 0,d;
	scanf("%d",&a);
	while(a--){
		scanf("%d",&b);
		if(b < 2) continue;
		if(b == 2 || b == 3){ c++; continue;}
		else if(b % 2 == 0) continue;
		for(d = 3;d*d <= b; d+=2)
		if(b%d==0) break;
		if(b % d == 0) continue;
		c++;
	}
	printf("%d\n",c);

	return 0;
}



Measured memory_bytes: 2104
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl

void chmin(ll &a, ll b) {
  if (a > b) {
    a = b;
  }
}
void chmax(ll &a, ll b) {
  if (a < b) {
    a = b;
  }
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  if (n <= a) {
    cout << n << endl;
    return 0;
  }

  ll total = (a + b);
  ll setNum = n / total;
  ll remain = n % (a + b);
  cout << (setNum * a + min(a, remain)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
    ld n,k;cin >> n >> k;
    ld ans = 0.0000000;
    if(n>=k) {ans = (n-k+1)/n;}
    ld p = 1/n;
    for(int i = 1;i<=n;i++){
        int ii = i;int cnt = 0;
        ld pp = 0.500000;
        if(ii>=k) break;
        while(ii*2<k){
            ii *= 2;
            pp *= 0.50000;
            cnt++;
        }
        ans += p*pp;
    }
    cout << fixed <<setprecision(20);
    cout << ans;
}

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


Measured memory_bytes: 3756
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<long long int> vec;
int Count[5], K;
long long arr[5][1005];

int main()
{
    scanf("%d %d %d %d", &Count[0], &Count[1], &Count[2], &K);
    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < Count[i]; j++)
        {
            scanf("%lld", &arr[i][j]);
        }
    }
    for(int i = 0; i < 3; i++)
    {
        sort(arr[i], arr[i] + Count[i], greater<long long int>());
    }
    for(int i = 0; i < Count[0]; i++)
    {
        for(int j = 0; j < Count[1]; j++)
        {
            for(int k = 0; k < Count[2]; k++)
            {
                if((i + 1) * (j + 1) * (k + 1) > K)
                {
                    break;
                }
                vec.push_back(arr[0][i] + arr[1][j] + arr[2][k]);
            }
        }
    }
    sort(vec.begin(), vec.end(), greater<long long int>());
    for(int i = 0; i < K; i++)
    {
        printf("%lld\n", vec[i]);
    }
}

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

using namespace std;

#define int long long

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef unordered_map<int,int> mii;
typedef unordered_map<char,int> mci;
typedef unordered_map<string,int> msi;

#define pb push_back
#define f first
#define s second 
 

void solve() {
    int n,k,ans;
    cin>>n>>k;
    vi h(n);
    for(int i=0;i<n;i++) {
        cin>>h[i];
    }
    vi dp(n);
    dp[n-1] = 0;
    for(int i=n-2;i>=0;i--) {
        ans = INF;
        for(int j=i+1;j<=min(i+k,n-1);j++) {
            ans = min(ans,abs(h[i]-h[j])+dp[j]);
        }
        dp[i] = ans;
    }
    cout<<dp[0]<<endl;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //#ifdef ONLINEJUDGE
        // freopen("input.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
    //#endif

    int tc; tc=1;
    for (int t = 1; t <= tc; t++) {
        //cout << "Case #" << t  << ": ";
        solve();
    }
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cout.precision(12);
    cout << fixed;
    cin.tie(0);

    int n, k;
    cin >> n >> k;

    long long ans = 0;
    int x = n / k;
    ans += 1LL*x*x*x;
    if (k % 2 == 0) {
        int q = k / 2;
        int y = n / q - x;
        ans += 1LL*y*y*y;
    }
    cout << ans << endl;

    return 0;
}


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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    int a,b;
    cin>>a>>b;
    if(b%2==0)
    {
        if(2*a>b || 4*a<b)
            cout<<"No"<<nl;
        else cout<<"Yes"<<nl;
    }
    else cout<<"No"<<nl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
#define forn(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define FORR(i,a,b) for(int i = a; i >= b; i--)
#define MAXN 100001

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;

vi g[MAXN];
int vis[MAXN];
void dfs(int u){
    vis[u] = 1;
    for(int i = 0; i < g[u].size(); i++){
        int v = g[u][i];
        if(!vis[v])
            dfs(v);
    }
    vis[u] = 2;
}

void solve(){
    int n, m;
    cin >> n >> m;
    int u, v, w;
    for(int i = 0; i < m; i++){
        cin >> u >> v >> w;
        u--; v--;
        g[u].PB(v);
        g[v].PB(u);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(!vis[i]){
            ans++;
            dfs(i);
        }
    }
    cout << ans << endl;
}

int main(){
    //int t; cin >> t;
    //while(t--) solve();

    solve();
    return 0;
}


Measured memory_bytes: 10752
/*
verified on 2020/6/13
https://atcoder.jp/contests/agc045/submissions/14201952
*/

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

using ll = long long;

using namespace std;

/* snippet starts */

// xorの掃き出し法をするためのクラス
// matに基底たちが入る
// Tはbitsetは無理(minしないといけないから)
template <typename T>
class BitLinearSpace {
    vector<T> bases; // この中身をsortしちゃうと壊れる

public:
    BitLinearSpace() = default;
    BitLinearSpace(vector<T> &matrix) {
        for (auto &mi:matrix) {
            add_val(mi, false);
        }
    }

    // valが張れるように基底を追加する
    // 追加した場合true, しなかった場合false
    // O(N) (ソートするとNlogN)
    // 追加後にソートするかを選ぶ
    bool add_val(T val) {
        if ((val = elementary_opperation(val))) {
            bases.push_back(val);
            return true;
        } else {
            return false;
        }
    }

    // 今のベクトル空間にvalが含まれるか(=basesの要素のxorでvalが作れるかをチェック)
    // O(n)
    bool includes(T val) {
        return elementary_opperation(val) == 0;
    }

    // 行列にvalを追加するていで行基本変形をvalに施す
    // 実際には追加しない
    // O(n)
    T elementary_opperation(T val) {
        for (auto &b:bases) {
            val = min(val, val ^ b);
        }
        return val;
    }

    T &operator[](int i) { return bases[(size_t)i]; }
    const T &operator[](int i) const { return bases[(size_t)i]; }

    auto begin() { return bases.begin(); }
    auto end() { return bases.end(); }
    auto begin() const { return bases.begin(); }
    auto end() const { return bases.end(); }
};

/* snippet ends */

int main() {
    int T;
    cin >> T;
    while (T--) {
        int n; cin >> n;
        ll a[n]; for (auto &ai:a) cin >> ai;
        string s; cin >> s;
        bool ans = false;
        BitLinearSpace<ll> bls;
        for (int i=n-1; i>=0; i--) {
            if (s[(size_t)i] - '0') {
                if (!bls.includes(a[i])) {
                    ans = true;
                    break;
                }
            } else {
                bls.add_val(a[i]);
            }
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 3588
import math
A, B = map(int, input().split())

def fact(x):
	temp = x
	arr = [1]
	for i in range(2, int(math.sqrt(x))):
		if temp % i == 0:
			c = 0
			while temp % i == 0:
				c += 1
				temp //= i
			arr.append(i)
	if temp != 1:
		arr.append(temp)
	if arr == []:
		arr.append(n)
	return arr

a = fact(A)
b = fact(B)
ans = 0
for i in a:
	if i in b:
		ans += 1


print(ans)

Measured memory_bytes: 9100
#include<bits/stdc++.h>
#define ff first
#define ss second
#define IO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
#define pi acos(-1.00)
const int INF = 1e9 + 5;
vector<vector<int> > adj;
vector<int> dis;
vector<int> value;
int main() {
    IO;
    int n, m;
    cin >> n >> m;
    adj.resize(n + 1);
    dis.resize(n + 1, INF);
    value.resize(n + 1);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    queue<int> q;
    q.push(1);
    dis[1] = 0;
    while(!q.empty()){
        int now = q.front();
        q.pop();
        for(int x: adj[now]){
            int new_dis = dis[now] + 1;
            if(new_dis < dis[x]) {
                value[x] = now;
                dis[x] = new_dis;
                q.push(x);
            }
        }
    }
    for(int i = 2; i <= n; i++)
        if(value[i] == 0){
            cout << "No\n";
            return 0;
        }
    cout << "Yes\n";
    for(int i = 2; i <= n; i++)
        cout << value[i] << '\n';
    return 0;
}


Measured memory_bytes: 10668
import java.util.*;

public class Main{
	public static void main(String args[]){
        Scanner sc1 = new Scanner(System.in);
        int k = sc1.nextInt();
        int x = sc1.nextInt();
        for(int i = 0; i < k-1; i++){
            System.out.print(x-k+1+i + " ");
        }
        
        System.out.print(x + " ");

        for(int i = 0; i < k-1; i++){
            System.out.print(x+i+1 + " ");
        }
    }
}

Measured memory_bytes: 23892
/*input
3 3 2 2
*/
#include <bits/stdc++.h>
#define ll long long int
#define lld long double
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	ll a,b,c,d;cin>>a>>b>>c>>d;
	ll array[a+1][b+1]={0};
	ll x=0;
	for(ll i=c;i<=a;i+=c){
		for(ll j=d;j<=b;j+=d){
			x++;	
		}
	}
	ll temp;
	if(((a*b)-x-(x*((c*d)-1)))==0){
		temp=1;
	}
	else{
		temp=ceil(x/((a*b)-x-(x*((c*d)-1))));
		temp++;
	}
	ll temp2=(temp*((c*d)-1))+1;
	for(ll i=1;i<=a;i++)
		for(ll j=1;j<=b;j++)
			array[i][j]=temp;

	for(ll i=c;i<=a;i+=c){
		for(ll j=d;j<=b;j+=d){
			//x++;	
			array[i][j]=(-1)*temp2;
		}
	}
	ll sum=0;
	for(ll i=1;i<=a;i++)
		for(ll j=1;j<=b;j++)
			sum+=array[i][j];

	if(sum<0)
		cout<<"No\n";
	else{
		cout<<"Yes\n";
		for(ll i=1;i<=a;i++){
			for(ll j=1;j<=b;j++)
				cout<<array[i][j]<<" ";
			cout<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3328
import sys
input = sys.stdin.readline

"""
次数1のところにちょっかいを出すことを繰り返す。ダブルリーチが実現できたら勝ち。
"""

N = int(input())
AB = [tuple(int(x)-1 for x in row.split()) for row in sys.stdin.readlines()]

graph = [set() for _ in range(N)]
for a,b in AB:
    graph[a].add(b)
    graph[b].add(a)

deg = [len(x) for x in graph]
deg_1 = set(i for i,x in enumerate(deg) if x == 1)

bl = False
while deg_1:
    x = deg_1.pop()
    y = graph[x].pop()
    graph[y].remove(x)
    for z in graph[y]:
        if z == x:
            continue
        graph[z].remove(y)
        if deg[z] == 1:
            bl = True
            break
        deg[z] -= 1
        if deg[z] == 1:
            deg_1.add(z)
    if bl:break
    graph[y].clear()
    if y in deg_1:
        deg_1.remove(y)

answer = 'First' if bl else 'Second'
print(answer)

Measured memory_bytes: 46208
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls signed
#define give main()
const int mod = 1000000007;
#pragma endregion

const int N = 100005;

int k, arr[15][11], t, n, st;
bool flag = false;
string s;

pls give {
    AC;
    cin >> k;
    for (int i=0; i<10; i++) arr[0][i] = 1;
    if (k < 10) {
        cout << k << nl;
        return 0;
    }
    t = 9;
    for (int i=1; i<10; i++) {
        arr[i][0] = arr[i-1][0] + arr[i-1][1];
        for (int j=1; j<10; j++) {
            arr[i][j] = (arr[i-1][j-1] + arr[i-1][j] + arr[i-1][j+1]);
            t += arr[i][j];
            if (t >= k) {
                st = i;
                flag = true;
                n = k - (t-arr[i][j]);
                s += j+'0';
                break;
            }
        }
        if (flag) break;
    }
    t = 0;
    // cout << n << nl;
    for (int i=st-1; i>=0; i--) {
        // cout << n << nl;
        for (int j=max((s.back()-'0')-1, 0); j<=(s.back()-'0')+1; j++) {
            t += arr[i][j];
            if (t >= n) {
                n = n - (t-arr[i][j]);
                s += j+'0';
                t = 0;
                break;
            }
        }
    }
    cout << s << nl;
}

Measured memory_bytes: 256
#coding:utf-8
n = int(input())
restaurant = []

for i in range(n):
    city, point = input().split()
    point = int(point)
    restaurant.append([city, point, i+1])

#print(restaurant)
#町は昇順、点数は降順　片方だけ降順にするときはキーにマイナスをつける
rank = sorted(restaurant, key=lambda x:(x[0],-x[1]))
#print(rank)

for _, _, number in rank:
    print(number)


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#define LEN 100005
#define MAX 100000

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

void initialize(void);
int isEmpty(void);
int isFull(void);
void enqueue(P);
P dequeue(void);

P Q[LEN+1],A[LEN+1];
int head, tail, n;

void enqueue(P x){
  if(isFull() == 1) fprintf(stderr,"Error(overflow)\n");
  Q[tail] = x;
  if(tail + 1 == MAX) tail = 0;
  else tail++;
}


P dequeue(void){
  P x;
  if(isEmpty() == 1) fprintf(stderr,"Error(underflow)\n");
  x = Q[head];
  if(head + 1 == MAX) head = 0;
  else head++;
  return x;
}


int main(){
  int elaps = 0, c = 0;
  int i,j=1,q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  
  head = 1;
  tail = n+1;
  
  while(1){
    u = dequeue();
    elaps = u.t - q;  
    if(elaps > 0){
      c += q;
      u.t = elaps;
      enqueue(u);
    }
    else if(elaps <= 0){
      c += u.t;
      strcpy(A[j].name,u.name);
      A[j].t = c;
      j++;
    }
    if(isEmpty() == 1) break;
  }

  for ( i = 1; i <= n; i++){
    printf("%s ", A[i].name);
    printf("%d", A[i].t);
    printf("\n");
  }
  
  return 0;
}

void initialize(void){
  head = tail = 0;
}

int isEmpty(void){
  if(head == tail) return 1;
  else return 0;
}

int isFull(void){
  if(head == (tail + 1) % MAX) return 1;
  else return 0;
}

Measured memory_bytes: 18880
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int n,i,count=0,ans=0;
  int *h;
  scanf("%d",&n );
  h = calloc(n,sizeof(int));

  scanf("%d", &h[0]);

  for(i=1; i<n; i++){
    scanf("%d", &h[i]);
      if(h[i] > h[i-1])
      {
        if(ans < count)
          {ans = count;}
        count = 0;
        continue;
      }
      count++;
  }

  if(ans < count)
    ans = count;

  printf("%d", ans);

  free(h);
  return 0;
}


Measured memory_bytes: 1728
#ifndef AC_ABC_LIB_HPP
#define AC_ABC_LIB_HPP

#include <iostream>
#include <string>
#include <vector>

std::vector<std::string> sys_args(int argc, char **argv) {
    std::vector<std::string> args;

    for (int i = 1; i < argc; ++i)
        args.emplace_back(argv[i]);

    return args;
}

template<typename T>
void print(const T& vs) {
    std::cout << "[ ";

    for (auto&& v : vs)
        std::cout << v << " ";

    std::cout << "]" << std::endl;
}

std::vector<int> get_n_vector(void) {
    size_t n;
    std::cin >> n;

    std::vector<int> hs;
    hs.reserve(n);

    for (size_t i = 0; i < n; ++i) {
        int h;
        std::cin >> h;
        hs.emplace_back(h);
    }

    return hs;
}

std::string get_line(void) {
    std::string line;
    getline(std::cin, line);
    return line;
}

#endif  // AC_ABC_LIB_HPP
using namespace std;

int main(int argc, char **argv) {
    auto s = get_line();

    int count = 0;
    char last = s[0];
    for (size_t i = 1; i < s.size(); ++i) {
        if (s[i] == last) {
            s[i] = (s[i] == '0' ? '1' : '0');
            count++;
        }
        last = s[i];
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 512
package main

import "fmt"

func main(){
	var s string
	
	/*入力を受け取る*/
	fmt.Scan(&s)

	/*入力をstring→文字の配列*/
	sRune := []rune(s)
	size := len(s)

	/*空の文字列*/
	s2 := make([]string, size+1)	
	j := 0;

	for i:=0; i<size; i++{
		switch text := string(sRune[i]); text{
		case "1":
			s2[j]=string(sRune[i])
			j++

		case "0":
			s2[j]=string(sRune[i])
			j++

		case "B":
			if j>0{
				j--
			}

		default:

		}
	}

	for i:= 0; i < j; i++{
		fmt.Printf(s2[i])
	}
 
	fmt.Printf("\n")

}


Measured memory_bytes: 512
#define taskname ""

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

using namespace std;
#define long long long

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int n, dp[N][2];
vector<int> g[N];

void dfs(int u, int par)
{
    dp[u][0] = dp[u][1] = 1;
    for (int v : g[u]) if (v != par) {
        dfs(v, u);
        dp[u][0] = ((long) dp[u][0] * (dp[v][0] + dp[v][1])) % MOD;
        dp[u][1] = ((long) dp[u][1] * dp[v][0]) % MOD;
    }
}

int main()
{
//    freopen(taskname".INP", "r", stdin);
//    freopen(taskname".OUT", "w", stdout);
    cin.tie(nullptr); ios_base::sync_with_stdio(false);

    cin >> n;
    for (int i = 1, u, v; i < n; ++i) {
        cin >> u >> v;
        g[u].push_back(v), g[v].push_back(u);
    }
    dfs(1, 0);

    cout << (dp[1][0] + dp[1][1]) % MOD;

    return 0;
}


Measured memory_bytes: 13440