akhauriyash/Code-Regression huggingface dataset:
def do_round_robin(process, tq):
    from collections import deque
    q = deque()
    elapsed_time = 0  # ??????????????????????§??????????????????????
    finished_process = []  # ????????????????????????????????????????????¨??????????????????????????§?????????

    # ?????\?????????????????????????????????
    for process_name, remaining_time in process:
        q.append([process_name, int(remaining_time)])

    while True:
        try:
            process_name, remaining_time = q.pop()
        except IndexError:  # ??????????????£???????????????????????????????????£???
            break
        else:
            elapsed_time += min(remaining_time, tq)
            remaining_time -= tq
            if remaining_time > 0:
                q.appendleft([process_name, remaining_time])
            else:
                finished_process.append((process_name, elapsed_time))
    return finished_process


if __name__ == '__main__':
    # ??????????????\???
    # ????????????????????????????????????????????????????°??????????????????????????????¨
    data = [int(x) for x in input().split(' ')]
    num_of_process = data[0]
    time_quantum = data[1]
    process = []
    for i in range(num_of_process):
        process.insert(0, [x for x in input().split(' ')])

    # ??????
    results = do_round_robin(process, time_quantum)

    # ???????????????
    for i in results:
        print('{0} {1}'.format(i[0], i[1]))

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


signed main(){
    string S;
    cin>>S;
    bool ok=true;
    map<char,int>memo;
    REP(i,S.size()){
        memo[S[i]]++;
    }
    REP(i,26){
        if(memo[(char)('a'+i)]==0){
            cout<<(char)('a'+i)<<endl;
            ok=false;
            break;
        }
    }
    if(ok)cout<<"None"<<endl;
}



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

int main(){
  int n,l;
  while(cin >> n >> l){
    int v[100000];
    vector<int> a, a2, b(n,0);

    for(int i=0;i<n;i++){
      cin >> v[i];
    }

    for(int i=0;i<n;i++){
      if(i != 0 && v[i] < v[i-1]) a.push_back(i);
      if(i != n-1 && v[i] < v[i+1]) a2.push_back(i);
     }

    while(1){
      bool f = false;      
      for(int i=0;i<a.size();i++){
	int c = b[a[i]];
	b[a[i]] = max(b[a[i]],b[a[i]-1] + l - v[a[i]-1]);
	if(c != b[a[i]]) f = true;
      }
      for(int i=a2.size()-1;i>=0;i--){
	if(a2[i] != n - 1 && v[a2[i]] < v[a2[i]+1]){
	  int c = b[a2[i]];
	  b[a2[i]] = max(b[a2[i]],b[a2[i]+1] + l - v[a2[i]+1]);
	  if(c != b[a2[i]]) f = true;
	}
      }
      if(!f) break;
    }

    int ans = 0;
    for(int i=0;i<n;i++) ans = max(ans,b[i]+l-v[i]);

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

Measured memory_bytes: 2172
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
vector<int>adj[MAXN];
int vis[MAXN][11];
int ans[MAXN],v[MAXN],d[MAXN],c[MAXN];
void color(int nd,int dis,int col){
	if(vis[nd][dis])
		return;
	vis[nd][dis]=1;	
	if(!dis){
		ans[nd]=col;
		return;
	}
	color(nd,dis-1,col);
	for(int i=0;i<int(adj[nd].size());i++){
		int to=adj[nd][i];
		color(to,dis-1,col);
	}
}
int main(){
	//~ #ifndef ONLINE_JUDGE
    //~ freopen("file.in", "r", stdin);
	//~ #endif	
	int n,m;
	scanf("%d%d",&n,&m);
	while(m--){
		int u,v;
		scanf("%d%d",&u,&v);
		adj[u].pb(v);
		adj[v].pb(u);
	}
	int q;
	scanf("%d",&q);
	for(int i=1;i<=q;i++)
		scanf("%d%d%d",v+i,d+i,c+i);
	for(int i=q;i>=1;i--)
		color(v[i],d[i],c[i]);
	for(int i=1;i<=n;i++)
		printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 12408
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let (a, b): (i64, i64) = {
      let v = read_vec();
      (v[0], v[1])
    };

    let res
    = if b % a == 0 {
      a + b
    }
    else {
      b - a
    };

    println!("{}", res);
}


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

int main() {
	long n;
	long sum=2;
	for(int i=0; i<50; i++){
		if(cin >> n){
		
		for(long j=2;j<=n;++j){
			sum+=j;
		}
		cout<<sum<<endl;
		sum=2;
		}
	}
	return 0;
}

Measured memory_bytes: 2968
s = gets.chomp
t = gets.chomp
ans = false

for i in 0..s.length-1 do
  new_st = s[i+1..s.length-1] + s[0..i]
  if new_st == t
    ans = true
    break
  end 
end

puts (ans ? 'Yes' : 'No')

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

int main() {
  int n;
  cin >> n;
  int max_a = 0, max_a_b = n;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a > max_a) {
      max_a = a;
      max_a_b = b;
    }
  }
  cout << max_a + max_a_b << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#define INF 1<<28
#define F first
#define S second
using namespace std;
  
int sx, sy, gx, gy;
typedef pair < int, int > P;
vector < P > v[5];
int memo[5][5][1111];
 
int dist(P a, P b){
  return abs(a.F - b.F) + abs(a.S - b.S);
}
 
 
int solve(int cnt, int now, int p){
  
  if(cnt == 4) return dist(v[now][p], P(gx, gy));
  if(~memo[cnt][now][p]) return memo[cnt][now][p];
  
  int ans = INF, next = (now+1)%5, cost;
  for(int i=0;i<v[next].size();i++){
    if(!cnt) cost = dist(P(sx, sy), v[next][i]);
    else cost = dist(v[now][p], v[next][i]);
    ans = min(ans, solve(cnt+1, next, i) + cost);
  }
  
  return memo[cnt][now][p] = ans;
}
  
int main(){
  
  int w, h;
  char c;
  
  while(scanf("%d %d", &w, &h), w){
     
    for(int i=0;i<5;i++) v[i].clear();
     
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
    scanf(" %c", &c);
    if(c == '.') continue;
    else if(c == 'S') sx = j, sy = i;
    else if(c == 'G') gx = j, gy = i;
    else v[c-'1'].push_back( P(j,i) );
      }
    }
     
    int a, b = INF;
    memset(memo, -1, sizeof(memo));
    for(int i=0;i<5;i++){
      if(b > solve(0,i,0)) a = i+1, b = solve(0,i,0);
    }
  
    b == INF?puts("NA"):printf("%d %d\n", a, b);
  
  }
}

