akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vvec a(4,vec (13));
    rep(i,n){
        int x;string s;
        cin>>s>>x;
        if(s=="S"){
            a[0][x-1]++;
        }
        if(s=="H"){
            a[1][x-1]++;
        }
        if(s=="C"){
            a[2][x-1]++;
        }
        if(s=="D"){
            a[3][x-1]++;
        }
    }
    rep(i,4){
        rep(j,13){
            if(a[i][j]==0){
                if(i==0){
                    cout<<"S "<<j+1<<endl;
                }if(i==1){
                    cout<<"H "<<j+1<<endl;
                }if(i==2){
                    cout<<"C "<<j+1<<endl;
                }if(i==3){
                    cout<<"D "<<j+1<<endl;
                }
            }
        }
    }
}


Measured memory_bytes: 3216
N, = map(int, input().split())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
ss = 0
rr = 0
for i in range(N):
    ss += a1[i]
    tt = 0
    for j in range(i, N):
        tt += a2[j]
    rr = max(ss+tt, rr)
print(rr)


Measured memory_bytes: 38512
(*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*)

open System;

let s = Console.ReadLine()

let ans str =
    match str with
    "SAT" -> 1
    | "FRI" -> 2
    | "THU" -> 3
    | "WED" -> 4
    | "TUE" -> 5
    | "MON" -> 6
    | "SUN" -> 7
    | _ -> 0
    
Console.WriteLine(ans s)

Measured memory_bytes: 13140
n = int(input())
m = [[0 for j in range(n)] for i in range(n)]
color = [0 for i in range(n)]
d = [0 for i in range(n)]
f = [0 for i in range(n)]
time = [0]


def dfs(u):
    color[u] = 1
    time[0] += 1
    d[u] = time[0]
    for i in range(n):
        if m[u][i] == 1 and color[i] == 0:
            dfs(i)

    color[u] = 2
    time[0] += 1
    f[u] = time[0]


def main():
    for i in range(n):
        data = list(map(int, input().split()))
        for j in range(2, len(data)):
            m[data[0]-1][data[j]-1] = 1

    for i in range(n):
        if color[i] == 0:
            dfs(i)

    for i in range(n):
        print(i+1, d[i], f[i])


if __name__ == '__main__':
    main()



Measured memory_bytes: 5812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "


int main()
{
    ll x; cin >> x;
    ll rx = sqrt(x);
    // cout << rx << endl;
    vector<ll> ret;
    FOR(i, 1, rx + 1) {
        if (x % i == 0) {
            ret.push_back(i);
            if (i != rx) {
                ret.push_back(x / i);
            }
        }
    };
    sort(begin(ret), end(ret));
    // PRINT(ret);

    ll b;
    ll aa;
    const ll ma = 1000000000;
    bool f = false;
    for(ll a = 1; a < ma; ++a) {
        for (const auto& y : ret) {
            b = a - y;
            if (a*a*a*a + b*a*a*a + b*b*a*a + a*b*b*b + b*b*b*b == x/y) {
                aa = a;
                f = true;
                break;
            };

            b = a + y;
            if (a*a*a*a + b*a*a*a + b*b*a*a + a*b*b*b + b*b*b*b == -x/y) {
                aa = a;
                f = true;
                break;
            };
        };
        if (f) break;
    };
    
    cout << aa << " "<< b << endl;
    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define rep2(i,j,k) for(int i=j;i>=k;i--)
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}
template<typename T> void chkmax(T &x,T y){x=x>y?x:y;}
template<typename T> void chkmin(T &x,T y){x=x<y?x:y;}

struct wzy{
	int l,r;
}co[200010];
inline bool cmp(wzy a,wzy b){
	return a.l<b.l;
}
inline int d(int ll,int rr){
	return max(0,rr-ll+1);
}

