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

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

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll A, ll P) {
  auto ans = (A*3 + P)/2;
  cout << ans << endl;
}

int main() {
  ll A;
  cin >> A;
  ll P;
  cin >> P;
  solve(A, P);
  return 0;
}


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

using ll = long long;

#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

void solve(ll K, string S) {
  ll N = S.size();
  combination c(N + K);

  mint ans = 0;
  rep(i, K + 1) {
    mint now = mint(26).pow(K - i);
    now *= mint(25).pow(i);
    now *= c(i + N - 1, N - 1);
    ans += now;
  }
  cout << ans << endl;
}

int main() {
  ll K;
  scanf("%lld", &K);
  std::string S;
  std::cin >> S;
  solve(K, S);
  return 0;
}


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

int N;

int main(){
	while(cin >> N && N>0){
		vector<int> v(N,0);
		for(int i=0;i<N;i++){
			cin >> v[i];
		}
		sort(v.begin(),v.end());
		int ans = 0;
		int now = v[0];
		int count = 1;
		for(int i=1;i<v.size();i++){
			if(v[i] == now) count++;
			else if(count>=now){
				ans += count - now;
				count = 1;
				now = v[i];

			}
			else if(count < now){
				ans += count;
				count = 1;
				now = v[i];
			}
		}
		if(v[v.size()-1] == now){
			if(count>=now){
				ans += count - now;
			}else{
				ans += count;
			}
		}
		cout << ans << endl;	
	}
}

Measured memory_bytes: 640
#include<cstdio>
using namespace std;
int a,b,k,i;
int main()
{
	scanf("%d%d%d",&k,&a,&b);
	for(i= a; i<=b; i++){
		if(i % k ==0) {
			printf("OK");
			break;
		}
	}
	if(i > b) printf("NG");
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  for (int i = 0; i < (int)(3); ++i) for (int j = 0; j < (int)(3); ++j) cin >> A[i][j];
  int N;
  cin >> N;
  for (int i = 0; i < (int)(N); ++i) {
    int b;
    cin >> b;
    for (int i = 0; i < (int)(3); ++i) for (int j = 0; j < (int)(3); ++j) if (A[i][j] == b) A[i][j] = -1;
  }

  for (int i = 0; i < (int)(3); ++i) {
    int r = 0, c = 0;
    for (int j = 0; j < (int)(3); ++j) {
      r += A[i][j];
      c += A[j][i];
    }
    if (r == -3 || c == -3) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  int a = 0, b = 0;
  for (int i = 0; i < (int)(3); ++i) {
    a += A[i][i];
    b += A[2 - i][i];
  }
  if (a == -3 || b == -3) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
  return 0;
}


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


int abs(int a){
  if(a>=0) return a;
  else return -a;
}

int min(int a, int b){
  if(a>=b) return b;
  else return a;
}

int main(){
  int N;
  scanf("%d",&N);
  int h[N+1];
  for(int i=1;i<=N;i++) scanf("%d",&h[i]);

  int DP[N+1];
  DP[1]=0;
  DP[2]=abs(h[1]-h[2]);
  for(int i=3;i<=N;i++){
    DP[i]=min(DP[i-1]+abs(h[i]-h[i-1]),DP[i-2]+abs(h[i]-h[i-2]));
  }

  printf("%d\n",DP[N]);
  return 0;
}

Measured memory_bytes: 896
/*
 * @Author: Luisvacson
 * @LastEditors: Luisvacson
 * @Descriptions: None
 * @Date: 2020-09-19 20:02:07
 * @LastEditTime: 2020-09-19 20:21:22
 * @FilePath: \VSC\C++\Practice\AC abc179 B.cpp
 */
#include <bits/stdc++.h>
using namespace std;

int n;
int a[105];
signed main()
{
    scanf("%d", &n);
    register int i;

    for (i = 1; i <= n; ++i) {
        int x, y;
        scanf("%d%d", &x, &y);
        a[i] = x - y;
    }
    /*
5
1 1
2 2
3 4
5 5
6 6
*/
    int t = 0;
    for (i = 1; i <= n; ++i) { //0,0,-1,0,0
        if (a[i] == 0)
            ++t;
        else if (t < 3 && a[i])
            t = 0;
    }
    puts(t >= 3 ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3760
#include<stdio.h>
#ifdef DEBUG
#include<conio.h>
#endif // DEBUG

int max_com_divisor(int a, int b) {
    while(a * b) {
        if(a > b) a %= b;
        else if(a < b) b %= a; 
        else return a;       
    }
    return a > b ? a : b;
}

int main () {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif // DEBUG

    int a, b;
    scanf("%d %d", &a, &b);

    printf("%d\n", max_com_divisor(a, b));

#ifdef DEBUG
    getch();
#endif // DEBUG
    return 0;
}




Measured memory_bytes: 2120
n = gets.to_s.to_i
a = gets.to_s.split.map{|t|t.to_i}.sort

h = Hash.new(0)
a.each do |k|
  h[k] += 1
end
# p h
v = h.values

l = 0
r = h.size - 1
d = 0
ans = v.reduce(0){|s,t|s+t}

(h.size).times do |i|
  
  if v[i] > 2 && v[i].even?
    t =  v[i] - 2
    v[i] -= t
    d += t/2
  elsif v[i] > 2 && v[i].odd?
    t =  v[i] - 1
    v[i] -= t
    d += t/2
  end
end

d += (v.count(2)+1) / 2

puts ans - d * 2

# puts ans

Measured memory_bytes: 16128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskA
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int T = 1;
            while (T-- > 0)
            {
                solveOne(in, out);
            }
        }

        private void solveOne(Scanner in, PrintWriter out)
        {
            int n = in.nextInt();
            if (n == 1)
                out.println(0);
            else
                out.println(1);
        }

    }
}