Measured memory_bytes: 1192
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);




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

	int N;
	cin >> N;
	vector<array<int, 2>>a(N), b(N);
	rep(i, N) {
		cin >> a[i][0] >> a[i][1];
		if (a[i][1] < a[i][0])swap(a[i][0], a[i][1]);
		b[i][0] = a[i][1];
		b[i][1] = a[i][0];
	}
	sort(ALL(a));
	sort(ALL(b));

	//大きいやつと小さいやつに分ける
	int ans = (a[N - 1][0] - a[0][0])*(b[N - 1][0] - b[0][0]);

	//広いやつと狭いやつに分ける
	int r = a[N-1][0], l = intmax;
	rep(i,N-1) {

		//l,rは狭いやつの範囲
		l = min(a[i][1], l);
		r = max(r, a[i][1]);
		ans = min(ans, (b[N-1][0] - a[0][0]) * (r - min(l, a[i + 1][0])));
	}
	cout << ans << endl;

	return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)
#define SUM(v) accumulate((v).begin(),(v).end(),0ll)
#define range(i,left,right) (left<=i && i<right)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int iscount(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int n,k;
    cin>>n>>k;
    set<int> have;
    REP(i,0,k){
        int d;
        cin>>d;
        REP(j,0,d){
            int a;
            cin>>a;
            have.insert(a);
        }
    }
    cout<<n-have.size()<<endl;
    return 0;
}


Measured memory_bytes: 3624
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
typedef long long ll;

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b)*b;
}