int main(){
	int n;read(n);int ans=0;
	int pos1=0;int pos2=0;int mx_l=0;int n1=0;int n2=0;int mi_r=INT_MAX;
	rep(i,1,n){
		read(co[i].l);read(co[i].r);
		if(co[i].l>mx_l){mx_l=co[i].l;pos1=i;}
		if(co[i].r<mi_r){mi_r=co[i].r;pos2=i;}	
	}
	n1=co[pos1].r;n2=co[pos2].l;int len=0;
	rep(i,1,n){
		int q1=co[i].l;int q2=co[i].r;
		if(i!=pos1&&i!=pos2){co[++len].l=q1;co[len].r=q2;}
	}
	sort(co+1,co+len+1,cmp);
	
	int mx=co[1].r;int ret=d(co[1].l,co[1].r);
	rep(i,2,len){
		if(mx>=co[i].l)chkmax(ret,d(min(mx,co[i].r),co[i].l));
		chkmax(mx,co[i].r);chkmax(ret,d(co[i].l,co[i].r));
	}
	chkmax(ans,ret+d(mx_l,mi_r));
	
	if(pos1==pos2){write(ans);return 0;}
	int mi=n1;
	rep2(i,len,1){
		chkmax(ans,d(mx_l,mi)+d(co[i].l,mi_r));
		chkmin(mi,co[i].r);
	} 
	chkmax(ans,d(mx_l,mi)+d(n2,mi_r));write(ans);
	return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
A, B = map(int, input().split())

def F(n):
    if n % 4 == 1:
        return 1
    elif n % 4 == 2:
        return 1 ^ n
    elif n % 4 == 3:
        return 0
    else:
        return n

print(F(A-1)^F(B))

Measured memory_bytes: 3060
def move(x,y,a)
  return if(x < 0)
  return if(y < 0)
  return if(a.size <= y)
  return if(a[0].size <= x)
  return if(a[y][x] == "#")
  a[y][x] = "#"
  @ans += 1
  move(x + 1, y ,a)
  move(x - 1, y, a)
  move(x, y + 1, a)
  move(x, y - 1, a)
end
while (true)
  w,h = gets.split.map &:to_i
  break if(w == 0)
  d = []
  @ans = 0
  x = y = 0
  h.times do |i|
    d[i] = gets.chomp
    if(d[i].include?("@"))
      y = i
      x = d[i].index("@")
    end
  end
  move(x, y, d)
  p @ans
end

Measured memory_bytes: 8768
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // C - Stones

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        String s = sc.next();

        char[] c = s.toCharArray();

        int min = n;
        int[] countB = new int[n + 1];
        int[] countW = new int[n + 1];

        for (int i = 0; i <= n; i++) {
            if (i > 0) {
                countB[i] = countB[i - 1];
                if (c[i - 1] == '#') ++countB[i];
            } else {
                countB[i] = 0;
            }
        }

        for (int j = n; j >= 0; j--) {
            if (j < n) {
                countW[j] = countW[j + 1];
                if (c[j] == '.') ++countW[j];
            } else {
                countW[j] = 0;
            }
            if (min > (countB[j] + countW[j])) min = countB[j] + countW[j];
        }

        System.out.println(min);
    }
}


Measured memory_bytes: 28720
import java.io.*;

public class Main {
  public static void main(String[] args){

    try {
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
      String radius = reader.readLine();
      double r = Double.parseDouble(radius);
      double circleArea = r * r * Math.PI;
      double circumference = 2 * Math.PI * r;
      System.out.printf("%f %f\n", circleArea, circumference);
    } catch (IOException e) {
      System.out.println(e);
    } catch (NumberFormatException e) {
      System.out.println("数字が正しくありません");
    }
  }
}



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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; return(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    cin >> n;
    vector<pair<ll, ll>> a;
    REP(i, 0, n) {
        ll tmp;
        cin >> tmp;
        a.emplace_back(tmp, i + 1);
    }
    sort(ALL(a));

    NREP() {
        cout << a.at(i).second << " ";
    }
    cout << endl;
}


Measured memory_bytes: 5308
m,n=[ int(x) for x in input().split()]    
k=1000000007

REM={}