Measured memory_bytes: 27128
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> 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; }

map<ll, ll> prime_factor(ll n){
	map<ll, ll> res;
	for(ll i = 2; i*i <= n; i++){
		while(n%i == 0){
			res[i]++;
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    map<ll, ll> pf = prime_factor(n);
    priority_queue<pair<ll, ll>> pq;
    for(auto p : pf){
        pq.push(make_pair(-p.first, p.first));
    }
    ll ans = 0;
    while(!pq.empty()){
        ll q = -pq.top().first, mul = pq.top().second;
        pq.pop();
        if(n%q == 0){
            n /= q;
            ++ans;
            pq.push(make_pair(-q * mul, mul));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <iostream>
#include <string>

int main()
{

    int x, y, z;

    scanf("%d", &x);
    scanf("%d", &y);
    scanf("%d", &z);

    int people;

    people = (x - z) / (y + z);

    std::cout << people << "\n";

    return 0;
}

Measured memory_bytes: 256
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif


void solve()
{
	int n ,m , ans = 0;
	cin >> n >> m ;
	vector<int> s[m] ; 
	rep(i,m){
		int k ;
		cin >> k ;
		rep(j,k){
			int x ;
			cin >> x ;
			x-- ;
			s[i].pb(x) ;
		}
	}
	vector<int> p(m) ;
	rep(i,m) cin >> p[i] ;
	rep(i,(1<<n)){
		// cout << i << endl ;
		int f = 1; 
		for(int j = 0 ; j < m ; ++j){
			int cnt = 0 ;
		    vector<int> tmp ;
			for(auto it : s[j]){
				// if(i == 3)
				// 	cout << j << " " << it << " " << ((1<<it)&i) << "\n"; 
				cnt += (((1<<it)&i) != 0) ;
			}
			// if(i == 3)
			// cout << cnt << "W" << p[j] << endl ;
			if(cnt%2 != p[j]){
				f= 0 ;
				break ;
			}
		}
		ans += f ;
	}
	cout << ans ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    static final long Mod = 1000000000+7;
    static long[] fact;
    static long[] inv;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        final int maxN = 200000+10;
        int H = sc.nextInt();
        int W = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        fact = new long[maxN+1];
        fact[0]=1;
        for(int i=1;i<=maxN;i++) fact[i]=(fact[i-1]*i)%Mod;
        inv = new long[maxN+1];
        inv[0]=1;
        inv[maxN]=pow(fact[maxN],Mod-2)%Mod;
        for(int i=maxN-1;i>=1;i--){
            inv[i]=((i+1)*inv[i+1])%Mod;
        }
        long ans=0;
        for(int i=b+1;i<=W;i++){
            ans = (ans+com(H-a+i-2,i-1)*com(a+W-i-1,a-1)%Mod)%Mod;
        }
        System.out.println(ans);
    }
    static long pow(long base, long p){
        long ans = 1;
        while(p>0){
            if((p&1)>0) ans = ans*base%Mod;
            base=base*base%Mod;
            p=p/2;

        }
        return ans;
    }
    static long com(int m, int n){
        return fact[m]*inv[n]%Mod*inv[m-n]%Mod;
    }
}


Measured memory_bytes: 27988
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
 
const ll mod = 1e9 + 7;
 
vector<string> g;
 
int main() {
    
    ll n, k;
    cin >> n >> k;
    
    ll ret = 0;
    for (ll i = k; i <= n + 1; ++i)
    {
        ll min = ((i - 1) * i) / 2ll;
        ll max = ((2ll * n + 1 - i) * i) / 2ll;
        ret += (max - min + 1ll) % mod;
        ret %= mod;
    }
    
    
    cout << ret << endl;
 
    
    return 0;
}

Measured memory_bytes: 3196
s = input()[::-1]
counts = [0] * 2019
counts[0] = 1
num, d = 0, 1
result = 0

for i in s:
    num += int(i) * d
    num %= 2019
    d *= 10
    d %= 2019
    counts[num] += 1
    
for cnt in counts:
    result += cnt*(cnt-1)//2
    
print(result)
    

Measured memory_bytes: 9284
#include<iostream>
using namespace std;
int main() {
    int r, c;
    int t[100][100] = {};
    int sumR, sumC[100] = {};
    
    cin >> r >> c;

    for (int i = 0; i < r + 1; i++) {
        for (int j = 0; j < c; j++) {
            if (i < r) {
                int n;
                cin >> n;
                cout << n << " ";
                sumR += n;
                sumC[j] += n;
            } else {
                cout << sumC[j] << " ";
                sumR += sumC[j];
            }
        }
        cout << sumR << endl;
        sumR = 0;
    }

    return 0;
}


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

int main(void){
  string s;
  int a=0,b=0,c=0;
  cin>>s;
  for(int i=0;i<3;i++){
    if(s[i]=='a')a=1;
    else if(s[i]=='b')b=1;
    else c=1;
  }
  cout<<(a==1&&b==1&&c==1?"Yes":"No");
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

int main() {

	int64_t N, K,i;
	cin >> N >> K;
	i = 1;
	while (1) {
		if (N >= pow(K, i)) {
			i++;
			continue;
		}
		else {
			break;
		}


	}

	cout << i;
	return 0;
}

Measured memory_bytes: 256
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))

# ===CODE===
tMOD = 998244353


def main():
    n = ni()
    a = na()

    tmp = []
    state = 0
    ans = 0
    for i in range(n):
        if len(tmp) < 1:
            hoge=0
        else:
            current_state = a[i]-tmp[-1]
            if current_state == 0:
                hoge=0
            elif state == 0:
                if current_state > 0:
                    state = 1
                else:
                    state = -1
            elif state * current_state < 0:
                tmp.clear()
                ans += 1
                state=0
        tmp.append(a[i])

    print(ans+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 16132
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n;
    cin>>n;
    ll sum=0;
    for(ll i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0) sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}


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


int main() {
  int n ;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.rbegin(),l.rend());
  int sum = 0;
  for(int i = 1; i < n;++i) sum += l[i];
  if(l[0] < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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



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

    for (int A = -200; A < 200; ++A) {
        for (int B = -200; B < A; ++ B) {
            if (pow(A, 5) - pow(B, 5) == X) {
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }

}

Measured memory_bytes: 4068
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int H,W;
char A[100][100];
int cnt[26];

int main(){
    cin>>H>>W;
    rep(i,H) rep(j,W){
        cin>>A[i][j];
        cnt[A[i][j]-'a']++;
    }

    bool res=true;
    if(H%2==0 && W%2==0){
        rep(i,26){
            if(cnt[i]%4!=0){
                res=false;
                break;
            }
        }
    }else if(H%2==1 && W%2==1){
        int c1=0, c2=0;
        rep(i,26){
            if(cnt[i]&1){
                c1++;
                cnt[i]--;
            }
            if(cnt[i]%2==0 && cnt[i]%4!=0) c2++;
        }
        if(!(c1==1 && c2<=H/2+W/2)){
            res=false;
        }
    }else{
        int odd=H&1?H:W;
        int even=H+W-odd;
        int c1=0, c2=0;
        rep(i,26){
            if(cnt[i]&1){
                c1++;
                cnt[i]--;
            }
            if(cnt[i]%2==0 && cnt[i]%4!=0) c2++;
        }
        if(!(c1==0 && c2<=even/2)){
            res=false;
        }
    }
    if(res){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define dbg(S) { int f=1; for(auto x:S) cerr<<(f?"[":", ")<<x, f=0; cerr<<"]\n"; }

using namespace std;

int main(){
	int n; cin>>n;
	int ans=0;
	for(int i=1;2*i<n;i++) ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define nn 190
char _map[nn][nn];
int n,m;int cnt[nn][nn][2];

int ask(int x1,int y1,int x2,int y2,int t)
{
	x1--,y1--;
	return cnt[x2][y2][t]+cnt[x1][y1][t]-cnt[x1][y2][t]-cnt[x2][y1][t];
}
int ask(int x1,int y1,int x2,int y2)
{
	if(x1<1 or y1<1 or x2>n or y2>m) return 0;
	return !ask(x1,y1,x2,y2,0) or !ask(x1,y1,x2,y2,1); 
}

int to[2][nn][nn][nn][2];//where, 1=|

void chkmax(int &x,int y)
{
	x=max(x,y);
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%s",_map[i]+1);
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
		if(_map[i][j]=='#') cnt[i][j][1]=1;
		else cnt[i][j][0]=1;
	
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
		for(int k=0;k<2;k++) cnt[i][j][k]+=cnt[i-1][j][k]+cnt[i][j-1][k]-cnt[i-1][j-1][k];
	
	int now=0;
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
	{
		int lst=m;
		for(int k=1;i+k-1<=n;k++)
		{
			while(lst>0 and !ask(i,j,i+k-1,j+lst-1)) lst--;
			to[now][i][j][k][1]=lst;
		}
		
		lst=n;
		for(int k=1;j+k-1<=m;k++)
		{
			while(lst>0 and !ask(i,j,i+lst-1,j+k-1)) lst--;
			to[now][i][j][k][0]=lst;
		}
	}
	int ans=0;
	if(to[now][1][1][n][1]>=m or to[now][1][1][m][0]>=n);else  
	while(ans<10000)
	{
		for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
		{
			for(int k=1;i+k-1<=n;k++)
			{
				int x=to[now][i][j][k][1]+j;int len=to[now][i][x][k][1]+x-1-j+1;
				chkmax(len,to[now][i][j][k][1]);
				chkmax(to[now^1][i][j][k][1],len);
				if(len>0 and len<=m) chkmax(to[now^1][i][j][len][0],k);
			}
			
			for(int k=1;j+k-1<=m;k++)
			{
				int x=to[now][i][j][k][0]+i;int len=to[now][x][j][k][0]+x-1-i+1;
				chkmax(len,to[now][i][j][k][0]);
				chkmax(to[now^1][i][j][k][0],len);
				if(len>0 and len<=n) chkmax(to[now^1][i][j][len][1],k);
			}
		
		}
		
		
		now^=1;
		int tmp=2;
		while(tmp--)
		{
			
			for(int k=n;k>=1;k--)
			for(int i=1;i+k-1<=n;i++) for(int j=1;j<=m;j++)
			{
				chkmax(to[now][i][j][k][1],to[now][i][j][k+1][1]);
		//		chkmax(to[now][i][j][k][1],to[now][i-1][j][k+1][1]),
		//		chkmax(to[now][i][j][k][1],to[now][i][j-1][k+1][1]);
				
				int len=to[now][i][j][k][1];
				chkmax(to[now][i][j][len][0],k);
			}
				
			
			for(int k=m;k>=1;k--)
			for(int i=1;i<=n;i++) for(int j=1;j+k-1<=m;j++)
			{
				chkmax(to[now][i][j][k][0],to[now][i][j][k+1][0]);
		//		chkmax(to[now][i][j][k][0],to[now][i-1][j][k+1][0]),
		//		chkmax(to[now][i][j][k][0],to[now][i][j-1][k+1][0]);
				
				int len=to[now][i][j][k][0];
				chkmax(to[now][i][j][len][1],k);
			}
			
		}	
		
		ans++;
		if(to[now][1][1][n][1]>=m or to[now][1][1][m][0]>=n) break;
		
	}
	printf("%d\n",ans);
	
	return 0;
} 


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

using namespace std;

char sd[10000];
int sn,we,wes,sns,n;
int main()
{
	sn=0; we=0; wes=0; sns=0;
	scanf("%s",sd+1);
	n=strlen(sd+1);
	for(int i=1;i<=n;i++)
	{
		if(sd[i]=='E')
		{
			if(wes) continue;
			if(we==-1) we=0,wes=1;
			if(we==0) we=1;
		}
		if(sd[i]=='W')
		{
			if(wes) continue;
			if(we==1) we=0,wes=1;
			else we=-1;
		}
		if(sd[i]=='N')
		{
			if(sns) continue;
			if(sn==1) sn=0,sns=1;
			else sn=-1;
		}
		if(sd[i]=='S')
		{
			if(sns) continue;
			if(sn==-1) sn=0,sns=1;
			else sn=1;
		}
	}
	if(sn||we) printf("No\n");
	else printf("Yes");
	return 0;
}

Measured memory_bytes: 256
def solve():
    n = read()
    result = think(n)
    write(result)


def read():
    return read_int(1)[0]


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n):
    p = 10 ** 9 + 7
    return mod_fact(n, p)

def mod_fact(n, p):
    if n == 1:
        return 1 % p

    result = 1 % p
    for i in range(n):
        r_1 = result % p
        r_2 = (i + 1) % p
        result = (r_1 * r_2) % p
    return result

def write(result):
   print(result)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
I=input()
N=int(I.split()[0])
L=int(I.split()[1])
x=1
A=[]
R=0

for i in range(N):
    A.append(x+L-1)
    R+=x+L-1
    x+=1
    
B=[]
for w in A:
    B.append(abs(w))

print(R-A[B.index(min(B))])

Measured memory_bytes: 3064
from itertools import combinations_with_replacement

N = int(input())
K = int(input())


def times_two(n):
    return 2 * n


def plus_k(n):
    return n + K


ans = []
for funcs in combinations_with_replacement((times_two, plus_k), N):
    value = 1
    for func in funcs:
        value = func(value)
    ans.append(value)
print(min(ans))


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
#include <fstream>
using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
const double pi = 3.14159265359;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    SORT(a);
    double ans = (double)a[0];
    for (int i = 1; i < N; ++i) {
        ans += (double)a[i];
        ans /= 2.0;
    }
    cout << ans << endl;
}

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

int main(){
  int n;
  int f[100005] = {};
  int *mode = f;
  int data[100005];

  mode++;
  
  cin >> n;
  for ( int i = 0; i < n; i++) {
    cin >> data[i];
  }
  
  for ( int i = 0; i < n; i++) {
    mode[data[i]]++;
    mode[data[i] + 1]++;
    mode[data[i] - 1]++;
  }

  int ans = 0;
  for ( int i = -1; i < 100000; i++) {
    if ( mode[i] > ans ) {
      ans = mode[i];
    }
  }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    rep(i,ty - sy){
        cout << "U";
    }
    rep(i,tx - sx){
        cout << "R";
    }
    rep(i,ty - sy){
        cout << "D";
    }
    rep(i,tx - sx){
        cout << "L";
    }
    cout << "L";
    rep(i,ty - sy + 1){
        cout << "U";
    }
    rep(i,tx - sx + 1){
        cout << "R";
    }
    cout << "D";
    cout << "R";
    rep(i, ty - sy + 1){
        cout << "D";
    }
    rep(i, tx - sx + 1){
        cout << "L";
    }
    cout << "U" << endl;
}


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


void solve(long long X, long long Y, long long A, long long B, long long C, std::vector<long long> p, std::vector<long long> q, std::vector<long long> r){
    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    //sort(r.begin(), r.end(), greater<ll>());
    priority_queue<ll, vector<ll>, greater<ll>> que;
    for(int i = 0;i < X;i++)que.push(p[i]);
    for(int j = 0;j < Y;j++)que.push(q[j]);
    for(auto a : r){
        if(a > que.top()){
            que.pop();
            que.push(a);
        }
    }
    ll ans = 0;
    while(!que.empty()){
        ans += que.top();
        que.pop();
    }
    cout<<ans<<endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> p(A);
    for(int i = 0 ; i < A ; i++){
        scanf("%lld",&p[i]);
    }
    std::vector<long long> q(B);
    for(int i = 0 ; i < B ; i++){
        scanf("%lld",&q[i]);
    }
    std::vector<long long> r(C);
    for(int i = 0 ; i < C ; i++){
        scanf("%lld",&r[i]);
    }
    solve(X, Y, A, B, C, std::move(p), std::move(q), std::move(r));
    return 0;
}


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

lli cache[100005];
lli getmin(vector<int> &h,int i,int n)
{
    if(i==n-1)
    {
        return 0;
    }

    if(cache[i]!=-1)
    {
        return cache[i];
    }

    lli r1=INT_MAX,r2=INT_MAX;
    if((i+1)<=(n-1))
    {
        r1 = abs(h[i]-h[i+1])+getmin(h,i+1,n);
    }

    if((i+2)<=(n-1))
    {
        r2 = abs(h[i]-h[i+2])+getmin(h,i+2,n);
    }

    cache[i] = min(r1,r2);

    return cache[i];
}

void solve()
{
    int n;
    cin>>n;
    vector<int> h(n);
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
        cache[i]=-1;
    }
    cache[n]=-1;

    lli res = getmin(h,0,n);
    cout<<res<<endl;
}

int main()
{
 solve();
}


Measured memory_bytes: 9216
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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)*}
    };
}

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)*}
    };
}

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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        xy: [[(usize1, i32)]; n],
    }
    
    let mut ma = 0;
    for bits in 0..1i32 << n {
        let mut ok = true;
        for i in 0..n {
            if (bits & 1 << i) == 0 { continue; }
            for &(p, k) in &xy[i] {
                if (bits >> p & 1) != k {
                    ok = false;
                }
            }
        }
        if ok {
            ma = max(ma, bits.count_ones());
        }
    }
    puts!("{}\n", ma);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int main()
{
    int n;
    cin>>n;
    int arr[n][3];
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<3;j++)
        {
            cin>>arr[i][j];
        }
    }
    int DP[n][3];
    for (int i=0;i<3;i++)
    {
        DP[n-1][i]=arr[n-1][i];
    }
    for (int i=n-2;i>=0;i--)
    {
        for (int j=0;j<3;j++)
        {
            //int col = max(0,j-1%3);
            DP[i][j]= max(DP[i+1][(j+2)%3]+arr[i][j],DP[i+1][(j+1)%3]+arr[i][j]);
        }
    }
   
    int res=0;
    for (int i=0;i<3;i++)
    {
        res = max(DP[0][i],res);
    }
    cout<<res;
    return 0;
}


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


