akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
const double pi=3.1415926535897932384626;

int main(){
    ll q,h,s,d;
    std::cin >> q>>h>>s>>d;
    ll n;
    std::cin >> n;
    ll ans=q*n*4;
    ans=min(h*n*2,ans);
    ans=min(s*n,ans);
    ll du=d*(n/2);
    if(n%2==1)du+=min({q*4,h*2,s});
    std::cout << min(ans,du) << std::endl;
}

Measured memory_bytes: 256
//https://arc096.contest.atcoder.jp/tasks/arc096_c
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, a) for (int i = 0; i < (a); ++i)
#define DEBUG(x) { cerr << #x << '=' << x << endl; }
#define Arr(a, l, r) { cerr << #a << " = {"; FOR(_, l, r) cerr << ' ' << a[_]; cerr << "}\n"; }
#define N 3030
#define pp pair<int, int>
#define endl '\n'
#define IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define taskname ""
#define bit(S, i) (((S) >> (i)) & 1)
using namespace std;

// f[n][k] : Divide n people into k group and someone can belong to no group.

int n;
long long MOD, f[N][N], c[N][N];

long long Pow(long long a, long long k, long long MOD) {
    if (k == 0) return 1;
    long long t = Pow(a, k >> 1, MOD);
    t = t * t % MOD;
    if (k % 2) t = t * a % MOD;
    return t;
}
long long POW[N], PPOW[N];
void Init() {
    cin >> n >> MOD;
    f[0][0] = c[0][0] = 1;
    FOR(nn, 1, n) {
        c[nn][0] = f[nn][0] = 1;
        FOR(k, 1, nn) {
            f[nn][k] = (f[nn - 1][k - 1] + f[nn - 1][k] * (k + 1)) % MOD;  
            c[nn][k] = (c[nn - 1][k] + c[nn - 1][k - 1]) % MOD;
        }
    } 
    POW[0] = 1;
    PPOW[0] = Pow(2ll, 1, MOD);
    FOR(i, 1, n) {
        POW[i] = POW[i - 1] * 2 % (MOD - 1);
        PPOW[i] = Pow(2ll, POW[i], MOD);
    }
}


// Way(i) = Sum(Way2(i, j)), j = 1..i
long long calWay2(int i, int j) {
    //Divide i first elements into j ramen and add ramen of (n - i) another elements to j groups or outside.
    long long res = f[i][j];
    //DEBUG(i);DEBUG(j);DEBUG(f[i][j]);
    res = res * Pow(2ll, 1ll * (n - i) * j, MOD) % MOD; 
    // (2 ^ (n - 1) -> number of ramen of j topping) ^ j -> into j groups
    return res;
}

// Number ways to topping 1..i used at most one, i + 1..n is arbitrary.    
long long calWay(int i) {
    long long res = 0;
    FOR(j, 0, i) res = (res + calWay2(i, j)) % MOD;
    res = res * PPOW[n - i] % MOD;
    // 2 ^ (2 ^ (n - 1)) -> Choose ramen of (n - i) topping outside
    // 2 ^ (p - 1) mod p = 1 mod p
    return res;
}

// -> Inclusion - exclusicion
void Solve() {
    long long hs = -1;
    long long res = 0;
    FOR(i, 0, n) {
        hs *= -1;
        res = (res + MOD + hs * c[n][i] * calWay(i) % MOD) % MOD;
    }
    cout << res << '\n';
}
int main() {
    #ifdef NERO
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
    double stime = clock();
    #else 
        //freopen(taskname".inp","r",stdin);
        //freopen(taskname".out","w",stdout);
    #endif //NERO
    IO;
    Init();
    Solve();
    #ifdef NERO
    double etime = clock();
    cerr << "Execution time: " << (etime - stime) / CLOCKS_PER_SEC * 1000 << " ms.\n";
    #endif // NERO
}

Measured memory_bytes: 141952
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //入力部分,最初のN（人数）を読み取る
            var N = int.Parse(Console.ReadLine());
            var input_data = new List<List<int[]>>();

            //人数分の証言を読み取る
            for(int i = 0; i < N; i++)
            {
                var num_evidence = int.Parse(Console.ReadLine());
                var tmp = new List<int[]>();
                //特定の人の証言の数だけ読み取る
                for(int j= 0; j < num_evidence; j++)
                {
                    var evidence = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    tmp.Add(evidence);
                }
                input_data.Add(tmp);
            }

            var max = 0;//正直者の最大値
            
            //仮定のパターンだけ繰り返す、1をNビットシフトさせた数。つまり2のN乗
            for (int i = 0; i < 1<<N ; i++)
            {
                var flag = true;//今回の仮定はすべてあってるかどうかを確認する
                for (int j = 0; j < N; j++)
                {
                    //仮定のパターンに対して１ビットずつ確認していく
                    if ((i >> j & 1) == 0) { continue; }//不誠実な人のパターンは無視
                    else
                    {
                        for(int k = 0; k < input_data[j].Count(); k++)
                        {
                            var num = input_data[j][k][0]-1;
                            if (((i >> num) & 1) != input_data[j][k][1])//パターンが一致しなかった
                            {
                                flag = false;
                            }
                            
                        }
                    }
                }
                if (flag)
                {
                    var c=0;//立っているビットの数、つまり正直者の数
                    for(int n = 0; n < N; n++)
                    {
                        if(((i >> n) & 1) == 1) { c++; }//１つずつずらして「1」が立っているビットの数を調べる
                    }
                    max = max > c ? max : c;
                }
                
            }
            Console.WriteLine(max);

        }
    }
}