def remainder(i):

    if i in REM.keys():
        return REM[i]

    if i==1:
        re=m%k
        REM[1]=re     
        return re

    if i==2:
        re=(m%k)**2%k
        REM[2]=re        
        return re
    
    left=i//2
    right=i-left
    REM[i]=remainder(left)*remainder(right)%k
    return REM[i]


print(remainder(n))


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 2e9;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	ll answer = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			for (int k = 1; k <= n; ++k) {
				answer += gcd(gcd(i, j), k);
			}
		}
	}
	cout << answer << '\n';
 	return 0;
}


Measured memory_bytes: 3652
///By Stephan Ramirez dsramirezc@unal.edu.co
#include<bits/stdc++.h>
#define ms(a,v) memset(a,v,sizeof a)
#define ll long long
#define N 2005
using namespace std;
int n,m;
char mt[N][N];
ll acum[N][N];
int main(){
	#ifdef LOCAL
		freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++)
        scanf("%s",mt[i]);
    for(int i=0;i<n;i++){
        int c=0;
        vector<int> aux;
        for(int j=0;j<m;j++){
            if(mt[i][j]=='#'){
                while(aux.size()>0){
                    acum[i][aux.back()]=c;
                    aux.pop_back();
                }
                c=0;
            }else{
                c++;
                aux.push_back(j);
            }
        }
        while(aux.size()>0){
            acum[i][aux.back()]=c;
            aux.pop_back();
        }
    }
    for(int i=0;i<m;i++){
        int c=0;
        vector<int> aux;
        for(int j=0;j<n;j++){
            if(mt[j][i]=='#'){
                while(aux.size()>0){
                    acum[aux.back()][i]+=c;
                    aux.pop_back();
                }
                c=0;
            }else{
                c++;
                aux.push_back(j);
            }
        }
        while(aux.size()>0){
            acum[aux.back()][i]+=c;
            aux.pop_back();
        }
    }
    ll ans=0;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            ans=max(ans,acum[i][j]-1);
    cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 35584
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class Main{

    static int gcd(int a , int b){
        return b == 0 ? a : gcd(b , a%b);
    }

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int num = Integer.valueOf(br.readLine());
        String[] inputs = br.readLine().split(" ");
        int[] input = new int[num];

        for(int i = 0; i < num; i++)    input[i] = Integer.valueOf(inputs[i]);
        
        int GCD = gcd(Math.max(input[0] , input[1]) , Math.min(input[0] , input[1]));
        
        if(num == 3) GCD = gcd(Math.max(GCD, input[2]) , Math.min(GCD , input[2]));

        for(int i = 1; i <= GCD; i++){
            if((GCD % i) == 0) System.out.println(i);
        }
        
    }
}

Measured memory_bytes: 24412
/******************************************************************************

            EYENINE,THE ELDER_WAND!!!
            THE ROOT OVER MINUS EIGHTY ONE!!

*******************************************************************************/

#include<bits/stdc++.h>
#define ALL_UP_WITH return 0
#define tc int tt;tt=read();while(tt--)
#define vi vector<int>
using namespace std;
long long int  gcd(long long int  p,long long  int q){
 if(p % q == 0)return q;
 return gcd(q, p % q);
 }

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
long long int k;cin>>k;
 long long int ans=0;
    for(long long int i=0;i<k;i++)
        for(long long int j=0;j<k;j++)
            for(long long int p=0;p<k;p++)
                    ans+=gcd(i+1,gcd(j+1,p+1));

    cout<<ans<<endl;

    ALL_UP_WITH;
}


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

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    printf("%c%c%c\n", toupper(s1[0]), toupper(s2[0]), toupper(s3[0]));
    return 0;
}


Measured memory_bytes: 3724
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    int cnt=1;
    if(b==1)cnt=0;
    else{
    while(1){
        if(cnt==1)b-=a;
        else b-=(a-1);
        if(b<=0)break;
        ++cnt;
    }
    }
    cout<<cnt<<endl;
    return 0;
    }


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