using namespace std;
int main() {

	int n;
	ll t[100];
	ll ans = 1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}

	for (int i = 0; i < n; i++) {
		ans = lcm(ans, t[i]);
	}

	cout << ans << endl;


	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A;
  int B;
  cin >> A;
  cin >> B;
  int n;
  if((B-1) % (A-1) == 0){
    cout << (B-1)/(A-1) << endl;
  }
  else if((B-1) % (A-1) > 0){
    cout << (B-1)/(A-1) + 1 << endl;
 
  }
}

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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	
		int n = sc.nextInt();
		
		double sum = 0;
		for (int i=0; i<n; i++) {
			double a = sc.nextDouble();
			String s = sc.next();
			if (s.equals("JPY")) sum += a;
			else sum += a * 380000.0;
		}
		
		System.out.println(sum);
		
	}
}


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

using namespace std;

int main() {
    vector<vector<int>> anpan;
    int n, k = -1;
    cin >> n;
    vector<int> zerad = {0};
        anpan.push_back(zerad);
        anpan.push_back(zerad);
        anpan.push_back(zerad);

    for (int i = 0 ; i < n ; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        anpan[0].push_back(max(anpan[1][i], anpan[2][i]) + a);
        anpan[1].push_back(max(anpan[0][i], anpan[2][i]) + b);
        anpan[2].push_back(max(anpan[0][i], anpan[1][i]) + c);
    }
    cout << max(anpan[0][n], max(anpan[1][n], anpan[2][n])) << endl;
}

Measured memory_bytes: 1644
a,b = gets.chomp.chars,gets.chomp.chars

if a.size > b.size
  puts "GREATER"
elsif b.size > a.size
  puts "LESS"
else
  a.size.times do |i|
    if a[i] > b[i]
      puts "GREATER"
      exit
	elsif b[i] > a[i]
      puts "LESS"
      exit
    else
    end
  end
  puts "EQUAL"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REP1(i, n) for (int i = 1; i < n + 1; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;

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;
}
// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N;
    REP(i, N)
    cin >> h[i];
    REP(i, 100010)
    {
        dp[i] = INF;
    }
    dp[0] = 0;
    REP1(i, N - 1)
    {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1)
            chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[N - 1] << endl;
}