Measured memory_bytes: 13524
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  for (int i = 0; i < m; i++) cin >> p[i] >> s[i];

  vector<bool> ac(n);
  vector<int> wa(n);
  for (int i = 0; i < m; i++) {
    if (s[i] == "AC") {
      ac[p[i]-1] = true;
    }
    else {
      if (!ac[p[i]-1]) wa[p[i]-1]++;
    }
  }

  int score = 0;
  int penalty = 0;
  for (int i = 0; i < n; i++) {
    if (ac[i]) {
      score++;
      penalty += wa[i];
    }
  }

  cout << score << " " << penalty << endl;

  return 0;
}


Measured memory_bytes: 6528
x=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())

print(x[k-1])

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

int main() {
  int N,L;
  cin >> N >> L;
  vector<string> S(N);
  for(int i=0;i<N;i++){cin >> S[i];}
  sort(S.begin(),S.end());
  string ans="";
  for(int i=0;i<N;i++){ans+=S[i];}
  cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
N, K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))

A_sort = sorted(A)
F_sort = sorted(F,reverse=True)
A_sort = np.array(A_sort)
F_sort = np.array(F_sort)
Asum = A_sort.sum()

l = -1
r = 0
for i in range(N):
    r = max(r,A_sort[i]*F_sort[i])

def judge(c):
    return Asum - np.minimum(A_sort,c//F_sort).sum() <= K

while r-l > 1:
    c = (l+r)//2
    if judge(c):
        r = c
    else:
        l = c
print(r)

Measured memory_bytes: 43636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    int n;
    cin >> n;
    int x[n];
    double opt = 0;
    rep(i, n) {
        cin >> x[i];
        opt += 1.0*x[i]/n;
    }
    int opt1 = floor(opt);
    int opt2 = ceil(opt);
    ll ans1 = 0;
    ll ans2 = 0;
    rep(i, n) {
        ans1 += pow(x[i]-opt1, 2);
        ans2 += pow(x[i]-opt2, 2);
    }   
    cout << min(ans1, ans2) << endl;
}

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