int main(void)
{
    string Sa, Sb, Sc;
    cin >> Sa >> Sb >> Sc;

    vector<string> S = {Sa, Sb, Sc};
    vector<int> pt(3, 0);
    vector<int> len = {(int) S[0].size(), (int) S[1].size(), (int) S[2].size()};


    int turn = 0;

    while (true)
    {

        char val = S[turn][pt[turn]];

        pt[turn]++;

        if(val == 'a'){
            turn = 0;
        } else if(val == 'b'){
            turn = 1;
        } else {
            turn = 2;
        }

        bool st = true;
        for (int i = 0; i < 3; i++)
        {
            st &= (pt[i] <= len[i]);
        }
        if(!st) break;
    }

    for (int i = 0; i < 3; i++)
    {
        if(pt[i] > len[i]){
            if(i == 0){
                cout << 'A' << endl;
            } else if(i == 1){
                cout << 'B' << endl;
            } else {
                cout << 'C' << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>
 
using namespace std;
 
/* template */
 
using ll = long long;
 
void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
 
#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};
 
struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};
 
using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}
 
template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
 
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
 
constexpr ll LNF = 1LL<<50;
 
constexpr int INF = 1e9+7;
 
const long double PI=3.14159265358979323846;

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x; cin >> x;
    if(x==0){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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

  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<ll> sum(n + 1, 0);
  rep(i, n) { sum[i + 1] = a[i] + sum[i]; }

  ll ans = 0;
  map<int, int> cnt;
  cnt[0] = 1;
  REP(i, 1, n + 1) {
    if (i >= k) cnt[(sum[i - k] - (i - k) + k) % k]--;
    ans += cnt[(sum[i] - i + k) % k];
    cnt[(sum[i] - i + k) % k]++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 12800
#import math
#import copy
#import sys
#import bisect
#input = sys.stdin.readline
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))
def div(x):#約数配列
    div=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            div.append(check)
            while(x%check==0):
                x=x//check
        check+=1
    if x != 1:
      div.append(x)
    return div
def div2(x):#素因数分解配列
    div2=[]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        while x%check==0:
            div2.append(check)
            x/=check
        check+=1
    if x != 1:
      div2.append(x)
    return div2

def main():
    #x,y = map(int,input().split())           x=1,y=2
    #a = input().split()                      a=['1','2','3',...,'n']
    #a = list(map(int,input().split()))       a=[1,2,3,4,5,...,n]
    #li = input().split('T')	              FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    #複数行の「1 2 3 4」型の入力を一配列に
    #x = sorted([list(map(int, input().split())) for _ in range(n)])
    #ソート x.sort(key=lambda y:y[1])
    # print("Yes")  print("No")  x=[[0 for _ in range(n)] for _ in range(n)]
    n=int(input())
    s=list(input())
    m=n
    cnt=0
    for i in range(n-1):
        if s[i+1]=="E":
            cnt+=1
    m=min(m,cnt)
    for i in range(n-1):
        if s[i+1]=="E":
            cnt-=1
        if s[i]=="W":
            cnt+=1
        if m > cnt:
            m=cnt
    print(m)
main()

Measured memory_bytes: 64240
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

const ll mod = 1e9 + 7;

ll dp[(ll)1e5 + 10] = {};

int main() {
    ll N, M;
    cin >> N >> M;
    V<ll> A(M);
    for(ll &e : A) cin >> e;

    if(N == 1) {
        cout << 1 << endl;
        return 0;
    }

    dp[0] = 1;

    for(ll i = 1; i <= N; i++) {
        auto ite = lower_bound(ALL(A), i);
        if(ite != A.end() && *ite == i) continue;
        if(i - 1 >= 0) (dp[i] += dp[i - 1]) %= mod;
        if(i - 2 >= 0) (dp[i] += dp[i - 2]) %= mod;
    }

    cout << dp[N] << endl;
    return 0;
}



Measured memory_bytes: 1536
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	sc.Split(bufio.ScanWords)
  k := nextInt()
  l := []int{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}
	fmt.Println(l[k-1])
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<list>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
const int maxn = 1e2+10;
const ll mod = 1e9+7;

bool f(string s)
{
	int len = s.length();
	for(int i=0;i<=len/2;i++)
	{
		if(s[i] != s[len-1-i]) return false;
	}
	return true;
}
int main()
{
	string s;
	cin>>s;
	int n = s.length();
	int start1 = 1;
	int end1 = (n-1)/2;
	int start2 = (n+3)/2;
	int end2 = n;
	bool f1,f2,f3;
	string s1 = s;
	string s2 = s.substr(0,end1);
	string s3 = s.substr(start2-1,n-start2+1);
	f1 = f(s1);
	f2 = f(s2);
	f3 = f(s3);
	if(f1&&f2&&f3) puts("Yes");
	else puts("No");
	
	return 0;
}
	

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

template<typename T>
std::ostream & operator<<(std::ostream & os, std::vector<T> vec)
{
    os<<"{ ";
    std::copy(vec.begin(), vec.end(), std::ostream_iterator<T>(os, " "));
    os<<"}";
    return os;
}

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector <vector<int>> count(26, vector <int>(N + 1, 0));
    for(int i = 1 ; i <= N ; ++i){
        ++count[S[i - 1] - 'a'][i];
        for(int j = 0 ; j < 26 ; ++j){
            count[j][i] += count[j][i - 1];
        }
    }
    // for(int i = 0 ; i < 26 ; ++i){
    //     cout << "i = " << i <<  count[i] << '\n';
    // }
    int maximum = 0;
    for(int i = 1 ; i <= N ; ++i){
        // cut at position i
        // X - [1...i], Y - [i + 1...N]
        int counter = 0;
        //cout << "========> cutting at position i = " << i << '\n';
        for(int j = 0; j < 26 ; ++j){
            int left = count[j][i];
            int right = count[j][N] - left;
            if(left > 0 && right > 0){
                ++counter;
            }
            //cout << "char = " << (char)('a' + j) << " left = " << left << " right = " << right << " counter = " << counter << '\n';
        }
        //cout << "final counter = " << counter << '\n';
        maximum = max(maximum, counter);
    }
    cout << maximum << '\n';
    return 0;
}


Measured memory_bytes: 3628
h, w = map(int, input().split())
a = []
for i in range(h):
	a.append(input())
ind1 = []
for i in range(h):
	if "#" in a[i][:]:
		ind1.append(i)
ind2 = []
for i in range(w):
	judge = 0
	for j in range(h):
		if "#" == a[j][i]:
			judge = 1
	if judge:
		ind2.append(i)
for i in range(len(ind1)):
	s = []
	for j in range(len(ind2)):
		s.append(a[ind1[i]][ind2[j]])
	print("".join(map(str, s)))
		


Measured memory_bytes: 3064
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
 
 
int main()
{
	int N,K,D,A,i,j,cnt=0;
	cin >> N >> K;

	int Arry[N+5]={0};
	for(i = 1; i <= K; i++)
	{
		cin >> D;
		for(j = 0; j < D; j++)
		{
			cin >> A;
			Arry[A]++;
		}
	}

	for(i = 1; i <= N; i++)
		if(Arry[i]==0)cnt++;

	cout << cnt << endl;
    


    biday;
}
 
//...............BYE BYE................

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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義(使うときはINFも書き換えろ!!)
//#define int long long
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  int h,a;cin >> h >> a;
  if(h%a==0)h--;
  cout << h/a+1 << endl;

}


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