int main(){

    int a, b, c, d; cin >> a >> b >> c >> d;

    
    if(abs(a - c) <= d) cout << "Yes" << endl;
    else{

        if(abs(a - b) <= d && abs(b - c) <= d) cout << "Yes" << endl;
        else cout << "No" << endl;

    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int W,H,N;
  cin >> W >> H >> N;
  int w1=0,w2=W,h1=0,h2=H;
  int x,y,a;
  while(cin >> x >> y >> a){
    if (a==1){w1=max(w1,x);}
    if (a==2){w2=min(w2,x);}
    if (a==3){h1=max(h1,y);}
    if (a==4){h2=min(h2,y);}
  }
  if(w1>=w2 || h1>=h2){cout << 0 << endl;}
  else{cout << (w2-w1)*(h2-h1) << endl;}
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <tuple>
using namespace std;
typedef long long i64;
const int MAXN = 200000 + 10;

typedef tuple<int, int, int> person;

int x, y, z, N;
person p[MAXN];
i64 sumx[MAXN], sumy[MAXN];

int main()
{
	cin >> x >> y >> z;
	N = x + y + z;
	for (int i = 1; i <= N; i++)
		cin >> get<0>(p[i]) >> get<1>(p[i]) >> get<2>(p[i]);
	sort(p + 1, p + N + 1, [](const person & a, const person & b) -> bool
	{	return ((get<0>(a) - get<1>(a)) > (get<0>(b) - get<1>(b)));});

	i64 sum = 0;
	priority_queue<int> PQ;

	for(int i = 1; i <= N; i++)
	{
		PQ.push(get<2>(p[i]) - get<0>(p[i]));
		sum += get<2>(p[i]) - get<0>(p[i]);

		if(PQ.size() > x)
			sum -= PQ.top(), PQ.pop();
		sumx[i] = sum;

	}

	sum = 0;
	while(!PQ.empty())
		PQ.pop();
	for(int i = N; i > 0; i--)
	{
		PQ.push(get<2>(p[i]) - get<1>(p[i]));
		sum += get<2>(p[i]) - get<1>(p[i]);
		if(PQ.size() > y)
			sum -= PQ.top(), PQ.pop();
		sumy[i] = sum;
	}

	i64 answer = -0x7F7F7F7F7F7F7F7FLL;
	for(int i = x; i <= N - y; i++)
		answer = max(answer, -(sumx[i] + sumy[i+1]));
	for(int i = 1; i <= N; i++)
		answer += get<2>(p[i]);
	cout << answer << endl;
}


Measured memory_bytes: 4216
import java.util.Scanner;

public class Main {

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

		int ab=sc.nextInt();
		int bc=sc.nextInt();
		int ca=sc.nextInt();

		if(ab*ab+bc*bc==ca*ca) {
			ans=ab*bc/2;
		}

		System.out.println(ans);
	}
	

}


Measured memory_bytes: 20948
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define all(a) a.begin(),a.end()
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//sort 降順
//reverse 逆順
 
int main() {
  ll a,b;
  ci(a>>b);
  string s;
  ci(s);
  vec c(b),d(b);
  vec e(a);
  
  ll f=0;
  for(i,1,a){
    if(s[i-1]=='A'&&s[i]=='C')
      e[i]+=e[i-1]+1;
    
    else
      e[i]=e[i-1];
  }
  
  for(i,0,b){
    ll l,r;
    ci(l>>r);
    co(e[r-1]-e[l-1]);
  }
}


Measured memory_bytes: 3456
m, d = list(map(int, input().split()))
count = 0
for i in range(1,m+1):
    for j in range(1,d+1):
        if j >= 10 and j % 10 >= 2 and j//10 >= 2 and (j % 10) * (j//10) == i:
            count += 1


print(count)

Measured memory_bytes: 3316
#include<stdio.h>
#include<string.h>
int main(){
    char s[4];
    int i,ans=0;
    scanf("%s",s);
    for(i=0; i<4; i++){
        if(s[i]=='+'){
            ans=ans+1;
        }
        else if(s[i]=='-'){
            ans=ans-1;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
n = int(input())
t = sorted([int(input()) for _ in range(n)],reverse = True)
def c_mul(x,y):
  d = x
  e = y
  while y%x != 0:
    z = y%x
    y = x
    x = z
  else:
    return d*e//x
for i in range(1,n):
  a = c_mul(t[0],t[i])
  if a != t[0]:
    t[0] = a
print(t[0])

Measured memory_bytes: 3064
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include<stack>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) for(auto r:v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define pc() pop_back()
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
#define ll long long
#define endl '\n'
#define st stack<int>
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
#define ss second
#define ff first> 
#define vpii vector<pii>
#define vvi vector<vi>
#define vs vector<string>
#define mii map<int,int>

int power(int a, int b) {
    int res = 1;
    while (b != 0) {
        if (b & 1) {
            res *= a;
        }
        a = (a * a);
        b = (b / 2);
    }
    return res;
}
template<typename T, typename U> inline void amin(T& x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T& x, U y) {
    if (x < y) x = y;
}
bool comp(int n) {
    vi v(4);
    int i = 0;
    while (n) {
        v[i] = n % 10;
        n /= 10;
        i++;


    }
    set<int> s(all(v));
    if (s.size() != 4) return false;
    else return true;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    vi v(n);
    rep(i, n) cin >> v[i];
    vi dp(n, 0);
    dp[1]=abs(v[1] - v[0]);
    reu(i, 2, n) {
        dp[i] = min(dp[i-2]+abs(v[i] - v[i - 2]), dp[i - 1] + abs(v[i] - v[i - 1]));

    }
    cout << dp[n - 1];



}

Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
	int S, h, m, s;
	scanf("%d",&S);
	
	h = S/3600;
	S = S%3600;
	m = S/60;
	s = S%60;
	
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}


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

stat = []
for i in range(n - 1):
  c, s, f = map(int, input().split())
  stat.append([c, s, f])

ans = []
for i in range(n - 1):
  temp = stat[i][1]
  for j in range(i, n - 1):
    c, s, f = map(int, stat[j])
    temp = max(s, temp)
    while temp % f != 0:
      temp += 1
    temp += c
  ans.append(temp)

for i in ans:
  print(i)
print(0)


Measured memory_bytes: 3188
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [input() for _ in range(n)]

n = int(input())
t,a = map(int, input().split())
h = list(map(int, input().split()))

ans = []


for i in range(n):
    tmp = t-h[i]*0.006
    ans.append([i+1,abs(a-tmp)])

ans.sort(key=lambda x:x[1])
print(ans[0][0])








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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

  ll N;
  cin >> N;
  
  string s;
  while( N ) N--, s.push_back('a'+N%26), N/=26;
  
  reverse(s.begin(),s.end());
  cout << s << endl;

  return 0;
}



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

using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  if(s[k-1]=='A'){
    s[k-1]='a';
  }
  else if(s[k-1]=='B'){
    s[k-1]='b';
  }
  else{
    s[k-1]='c';
  }
  cout << s << endl;
  
}


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

const int MOD = 1000000007;
struct modint {
  long long val;
  modint(long long val=0) : val((val % MOD + MOD) % MOD){}
  modint operator-() const { return modint(-val); }
  modint& operator+=(const modint a) { if ((val += a.val)     >= MOD) val -= MOD; return *this; }
  modint& operator-=(const modint a) { if ((val += MOD-a.val) >= MOD) val -= MOD; return *this; }
  modint& operator*=(const modint a) { (val *= a.val) %= MOD; return *this; }
  modint operator+(const modint a) const { return (modint)*this += a; }
  modint operator-(const modint a) const { return (modint)*this -= a; }
  modint operator*(const modint a) const { return (modint)*this *= a; }
  modint pow(long long n) const { modint r(1), m(val); while (n > 0) { if (n & 1) {r *= m;} m *= m; n >>= 1; } return r; }
  modint inv() const { return pow(MOD-2); }
  modint& operator/=(const modint a) { return (*this) *= a.inv(); }
  modint operator/(const modint a) const { return (modint)*this /= a; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  friend ostream &operator<<(ostream &os, const modint &p) { return os << p.val; }
  friend istream &operator>>(istream &is, modint &a) { long long t; is >> t; a = modint(t); return (is); }
};

int N;
long long A[200000], B[200000];

signed main() {
  cin >> N;
  for(int i=0; i<N; i++) cin >> A[i] >> B[i];

  int zero = 0;
  map<pair<long long, long long>, pair<int,int>> mp;
  for(int i=0; i<N; i++) {
    long long a = A[i], b = B[i];
    if(a==0 && b==0) {zero++; continue;}
    long long g = gcd(a,b);
    a /= g;
    b /= g;
    if(a < 0) { a=-a; b=-b; }
    if(a == 0 && b<0) { b=-b; }
    if(b > 0) mp[make_pair(a,b)].first++;
    else      mp[make_pair(-b,a)].second++;
  }

  modint ans = 1;
  for(auto i : mp) {
    ans *= (modint(2).pow(i.second.first) - 1) + (modint(2).pow(i.second.second) - 1) + 1;
  }
  ans += zero;
  ans -= 1;

  cout << ans << endl;
}


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

using namespace std;

struct Dice
{
  // int x, y;
  int l, r, f, b, d, u;

  void RollN()
  {
    //  --y;
    int buff = d;
    d = f;
    f = u;
    u = b;
    b = buff;
  }

  void RollS()
  {
    // ++y;
    int buff = d;
    d = b;
    b = u;
    u = f;
    f = buff;
  }

  void RollL() // ----->
  {
    int buff = f;
    f = l;
    l = b;
    b = r;
    r = buff;
  }

  void RollR() // <------
  {
    int buff = f;
    f = r;
    r = b;
    b = l;
    l = buff;
  }

  void RollE() // .o -> o.
  {
    // --x;
    int buff = d;
    d = l;
    l = u;
    u = r;
    r = buff;
  }


  void RollW() // o. -> .o
  {
    //  ++x;
    int buff = d;
    d = r;
    r = u;
    u = l;
    l = buff;
  }


  vector< Dice > makeDice()
  {
    vector< Dice > ret;
    for(int i = 0; i < 6; i++) {
      Dice d(*this);
      if(i == 1) d.RollN();
      if(i == 2) d.RollS();
      if(i == 3) d.RollS(), d.RollS();
      if(i == 4) d.RollL();
      if(i == 5) d.RollR();
      for(int j = 0; j < 4; j++) {
        ret.emplace_back(d);
        d.RollE();
      }
    }
    return (ret);
  }
};

int latte[3][3], malta[3][3];
set< int > st;
Dice dice[3][3][3];
vector< Dice > beet;

void dfs(int idx)
{
  if(idx == 27) {
    int ret = 0;
    for(int i = 0; i < 3; i++) {
      for(int j = 0; j < 3; j++) {
        ret += dice[i][2][j].r;
      }
    }
    st.emplace(ret);
    return;
  }
  int i = idx / 3 % 3, j = idx % 3, k = idx / 9;
  for(auto &s : beet) {
    if(k == 0 && latte[i][j] && latte[i][j] != s.u) continue;
    if(i == 2 && malta[k][j] && malta[k][j] != s.f) continue;
    if(i && dice[i - 1][j][k].b + s.f != 7) continue;
    if(j && dice[i][j - 1][k].l + s.r != 7) continue;
    if(k && dice[i][j][k - 1].d + s.u != 7) continue;
    dice[i][j][k] = s;
    dfs(idx + 1);
  }
}

int main()
{
  beet = ((Dice) {4, 3, 2, 5, 6, 1}).makeDice();

  int T;
  cin >> T;
  while(T--) {
    for(int i = 0; i < 3; i++) {
      for(int j = 0; j < 3; j++) {
        cin >> latte[i][j];
      }
    }
    for(int i = 0; i < 3; i++) {
      for(int j = 0; j < 3; j++) {
        cin >> malta[i][j];
      }
    }
    dfs(0);
    bool first = false;
    if(st.empty()) {
      cout << 0 << endl;
    } else {
      for(auto &s : st) {
        if(first++) cout << " ";
        cout << s;
      }
      cout << endl;
      st.clear();
    }
  }
}

Measured memory_bytes: 3016
#include <stdio.h>
#include <math.h>
int main(void){
    int i;
    int d;
    int sum;
    do{
        d=-1;
        scanf("%d",&d);
        if(d==-1)break;
        
        sum=0;
        for(i=1;i<(600/d);i++){
            sum=sum+(int)pow(d*i,2)*d;
        }
        printf("%d\n",sum);
        
    }while(d!=-1);
    
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
const int N=110;
int n,b[N];
int ans;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for (int i=1;i<n;++i) cin>>b[i];
	ans+=b[n-1];
	for (int i=n-1;i>1;--i) ans+=min(b[i],b[i-1]);
	ans+=b[1];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
if len(str(N)) == 1:
  print(N)
elif len(str(N)) == 2:
  print(9)
elif len(str(N)) == 3:
  N = N - 90
  print(N)
elif len(str(N)) == 4:
  print(909)
elif len(str(N)) == 5:
  N = N - 9090
  print(N)
else:
  print(90909)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys


def solve(S: str):
    print(S.count("+")-S.count("-"))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>

int main(void){

    char S[4];
    scanf("%s",&S);
    if((S[0]==S[1] && S[2]==S[3] && S[0]!=S[2])||(S[0]==S[2] && S[1]==S[3] && S[0]!=S[1])||(S[0]==S[3] && S[1]==S[2] && S[0]!=S[1])){
        printf("Yes\n");
    } 
    else printf("No\n");

    return 0;

}

Measured memory_bytes: 128