int main(void)
{
	char s[20];
	cin >> s;
	
	for(int i=0;i<20;i++){
		if(s[i] == ',') s[i] = ' ';
	}
	
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
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);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        int N;
        int M;
        boolean[] a;
        int mod = (int) (1e9 + 7);

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            N = in.nextInt();
            M = in.nextInt();
            a = new boolean[N + 1];
            Arrays.fill(a, true);
            for (int i = 0; i < M; i++) {
                a[in.nextInt()] = false;
            }

            int[] dp = new int[N + 1];
            dp[0] = 1;
            for (int i = 1; i <= N; i++) {
                if (a[i]) {
                    dp[i] = dp[i - 1];
                    if (i - 2 >= 0) {
                        dp[i] += dp[i - 2];
                    }
                    dp[i] %= mod;
                }
            }
            out.println(dp[N]);
        }

    }
}



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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(n % 2 == 0) {
        string t, t2;
        for(int i = 0; i < n/2; i++) {
            t.push_back(s[i]);
        }
        for(int i = n/2; i < n; i++) {
            t2.push_back(s[i]);
        }
        if(t == t2) cout << "Yes\n";
        else cout << "No\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
d,e=[list(map(int,input().split()))for _ in range(2)];e[3],e[4]=e[4],e[3]
t=0
m={0:'012345',1:'152304',2:'215043',3:'310542',4:'402351',5:'513240'}
for i in range(6):
 f=[d[int(j)]for j in m[i]];f[3],f[4]=f[4],f[3]
 if f[0]==e[0]:
  f=f[1:5]*2
  for j in range(4):
   if f[j:j+4]==e[1:5]:t=1
print(('No','Yes')[t])


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string x,y;
    cin>>x>>y;
    int f=0,len1,len2;
    len1=x.length();
    len2=y.length();
    if(len1>len2)
        f=1;
    else if(len1<len2)
        f=-1;
    else{
        for(int i=0;i<len1;i++){
            if(x[i]>y[i]){
                f=1;
                break;
            }
            else if(x[i]<y[i]){
                f=-1;
                break;
            }
        }
    }

    if(f==0)
        cout<<"EQUAL"<<endl;
    else if(f==1)
        cout<<"GREATER"<<endl;
    else
        cout<<"LESS"<<endl;

    return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
#define LL long long
#define INF 1e15
#define M 3000
using namespace std;
int n,m,s,head[55],tot,c[55],d[55];
LL dp[55][3010];
struct node{
	int to,next,a,b;
}e[105*2];
void add_edge(int u,int v,int a,int b){
	tot++,e[tot].to=v,e[tot].a=a,e[tot].b=b,e[tot].next=head[u],head[u]=tot;
}
int main(){
	int i,j,u,v,a,b,flag;
	scanf("%d%d%d",&n,&m,&s);
	for(i=1;i<=m;i++){
		scanf("%d%d%d%d",&u,&v,&a,&b);
		add_edge(u,v,a,b),add_edge(v,u,a,b);
	}
	for(i=1;i<=n;i++)scanf("%d%d",&c[i],&d[i]);
	for(i=1;i<=n;i++)
		for(j=0;j<=M;j++)dp[i][j]=INF;//注意j从0开始
	s=min(M,s);
	dp[1][s]=0;
	while(1){
		flag=0;
		for(u=1;u<=n;u++){//Bellman-Ford思想
			for(j=0;j<=M;j++){
				if(j>=c[u])dp[u][j]=min(dp[u][j],dp[u][j-c[u]]+d[u]);//01背包
				for(b=head[u];b;b=e[b].next){
					v=e[b].to;
					if(j>=e[b].a&&dp[v][j-e[b].a]>dp[u][j]+e[b].b){
						flag=1;
						dp[v][j-e[b].a]=dp[u][j]+e[b].b;
					}
				}
			}
			for(j=M-1;j>=0;j--)dp[u][j]=min(dp[u][j],dp[u][j+1]);//清空手上的钱，但不消耗时间
		}
		if(!flag)break;
	}
	for(i=2;i<=n;i++)printf("%lld\n",dp[i][0]);
	return 0;
}

Measured memory_bytes: 2916
#include <iostream>

using namespace std;

int main() {

  int value,change;
  int coins;


  while(1) {

    cin >> value;

    if(value==0) break;

    coins=0;
    change=1000-value;

    coins+=change/500;
    change%=500;

    coins+=change/100;
    change%=100;

    coins+=change/50;
    change%=50;

    coins+=change/10;
    change%=10;

    coins+=change/5;
    change%=5;

    coins+=change/1;
    change%=1;

    cout << coins << endl;

  }

  return 0;

}

Measured memory_bytes: 0
#include <stdio.h>
int main(void)
{
	int x,y,z;
	scanf("%d %d %d",&x,&y,&z);
	
	if(x<=y&&y<=z){printf("%d %d %d\n",x,y,z);}
	else if(y<=x&&x<=z){printf("%d %d %d\n",y,x,z);}
	else if(x<=z&&z<=y){printf("%d %d %d\n",x,z, y);}
	else if(y<=z&&z<=x){printf("%d %d %d\n",y ,z ,x);}
	else if(z<=x&&x<=y){printf("%d %d %d\n",z, x, y);}
	else if(z<=y&&y<=x){printf("%d %d %d\n",z ,y ,x);}
	
	return 0;
}

Measured memory_bytes: 1024
dishes = []
for i in range(5):
    dishes.append(int(input()))

dishes.sort(key=lambda x: x % 10)

flag = True
sum_dish = 0

for dish in dishes:
    if dish % 10 == 0:
        sum_dish += dish
    elif flag:
        sum_dish += dish
        flag = False
    else:
        sum_dish += dish + (10 - dish % 10)

print(sum_dish)

Measured memory_bytes: 3060
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    ll N, R;
    cin >> N >> R;
    if (N >= 10) {
        cout << R << endl;
    } else {
        cout << R + 100 * (10 - N) << endl;
    }
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
const ll MAX = 510000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll MODpow(ll a,ll n,ll mod=MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
void Main(){
    COMinit();
    string s;cin>>s;
    ll n=s.size();
    ll k;cin>>k;
    ll cnt=0;
    For(i,0,n){
        if(cnt>k) break;
        if(s[i]!='0') {
            int keta=s[i]-'0';
            if(cnt==k){
                ans++;
            }
            else if(cnt==k-1){
                ans+=(keta-1)+9*COM(n-i-1,1);
            }
            else if(cnt==k-2){
                ans+=(keta-1)*9*COM(n-i-1,1)+9*9*COM(n-i-1,2);
            }
            else if(cnt==k-3){
                ans+=(keta-1)*9*9*COM(n-i-1,2)+9*9*9*COM(n-i-1,3);
            }
            cnt++;
        }
    }
    if(cnt==k) ans++;
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 12160
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    h,n = map(int, input().split())
    a = list(map(int, input().split()))
    if h<=sum(a):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 13856
package main

import "fmt"

func main() {
	var s string
	fmt.Scanf("%s", &s)

	fmt.Println(logic(s))
}

func logic(s string) string {
	switch s {
	case "Sunny":
		return "Cloudy"
	case "Cloudy":
		return "Rainy"
	case "Rainy":
		return "Sunny"
	}
	return ""
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 19 20:44:36 2020

@author: Kanaru Sato
"""

import math

n,d = list(map(int, input().split()))
xs = []

for i in range(n):
    xs.append(list(map(int, input().split())))

count = 0

for i in range(n):
    for j in range(i+1, n):
        l = 0
        for k in range(d):
            l += (xs[i][k]-xs[j][k])**2
        if math.sqrt(l) - int(math.sqrt(l)) == 0:
            count += 1

print(count)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
long N,P,cnt[200101],T[2<<17],ans,mod,i;

int main()
{
    string s;cin>>s;
    N=s.size();P=2019;
    T[N-1]=1;
    for(int i=N-2;i>=0;i--) T[i]=T[i+1]*10%P;
    cnt[0]=1;
    for(int i=0;i<N;i++)
    {
        mod=(mod+(s[i]-'0')*T[i])%P;
        ans+=cnt[mod]++;
        //cout<<mod<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5156
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

//Time Trial
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int[][] d = {{-1,0},{0,1},{1,0},{0,-1}};
		//positions to ID
		int[][][] assign = new int[50][50][50];
		//ID to three positions
		int[][] ref = new int[19601][3];
		int ID = 0;
		for(int i=0;i<50;i++)for(int j=i+1;j<50;j++)for(int k=j+1;k<50;k++){
			ref[ID][0] = i; ref[ID][1] = j; ref[ID][2] = k;
			assign[i][j][k]=ID++;
		}
		boolean[][] u = new boolean[19601][50];
		for(;;){
			int w = sc.nextInt(), h = sc.nextInt();
			if((w|h)==0)break;
			char[][] map = new char[h][];
			int[][] id = new int[h][w], rid = new int[50][2];
			int[] tile = new int[3], rock = new int[3];
			int kt = 0, kr = 0, start = 0, M = 0;
			for(int i=0;i<h;i++){
				map[i] = sc.next().toCharArray();
				for(int j=0;j<w;j++){
					if(map[i][j]=='@'){
						id[i][j] = M;
						map[i][j] = '.';
						rid[M][0] = i; rid[M][1] = j;
						start = M++;
					}
					else if(map[i][j]=='_'){
						id[i][j] = M;
						map[i][j] = '.';
						rid[M][0] = i; rid[M][1] = j;
						tile[kt++] = M++;
					}
					else if(map[i][j]=='*'){
						id[i][j] = M;
						map[i][j] = '.';
						rid[M][0] = i; rid[M][1] = j;
						rock[kr++] = M++;
					}
					else if(map[i][j]=='.'){
						rid[M][0] = i; rid[M][1] = j;
						id[i][j] = M++;
					}
					else id[i][j] = -1;
				}
			}
			int G = assign[tile[0]][tile[1]][tile[2]], S = assign[rock[0]][rock[1]][rock[2]];
			for(boolean[]a:u)Arrays.fill(a, false);
			u[S][start] = true;
			List<int[]> l = new ArrayList<int[]>();
			l.add(new int[]{S, start});
			int step = 0, res = -1;
			while(!l.isEmpty()){
				List<int[]> next = new ArrayList<int[]>();
				for(int[] a:l){
					if(G==a[0]){
						res = step; next.clear(); break;
					}
					//now rock positions
					int[] r = ref[a[0]], nr = new int[3];
					int pi = rid[a[1]][0], pj = rid[a[1]][1];
					for(int k=0;k<4;k++){
						int ni = pi+d[k][0], nj = pj+d[k][1], npos = id[ni][nj];
						if(npos==-1)continue;
						nr[0] = r[0]; nr[1] = r[1]; nr[2] = r[2];
						int mpos = id[ni+d[k][0]][nj+d[k][1]];
						if(r[0]==npos){
							if(mpos==-1||r[1]==mpos||r[2]==mpos)continue;
							nr[0] = mpos;
						}
						else if(r[1]==npos){
							if(mpos==-1||r[0]==mpos||r[2]==mpos)continue;
							nr[1] = mpos;
						}
						else if(r[2]==npos){
							if(mpos==-1||r[0]==mpos||r[1]==mpos)continue;
							nr[2] = mpos;
						}
						Arrays.sort(nr);
						int ns = assign[nr[0]][nr[1]][nr[2]];
						if(!u[ns][npos]){
							u[ns][npos] = true; next.add(new int[]{ns, npos});
						}
					}
				}
				step++;
				l = next;
			}
			System.out.println(res);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 19000
///http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_C
#include <bits/stdc++.h>
using namespace std;

int main(){

    int x, y, gtr;



    while(cin >> x >> y){

            if(x==0 && y==0) break;
            else if(x >= y) cout << y << " " << x << endl;
            else cout << x << " " << y << endl;
    }



    return 0;
}



Measured memory_bytes: 3012
import java.util.*;
import java.io.*;
import java.math.BigInteger;
 
public class Main {
	public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	int D = s.nextInt();
	int T = s.nextInt();
	int S = s.nextInt();
	
	if(D > T*S){
		System.out.println("No");
	}else{
		System.out.println("Yes");
	}
		
	
	
	
	

    
  }
}

Measured memory_bytes: 35664
def poor(a,b,c):
  if a==b and b==c and c==a:
    return False
  if a!=b and b!=c and c!=a:
    return False
  return True

a,b,c = map(int, input().split())

if poor(a,b,c):
  print("Yes")
else:
  print("No")


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

ll find_gcd(ll a, ll b){
    if(b == 0) return a;
    return find_gcd(b, a%b);
}

int main(){
    int n;
    cin >> n;
    
    vector<ll> a(n), L(n), R(n);
    rep(i,n) cin >> a[i];
    
    rep(i,n-1){
        L[i+1] = find_gcd(L[i], a[i]);
    }
    
    for(int i = n - 1; i > 0; i--){
        R[i-1] = find_gcd(R[i], a[i]);
    }
    
    ll ans = 1;
    rep(i,n) ans = max(ans,find_gcd(L[i], R[i]));
    
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	double PI = acos(-1);
	double r; cin >> r;
	printf("%.10f\n", 2 * r * PI);
	return 0;
}

Measured memory_bytes: 3788
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-9
#define M_PI 3.141592653589793
#define bsize 300

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 300031;

string st;

int n,l;
vector<int> v;
int s;
int ans;

int main(){
//    freopen("apache.in","r",stdin);
//    freopen("apache.out","w",stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
 //   cin.tie(0);

    cin>>n>>l;

    for (int i=0;i<n;i++){
    	v.push_back(l+i);
    	s+=v.back();
    }

    ans=-1e9;

    for (int i=0;i<v.size();i++){
    	int here=0;
    	for (int j=0;j<v.size();j++){
    		if (j!=i)
    			here+=v[j];
    	}
    	if (abs(s-here)<abs(s-ans))
    		ans=here;
    }

    cout<<ans<<endl;

//    cin.get(); cin.get();
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	x := getInt()

	if x >= 1200 {
		out("ARC")
	} else {
		out("ABC")
	}
}


Measured memory_bytes: 640
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=[]
b=[0]*n
q=0
for i in range(n):
  a.append((1/2)*(p[i]+1))
for j in range(k):
  q+=a[j]

b[0]=q

for l in range(1,n-k+1):
  b[l]=b[l-1]-a[l-1]+a[k+l-1]
print(max(b))


  

Measured memory_bytes: 77448
SHIFT = 1 << 20


class fenwick_tree:
    """
    区間の一点更新と，区間和の取得がO(log n)で可能なデータ構造
    1-indexedで実装
    """

    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N+1)

    def sum_until(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & (-i)
        return s

    def sum_acc(self, i, j):
        """ [i,j] の和を返す """
        return self.sum_until(j) - self.sum_until(i-1)

    def add(self, i, x):
        if i <= 0:
            return
        while i <= self.size:
            self.tree[i] += x
            i += i & (-i)


def main():
    N, Q = (int(i) for i in input().split())
    C = [int(i) for i in input().split()]
    Query = [[] for _ in range(N+1)]
    for j in range(Q):
        le, ri = (int(i) for i in input().split())
        Query[ri].append(le << 20 | j)

    lastappend = [-1] * (N + 1)
    bit = fenwick_tree(N)
    ans = [0]*Q

    for i, a in enumerate(C, start=1):
        if lastappend[a] != -1:
            bit.add(lastappend[a], -1)
        lastappend[a] = i
        bit.add(i, 1)
        for le in Query[i]:
            j = le % SHIFT
            le >>= 20
            ri = i
            ans[j] = bit.sum_acc(le, ri)

    print(*ans, sep="\n")


if __name__ == '__main__':
    main()


Measured memory_bytes: 187900
#include<bits/stdc++.h>
using namespace std;
int grid[40][40];
int dy[4] = {1, 0, -1, 0};
int dx[4] = {0,-1, 0, 1};
int w, h;

int dfs(int x, int y, int depth){
  if(depth >= 10)return 1e9;
  int res = 1e9;
  bool flag = false;
    
  for (int i = 0; i < 4; i++) {
    int nx = x, ny = y;
    if(grid[ny + dy[i]][nx + dx[i]] == 1)continue;
    while(0 <= nx + dx[i] && nx + dx[i] < w &&
          0 <= ny + dy[i] && ny + dy[i] < h &&
          grid[ny + dy[i]][nx + dx[i]] == 0)
      nx += dx[i], ny += dy[i];
    
    if(nx + dx[i] < 0 || w <= nx + dx[i] ||
       ny + dy[i] < 0 || h <= ny + dy[i]){
      continue;
    }else if(grid[ny + dy[i]][nx + dx[i]] == 3){
      return depth + 1;
    }else{
      flag = true;
      grid[ny + dy[i]][nx + dx[i]] = 0;
    }
    res = min(res, dfs(nx, ny, depth + 1));
    if(flag)grid[ny + dy[i]][nx + dx[i]] = 1;
  }
  return res;
}

int main(int argc, char *argv[]){
  while(cin >> w >> h, w){
    memset(grid, 0, sizeof(grid));
    int sx, sy, tx, ty;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> grid[i][j];
        if(grid[i][j] == 2){
          sx = j;sy = i;
          grid[i][j] = 0;
        }else if(grid[i][j] == 3){
          tx = j;ty = i;
        }
      }
    }
    int ans = dfs(sx, sy, 0);
    if(ans == 1e9){
      std::cout << -1 << std::endl;
    }else{
      std::cout << ans << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n, p[100];
  while(cin >> n){
    for(int i = 0 ; i < n ; i++ ) cin >> p[i];
    sort( p, p + n);
    int ret = p[0];
    for(int i = 1 ; i < n ; i++ ) ret += p[i] += p[i - 1];
    cout << ret << endl;
  }
}

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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

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

  int N;
  cin >> N;
  int D[N];
  REP(i,N) cin >> D[i];
  int mod = 998244353;
  if (D[0] != 0) {
    cout << 0 << endl;
    return 0;
  }

  vector<int> v(N,0);
  REP(i,N) v[D[i]]++;
  if (v[0] != 1) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  EACH(i,1,N) {
    REP(j,v[i]) ans = (ans * v[i-1]) % mod;
  }

  cout << ans << endl;

  return 0;
}



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

int main(void) {
  int N, A, B;
  cin >> N >> A >> B;
  int answer = 0;
  for (int i = 1; i <= N; ++i) {
    int sum = 0;
    int num = i;
    while (num) {
      sum += num % 10;
      num /= 10;
    }
    if (A <= sum && sum <= B) answer += i;
  }
  cout << answer << endl;
  return 0;
}

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

Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main() {
	int N; cin >> N;
	int K; cin >> K;
	int sum = 0;
	REP(i, N){
		int inp; cin >> inp;
		sum += 2 * min(inp, K - inp);		
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
//
//  main.cpp
//  ABC
//
//  Created by Amarsanaa Davaasuren on 2019/08/31.
//  Copyright © 2019 Amarsanaa Davaasuren. All rights reserved.
//
# include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define rn return

using namespace std;
using ll = long long;

int main(){
    ll a[3];
    rep(i,3) cin >> a[i];
    sort(a,a+3);
    cout << (a[2]-a[0]);
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vvchar vector<vector<char>>
#define vchar vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vint a(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    
    vb dp(1e6+1,true);

    rep(i,n){
        if(i!=0){
            if(a[i]==a[i-1]){
                dp[a[i]]=false;
                continue;
            }
        }
        if(dp[a[i]]==true){
            for(int j=a[i]*2; j<1e6+1; j+=a[i]){
                dp[j]=false;
            }
        }
    }
    int res=0;
    rep(i,n)if(dp[a[i]])res++;
    cout<<res<<endl;

}

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

using namespace std;


template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s)
{
    return '"' + s + '"';
}

string to_string(const char* s)
{
    return to_string((string) s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out()
{
    cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const long long INF = 1e18;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<long long> a(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    vector<long long> dp1(n + 1, -INF), dp0(n + 1, -INF);

    dp0[1] = a[1];
    dp1[1] = -a[1];
    for (int i = 2; i < n; i++)
    {
        dp0[i] = max(dp0[i - 1] + a[i], dp1[i - 1] - a[i]);
        dp1[i] = max(dp0[i - 1] - a[i], dp1[i - 1] + a[i]);
    }
    long long ans = max(dp0[n - 1] + a[n], dp1[n - 1] - a[n]);
    cout << ans;
    return 0;
}



Measured memory_bytes: 5564
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int a = scan.nextInt();
      	int b = scan.nextInt();
      	String s = (a * b % 2 == 0) ? "Even" : "Odd";
      	System.out.println(s);
    }
}

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

using namespace std;

int main() {
  int64_t x;
  cin >>x;
  int64_t a,b;
  bool ju =false;
  for(int64_t i=-1000; i<=1000; i++){
    for(int64_t j=-1000; j<=1000;j++){
      if( (pow(j,5)-pow(i,5))==x){
        b=i;
        a=j;
        ju=true;
        break;
      }
    }
    if(ju)
      break;
  }
  cout << a << " "<<b<< endl;
}


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

int main()
{
	long n;
	cin >> n;
	
	long sum = 0;

	for (long i = 1; i*i <= n; i++) {
		if (n%i == 0 && (n-i)/i > i)	sum += (n-i)/i;
	}

	cout << sum << endl;
}


Measured memory_bytes: 256
n = int(input())
b = [[] for i in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        b[i].append((x - 1, y))

ans = 0

for bit in range(1 << n):
    syojiki = []
    flag = True

    for i in range(n):
        # フラグが立っていれば a に、なければ b に乗せる
        if bit & (1 << i):
            syojiki.append(1)
        else:
            syojiki.append(0)

    for i in range(n):
        for j in b[i]:  # 証言内容
            if syojiki[i] and syojiki[j[0]] != j[1]:
                flag = False
    if flag:
        ans = max(ans, sum(syojiki))

print(ans)

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

int main()
{
    int n, a;
    scanf("%d %d", &n, &a);
    if(n <= 500)
    {
        printf("Yes");
        return 0;
    }
    n = n % 500;
    if(n <= a)
        printf("Yes");
    else
        printf("No");
    return 0;
}

Measured memory_bytes: 128
x, k, d = map(int, input().split())

if x + k * d <= 0:
    print(-(x + k * d))
elif x - k * d >= 0:
    print(x - k * d)
elif x >= 0:
    print(min([abs(x - (k - 2 * i) * d) for i in range((k * d - x) // (2 * d) - 100, (k * d - x) // (2 * d) + 100)]))
else:
    print(min([abs(x + (k - 2 * i) * d) for i in range((k * d + x) // (2 * d) - 100, (k * d + x) // (2 * d) + 100)]))


Measured memory_bytes: 9208
# coding: utf-8
K, S = map(int, input().split())
cnt=0
for x in range(K+1):
        yz = S - x
        if yz < 0:
                break
        elif yz > 2*K:
                continue
        else:
                for y in range(K+1):
                        z = S - x - y
                        if 0<=z<=K:
                                cnt+=1
print(cnt)


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

void solve(){
	ll x[88];
	x[0] = 2, x[1] = 1;
	for (int i = 2; i < 88; i++) {
		x[i] = x[i - 2] + x[i - 1];
	}
	int n; cin >> n;
	cout << x[n] << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	//init();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main() {
    long long n,m,d;
    scanf("%lld%lld%lld", &n, &m, &d);
    double ret;
    if (d == 0) {
        ret = 1.0*(n-d)*(m-1)/(n*n);
    } else {
        ret = 2.0*(n-d)*(m-1)/(n*n);
    }
    printf("%.9lf\n", ret);
    return 0;
}

Measured memory_bytes: 128
n, a, b = map(int, input().split())

# 全通りーa本の通りーb本の通り
# 全通り→ 2**n-1
p = 10**9+7
ansAll = pow(2,n,p)
ansAll -= 1

# a本の通り→X*Y**p-2, X=n*n-1*...をa回, Y=a*a-1*...をa回
X = 1
Y = 1
for i in range(a):
    X = X*(n-i)%p
    Y = Y*(a-i)%p
ansA = pow(Y,p-2,p)
ansA = (ansA*X)%p

# bも同様
X = 1
Y = 1
for i in range(b):
    X = X*(n-i)%p
    Y = Y*(b-i)%p
ansB = pow(Y,p-2,p)
ansB = (ansB*X)%p

ans = (ansAll - ansA - ansB)%p

print(ans)

Measured memory_bytes: 38896
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
  int n,m;
  cin >> n >> m;
  int a[n],b[m];
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<m; i++) cin >> b[i];
  sort(b,b+m,greater<int> ());
  int j=0;
  int d[n],max=0,ans;
  fill(d,d+n,0);
  for(int i=0; i<n; i++) {
    while(b[j]>=a[i]) {
      d[i]++;
      j++;
      if(d[i]>max) {
    max=d[i];
    ans=i;
      }
    }
  }
  cout << ans+1 << endl;
  return 0;
}


Measured memory_bytes: 1188
import bisect
import sys


sys.setrecursionlimit(10**6)
INF = 10**6


class SegTree:

    def __init__(self, N):
        self.N = N
        self.data = [- INF] * (2 * N - 1)

    def update(self, i, x):
        n = self.N + i - 1
        self.data[n] = x
        while n > 0:
            n = (n - 1) // 2
            self.data[n] = max(self.data[2 * n + 1], self.data[2 * n + 2])        

    def elem(self, i):
        return self.data[self.N + i - 1]

    def _query(self, a, b, k, l, r):
        if r <= a or b <= l:
            return - INF
        if a <= l and r <= b:
            return self.data[k]
        val_left = self._query(a, b, 2 * k + 1, l, (l + r) // 2)
        val_right = self._query(a, b, 2 * k + 2, (l + r) // 2, r)
        return max(val_left, val_right)

    def query(self, a, b):
        return self._query(a, b, 0, 0, self.N)


def main():
    MOD = 998244353
    N = int(input())
    robot_list = [list(map(int, input().split())) for _ in range(N)]
    robot_list.sort()  # x座標の昇順でソート
    X = [robot[0] for robot in robot_list]
    D = [robot[1] for robot in robot_list]

    PW_N = 1
    while PW_N < N:
        PW_N *= 2
    next_robot_tree = SegTree(PW_N)
    next_robot_tree.update(N - 1, N)
    for n in range(N - 2, - 1, - 1):
        if X[n] + D[n] <= X[n + 1]:
            next_robot_tree.update(n, n + 1)
        else:
            next_robot = bisect.bisect_left(X, X[n] + D[n])
            next_robot = next_robot_tree.query(n, next_robot)
            next_robot_tree.update(n, next_robot)

    cnt = [0] * (N + 1)
    cnt[0] = 1
    for n in range(N):
        cnt[n + 1] += cnt[n]
        cnt[n + 1] %= MOD
        next_robot = next_robot_tree.elem(n)
        cnt[next_robot] += cnt[n]
        cnt[next_robot] %= MOD
    print(cnt[N])


if __name__ == '__main__':
    main()

Measured memory_bytes: 140328
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)

    if temp!=1:
        arr.append(1)

    if arr==[]:
        arr.append(1)

    return arr

n = int(input())
ln = factorization(n)
ans = 0
for i in range(1, max(ln) + 1):

    ln = [x for x in ln if x >= i]
    ans += len(ln)
    ln = list(map(lambda x: x - i, ln))
    if sum(ln)==0:
        break
import sys

if n == 1:
    print(0)
    sys.exit()
print(ans)

Measured memory_bytes: 63412
#include <bits/stdc++.h>
using namespace std;
#define test(t) int t; cin>>t; while(t--)
#define p1(x) { cout << " [" << #x << ": " << x << "]\n"; }
#define p2(x) { cout << " [" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]\n"; }
 
void solve()
{
	for(int i=1; i<=5; i++) {
		int x;
		cin>>x;
		if(x==0) {
			cout<<i;
			exit(0);
		}
	}
	cout<<"-1"<<endl;
}
 
int main() {
	// your code goes here
	//test(t)
		solve();
	return 0;
}
 

Measured memory_bytes: 3636
S = input()
mod = 2019
rem = [0] * mod
rem[0] = 1
now = 0
for k,v in enumerate(S[::-1]):
  now += int(v) * pow(10,k,mod)
  rem[now % mod] += 1
ans = 0
for i in rem:
  ans += i * (i-1) // 2
print(ans)


Measured memory_bytes: 9272
#include <bits/stdc++.h>
#define prique priority_queue
#define inf 1145141919364364
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll a[22],b[22],c[22];
signed main(){
	ll n,ans=0;
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	rep(i,n-1)cin>>c[i];
	rep(i,n-1){
		if(a[i+1]-a[i]==1)ans+=b[a[i]-1]+c[a[i]-1];
		else ans+=b[a[i]-1];
	}
	ans+=b[a[n-1]-1];
	cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

int main(){
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;

  vector<int> sum(n + 1, 0);
  for(int i = 0; i < n; ++i){
    if(i + 1 < n && s.substr(i, 2) == "AC")sum[i + 1] = sum[i] + 1; 
    else sum[i + 1] = sum[i];
  }

  for(int i = 0; i < q; ++i){
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    cout << sum[r] - sum[l] << endl;
  }
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N,a[200];
    int count=0;
    cin >> N;
    for (int i=0;i<N;i++){
        cin >> a[i];
    }
    
    while(1){
        for (int i=0;i<N;i++){
            if(a[i]%2!=0){
                cout << count << endl;
                return 0;
            }
            else{
                a[i] = a[i]/2;
            }
        }
        count++;
    }
    return 0;
}

Measured memory_bytes: 256
def gcd(a, b)
  a, b = b, a if a > b
  until a == 0
    a, b = b%a, a
  end
  return b
end

def lcm(a, b)
  a*b/gcd(a, b)
end

a, b = gets.split.map(&:to_i)

puts lcm(a, b)

Measured memory_bytes: 1788