long long N;
char s[100001];
char animals[100001];

char reverse_animal(char animal) {
  if (animal == 'S')
    return 'W';
  else
    return 'S';
}
char next_animal(char animal, long long index) {
  if (animal == 'S') {
    if (s[index] == 'o')
      return animals[index - 1];
    else
      return reverse_animal(animals[index - 1]);
  } else {
    if (s[index] == 'o')
      return reverse_animal(animals[index - 1]);
    else
      return animals[index - 1];
  }
}

void set_animals() {
  long long i;
  for (i = 1; i < N; i++) {
    animals[i + 1] = next_animal(animals[i], i);
  }
}  

void check_animals(char tail) {
    if (animals[N - 1] == tail && animals[N] == animals[0]) {
      animals[N] = '\0';
      printf("%s\n", animals);
      exit(EXIT_SUCCESS);
    }
}
int main() {
  scanf("%lld%*c", &N);
  scanf("%s%*c", s);
  char tail;
  animals[0] = 'S';
  if (s[0] == 'o') {
    tail = 'S';
    animals[1] = 'S';
    set_animals();
    check_animals(tail);
    tail = 'W';
    animals[1] = 'W';
    set_animals();
    check_animals(tail);
  } else {
    tail = 'W';
    animals[1] = 'S';
    set_animals();
    check_animals(tail);
    tail = 'S';
    animals[1] = 'W';
    set_animals();
    check_animals(tail);
  }
  animals[0] = 'W';
  if (s[0] == 'o') {
    tail = 'W';
    animals[1] = 'S';
    set_animals();
    check_animals(tail);
    tail = 'S';
    animals[1] = 'W';
    set_animals();
    check_animals(tail);
  } else {
    tail = 'S';
    animals[1] = 'S';
    set_animals();
    check_animals(tail);
    tail = 'W';
    animals[1] = 'W';
    set_animals();
    check_animals(tail);
  }
    printf("-1\n");
  return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  unordered_map<ll, ll> mp;

  for (int i = 2; i <= n; ++i) {
    int j = 2;
    int a = i;
    while (a != 1) {
      if (a % j == 0)
        mp[j]++, a /= j;
      else
        j++;
    }
  }

  ll ans = 1;
  for (auto m : mp) ans = ans * (m.second + 1) % MOD;

  cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	println(max(x - y, 0LL));
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 1;
		int i = 1;
		while(i <= n){
			ans = i;
			i *= 2;
		}
		System.out.println(ans);
	}
}


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

