akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<tuple>
#include<queue>
#include<algorithm>
 
int const MAXN = 50;
double const INF = 1e9;
double const eps = 5e-7;
int x[MAXN], y[MAXN], N;
 
double min_possible(double cx, double cy, double r) {
  double res = 0.0;
  for(int i = 0; i < N; ++i) {
    double dx = x[i] - cx, dy = y[i] - cy;
    dx = std::max(std::fabs(dx) - r, 0.0);
    dy = std::max(std::fabs(dy) - r, 0.0);
    res = std::max(res, dx*dx + dy*dy);
  }
  return std::sqrt(res);
}
 
double calc(double cx, double cy) {
  double res = 0.0;
  for(int i = 0; i < N; ++i) {
    double dx = x[i] - cx, dy = y[i] - cy;
    res = std::max(res, dx*dx + dy*dy);
  }
  return std::sqrt(res);
}
 
int main() {
  std::cin >> N;
  for(int i = 0; i < N; ++i) std::cin >> x[i] >> y[i];
  
  std::queue<std::tuple<double, double, double>> q;
  double ans = INF;
  q.emplace(500.0, 500.0, 500.0);
  while(q.size()>0) {
    double xx, yy, rr; 
    std::tie(xx, yy, rr) = q.front(); q.pop();
    double d = min_possible(xx, yy, rr);
    if(d >= ans - eps*std::max(d, 1.0)) continue; // cut-off no improve
    ans = std::min(ans, calc(xx, yy));
    for(double rx: {-0.5, 0.5}) for(double ry: {-0.5, 0.5}) {
      q.emplace(xx+rx*rr, yy+ry*rr, rr*0.5);
    }
  }
  std::cout << std::setprecision(10) << std::fixed << ans << std::endl;
  return 0;
}

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

int main() {
#define int long long
    int n;
    cin >> n;
    int h[n+1],dp[n+1];
    for(int i=1;i<=n;i++)
    {
        cin >> h[i];
    }
    dp[2]=abs(h[2]-h[1]);
    dp[3]=min(abs(h[3]-h[1]),abs(h[3]-h[2]) + abs(h[2]-h[1]));
    for(int i=4;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n] << endl;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a.at(i);
	}
	sort(a.begin(), a.end(), greater<int>());

	int ans = 0;

	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			ans += a.at(i);
		}
		else {
			ans -= a.at(i);
		}
	}

	cout << ans << endl;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n, m; cin >> n >> m; vector<int>v, result(n, 0);
	rep(i, 0, m) {
		int a; cin >> a; v.push_back(--a);
	}

	rep(i, 0, m) {
		vector<int>vote;
		int x(0);
		rep(j, 0, n) {
			int b; cin >> b; vote.push_back(--b);
			if (vote[j] == v[i]) {
				result[j]++;
			}
			else x++;
		}
		result[v[i]] += x;

	}
	rep(i, 0, n)cout << result[i] << endl;
	return 0;
}