Measured memory_bytes: 5136
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int>Data(n);
  for(int i=0;i<n;i++)cin>>Data[i];
  sort(Data.begin(),Data.end());
  int ans=0;
  for(int i=0;i<k;i++){
    ans+=Data[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#define N 100

char a[N+1][N+1];

int main(){
  int c, r, l, i, j, n;
  for(i=0;i<=N;i++) for(j=0;j<=N;j++) a[i][j] = 0;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d%d", &c, &r);
    while(r--){
      scanf("%d", &l);
      a[c][l] = 1;
    }
  }
  for(i=1;i<=n;i++) for(j=1;j<=n;j++) printf("%d%c", a[i][j], (j==n) ? '\n' : ' ');
  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep4(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

void solve(ll h){
    ll ans=0;
    ll base=1;
    while(h>0){
        ans+=base;
        h/=2;
        base*=2;
    }
    cout<<ans<<endl;
}

int main(){
    ll h;
    scanf("%lld",&h);
    solve(h);
}


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

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x, y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x, y, z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define db4(x, y, z, w) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<","<<#w<<"="<<w<<'\n'
#define sz(a) int((a).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
#define PR(a, n) {cout<<#a<<"="; for(int __=0;__<n;__++)cout<<a[__]<<' '; cout<<"\n"; }
using namespace std;
using ll = unsigned long long;
#define int ll

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;

    vector<vector<char>> a(n,vector<char>(m));
    for(auto &it: a){
        for(auto &i:it)cin >> i;
    }
    vector<vector<int>> dp(n,vector<int>(m));
    dp[0][0] =1;
    for(int col = 1; col < m ; ++col){
        if(a[0][col] == '#')break;
        dp[0][col] = 1;
    }
    for(int row = 1; row < n; ++row) {
        if (a[row][0] == '#')break;
        dp[row][0] = 1;
    }
    int mod = 1e9+7;
    for(int row = 1;row<n;++row){
        for(int col = 1;col < m; ++col){
            if(a[row][col] == '#'){
                dp[row][col] = 0;
            }
            else {
                dp[row][col] += dp[row - 1][col] + dp[row][col - 1];
                dp[row][col] %= mod;
            }
        }
    }
    cout << dp[n-1][m-1] << '\n';
    return 0;
}

Measured memory_bytes: 9088
#include <iostream>

using namespace std;

int main(void)
{	
	int n, T;
	cin >> n >> T;
	
	int c, t;
	int min = 10000000;
	for (int i = 0; i < n; i++) {
		cin >> c >> t;
		if (t <= T && min > c) {
			min = c;
		}
	}
	if (min == 10000000) {
		cout << "TLE" << endl;
	}
	else {
		cout << min << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
d = defaultdict(int)

n=int(input())
a = list(map(int,input().split()))
q=int(input())
bc = [list(map(int, input().split())) for i in range(q)]

#print(bc)

for el in a:
    d[el] += 1

def s_sum(dd):
    res = 0
    for k,v in dd.items():
        res += k * v
    return res

wk = s_sum(d)

for ss in bc:
    b = ss[0]
    c = ss[1]

    b_cnt = d[b]
    c_cnt = d[c]
    d[b] = 0
    d[c] += b_cnt
    wk = wk + b_cnt*c - b_cnt*b
    print(wk)


Measured memory_bytes: 107192
a=10**9+7
#print(a)
n=int(input())
s=list(map(int,input().split()))
s.sort()
t=n//2
ans=0
if n%2==0:
  check=[2*i+1 for i in range(t)]
  check*=2
  check.sort()
  

else:
  check=[2*i for i in range(t+1)]
  check*=2
  check.sort()
  check.remove(0)
  #print(check)

if check==s:
  ans=(2**t)%a
print(ans)
  

Measured memory_bytes: 14008
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scan = new java.util.Scanner(System.in);

		int n = scan.nextInt();
		long[] a = new long[n];


		for(int i=0;i<n;i++) {

			 a[i] = scan.nextLong();
			 if(a[i]==0) {
				 System.out.println(0);
				 return;
			 }
		}

long c =1;
for(int i=0;i<n;i++) {
	if(a[i] <= 1000000000000000000L / c)
		c *= a[i];
	else {
		System.out.println(-1);
		return;
	}
}

if(c > 1000000000000000000L)
			System.out.println(-1);
else
	System.out.println(c);

	scan.close();

	}

}


Measured memory_bytes: 50348
n=int(input())
arr=list(map(int,input().split()))
for i in range(n-2,0,-1): # 列を後ろからみる
 if arr[i]>arr[i+1]: # 単調非減少になっていないとき、手前の要素の値を1減らす
   arr[i]-=1
   if arr[i]>arr[i+1]: # 1減らしても単調非減少にならないとき、答えはNo
     print('No')
     break
else:
 print('Yes')

Measured memory_bytes: 14396
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner scn=new Scanner(System.in);
        int n=scn.nextInt();
        int answer=0;
        for(int i=0;i<n;i++){
            int buf =scn.nextInt();
            int cnt=0;
            while(buf%2==0){
                buf/=2;
                cnt++;
            }
          	if(i==0){
            	answer=cnt;
            }else{
            	answer=Math.min(cnt,answer);
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 23252
N, M = map(int, input().split())

A = list(set(map(int, input().split(" "))))
G = A.copy()
 
while not any(x % 2 for x in G):
    G = [i // 2 for i in G]
 
if not all(x % 2 for x in G):
    print(0)
    exit(0)
    
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    return a * b // gcd(a, b)
    
total = 1

for x in A:
    total = lcm(total, x // 2)

print((M // total + 1) // 2)

Measured memory_bytes: 11128
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    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([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

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

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
ans = 0
for i in range(1,int(math.sqrt(n))+1):
    ans+=max(((((n-1)//i-(i-1))-1)*2+1),0)
print(ans)

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

N=int(input())
S=list(input().strip())
Q=int(input())

LEN=N

BIT=[[0]*(LEN+1) for i in range(26)]

def update(v,w,i): # index vにwを加える
    while v<=LEN:
        BIT[i][v]+=w
        v+=(v&(-v)) # 自分を含む大きなノードへ. たとえばv=3→v=4

def getvalue(v,i): # [1,v]の区間の和を求める
    ANS=0
    while v!=0:
        ANS+=BIT[i][v]
        v-=(v&(-v)) # 自分より小さい2ベキのノードへ. たとえばv=3→v=2へ
    return ANS

for i in range(N):
    update(i+1,1,ord(S[i])-97)

for i in range(Q):
    qf,x,y=input().split()
    qf=int(qf)

    if int(qf)==1:
        x=int(x)
        update(x,-1,ord(S[x-1])-97)
        update(x,1,ord(y)-97)
        S[x-1]=y

    else:
        x=int(x)
        y=int(y)
        ANS=0
        for i in range(26):
            if getvalue(y,i)-getvalue(x-1,i)>0:
                ANS+=1

        print(ANS)
        
    


Measured memory_bytes: 164252
function main(lines) {
  const input = lines.split(' ').map(function(val){return parseInt(val);})
  const W = input[0]
  const H = input[1]
  const x = input[2]
  const y = input[3]
  const r = input[4]
  const xMin = x - r
  const xMax = x + r
  const yMin = y - r
  const yMax = y + r
  
  if(0<=xMin && xMax<=W && 0<=yMin && yMax<=H){
      console.log('Yes')
  } else {
      console.log('No')
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    map<ll,ll> A;
    REP(i,0,N) {
        ll a;
        cin >> a;
        ++A[a];
    }
    ll Q;
    cin >> Q;
    vec B(Q), C(Q);
    REP(i,0,Q) cin >> B[i] >> C[i];

    ll sum = 0;
    FORR(a,A) sum += a.first * a.second;
    REP(i,0,Q) {
        if(A[B[i]] != 0) {
            sum += A[B[i]] * (C[i] - B[i]);
            A[C[i]] += A[B[i]];
            A[B[i]] = 0;
        }
        PR(sum);
    }



    return 0;
}

/*

1 2 3 4
2 2 3 4
2 2 4 4

*/

Measured memory_bytes: 10468
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class Main {

	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			boolean ok = true;
			for(int i = 0; i < N; i++) {
				final int a = sc.nextInt();
				
				if(a % 2 != 0) { continue; }
				if(a % 3 == 0 || a % 5 == 0) { continue; }
				
				ok = false;
			}
			
			System.out.println(ok  ? "APPROVED" : "DENIED");
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int s, prev, ans = 2;
    cin >> s;

    set<int> st;
    st.insert(s);
    prev = s;
    while (true)
    {
        int v;
        if (prev % 2 == 0)
            v = prev / 2;
        else
            v = prev * 3 + 1;

        if(st.count(v) > 0)
            break;

        st.insert(v);
        prev = v;
        ans++;
    }

    cout << ans << endl;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll a,b,x;
    string S;
    cin >> a>>b>>x;

    if(a==0){
        cout << b / x + 1 << endl;
    }
    else{
        cout << b / x - (a - 1) / x << endl;
    }

}


Measured memory_bytes: 256
//ポイント：ビットごとに考える、(X(,Y)の選び方に) 依存しないものを探す。
//まずスコア = X + Y = Σ2^i * (Xi + Yi)
//適当にX,Yを選んでXi≠Yi (Xi,Yi={0,1})になったら、他の選び方でもXi≠Yi。このときXi+Yi=1。
//適当にX,Yを選んでXi=Yiになったら、選び方によってはXi+Yi=2Xi (選び方に依存).
//↑をもうちょっと書きやすい形にすると、全体のxor = Wとおくことで、
//Wi=1なら、常にXi+Yi=1
//Wi=0なら、Xi+Yi=2Xi
//つまり、Wi = 1なるiについては常にスコア += 2^i。Wi = 0なるiについてはスコア += 2 * 2^i * Xi。
//ここで、Wj=0なるjについてAiのjビット目を0に置き換えたものをAi'とおく。すると、同じ要素の選び方について、
//Σ2^i * (Xi + Yi) (Wi = 0)は、Aiを使ってもAi'を使っても変化しないので、以降はAi'を用いてみる。
//すると、Wi = 0が常になりたつことになり、スコア = 2Xに変形できる。よって、Xを最大化すればよい。
//今度は、A1'～AN'のうちいくつかを選ぶことで作れるxorの条件（集合）を考える。
//（0個選んでも、全部選んでもxor=0より、そのような場合も考えて良いことに注意する）
//すると、F2上の線形和みたいなので表せる形が条件になることが分かって、線形和（線形従属）といえば掃き出し法なので、
//掃き出し法を実行してみる（(Ai', Aj') -> replace -> (Ai', Ai' xor Aj')してみる）と、作れるxorの集合は変化しない
//ことに気付く。よって、掃き出し法ができ、「自明に貪欲できる形」に変形することができる。

#include <iostream>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
#define rrep(i, n) for(i = n - 1; i >= 0; i--)
using namespace std;

int n;
int a[100000];

signed main() {
	int i, j;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	
	int w = 0;
	rep(i, n) w ^= a[i];
	rep(i, n) a[i] &= ~w;
	
	int cor = 0;
	rrep(i, 60) {
		for (j = cor; j < n; j++) {
			 if ((a[j] >> i) & 1) break;
		}
		if (j == n) continue;
		swap(a[cor], a[j]);
		for (j = cor + 1; j < n; j++) {
			if ((a[j] >> i) & 1) a[j] ^= a[cor];
		}
		cor++;
	}
	
	int x = 0;
	rep(i, n) {
		if ((x ^ a[i]) > x) x ^= a[i];
	}
	
	cout << 2 * x + w << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int N; long long S, A[100100], R[200200];

int main()
{
	scanf ("%d", &N);
	for (int i = 1; i <= N; i++){
		scanf ("%lld", &A[i]);
		S += A[i];
		R[i] = R[i + N] = A[i];
	}

	for (int i = N * 2; i >= 0; i--) R[i] += R[i + 2];
	for (int i = 1; i <= N; i++) printf ("%lld ", S - (R[i + 1] - R[i + N]) * 2);

	return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int N, M;
vector<int>G[100010];
int cnt[100010];
int dep[100010];
int main() {
	REP(i, 100010) {
		cnt[i] = 0;
		dep[i] = 0;
	}
	cin >> N >> M;
	REP(i, N +M- 1) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		cnt[b]++;
	}
	stack<int>st;
	REP(i, N) {
		if (cnt[i] == 0) {
			st.push(i);
		}
	}
	vector<int>ans;
	while (st.size()) {
		int i = st.top(); st.pop();
		ans.push_back(i);
		for (auto j : G[i]) {
			cnt[j]--;
			if (cnt[j] == 0)st.push(j);
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int to : G[ans[i]]) {
			dep[to] = max(dep[to], dep[ans[i]] + 1);
		}
	}
	int root = ans[0];
	int res[100100];
	res[root] = -1;
	REP(i, N) {
		for (int j : G[ans[i]]) {
			if (dep[ans[i]] + 1 == dep[j]) {
				res[j] = ans[i];
			}
		}
	}
	REP(i, N) {
		cout << res[i] + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 7928
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> p(m);
    for(int i = 0;i < m;i++){
          cin >> p[i].first >> p[i].second;
          p[i].first--;
    }
    
    for(int i = 0;i < 1000;i++){
          string s = to_string(i);
          if(s.size() != n){
                continue;
          }
          bool ok = true;
          for(int j = 0;j < m;j++){
                if(s[p[j].first] != p[j].second + '0'){
                      ok = false;
                }
          }
          if(ok){
                cout << s << endl;
                return 0;
          }
    }
    cout << -1 << endl;
}


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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using ld = long double;

template <typename T>
int sz(T &x) {
  return (int)(x.size());
}


const int mod = 998244353;
const int inf = 1'000'000'007;
const ll linf = (ll)(1e18);

int power(int x, int y) {
  if (y == 0) {
    return 1;
  }
  int z = power(x, y >> 1);
  z = z * 1ll * z % mod;
  if (y & 1) {
    z = z * 1ll * x % mod;
  }
  return z;
}

void solve() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  vector<vector<ll> > jump(60, vector<ll> (n + 1, n + 1));
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  map<int, int> lastPos;
  for (int i = n - 1; i >= 0; --i) {
    if (lastPos.count(a[i])) {
      jump[0][i] = lastPos[a[i]] - i + 1;
    }
    lastPos[a[i]] = i;
  }
  for (int i = n - 1; i >= 0; --i) {
    if ((i + jump[0][i]) > n) {
      jump[0][i] = min(jump[0][i], 0ll + (n - i) + lastPos[a[i]] + 1);
    }
  }
  for (int j = 1; j < 60; ++j) {
    for (int i = 0; i < n; ++i) {
      int to = (i + jump[j - 1][i]) % n;
      jump[j][i] = min(linf, jump[j - 1][i] + jump[j - 1][to]);
    }
  }
  int start = 0;
  ll rem = n * 1ll * k - 1;
  for (int i = 59; i >= 0; --i) {
    if (jump[i][start] <= rem) {
      rem -= jump[i][start];
      start = (start + jump[i][start]) % n;
    }
  }

  vector<int> values;
  map<int, int> cnt;
  for (int i = start; i < n; ++i) {
    if (cnt[a[i]] == 0) {
      cnt[a[i]]++;
      values.push_back(a[i]);
    } else {
      while (true) {
        int last = values.back();
        cnt[last]--;
        values.pop_back();
        if (last == a[i]) {
          break;
        }
      }
    }
  }

  for (int i : values) {
    cout << i << " ";
  }
}

int main() {
  #ifndef LOCAL58
    // don't forget to remove if interactive
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
  #endif

  int t;
  t = 1;
  while(t--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 117524
s = input()
t = input()


abc = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
ls = []
lt = []
for i in range(len(abc)):
    ls.append(s.count(abc[i]))
    lt.append(t.count(abc[i]))
ls.sort()
lt.sort()
ans = "Yes"
if len(ls) == len(lt):
    for i in range(len(ls)):
        if ls[i] != lt[i]:
            ans = "No"
            break
else:
    ans = "No"
print(ans)

Measured memory_bytes: 41456
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#include<queue>
#include<tuple>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
#define mp(a,b) make_pair(a,b)
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<int,pi> pii;
typedef pair<ll,pii> pli;
const int INF=1e+9;
const ll INFLL=1e+17;
bool comp(ll &a,ll &b){
  return a>b;
}
bool f[1010][1010][1010];
int main(){
  int x,y,z,k;cin>>x>>y>>z>>k;
  ll a[1010],b[1010],c[1010];
  rep(i,x) cin>>a[i];
  rep(i,y) cin>>b[i];
  rep(i,z) cin>>c[i];
  sort(a,a+x,comp);
  sort(b,b+y,comp);
  sort(c,c+z,comp);
  priority_queue<pli> q;
  int cnt=0;
  ll res[3010];
  fill(f,0);
  q.push(mp(a[0]+b[0]+c[0],mp(0,mp(0,0))));
  f[0][0][0]=true;
  while(cnt<k){
    pli p=q.top();q.pop();
    ll v=p.first;
    int i=p.second.first;
    int j=p.second.second.first;
    int l=p.second.second.second;
    res[cnt]=v;
    cnt++;
    if(i+1<x&&!f[i+1][j][l]){
      q.push(mp(a[i+1]+b[j]+c[l],mp(i+1,mp(j,l))));
      f[i+1][j][l]=true;
    }
    if(j+1<y&&!f[i][j+1][l]){
      q.push(mp(a[i]+b[j+1]+c[l],mp(i,mp(j+1,l))));
      f[i][j+1][l]=true;
    }
    if(l+1<x&&!f[i][j][l+1]){
      q.push(mp(a[i]+b[j]+c[l+1],mp(i,mp(j,l+1))));
      f[i][j][l+1]=true;
    }
  }
  rep(i,k) prin(res[i]);
  

  return 0;
}


Measured memory_bytes: 1006720
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n; cin >> n;
    if(n == 1){
        cout << "Hello World" << endl;
    }
    else{
        ll a, b;
        cin >> a >> b;
        cout << a+b << endl;
    }
}

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


#define ll long long

using namespace std;
inline ll keta(ll n) {
	if (n < 10) return n;

	return keta(n / 10) + n % 10;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	string s;

	cin >> s;
	int sum = 0;

	for (auto x : s) sum += x -'0';

	if (sum % 9 == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3740
using System;
 
class Program{
	static void Main(){
		string s = Console.ReadLine();
		int n;
		while((n = int.Parse(s)) != 0){
			int max = -100001;
			int sum = 0;
			
			while(n-- > 0){
				int m = int.Parse(Console.ReadLine());
				sum += m;
				if(sum > max) max = sum;
				if(sum < 0) sum = 0;
			}
			Console.WriteLine(max);
			s = Console.ReadLine();
		}
	}
}

Measured memory_bytes: 9276
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
int main()
{
	int n = in(), q = in();
	vector<list<int>>L(n);
	REP(i, q)
	{
		int t, x, s;
		switch (in())
		{
		case 0:
			t = in(), x = in();
			L[t].push_back(x);
			break;
		case 1:
			t = in();
			if (L[t].size() != 0)
			{
				auto itr = L[t].begin();
				REP(j, L[t].size())
				{
					if (j != 0)cout << ' ';
					cout << *itr++;
				}
			}
			cout << endl;
			break;
		case 2:
			s = in(), t = in();
			L[t].splice(L[t].end(), L[s]);
			break;
		}
	}
}


Measured memory_bytes: 18712
#include <stdio.h>
 int main() {
     int n;
     scanf("%d", &n);
     int r1 = n / 10;
     int r2 = n % 10;
     if (r1 == 9 || r2 == 9)
         puts("Yes");
     else
         puts("No");
     return 0;
}

Measured memory_bytes: 128
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




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


int main(){

    ll N, M, K;
    cin >> N >> M >> K;

    vll SA(N + 1), SB(M + 1);
    FOR(i, 1, N + 1){ cin >> SA[i]; SA[i] += SA[i - 1]; }
    FOR(i, 1, M + 1){ cin >> SB[i]; SB[i] += SB[i - 1]; }

    ll ans = 0;
    REP(i, N + 1){
        ll rem = K - SA[i];
        if (rem < 0) break;
        ll j = upper_bound(ALL(SB), rem) - SB.begin();
        chmax(ans, i + j - 1);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6428
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int N,H;
  cin >> N >> H;
  vector <int> a(N);
  vector <int> b(N);
  for( int i=0;i<N;i++ )
    cin >> a[i] >> b[i];

  int ma = *max_element(a.begin(), a.end());

  int ans = 0;

  sort(b.begin(), b.end());
  for( int i=N-1;i>-1;i-- )
    {
      if( ma<b[i] )
	{
	  H-=b[i];
	  ans+=1;
	  if(H<=0)
	    {
	      cout << ans << endl;
	      return 0;
	    }
	}
      else
	break;
    }
  if( H%ma==0 )
    ans += H/ma;
  else
    ans += H/ma+1;    
  cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int D = Math.abs(X - sc.nextInt());
        for(int i = 1; i < N; i++){
            int diff = Math.abs(X - sc.nextInt());
            D = gcd(diff, D);
        }
        System.out.println(D);
        sc.close();
    }

    private static int gcd(int x, int y) {

        if(x == 0 || y == 0) return 0;
        int t;
        if(y > x){
            t = y;
            y = x;
            x = t;
        }
        while((t = x % y) != 0 ){
            x = y;
            y = t;
        }
        return y;
    }

}


Measured memory_bytes: 48660
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    int n;
    int k;
    cin >> n >> k;
    int count = 0;
    for (int i = 0; i < n; ++i) {
        int h;
        cin >> h;
        if (h >= k) {
            ++count;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
static const int MAX = 100;
int N;
int ADJ[MAX][MAX];
int depth[MAX];

enum STATUS { ACTIVE = 0, MARKED, VISITED, };
int status[MAX] = {ACTIVE};

void visit(int id) {
  status[id] = VISITED;
}
void mark(int id) {
  status[id] = MARKED;
}

void bfs(int id) {
  queue<int> q;
  q.push(id);
  depth[id] = 0;

  while (!q.empty()) {
    int u = q.front();
    q.pop();
    visit(u);
    for (int i = 0; i < N; i++) { 
      if (ADJ[u][i] && status[i] == ACTIVE) {
        q.push(i);
        mark(i);
        depth[i] = depth[u] + 1;
      }
    }
  }
}

int main() {
  cin >> N;
  int id, nn, x;
  for (int i = 0; i < N; i++) {
    cin >> id >> nn;
    id--; // 0-based
    for (int j = 0; j < nn; j++) {
      cin >> x;
      x--; // 0-based
      ADJ[id][x] = 1;
    }
  }
  for (int i = 0; i < N; i++)
    depth[i] = -1;

  bfs(0);
  for (int i = 0; i < N; i++)
    cout << i+1 << " " << depth[i] << endl;
}

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

int main()
{
  int n;
  int m;
  cin >> n >> m;
  int total = 0;
  for (int i = 0; i < m; i++) {
    int tmp;
    cin >> tmp;
    total += tmp;
  }
  cout << max(-1, n - total) << '\n';
  return 0;
}


Measured memory_bytes: 3636