int main() {
    int H1, M1, H2, M2, K; cin >> H1 >> M1 >> H2 >> M2 >> K;
    int x = H1 * 60 + M1;
    int y = H2 * 60 + M2;
    cout << y - x - K << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<pair<int,int> > x;
    for(int i=0;i<n;i++){
        int y;
        cin >> y;
        x.push_back(make_pair(y,i));
    } 

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

    vector<int> ans(n,-1);


    for(int i=0;i<n;i++){
        if(i<=n/2-1){
            ans.at(x.at(i).second)=x.at(n/2).first;
        }else{
            ans.at(x.at(i).second)=x.at(n/2-1).first;
        }
    }

    for(int i=0;i<n;i++) cout << ans.at(i) << endl;
}

Measured memory_bytes: 5492
#include <stdio.h>
#include <string.h>
#define M 36
#define O 0
#define I 1

typedef struct {
  char mark;
  int value;
} Card;

void BubbleSort(Card *,int);
void SelectionSort(Card *,int);
void disply(Card *,int);
int isStable(Card *,Card *,int);

int main(){
  Card C1[M+I], C2[M+I];
  int i, N;

  scanf("%d",&N);
  for(i=O;i<N;i++){
    scanf(" %c%d",&C1[i].mark,&C1[i].value);
  }
  for(i=O;i<N;i++){
    C2[i] = C1[i];
  }
  BubbleSort(C1,N);
  disply(C1,N);
  printf("Stable\n");
  SelectionSort(C2,N);
  disply(C2,N);
  if( isStable(C1,C2,N)==O){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }
  return 0;
}
void BubbleSort(Card C1[], int N)
{
  int i, j;
  Card t;

  for(i=O;i<N;i++){
    for(j=N-I;j>i;j--){
      if(C1[j].value<C1[j-I].value ){
        t=C1[j];
        C1[j]=C1[j-I];
        C1[j-I]=t;
      }
    }
  }
}
void SelectionSort(Card C2[], int N){
  int i,j,Min;
  Card t;

  for(i=O;i<N;i++){
    Min=i;
    for(j=i;j<N;j++){
      if(C2[j].value<C2[Min].value){
	Min=j;
      }
    }
    t=C2[i];
    C2[i]=C2[Min];
    C2[Min]=t;
  }
}