Measured memory_bytes: 3152
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int N, A, B;
  sc.scan(N, A, B);

  writeln(min(N * A, B));
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto A = RD;
	auto B = RD;

	writeln(min(A*N, B));
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main (void) {
    int X;

    cin >> X;

    for (int i = 1; i <= X; i++) {
        if (i * (i + 1) / 2 >= X) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#include<cctype>

#define rep(a,b) for(register int i=a;i<=b;i++)
#define red(a,b) for(register int i=a;i>=b;i--)
#define ULL unsigned long long
#define LL long long

using namespace std;

int cal(int a[])
{
	
}

int main()
{
    int a[3]; 
    cin>>a[1]>>a[2]>>a[3];
    sort(a+1,a+1+3);
    cout<<a[3]*10+a[1]+a[2]<<endl;
}

Measured memory_bytes: 256
def main():
    s = input()
    res = 0
    for i in range(len(s)):
        for j in range(i, len(s)):
            if all("ACGT".count(c) == 1 for c in s[i:j+1]):
                res = max(res, j-i+1)
    print(res)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<iostream>

using namespace std;
int main()
{int A, B, C, X;
 cin >> A >> B >> C >> X;
 
 int cnt = 0;
 
 for(int i = 0; i <= A ; i++)
  {for(int j = 0; j <= B ; j++)
   {for(int l = 0; l <= C ; l++)
    {if(500*i + 100*j + 50*l == X){cnt++;}}}}
 
 cout << cnt << endl;
 
 return 0;
}

Measured memory_bytes: 256
i = [int(input().strip()) for i in range(6)]


for s in range(1,6):
  if s == 1:
    minimum = i[s]
  else:
    if minimum > i[s]:
      minimum=i[s]

tmp = i[0] % minimum
if tmp == 0:
  group = i[0] // minimum
else:
  group = (i[0] // minimum) + 1

print(group + 4)


Measured memory_bytes: 3060
/*  
     author : masaow    
     g++ : 17.3.20  
*/        
#include <bits/stdc++.h>  
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- \n  "
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x)               cout << x << "\n" ; 
#define MOD                100000007
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set ; 
const int N = 2e5+7;  
/*  
    time : 10 : 14    
    date : 24.01.2020
*/    

// int L,R,mid,target,idx ;
ll solve(ll x){ 
  if(x == 1 )
    return 1 ;
  return 1+2*solve(x/2) ; 
}
int tests(){
  ll x ;
  cin >> x ; 
  cout << solve(x) << '\n'  ;  
  return 0 ; 
}
int main(){
    I__O ;  
    int cases = 1 ; 
    // cin >> cases;  
    while(cases--)
      tests(); 
  return 0 ; 
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program {
	static void Main(string[] args) {
		List<Music> snds = new List<Music>();
		int musicCount = int.Parse(Console.ReadLine());
		for(int i=0; i<musicCount; i++) {
			string[] musicInfo = Console.ReadLine().Split(' ');
			snds.Add(new Music(musicInfo[0], int.Parse(musicInfo[1])));
		}
		string sleepMusic = Console.ReadLine();
		int timeSleep = 0;
		bool isSleeping = false;
		foreach(Music m in snds) {
			if(isSleeping) {
				timeSleep += m.t;
			} else if(m.s == sleepMusic) {
				isSleeping = true;
			}
		}
		Console.WriteLine(timeSleep);
	}
	
	class Music {
		public Music(string _s, int _t) {
			s = _s;
			t = _t;
		}
		public string s;
		public int t;
	}
}

Measured memory_bytes: 13268
a = [0,0,0,0]

n = int(input())

for i in range(n):
    s = input()
    if s == 'AC':
        a[0]+=1
    elif s == 'WA':
        a[1]+=1
    elif s == 'TLE':
        a[2]+=1
    else:
        a[3]+=1
print('AC x',a[0])
print('WA x',a[1])
print('TLE x',a[2])
print('RE x',a[3])


Measured memory_bytes: 9196
#include <iostream>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
char data[30][30];

int bfs(int sx,int sy,int gx,int gy){
	int dist[30][30]={0};
	bool done[30][30]={0};
	
	queue<pair<int,int> >Q;
	done[sy][sx] = 1;
	Q.push(make_pair(sx,sy));
	while(Q.size()){
		pair<int,int> q = Q.front(); Q.pop();
		static const int dx[] = {1,-1,0,0},dy[]={0,0,-1,1};
		if(q.first == gx && q.second == gy) return dist[gy][gx];
		rep(i,4){
			int tx = q.first + dx[i] , ty = q.second + dy[i];
			if(data[ty][tx] == 'x')continue;
			if(done[ty][tx])continue;
			done[ty][tx] = true;
			dist[ty][tx] = dist[q.second][q.first]+1;
			Q.push(make_pair(tx,ty));
		}
	}
	return (1<<21);
}
int main(){
	int W,H;
	while(cin >> W >> H , W){
		rep(i,30)rep(j,30)data[i][j] = 'x';
		rep(i,H)rep(j,W)
			cin >> data[i+1][j+1];
		vector< pair<int,int> > pos;
		int sx,sy;
		rep(i,30)rep(j,30)
			if(data[i][j] == '*') pos.push_back(make_pair(j,i));
		rep(i,30)rep(j,30)
			if(data[i][j] == 'o')sx = j , sy = i;

		int dp[1<<10][10];
		rep(i,1<<10)rep(j,10)dp[i][j] =(1<<21);
		int n = pos.size();
		rep(i,n){
			dp[1<<i][i] = bfs(sx,sy,pos[i].first,pos[i].second);
		}
		int dist[10][10] = {0};
		rep(i,n)rep(j,n)dist[i][j] = bfs(pos[i].first,pos[i].second,pos[j].first,pos[j].second);
		
		rep(i,1<<n)rep(j,n)rep(k,n)
			dp[i|(1<<k)][k] = min(dp[i|(1<<k)][k],dp[i][j]+dist[j][k]);
		int ret = (1<<21);
		rep(i,n)ret = min(ret,dp[(1<<n)-1][i]);
		cout << (ret<(1<<21)?ret:-1) << endl;
	}
}

Measured memory_bytes: 952
#include<bits/stdc++.h>
#define ll unsigned long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
using namespace std;
const int N=2e5+10;
int n,m,pa[N],sz[N],res=1;
int find(int x){return pa[x]==x?x:pa[x]=find(pa[x]);}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)pa[i]=i,sz[i]=1;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		int fa=find(a),fb=find(b);
		if(fa!=fb)pa[fa]=fb,sz[fb]+=sz[fa],res=max(res,sz[fb]);
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 5384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL read()
{
    LL x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

const int maxn=1e5+10;
int a[maxn];
int n;
int c[maxn*15];
int pre[maxn*15];
int lowbit(int x)
{
    return x&-x;
}
void add(int x)
{
    for(int i=x;i<=2*maxn;i+=lowbit(i))c[i]++;
}
LL query(int x)
{
    LL res=0;
    for(int i=x;i>0;i-=lowbit(i))res+=c[i];
    return res;
}

//#define maxn 100010
//#define lowbit(x) x&-x
//int c[maxn*10];
//int n,a[],s[N*10];
//void add(int x){
//    for(int i=x;i<=2*maxn;i+=lowbit(i))c[i]++;
//}
//LL query(int x){
//    LL sum=0;
//    for(int i=x;i>0;i-=lowbit(i))sum+=c[i];
//    return sum;
//}
bool check(int x)
{
    memset(c,0,sizeof(c));
    pre[0]=0;
    for(int i=1;i<=n;i++)pre[i]=pre[i-1]+(a[i]>=x?1:-1);
    LL res=0;
    for(int i=0;i<=n;i++){
        res+=query(pre[i]+maxn);
        add(pre[i]+maxn);
    }
    return res>=1LL*n*(n+1)/4;
}

//bool check(int x){
//    for(int i=1;i<=2*maxn;i++)c[i]=0;
//    pre[0]=0;
//    for(int i=1;i<=n;i++)
//        pre[i]=pre[i-1]+(a[i]>=x?1:-1);
//    LL sum=0;
//    for(int i=0;i<=n;i++){
//        sum+=query(pre[i]+maxn);
//        add(pre[i]+maxn);
//    }
//    return sum>=1ll*n*(n+1)/4;
//}
int main()
{
    n=read();
    int L=0,R=0,ans=0;
    for(int i=1;i<=n;i++){
        a[i]=read();
        R=max(R,a[i]);
    }
//        printf("test %d\n",check(30));
    while(L<=R){
        int mid=(L+R)>>1;
//        printf("test %d %d %d %d\n",L,R,mid,check(mid));
        if(check(mid)){
            L=mid+1;ans=mid;
        }
        else{
            R=mid-1;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 8704
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

vin par(60);
vin deep(60);
void init(int n);
int root(int x);
void unite(int x,int y);
bool same(int x,int y);

int main(){
    int n,m;cin>>n>>m;
    vin a(m),b(m);
    rep(i,m)cin>>a[i]>>b[i];
    int ans=0;
    rep(i,m){
        init(n);
        rep(j,m){
            if(j==i)continue;
            unite(a[j],b[j]);
        }
        set<int> judge;
        rep(i,n)judge.insert(root(i+1));
        if(judge.size()!=1)ans++;
    }
    cout<<ans<<endl;
}

void init(int n){
    rep(i,n+1){
        par[i]=i;
        deep[i]=0;
    }
}
int root(int x){
    if(par[x]==x)return x;
    else return par[x]=root(par[x]);
}
void unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y)return;
    if(deep[x]<deep[y])par[x]=y;
    else{
        par[y]=x;
        if(deep[x]==deep[y])deep[x]++;
    }
}
bool same(int x,int y){
    return root(x)==root(y);
}

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

typedef long long int ll;

int main() {
    int a,L;
    cin>>a>>L;
    ll sum=0;
    if(L<0){
        if(1-a<L){
            for(int i=1;i<a+1;i++){
                sum+=L+i-1;
            }
            cout<<sum;
            return 0;
        }
        else{
            for(int i=1;i<a;i++){
                sum+=L+i-1;
            }
            cout<<sum;
            return 0;
        }
    }
    else{
        for(int i=2;i<a+1;i++){
            sum+=L+i-1;
        }
        cout<<sum;
        return 0;
    }

}

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

int main()
{
	string s;
	cin >> s;
	string Wether[3] = {"Sunny", "Cloudy", "Rainy"};
	for (int i = 0; i < 3; ++i)
	{
		if(s == Wether[2])
		{
			cout << Wether[0];
			break;
		}
		else if(s == Wether[i])
		{
			cout << Wether[i+1];
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
S=input()

if S == 'zyxwvutsrqponmlkjihgfedcba':
    ans='-1'
else:
    if len(S)<26:
        for c in [chr(ord('a') + i) for i in range(26)]:
            if c not in S:
                ans = S+c
                break
    else:
        for i in range(25):
            if ord(S[25-i-1]) < ord(S[25-i]):
                for c in sorted(S[25-i:]):
                    if ord(S[24-i]) < ord(c):
                        ans=S[:24-i] + c
                        break
                break

print(ans)

Measured memory_bytes: 38384
import math

N, D = map(int, input().split())

# 2次元リストの用意
X = []

# 2次元リストに格納
for i in range(N):
    X.append([int(i) for i in input().split()])

# print(X)
ans = 0
for i in range(N):

    for j in range(i+1, N):

        total = 0
        for k in range(D):
            total += (X[i][k] - X[j][k]) ** 2
        
        sq = math.sqrt(total)
        if sq  == int(sq): ans += 1


print('{}'.format(ans))

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

b=[] #全部の可能性
for i in range(2**n):
    temp=[]
    for j in range(n):
        if (i>>j)&1==1:
            temp.append(1)
        else:
            temp.append(0)
    b.append(temp)
    
ans=[]
for c in b:
    flag=True
    for i in range(n):
        if flag==True:
            if c[i]==1:
                for k in range(len(xy[i])):
                    if c[xy[i][k][0]]!=xy[i][k][1]:
                        flag=False
                        break
        if i==n-1 and flag==True:
            ans.append(c.count(1))
print(max(ans))


Measured memory_bytes: 10356
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int k = sc.nextInt();
        Long[] a = new Long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        Arrays.sort(a);
        long result = Long.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            if ((i + k - 1) < n && result > Math.abs(a[i] - a[i + k - 1])) {
                result = Math.abs(a[i] - a[i + k - 1]);
            }
        }
        System.out.println(result);

    }

}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
bool used[55];
int cnt;
int n;
bool ok;
void dfs(vector<vector<int>> graph,int x){
    cnt++;
    used[x] = true;
    if(cnt==n){ ok=true; return;}
    rep(i,0,graph[x].size()){
        if(!used[graph[x][i]]) dfs(graph,graph[x][i]);
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int m; cin >> n >>m;
    vector<vector<int>> graph(n);
    vector<pair<int,int>> memo(m);
    rep(i,0,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
        memo[i] = make_pair(a,b);
    }
    rep(i,0,n) sort(all(graph[i]));
    int ans=0;
    rep(i,0,m){
        graph[memo[i].first].erase(lower_bound(all(graph[memo[i].first]),memo[i].second));
        graph[memo[i].second].erase(lower_bound(all(graph[memo[i].second]),memo[i].first));
        rep(i,0,55) used[i] = false;
        cnt=0;
        ok = false;
        dfs(graph,0);
        if(!ok) ans++;
        graph[memo[i].first].push_back(memo[i].second);
        graph[memo[i].second].push_back(memo[i].first);
        sort(all(graph[memo[i].first]));
        sort(all(graph[memo[i].second]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;



int main(){
    ll a,b;
    cin >> a >> b;
    if (a+b>=24){
        a-=24;
    }
    cout << a+b << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n;
    int a;
    int i;
    int ans[9] = {};
    int answer = 0;
    int min;
    int max;
    int x;
    
    scanf("%d", &n);
    for( i = 0; i < n; ++i){
        scanf("%d", &a);
        x = a/400;
        if( x > 7){
            ans[8] = ans[8] + 1;
        }else{
            ans[x] = 1;
        }
    }
    answer = ans[0] + ans[1] + ans[2] + ans[3] + ans[4] + ans[5]  + ans[6] + ans[7];
    if( answer > 0){
        min = answer;
    }else{
        min = 1;
    }
    
    max = answer + ans[8];
    
    printf("%d %d\n", min, max);
    return 0;
}


Measured memory_bytes: 128
use std::io;

fn main() {
    let (n, l) = {
        let v = read_values::<usize>();
        (v[0], v[1])
    };

    let a = read_values::<usize>();
    let mut x = n;
    for i in 0..(n - 1) {
        if a[i] + a[i + 1] >= l {
            x = i;
            break;
        }
    }

    if x == n {
        println!("Impossible");
        return;
    }

    println!("Possible");
    for i in 0..x {
        println!("{}", i + 1);
    }
    for i in (x..(n - 1)).rev() {
        println!("{}", i + 1);
    }
}

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}

fn read_values<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    read_line()
        .split(' ')
        .map(|a| a.trim().parse().unwrap())
        .collect()
}

Measured memory_bytes: 8444
object Main extends App {
  import scala.annotation.tailrec
  
  @tailrec
  def help(s:List[Char],t:List[Char]):List[Char] = {
    s match {
      case h0::h1::tail => help(tail,h0::t)
      case h::Nil => (h::t).reverse
      case _ => t.reverse
    }
  }
  
  val s = readLine.toList
  println(help(s,Nil).mkString)
}

Measured memory_bytes: 40056
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <stack>
#include <queue>
using namespace std;

int main() {
    string S;
    long long K;
    cin >> S >> K;
    long long slen = S.length();
    char ans = '1';
    for (int i = 0; i < min(slen, K); i++) {
        if (S[i] != '1') {
            ans = S[i];
            break;
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <map>
#define ull unsigned long long
using namespace std;

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

    double a[n];
    for (int i=0;i<n;i++) cin>>a[i];
    sort(a, a+n);

    double sum = a[0] + a[1];
    sum/=2;

    for (int i=2;i<n;i++){
        sum = (sum+a[i])/2;
    }

    cout<<setprecision(10)<<fixed<<sum<<endl;
    return 0;
}


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

int h, w, k;

map<pair<int, int>, long long> dp;

long long dfs(int now, int x) {
	if (now == h) return x == k - 1;
	auto status = make_pair(now, x);
	if (dp.count(status)) return dp[status];
	long long res = 0;
	for (int i = 0; i < 1 << (w - 1); i++) {
		bool check = true;
		for (int j = 0; j < w - 2; j++) {
			if ((i >> j & 1) && (i >> (j + 1) & 1)) {
				check = false;
				break;
			}
		}
		if (check) {
			if (0 < x && (i >> (x - 1) & 1)) {
				res += dfs(now + 1, x - 1);
				res %= INF;
			}
			else if (x + 1 < w && ((i >> x) & 1)) {
				res += dfs(now + 1, x + 1);
				res %= INF;
			}
			else {
				res += dfs(now + 1, x);
				res %= INF;
			}
		}
	}
	return dp[status] = res;
}

void hawawa()
{
	string str;
	cin >> str;
	if ("00" < str.substr(0, 2) && str.substr(0, 2) < "13") {
		if ("00" < str.substr(2) && str.substr(2) < "13") {
			cout << "AMBIGUOUS\n";
		}
		else {
			cout << "MMYY\n";
		}
	}
	else {
		if ("00" < str.substr(2) && str.substr(2) < "13") {
			cout << "YYMM\n";
		}
		else {
			cout << "NA\n";
		}
	}
}


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define turbo(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
typedef long long ll;
int main()
{
	turbo();
	string s="",s1="";
	int x,y,tx,ty,i;
	cin>>x>>y>>tx>>ty;
	int j=y;
	s1+="L";
	while(j!=ty){
		s+="U";
		j++;
		s1+="U";
	}
	j=x;
	s1+="U";
	while(j!=tx){
		s+="R";
		s1+="R";
		j++;
	}
	s1+="RD";
	int sz=s.size(); 
	for(i=0;i<sz;i++){
		if(s[i]=='U'){
			s+="D";
		}
		else{
			s+="L";
		}
	}
	sz=s1.size();
	for(i=0;i<sz;i++){
		if(s1[i]=='U'){
			s1+="D";
		}
		else if(s1[i]=='D'){
			s1+="U";
		}
		else if(s1[i]=='L'){
			s1+="R";
		}
		else{
			s1+="L";
		}
	}
	s+=s1;
	cout<<s<<endl;
	return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign

signed main()
{
    int n, m, ans = 0;
    vi path;
    cin >> n >> m;
    vvb graph(n, vb(n, false));
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        graph[a-1][b-1] = true;
        graph[b-1][a-1] = true;
    }
    rep(i, n) { path.pb(i); }
    do {
        int bef = 0, ret = 1;
        //rep(i, n) { cout << path[i]; } cout << endl;
        Rep(i, n) {
            if (!graph[bef][path[i]]) {
                ret = 0;
                break;
            }
            bef = path[i];
        }
        ans += ret;
    } while (next_permutation(path.begin()+1, path.end()));

    cout << ans << endl;

    return 0;
}



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

int main() {
  int n;
  cin>>n;
  vector<int> len(n);
  for (int i = 0; i < n; i++) {
    cin>>len[i];
  }
  sort(len.begin(), len.end());
  int sum = 0;
  for (int i = 0; i < n-1; i++) {
    sum += len[i];
  }
  cout<<(sum > len[n-1] ? "Yes":"No")<< endl;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b = inpl()
s = input()
kaku = 0
e = 0
for _,t in enumerate(s):
    if t == 'a':
        if kaku < a+b:
            print('Yes')
            kaku += 1
        else: print('No')
    elif t == 'b':
        if kaku < a+b and e < b:
            print('Yes')
            kaku += 1; e+= 1
        else: print('No')
    else:
        print('No')
    

Measured memory_bytes: 79572
from collections import defaultdict
from heapq import heappop, heappush
class Graph(object):
    """
    隣接リストによる有向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    """
    ダイクストラ法（二分ヒープ）による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start):
        self.g = graph.graph

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        """
        startノードからgoalノードまでの最短距離
        """
        return self.dist[goal]

    def shortest_path(self, goal):
        """
        startノードからgoalノードまでの最短経路
        """
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]
import sys
input = sys.stdin.readline
def solve():
  n,m = (int(i) for i in input().split())
  route = Graph()
  tmp = [[0]*n for _ in range(n)]
  
  for i in range(m):
    a,b,c = (int(i) for i in input().split())
    route.add_edge(a-1,b-1,c)
    route.add_edge(b-1,a-1,c)
    tmp[a-1][b-1] = 1

  
  for i in range(n):
    #iを始点としてjに着く経路
    ds = Dijkstra(route,i)
    for j in range(n):
      if not i== j:
        query = ds.shortest_path(j)
        for k in range(len(query)-1):
            tmp[query[k]][query[k+1]] = 0
  ans = 0
  for i in range(n):
    ans += sum(tmp[i])
  print(ans)
        
solve()

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

class UnionFind
{
public:
		vector<int> data;
		UnionFind(int size):data(size, -1){}

		bool unionSet(int x, int y)
		{
			x = root(x); y=root(y);
			if(x != y)
			{
				if(data[y] < data[x]) swap(x, y);
				data[x] += data[y]; data[y] = x;
			}
			return x != y;
		}
		int root(int x)
		{
			return data[x] < 0 ? x:data[x]=root(data[x]);
		}

};


int main()
{
	int N;
	while(cin >> N, N)
	{
		UnionFind uf(N*N);
		for(int i=0; i<N; i++)
		for(int j=0; j<N; j++)
		{
			int x,y;
			cin >> x >> y;
			uf.unionSet(i*N+j, y*N+x);
		}
		
		bool used[10000]={0};
		int ret=0;
		for(int i=0; i<N; i++)
		for(int j=0; j<N; j++)
		{
			if(used[uf.root(i*N+j)]) continue;
			used[uf.root(i*N+j)]=1;
			ret++;
		}
		
		cout << ret << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int a, b, n, m, mi=1000000, ma=0;
	cin >> n >> m;
	rep(i, m) {
		cin >> a >> b;
		ma = max(ma, a);
		mi = min(mi, b);
	}
	cout << max(mi - ma + 1, 0ll) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int scores(int iwa, int yam, int a, int b, int c, int d)
{
    return iwa*a + yam*b + (int)(iwa/10)*c + (int)(yam/20)*d;
}

int main()
{
    int h1, h2;
    int k1, k2;
    int a, b, c, d;

    while(cin>>h1>>h2) {
        cin >> k1 >> k2;
        cin >> a >> b >> c >> d;

        int h_score = scores(h1, h2, a, b, c, d);
        int k_score = scores(k1, k2, a, b, c, d);

        if (h_score > k_score) {
            cout << "hiroshi" << endl;
        } else if (h_score < k_score) {
            cout << "kenjiro" << endl;
        } else {
            cout << "even" << endl;
        }
    }
    return 0;
}

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

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

    vector<long long int> a(3*n);
    for(int i=0; i<3*n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    long long int ans = 0;
    for(int i=1; i<2*n; i+=2){
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5520
N, K = map(int,input().split())
 
count = 0
 
# N = n*b + r
for b in range(1,N+1):
    n = N // b
    r = N % b
    count += n*max(0,b-K) + max(0,r-K+1)
 
# a=0の場合を引く
if K==0:
    count -= N
 
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;
int main(){
    string S;
    int prace = 700;
    cin >> S;
    for(int i=0;i < 3;i++){
        if(S[i] == 'o'){
            prace += 100;
        }
    }
cout << prace << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  int ans=0;
  
  for(int i=1; i<=n; i++){
    if(i<10||i>99 && i<1000||i>9999 && i<100000||i>999999)ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3628
//People only find me interesting because they can't tell whether I'm serious or not

#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
typedef double db;
//typedef __int128 s128;
//typedef __uint128_t u128;
//typedef unsigned long long u64;
#define int long long int
#define P 998244353
#define Q 1000000006
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define N 100005
#define PI 3.14159265359
#define inf LLONG_MAX
using namespace __gnu_pbds;
using namespace std;
void solve(){
    ll h1,h2,m1,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    ll tot = (h2-h1)*60 + (m2-m1);
    cout<<max(0ll, tot-k);
}
signed main() {
    teevra_gati
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    solve();
    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



ll n, m;
ll a[maxn];

vector<pair<ll,ll>> v;


vector<pair<ll,ll>> ev[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n>>m;
    for (int i=0; i<n; i++) {
	cin>>a[i];
	--a[i];
    }

    for (int i=0; i+1<n; i++) {
	v.push_back({a[i],a[i+1]});
    }

    n = v.size();
    ll tot = 0;

    for (int i=0; i<n; i++) {
	auto p = v[i];
	ll from = p.first;
	ll to = p.second;
	ll dist = (to-from+m)%m;
	tot += dist;
	ev[from].push_back({0,i});
	ev[to].push_back({1,i});
	//0: open, 1: close
    }

    ll best = tot;

    set<ll> active;//ids
    ll saving = 0;
    for (int i=0; i<m*2; i++) {
	saving += (ll)active.size();
	ll cur = tot - saving + (ll)active.size();

	best = min(best, cur);
	
	for (auto p: ev[i%m]) {
	    int id = p.second;
	    if (p.first == 0) {
		active.insert(id);
	    } else if (p.first == 1) {
		if (active.count(id)) {
		    ll from = v[id].first; ll to = v[id].second;
		    ll dist = (to-from+m)%m;
		    saving -= dist;
		    active.erase(id);
		}
	    }
	}
    }

    out(best);

    return 0;
}


Measured memory_bytes: 35440
#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);
    string s, t;
    cin >> s >> t;
    if(s.size()+1 == (t.size()) && s.substr(0, s.size()) == t.substr(0, s.size())) Yes();
    else No();
}

Measured memory_bytes: 3652
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 500005
#define M 200005
#define seed 23333
#define mo 998244353
#define Mo 1000000007

using namespace std;
int i,j,m,n,p,k,fail[N],Fail[N],ans;
char c[N],s[N];
int main()
{
		scanf("%s",c+1); n=strlen(c+1);
		for (i=2;i<=n;++i)
		{
				while (j&&c[j+1]!=c[i]) j=fail[j];
				if (c[j+1]==c[i]) ++j;
				fail[i]=j;
		}
		if (n%(n-fail[n])!=0||!fail[n]) 
		printf("1\n1\n");
		else 
		if (n-fail[n]==1) printf("%d\n1\n",n);
		else 
		{
			for (i=1;i<=n;++i) s[n-i+1]=c[i];
			for (i=2,j=0;i<=n;++i)
			{
				while (j&&s[j+1]!=s[i]) j=Fail[j];
				if (s[j+1]==s[i]) ++j;
				Fail[i]=j;
			}	
			for (i=1;i<n;++i)
				if ((!fail[i]||i%(i-fail[i])!=0)&&(!Fail[n-i]||(n-i)%(n-i-Fail[n-i])!=0)) ++ans;
			printf("2\n%d\n",ans);				
		}
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
const int N=1e3+5;
int H,W,A,B,i,j,a[N];
char c[N][N];
inline void solve(int p,int q){
	int i,j,k;
	for(i=1;i<=q;++i)a[i]=B;for(;i<=W;++i)a[i]=H-B;
	for(i=1;i<=H;++i){
		k=i<=p?A:W-A;
		for(j=1;j<=W;++j)if(a[j] && k)--a[j],--k,c[i][j]='1';
		puts(c[i]+1);
	}
	exit(0);
}
int main(){
	scanf("%d%d%d%d",&H,&W,&A,&B);
	for(i=1;i<=H;++i)for(j=1;j<=W;++j)c[i][j]='0';
	for(i=0;i<=H;++i)for(j=0;j<=W;++j)if(A*i+(W-A)*(H-i)==B*j+(H-B)*(W-j))solve(i,j);
	puts("-1");
}

Measured memory_bytes: 2176
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n,m=MI()
	A=LI()
	A.sort(reverse=True)
	S=sum(A)


	ans="Yes"

	for i in range(m):
		if A[i]*4*m<S:
			ans="No"
			break

	print(ans)
















if __name__ == "__main__":
	main()


Measured memory_bytes: 62092
N = int(input())
A = list(map(int, input().split()))
ans = 0
while True:
    isAllEven = True
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] = A[i] // 2
        else:
            isAllEven = False

    if isAllEven == False:
        break;
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr ll INF = 1e18 + 10;
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;
//    cout << setprecision(20) << ans << "\n";

vector<pair<ll, ll>> primeFactorize(ll N)
{
    vector<pair<ll, ll>> res;
    for (ll a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        ll ex = 0;

        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }

    if (N != 1)
        res.push_back({N, 1});
    return res;
}

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

    char c;
    cin >> c;
    if (c >= 'A' && c <= 'Z')
    {
        cout << "A"
             << "\n";
    }
    else
    {
        cout << "a"
             << "\n";
    }

    return 0;
}


Measured memory_bytes: 3640
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return table


def main():
    X = int(input())

    table = sieve(10**6)
    for p in table:
        if p >= X:
            print(p)
            return


if __name__ == '__main__':
    main()

Measured memory_bytes: 16800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll max_n=2e5+100;
const ll inf=0x3f3f3f3f;
ll t,n,m,p[max_n],v[max_n],q[max_n],dp[max_n];
int main(){
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n>>m;
    ll wmax=0,sum=0;
    for(int i=0;i<n;i++){
        cin>>q[i]>>p[i];
        sum+=p[i];
    }
    memset(dp,0x3f,sizeof(dp));
    ll ans=0;
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(ll j=sum;j>=p[i];j--){
            dp[j]=min(dp[j],dp[j-p[i]]+q[i]);
            if(dp[j]<=m){
                ans=max(ans,j);
            }
        }
    }cout<<ans<<endl;
    return 0;
}


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

int main() {
	int N, T;
	cin >> N >> T;
	vector<int> vec(2);
	vector<int> cost(N);
	int count = 0;

	for (int i = 0; i < N; i++) {
		cin >> vec.at(0) >> vec.at(1);

		if (vec.at(1) <= T)
			cost.at(i) = vec.at(0);
		else
			count++;
	}

	if (count == N)
		cout << "TLE" << endl;
	else {
		sort(cost.begin(), cost.end());
		cout << cost.at(count) << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[200005],n;
bool b[200005];
inline bool pd(int x){
	for(int i=1;i<=n*2-1;i++)
		b[i]=(a[i]>=x);
	b[0]=b[1];
	for(int i=n;i<=n+n-1;i++){
		if(b[i]==b[i+1]) return b[i];
		if(b[n+n-i]==b[n+n-i-1]) return b[n+n-i];
	}
	return b[1];
}
int main(int argc, char** argv) {
	cin >> n;
	for(int i=1;i<=n*2-1;i++) cin >> a[i];
	int l=1,r=n*2,ans=0;
	while(l<=r){
		int md=(l+r)/2;
		if(pd(md))
			l=md+1,ans=max(ans,md); 
		else
			r=md-1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1280
import math
from itertools import permutations

n = int(input())
l = []
for i in range(n):
    x, y = map(int, input().split())
    l.append([x, y])

ans = []
for i in permutations(range(n)):
    temp = 0
    for j in range(n-1):
        temp += math.sqrt((l[i[j+1]][0] - l[i[j]][0])**2 + (l[i[j+1]][1] - l[i[j]][1])**2)
    ans.append(temp)

print(sum(ans)/len(ans))

Measured memory_bytes: 42476
[N, K] = list(map(int, input().split()))
answer = 0
for i in range(K, N+2):
    S_min = i*(i-1)/2
    S_max = (2*N-i+1) * i/2
    answer += S_max - S_min +1
answer %= 7+10**9
print(int(answer))

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

// マクロ
// forループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair



int main() {
    int N, K; cin >> N >> K;
    int d[109], A[109][109];
    REP(i, K) {
        cin >> d[i];
        REP(j, d[i]) cin >> A[i][j]; 
    }

    int sunuke[109];
    FOR(i, 1, N) sunuke[i] = 0;
    REP(i, K) {
        REP(j, d[i]) {
            sunuke[A[i][j]]++;
        }
    }
    int ans = 0;
    FOR(i, 1, N) {
        if (sunuke[i] == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3680
import math
import collections
import itertools

def YesNo(Bool):
    if(Bool):
        print("Yes")
    else:
        print("No")
    return

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return len(lower_divisors) + len(upper_divisors[::-1])


def getNumsOfDivisorsOfEachNumbers(n: int):
    # validation check
    if not isinstance(n, int):
        raise("[ERROR] parameter must be integer")
    if n < 0:
        raise("[ERROR] parameter must be not less than 0 (n >= 0)")
    nums = [0] * (n + 1) # 0-indexed
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            nums[j] += 1
    nums.pop(0)
    return nums

def resolve():

    N=int(input())


    print(sum(getNumsOfDivisorsOfEachNumbers(N-1)))
    # cnt=0
    # for i in range(N):
    #     cnt+=num_divisors_table(i)

    # print(cnt)

resolve()


Measured memory_bytes: 16968