void disply(Card C[],int N)
{
  int i;

  for(i=O;i<N;i++){
    if(i>O){
      printf(" ");
    }
    printf("%c%d",C[i].mark,C[i].value);
  }
  printf("\n");
}

int isStable(Card C1[],Card C2[],int N)
{
  int i;

  for(i=O;i<N;i++)
    if(C1[i].mark!=C2[i].mark){
      return I;
    }
  return O;
}



Measured memory_bytes: 2096
#include<bits/stdc++.h>
#define N 100005
#define debug(x) cout<<#x<<":"<<x<<endl;
using namespace std;
int n,A[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	sort(A+1,A+1+n);
	printf("%d",A[n/2+1]-A[n/2]);
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define Endl endl
#define mod  1000000007
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
#define maxi 500111

ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
ll intpoint(ll x1, ll y1, ll x2, ll y2) { return ( __gcd(abs(x1-x2),abs(y1-y2))+1); }
bool isvalid(ll x,ll y,ll n,ll m) { return (x>=0&&x<n&&y>=0&&y<m); }
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int pp = uniform_int_distribution<int>(0, kk-1)(rng);
// ---------------------///////////////---------------------------------
// ---------------------///////////////----------------------------------
// -------------/////////////////---------------------------------///////



int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // ll n;
    // cin>>n;

    // ll ap[n+11];
    // for(ll i=0;i<n;i++){
    //   cin>>ap[i];
    // }

    ll a,b,c;
    cin>>a>>b>>c;

    ll p = __gcd(a,b);

    ll cnt = 0;
    for(ll i = p;i>=1;i--){
      if(p%i == 0){
        cnt++;
      }
      if(cnt == c){
        cout<<i;
        return 0;
      }
    }
    
    // cout<<"-1\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(c>a*b)
        printf("%d\n",a*b);
    else if(c<a*b || c==a*b)
        printf("%d\n",c);

    return 0;
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		ArrayList<Integer> shoplist= new ArrayList<Integer>();

		for(int i=0;i<N;i++) {
			shoplist.add(sc.nextInt());
		}
		sc.close();
		Collections.sort(shoplist);

		int result = 0;
		for(int i=0;i<K;i++) {
			result = result + shoplist.get(i);
		}

		System.out.println(result);

	}


}

Measured memory_bytes: 30408
def solve():
    def dfs(node, path, rest):
        if rest == 0:
            nonlocal ans
            ans += 1
        for next_node in adj[node]:
            if next_node not in path:
                dfs(next_node, path + [next_node], rest - 1)
                
    
    from sys import stdin
    f_i = stdin
    
    N, M = map(int, f_i.readline().split())
    
    adj = [[] for i in range(N)]
    for i in range(M):
        a, b = map(int, f_i.readline().split())
        a -= 1
        b -= 1
        adj[a].append(b)
        adj[b].append(a)
    
    ans = 0
    dfs(0, [0], N - 1)
    
    print(ans)

solve()

Measured memory_bytes: 3316
#include <iostream>

using namespace std;
const int kBalln = 10;
int ball[kBalln];

bool ExistAsceOrder(int i, int a, int b){
  if (i == kBalln)  return true;

  if (a < ball[i] && ExistAsceOrder(i+1,ball[i],b)) return true;

  if (b < ball[i] && ExistAsceOrder(i+1,a,ball[i])) return true;

  return false;
}

int main(){
  int n;

  cin >> n;
  for (int j = 0; j < n; ++j)
    {
      for (int i = 0; i < kBalln; ++i)
        {
          cin >> ball[i];
        }
      cout << (ExistAsceOrder(0,0,0)? "YES" : "NO") << endl;
    }
  return 0;
}

Measured memory_bytes: 1152
package main

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

const abcd = "abcdefghijklmnopqrstuvwxyz"

// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}

var inf int = 1e13
var mod = 1000000007

// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	s := next.next()
	k := next.Int()
	ans := make([]byte, len(s))
	for i := 0; i < len(s); i++ {
		if s[i] == 'a' {
			ans[i] = 'a'
			continue
		}
		if int('z'-s[i]+1) <= k {
			k -= int('z' - s[i] + 1)
			ans[i] = 'a'
		} else {
			ans[i] = s[i]
		}
	}
	log.Println(k)
	n := int(ans[len(s)-1] - 'a')
	n = (n + k) % len(abcd)
	log.Println(n)
	ans[len(s)-1] = abcd[n]
	fmt.Println(string(ans))
}

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

// Pair is liked C++ pair
type Pair struct {
	a, b int
}

// Pairs is sorted by []Pair struct
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func sum(a ...int) int {
	r := a[0]
	if len(a) > 1 {
		for i := 1; i < len(a); i++ {
			r += a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

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

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

// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1536
S=input()


if "W" in S:
    if not "E" in S:
        print("No")
        exit()

if "E" in S:
    if not "W" in S:
        print("No")
        exit()

if "N" in S:
    if not "S" in S:
        print("No")
        exit()

if "S" in S:
    if not "N" in S:
        print("No")
        exit()
        
print("Yes")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
 
int main (){
  string S;
  cin>>S;
  if(S[S.length()-1]=='s'){
    cout<<S<<"es";
  }
  else{
    cout<<S<<"s";
  }
}

Measured memory_bytes: 3620
def x_ijo_min(lst, x):
    if lst[0] >= x: return lst[0]
    left = 0 # xより小さい
    right = len(lst) # x以上
    while left+1 < right:
        mid = (left+right) // 2
        if lst[mid] < x:
            left = mid
        else:
            right = mid
    if right == len(lst): return False
    else: return lst[right]

n = int(input())

dic_up = {}
dic_down = {}
dic_hor = {}
dic_ver = {}
lst = []
for i in range(n):
    xi, yi, ui = input().split()
    xi, yi = int(xi), int(yi)
    up = xi - yi
    down = xi + yi
    if (ui, up) in dic_up:
        dic_up[(ui, up)].append(xi)
    else:
        dic_up[(ui, up)] = [xi]
    if (ui, down) in dic_down:
        dic_down[(ui, down)].append(xi)
    else:
        dic_down[(ui, down)] = [xi]
    if (ui, xi) in dic_ver:
        dic_ver[(ui, xi)].append(yi)
    else:
        dic_ver[(ui, xi)] = [yi]
    if (ui, yi) in dic_hor:
        dic_hor[(ui, yi)].append(xi)
    else:
        dic_hor[(ui, yi)] = [xi]
    lst.append([xi, yi, ui, up, down])

for key in dic_up.keys():
    dic_up[key].sort()
for key in dic_down.keys():
    dic_down[key].sort()
for key in dic_hor.keys():
    dic_hor[key].sort()
for key in dic_ver.keys():
    dic_ver[key].sort()

ans = 10**9
for i in range(n):
    xi, yi, ui, up, down = lst[i]
    if ui == 'U':
        if ('D', xi) in dic_ver:
            dy = x_ijo_min(dic_ver[('D', xi)], yi)
            if dy: ans = min(ans, (dy-yi)*5)
        if ('L', up) in dic_up:
            lx = x_ijo_min(dic_up[('L', up)], xi)
            if lx: ans = min(ans, (lx-xi)*10)
    if ui == 'R':
        if ('U', down) in dic_down:
            ux = x_ijo_min(dic_down[('U', down)], xi)
            if ux: ans = min(ans, (ux-xi)*10)
        if ('D', up) in dic_up:
            dx = x_ijo_min(dic_up[('D', up)], xi)
            if dx: ans = min(ans, (dx-xi)*10)
        if ('L', yi) in dic_hor:
            lx = x_ijo_min(dic_hor[('L', yi)], xi)
            if lx: ans = min(ans, (lx-xi)*5)
    if ui == 'D':
        if ('L', down) in dic_down:
            lx = x_ijo_min(dic_down[('L', down)], xi)
            if lx: ans = min(ans, (lx-xi)*10)

if ans == 10**9:
    print('SAFE')
else:
    print(ans)

Measured memory_bytes: 290868