akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//  test
//
//  Created by 田宇航 on 2019/8/4.
//  Copyright © 2019 田宇航. All rights reserved.
//
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<stack>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define MAXN 100000+50
#define MAXM 30000
#define ll long long
#define rep(i,n,m) for(int i=n;i<=m;++i)
#define mod 1000000000 + 7
#define mian main
#define mem(a, b) memset(a, b, sizeof a)
#ifndef ONLINE_JUDGE
#define dbg(x) cout << #x << "=" << x << endl;
#else
#define dbg(x)
#endif
inline int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        x = 10 * x + ch - '0';
        ch = getchar();
    }
    return x * f;
}
int a[MAXN];
//1 1 1 1 1   RL R L R    L   RL R R  
int main()
{
    //while(1){
        
    int n=read();
    rep(i,1,n) a[i]=read();
        for(int i=n;i>1;--i)
    if(a[i]-a[i-1]<0) a[i-1]--;
    bool flag=0;
    rep(i,1,n-1)
    {
        if(a[i]-a[i+1]>0) {flag=1;break;}
    }
    if(flag) puts("No");
    else puts("Yes");
   // }
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final double D8 = 0.08;
		final double D10 = 0.10;
		int a = sc.nextInt();
		int b = sc.nextInt();

		for(int i = 0; i <= 100 / D8; i++) {
			if( a == (int)( i * D8) ) {
				if( b == (int)(i * D10) ) {
					System.out.println(i);
					System.exit(0);
				}
			}
		}
		System.out.println(-1);
	}
}


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

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

    set<int> P;
    int p;
    for (size_t i = 0; i < N; i++)
    {
        cin >> p;
        P.insert(p);
    }

    for (int i = 0; i < 200; i++)
    {
        if (P.find(X - i) == P.end())
        {
            cout << X - i << endl;
            return 0;
        }
        if (P.find(X + i) == P.end())
        {
            cout << X + i << endl;
            return 0;
        }
    }
}


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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), k = fs.nextInt();
		double p = 0;
		
		for(int i=1;i<=n;i++) {
			int t = i;
			double q = 1.0/n;
			while(t<k) {
				t <<= 1;
				q /= 2.0;
			}
			p += q;
		}
		System.out.println(p);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 21972
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, d int
	fmt.Scan(&n, &d)
	x := make([][]float64, n)
	for i := 0; i < n; i++ {
		x[i] = make([]float64, d)
	}
	
	for i := range x {
		for j := range x[i] {
			var num float64
			fmt.Scan(&num)
			x[i][j] = num
		}
	}

	var counter int

	for i := 0; i < n-1; i++ {
		for j := i+1; j < n; j++ {
			dist := 0.0
			for k := 0; k < d; k++ {
				dist += math.Pow((x[i][k] - x[j][k]), 2.0) 
			}
			dist = math.Sqrt(dist)
			if dist == math.Ceil(dist) {
				counter++
			}
		}
	}

	fmt.Println(counter)
}


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

using namespace std;


int main()
{
    int N;
    int dig1, dig10, dig100;
    cin >> N;
    dig1 = N % 10;
    dig10 = N / 10 % 10;
    dig100 = N /100;

    if (dig100 == dig10) {
        if (dig10 >= dig1) {
            cout << dig100*100 + dig100*10 + dig100 << endl;
        } else {
            dig100++;
            cout << dig100*100 + dig100*10 + dig100 << endl;
        }

    } else if (dig100 > dig10) {
        cout << dig100*100 + dig100*10 + dig100 << endl;
    } else {
        dig100++;
        cout << dig100*100 + dig100*10 + dig100 << endl;
    }
    
    
    return 0;   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int n,m;
int32_t main(){
    fastio;
    cin >> n >> m;
    vector<int> p(m);
    vector<int> blb[m];
    for(int i=0;i<m;i++){
        int x;
        cin >> x;
        for(int j=0;j<x;j++){
            int k;
            cin >> k;
            k--;
            blb[i].pb(k);
        }
    }
    for(int i=0;i<m;i++) cin >> p[i];
    int lim = pow(2,n);
    int ans = 0;
    for(int i=0;i<lim;i++){
        bool ok = true;
        //cout << i << " : " << endl;
        for(int j=0;j<m;j++){
            int k = 0;
            for(int x : blb[j]){
                if(i&(1<<x)){
                    k++;
                }
            }
            //cout << k << " " << p[j] << endl;
            if(k%2 != p[j]){
                ok = false;
                break;
            }
        }
        ans+=ok;
    }
    cout << ans << endl;
}

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

#define LL long long
int g[10][10], ans;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n, m, x, y; cin >> n >> m;
    while(m--) {
        cin >> x >> y;
        g[x][y]++, ++g[y][x];
    }

    vector<int> v(n);
    for(int i = 0; i < n; i++) v[i] = i + 1;

    do {
        bool ok = 1;
        for(int i = 1; i < n; i++) if(!g[v[i-1]][v[i]]) ok = 0;
        ans += ok;
    }
    while(next_permutation(v.begin() + 1, v.end()));

    cout << ans;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <math.h>

int main(void)
{
	int a,b,digit;
	while(1){
		if(scanf("%d %d",&a,&b) ==EOF) break;
		digit = log10((double)(a+b));
		printf("%d\n",digit+1);
	}
	return 0;
}

Measured memory_bytes: 1072
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
W = [int(stdin.readline().rstrip()) for _ in range(N)]

def check(P):
    i = 0
    for _ in range(K):
        s = 0
        while s+W[i] <= P:
            s += W[i]
            i += 1
            if i == N:
                return N
    return i

def solver():
    mid, l, u = 0, 0, 100000*10000
    while u-l > 1:
        mid = (l+u)//2
        v = check(mid)
        if v >= N:
            u = mid
        else:
            l = mid
    return u
    
print(solver())


Measured memory_bytes: 9580
package main
 
import (
  "fmt"
)
 
func main() {
  var N, M int
  var a, b int
  fmt.Scan(&N)
  fmt.Scan(&M)
  
  city := make(map[int]int)
  for i := 0; i < M; i++ {
    fmt.Scan(&a)
    fmt.Scan(&b)
    city[a]++
    city[b]++
  }
  for i := 1; i <= N; i++ {
	fmt.Printf("%d\n", city[i])
  }
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<int> x;
  Solver(LL n) : n(n), x(n){};

  void solve() {
    for (int i = 0; i < n; ++i) {
      cin >> x[i];
    }
    int ans = INF;
    for (int i = 1; i <= 100; ++i) {
      int tmp = 0;
      for (int j = 0; j < n; ++j) {
        tmp += (x[j] - i) * (x[j] - i);
      }
      ans = min(ans, tmp);
    }
    cout << ans << endl;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    long n;
    cin >> n;
 
    vector<long long> p(n);
    for (auto &x : p) {
        cin >> x;
    }
 
    vector<long long> q(n);
    for (auto &x : q) {
        cin >> x;
    }
 
    vector<long long> tmp = p;
 
    sort(tmp.begin(), tmp.end());
 
    long long ip = 0;
    long long iq = 0;
    long long index = 0;
    do {
        if (p == tmp) {
            ip = index;
        }
        if (q == tmp) {
            iq = index;
        }
        index++;
 
    }while(next_permutation(tmp.begin(), tmp.end()));

    cout << abs(ip - iq) << endl;
}

Measured memory_bytes: 3616
N = int(input())
D,X = map(int, input().split())
A = []

for i in range(N):
  A.append(int(input()))


counter = 0

for i in A:
  j = i
  # counter +=1
  # j = 2 * j + 1
  r = i
  y = 1
  counter +=1
  while r <= D:
    # print(r)
    r = j * y + 1
    y += 1
    if r <= D:
      counter+=1



# print("_______________________")
print(counter + X)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
    #define m ((long long)1e9+7)
    using namespace std;
     
    int main() {
        ios_base::sync_with_stdio(false);cin.tie(NULL);
    	int h,w;cin>>h>>w;
    	long long dp[h+1][w+1];
    	for(int i=0;i<=h;i++)
    	for(int j=0;j<=w;j++)
    	dp[i][j]=0;
    	char c;
    	for(int i=1;i<=h;i++)
    	{
    	    for(int j=1;j<=w;j++)
    	    {
    	        cin>>c;
    	        if(c=='#')
    	        dp[i][j]=-1;
    	    }
    	}
    	dp[1][1]=1;
    	for(int i=1;i<=h;i++)
    	{
    	    for(int j=1;j<=w;j++)
    	    {
    	        if((i!=1||j!=1)&&dp[i][j]!=-1){
    	        if(dp[i-1][j]!=-1&&dp[i][j-1]!=-1)
    	        dp[i][j]=(dp[i][j-1]+dp[i-1][j])%m;
    	        else if(dp[i-1][j]==-1&&dp[i][j-1]==-1)
    	        dp[i][j]=0;
    	        else if(dp[i-1][j]==-1)
    	        dp[i][j]=dp[i][j-1];
    	        else
    	        dp[i][j]=dp[i-1][j];}
    	    }
    	}
    	cout<<dp[h][w]<<endl;
    	return 0;
    }

Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
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;}
const long long INF=1LL<<60;
//set<int>::iterator it;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	string str,t;
	set<string> s;
	int i,n;
	set<string>::iterator it;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>str;
		if(i!=0&&str[0]!=t[t.length()-1]){
			cout<<"No"<<endl;
			return 0;
		}
		s.insert(str);
		t=str;
	}
	if(s.size()!=n){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	
	
	return 0;
}

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

using namespace std;

int main(){

  int n,m;
  cin >> n >> m;
  int a[n][m],b[m];
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> a[i][j];
    }
  }
  for(int i=0;i<m;i++){
    cin >> b[i];
  }
  for(int i=0;i<n;i++){
    int sum =0;
    for(int j=0;j<m;j++){
      sum += (a[i][j]*b[j]);
    }
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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



int main() {
	
	int a, b, c;
	cin >> a >> b >> c;
	
	int ans = -1;
	rep(i, 100){
		int tmp = 60 * i + c;
		if(tmp % (a + b) <= a){
			ans = tmp;
			break;
		}
	}

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

Measured memory_bytes: 3080
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    char[] S = scn.nextLine().toCharArray();
    ArrayList<Character> Slist = new ArrayList<>();
    for (Character ch : S) {
      Slist.add(ch);
    }

    int count = 0;
    int i = 0;
    while (i < Slist.size() - 1) {
      String chunk = Slist.get(i).toString() + Slist.get(i + 1).toString();

      if (chunk.equals("10") || chunk.equals("01")) {
        count += 2;
        Slist.remove(i);
        Slist.remove(i);
        i = (i - 1 < 0) ? 0 : --i;
      } else {
        i++;
      }

    }

    System.out.println(count);
  }

}


Measured memory_bytes: 44428
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class A {
        public void solve(int testNumber, InputReader sc, PrintWriter out) {
            String s = sc.nextLine();
            if (s.equals("ARC"))
                out.println("ABC");
            else out.println("ARC");
        }

    }

    static class InputReader {
        BufferedReader br;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}



Measured memory_bytes: 32564
from operator import itemgetter
N, H = map(int, input().split())
b = []
a = []
for i in range(N):
    n, m = map(int, input().split())
    b.append(m)
    a.append(n)
a_max = max(a)
ans = 0
b.sort(reverse = True)
for i in range(N):
    if H <= b[i] or H <= a_max:
        ans += 1
        break
    if b[i] >= a_max:
        H -= b[i]
        ans += 1
        if i == N-1:
            ans += 1 + ((H-1) // a_max)

    else:
        ans += 1 + ((H-1) // a_max)
        break
print(ans)


Measured memory_bytes: 61784
/*
░░░░░░░░░░░░░░░░▄▄█▀▀██▄▄░░░░░░░
░░░░░░░░░░░░░▄█▀▀░░░░░░░▀█░░░░░░
░░░░░░░░░░░▄▀░░░░░░░░░░░░░█░░░░░
░░░░░░░░░▄█░░░░░░░░░░░░░░░█░░░░░
░░░░░░░██▀░░░░░░░▄▄▄░░▄░█▄█▄░░░░
░░░░░▄▀░░░░░░░░░░████░█▄██░▀▄░░░
░░░░█▀░░░░░░░░▄▄██▀░░█████░██░░░
░░░█▀░░░░░░░░░▀█░▀█▀█▀▀▄██▄█▀░░░
░░░██░░░░░░░░░░█░░█░█░░▀▀▄█▀░░░░
░░░░█░░░░░█░░░▀█░░░░▄░░░░░▄█░░░░
░░░░▀█░░░░███▄░█░░░░░░▄▄▄▄█▀█▄░░
░░░░░▀██░░█▄▀▀██░░░░░░░░▄▄█░░▀▄░
░░░░░░▀▀█▄░▀▄▄░▄░░░░░░░███▀░░▄██
░░░░░░░░░▀▀▀███▀█▄░░░░░█▀░▀░░░▀█
░░░░░░░░░░░░▄▀░░░▀█▄░░░░░▄▄░░▄█▀
░░░▄▄▄▀▀▀▀▀█▀░░░░░█▄▀▄▄▄▄▄▄█▀▀░░
░▄█░░░▄██▀░░░░░░░░░█▄░░░░░░░░░░░
█▀▀░▄█░░░░░░░░░░░░░░▀▀█▄░░░░░░░░
█░░░█░░░░░░░░░░░░░░░░░░█▄░░░░░░░*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define mp make_pair
const ll mod = 1000000007;
const ll nmax=2525*1001;
#define int ll
int n, q;
string s, t;
vi v[30];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
	cin>>s>>t;
	for(int i=0; i<s.size(); i++){
		v[s[i]-'a'].pb(i);
	}
	int rotations=0, last=-1;
	for(int i=0; i<t.size(); i++){
		int c=t[i]-'a';
		if(v[c].empty()) return cout<<-1, 0;
		auto it=upper_bound(v[c].begin(), v[c].end(), last);
		if(it==v[c].end()) rotations++, last=v[c][0];
		else last=*it;
	}
	cout<<rotations*s.size()+last+1;
}

Measured memory_bytes: 1736
#coding:utf-8
n = int(input())
max_rank = 0

for i in range(n):
    a, b = map(int, input().split())
    #持ってる情報で最下位になっているデータがあれば、それより低い点の人はさらにb人いる
    if max_rank < a:
        max_rank = a
        ans = max_rank + b

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
   int n,k;
   cin >> n >>k;
   int a[n];
   for(int i=0;i<n;i++){ 
      cin >>a[i];
   }
   sort(a,a+n);
   int sum = 0;
   for(int i=0;i<k;i++){ 
      sum += a[i];
   }
   cout << sum<<endl;
    
}


Measured memory_bytes: 3564
import java.util.*;

class Main{

    int INF = Integer.MAX_VALUE;

    void solve(){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] ab = new int[m][2];
        for(int i=0; i<m; i++){
            ab[i][0] = sc.nextInt()-1;
            ab[i][1] = sc.nextInt()-1;
        }

        Arrays.sort(ab, new Comparator<int[]>(){
                public int compare(int[] a, int[] b){
                    if(a[0]>b[0]) return 1;
                    if(a[0]<b[0]) return -1;
                    if(a[1]>b[1]) return 1;
                    if(a[1]<b[1]) return -1;
                    return 0;
                }
            });

        int cnt = 0;
        int idx = 0;
        while(idx<n){
            int max = -1;
            for(int i=0; i<m; i++){
                if(ab[i][0]>idx) break;
                if((max==-1 || ab[max][1]<ab[i][1]) && ab[i][1]>=idx) max = i;
            }
            if(max==-1) break;
            idx = ab[max][1]+1;
            ab[max][0] = -1;
            cnt++;
        }

        if(idx!=n) System.out.println("Impossible");
        else System.out.println(cnt);
    }

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

Measured memory_bytes: 20460
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

  int n;
  double t, a;
  cin>>n>>t>>a;
  double diff = 100000000000;
  int num = 0;
  REP(i, n)
  {
    double x;
    cin >> x;
    if (abs((t -x*0.006)-a)<diff){
      diff = abs((t - x * 0.006) - a);
      num = i + 1;
    }
  }
  cout << num << endl;
}


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

int dif3(int a, int b, int c) { return max({a, b, c}) - min({a, b, c}); }

int dif2(int x, int y) {
  int y0 = y / 3;
  int y1 = y - y0;
  int t1, t2;
  int x0 = x / 2;
  int x1 = x - x0;
  t1 = dif3(x * y0, y1 * x0, y1 * x1);
  t2 = dif3(x * (y0 + 1), (y1 - 1) * x0, (y1 - 1) * x1);
  // cerr << x << " " << y << " " << t1 << " " << t2 << endl;
  return min(t1, t2);
}

int main() {
  int h;
  int w;
  cin >> h >> w;
  if (h % 3 == 0 || w % 3 == 0) {
    cout << 0 << endl;
    return 0;
  }
  int ans = min({h, w, dif2(h, w), dif2(w, h)});
  cout << ans << endl;
}

Measured memory_bytes: 256
A,B=map(int,input().split())
S=str(input())
ans="Yes"
num="0","1","2","3","4","5","6","7","8","9"
for i in range(A+B+1):
    if i<A:
        if S[i] not in num:
            ans="No"
            break
    elif i==A:
        if S[i]!="-":
            ans="No"
            break
    elif i<=A+B:
        if S[i] not in num:
            ans="No"
            break
print(ans)

Measured memory_bytes: 8856
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

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

    int N; cin >> N;
    ll m_count = 0;
    vector<ll> A(N); vector<ll> B(N);
    rep(i, N) {
        cin >> A[i];
        if(A[i] <= 0) {
            B[i] = (-1) * A[i];
            m_count ++;
        }
        if(A[i] > 0) B[i] = A[i];
    }
    sort(B.begin(), B.end());
    ll sum = 0;
    rep(i, N) sum += B[i];
    if (m_count % 2 == 0) cout << sum << endl;
    if (m_count % 2 == 1) cout << sum - 2 * B[0] << endl;
    
 

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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 main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int ans;
    rep(i,5){
        int x;
        cin >> x;
        if(x == 0){
            ans = i+1;
            break;
        }
    }

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


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

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
	int n, k, q;
	cin>>n>>k>>q;
	int c;
	vector<int> a, b;
	rep(i, q){
		cin>>c;
		a.push_back(c);
	}
	rep(i, n){
	b.push_back(k - q);
	}
	rep(i, q){
		b[a[i] - 1]++;
	}
	rep(i, n){
		if(b[i] > 0)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1528
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

pub fn keta(mut n: u64) -> u64 {
    let mut k = 0;
    let d = 10;
    while n != 0 {
        k += 1;
        n /= d;
    }
    k
}

pub fn divisor(n: u64) -> Vec<u64> {
    let mut res = Vec::new();
    for i in (1..).take_while(|x| x * x <= n) {
        if n % i == 0 {
            res.push(i);
            if i != n / i {
                res.push(n / i);
            }
        }
    }
    res
}

fn main() {
    input! {
        n: u64
    }
    let v = divisor(n);
    let res = v.iter().fold(std::u64::MAX, |a,x| {
        let b = std::cmp::max(keta(*x), keta(n / x));
        std::cmp::min(a,b)
    });
    println!("{}", res);
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(){
    int a, b, c, d, i, cnt=0;

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

    for(i=0; i<=100; i++){
        if(a <= i && i < b && c <= i && i < d)
            cnt++;
    }

    printf("%d\n", cnt);
    
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
#define int long long
typedef pair<int,int> P;
typedef pair<int,P> PP;

int dfs(int v,vector<int>& used,const vector<vector<int> >& g,int k){
  if(used[v]!=-1){
    return k==used[v];
  }
  used[v]=k;
  int res=1;
  for(int i=0;i<g[v].size();i++){
    if(dfs(g[v][i],used,g,(k+1)%2)==0)res=0;
  }
  return res;
}

signed main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int> > g(n);
  for(int i=0;i<m;i++){
    int u,v;
    cin>>u>>v;
    u--,v--;
    g[u].pb(v);
    g[v].pb(u);
  }
  
  int sum=0;
  int ind=0;
  for(int i=0;i<n;i++){
    if(g[i].size()==0){
	 ind++;
	 sum+=n;
    }
  }
  sum+=(n-ind)*ind;
  
  int cn[2]={};
  vector<int> used(n,-1);
  for(int i=0;i<n;i++){
    if(used[i]!=-1||g[i].size()==0)continue;
    cn[dfs(i,used,g,0)]++;
  }
  
  sum+=cn[1]*cn[1]*2;
  sum+=cn[0]*cn[0];
  sum+=cn[1]*cn[0];
  sum+=cn[0]*cn[1];
  
  cout<<sum<<endl;
  return 0;
}


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

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define inf (0x3f3f3f3f)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define Rep(i, a) for (int i = 0; i < a; ++ i)
#define For(i, a, b) for (int i = a; i <= b; ++ i)
#define Forr(i, a, b) for (int i = a; i >= b; -- i)
#define Travel(i, x) for (int i = head[x]; i; i = nxt[i])

using namespace std;

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

template<class T>inline T read(T &_) {
	T __ = getchar(), ___ = 1; _ = 0;
	for (; !isdigit(__); __ = getchar()) if (__ == '-') ___ = -1;
	for (; isdigit(__); __ = getchar()) _ = (_ << 3) + (_ << 1) + (__ ^ 48);
	return _ *= ___;
}

template<class T>inline bool chkmax(T &_, T __) { return _ < __ ? _ = __, 1 : 0; }
template<class T>inline bool chkmin(T &_, T __) { return _ > __ ? _ = __, 1 : 0; }

inline void proStatus() {
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>());
}

const int N = 5e3 + 7;

PII a[N], b[N];

char s[N], t[N];

int n, ans = inf, c, d;

void Solve() { 
	For(i, 0, n) { 
		if ((a[1].y + b[1].y + i) & 1) continue;
		int res = 0, now = 1;
		while (now <= c) { 
			int ps = a[now].x, pt = now + i <= d ? b[now + i].x : n + 1;
			res += abs(pt - ps), ++ now;
		}
		while (now + i <= d) res += n + 1 - b[now + i].x, ++ now;
		For(j, 1, i) {
			int pt = j <= d ? b[j].x : n + 1; 
			res += pt - 1; 
		}
		chkmin(ans, res);
	}
}

int main() {

	scanf("%d%s%s", &n, s + 1, t + 1);

	For(i, 1, n) { 
		if (s[i] != s[i - 1]) 
			a[++ c] = mp(i, s[i] ^ 48);
		if (t[i] != t[i - 1]) 
			b[++ d] = mp(i, t[i] ^ 48);
	}
	Solve(), swap(c, d), swap(a, b), Solve();

	printf("%d\n", ans);

	return 0;
}

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

int main()
{
    int H, W;
    while (cin >> H >> W)
    {
        if (H == 0 && W == 0)
            break;

        // put top
        for (int col = 0; col < W; ++col)
        {
            cout << "#";
        }
        cout << "\n";

        // put middle
        for (int row = 1; row < H - 1; ++row)
        {
            cout << "#";
            for (int col = 1; col < W - 1; ++col)
            {
                cout << ".";
            }
            cout << "#\n";
        }
        // put bottom
        for (int col = 0; col < W; ++col)
        {
            cout << "#";
        }
        cout << "\n\n";
    }
}


Measured memory_bytes: 3028
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var S = ReadLine();
            var T = ReadLine();
            var posS = new Dictionary<char, List<long>>();
            for (var i = 0; i < S.Length;++i)
            {
                var s = S[i];
                if (!posS.ContainsKey(s)) posS[s] = new List<long>();
                posS[s].Add(i);
            }
            var pre = -1L;
            var cycle = 0L;
            foreach (var t in T)
            {
                if (!posS.ContainsKey(t))
                {
                    WriteLine(-1);
                    return;
                }
                var n = ~posS[t].BinarySearch(pre, new ub<long>());
                if (posS[t].Count <= n)
                {
                    ++cycle;
                    n = 0;
                }
                pre = posS[t][n];
            }
            WriteLine(cycle * S.Length + pre + 1);
        }
        public class ub<T> : IComparer<T> where T : IComparable<T>
        {
            public int Compare(T x, T y) => 0 < x.CompareTo(y) ? 1 : -1;
        }
    }
}

Measured memory_bytes: 16096
object Main extends App {

  // 期待値 1 + pi /2
  /**
   * 期待値の合計 = 合計の期待値
   * 区間の和
   * 尺取スライドホゲホゲ: 区間の合計値4つ + 次の1つ - 前の1つ
   * 累積和: 6~10 = (1~10) - (1~5)
   */

  val sc = new java.util.Scanner(System.in)
  val N, K = sc.nextInt
  var a: Vector[Double] = Vector()

  for (i <- 0 until N) {
    val ai: Double = sc.nextInt
    val p: Double = (ai + 1) / 2
    a = a :+ p
  }
  var shaku = a.slice(0, K).foldLeft(0.0)(_ + _)
  var ans:Double = shaku
  for (i <- 0 until N-K) {
    shaku = shaku + a(i + K) - a(i)
    ans = math.max(shaku, ans)
  }
  println(ans)
}



Measured memory_bytes: 77732
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] p = new int[N];
    for (int i = 0; i < N; i++) p[i] = sc.nextInt();
    sc.close();

    long[] s = new long[N + 1];
    for (int i = 0; i < N; i++) {
      long n = p[i] + 1;
      s[i + 1] = s[i] + n;
    }

    long max = 0;
    for (int i = K; i < N + 1; i++) {
      max = Math.max(max, s[i] - s[i - K]);
    }

    BigDecimal ans = BigDecimal.valueOf(max).divide(BigDecimal.valueOf(2));
    System.out.println(ans.toPlainString());
  }
}


Measured memory_bytes: 86604
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj;
ll n,m;
ll a,b,c,d,e,g,h,r,w;
ll l,ans,sum;
ll num;
ll x[500005],y[500005],z[500005];
bool dame,flag,ok;

int main(){
	cin >> n;
	cin >> a >> b;
	for(i=0;i<n;i++){
		cin >> d;
		if(d <= a){
			c++;
		}else if(d >= b+1){
			j++;
		}else{
			k++;
		}
	}
	p(min(c,min(j,k)));

	return 0;
}

Measured memory_bytes: 25216
import sys
from pprint import pprint
import heapq

def solve(n, m, a):
  #pprint(a)
  cands = []
  ans = 0
  for i in xrange(m+1):
    # print i
    if i in a and len(a[i]) > 0:
      for v in a[i]:
        heapq.heappush(cands, v)

    # pprint(cands)
    if len(cands) > 0:
      w = heapq.heappop(cands) 
      # pprint(-1 * w)
      ans += -1 * w

  print(ans)


if __name__ == '__main__':

  n, m = map(int, sys.stdin.readline().strip().split(" "))
  # print n, m
  a = {}
  # pprint(a)
  for _ in xrange(n):
    a_i, b_i = map(int, sys.stdin.readline().strip().split(" "))
    # print a_i, b_i
    
    if a_i not in a:
      a[a_i] = []
    a[a_i].append(-1 * b_i)
  solve(n, m, a)

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

const long long int MOD = 1e9+7;
#define pb push_back
typedef long long ll;
const long long int N = 1e6;

int main(){
    
    int n;
    cin>>n;
    vector<int> dp(n+5,0),h(n+5);
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++){
        dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]) , dp[i-1]+abs(h[i-1]-h[i]));
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 3980
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    char a[1000],b[1000];
    cin>>a>>b;
    //cout<<a<<" "<<b<<endl;
    int ln1,ln2;
    ln1=strlen(a);
    ln2=strlen(b);
    if(ln1>ln2){
        cout<<"GREATER"<<endl;
    }
    else if(ln1<ln2){
        cout<<"LESS"<<endl;
    }
    else{
        if(a[0]>b[0]){
            cout<<"GREATER"<<endl;
        }
        else if(a[0]<b[0]){
            cout<<"LESS"<<endl;
        }
        else{
            cout<<"EQUAL"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
A = iil()

ans = 30

for i in A:
    num = i
    count = 0
    while num%2 == 0:
        num //=2
        count += 1
    ans = min(ans,count)

print(ans)

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n + 1, 0);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < 41; i++) {
        if (i == k) break;
        vector<int> imos(n, 0);
        for (int j = 0; j < n; j++) {
            int l = max(0, j - a[j]);
            int r = min(n - 1, j + a[j]);
            imos[l]++;
            imos[r + 1]--;
        }
        for (int j = 0; j < n; j++) imos[j + 1] += imos[j];
        a = imos;
    }
    for (int i = 0; i < n; i++) {
        cout << a[i] << ((i + 1 < n) ? ' ' : '\n');
    }
}

Measured memory_bytes: 4848
import math
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

dist = abs(a-b)
pace = abs(v) - abs(w)

if pace <= 0:
  print('NO')
elif math.ceil(dist / pace) > t:
  print('NO')
else:
  print('YES')

Measured memory_bytes: 9088
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

// doc: https://shibh308.github.io/library/library/lib/classes/unionfind.cpp.html
struct UnionFind{
    vector<int> par;
    int count;
    UnionFind(int n) : par(n, -1), count(0){}
    int Find(int x){return par[x] < 0 ? x : Find(par[x]);}
    int Size(int x){return par[x] < 0 ? -par[x] : Size(par[x]);}
    bool Unite(int x, int y){
        x = Find(x);
        y = Find(y);
        if(x == y)
            return false;
        if(par[x] > par[y])
            swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return ++count;
    }
};


void solve(long long n, long long m, std::vector<long long> a, std::vector<long long> b){
    UnionFind uf(n);
    for(int i = 0; i < m; ++i)
        uf.Unite(a[i] - 1, b[i] - 1);
    int ans = 0;
    for(int i = 0; i < n; ++i)
        chmax(ans, uf.Size(i));
    cout << ans << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 7224
/* ABC159 E
 * 2020.4.4~
 * 2020.4.11 TLE後変更
 * H 1-10
 * W 1-10000
 * K 1-H*W
 */
#include <iostream>
#include <vector>
#include <climits>
//#include <algorithm>
using namespace std;

//#define DB

#ifdef DB
#define _DB(f) \
{  \
f; \
}
#else
#define _DB(f)
#endif

inline int max(int x, int y){
  return (x>y)?x:y;
}
inline int min(int x, int y){
  return (x<y)?x:y;
}

int s[10][1000]; //最大
int H,W,K;

void init_mat(){
  cin >> H >> W >> K;
  string st;
  for(int i=0;i!=H;++i){
    cin >> st; // W桁の文字列で入力される
    for(int j=0;j!=W;++j){
      s[i][j] = st[j]-'0';
    }
  }
  return;
}

/* 行区切りのvectorが与えられたとき，
   ある列での行区間ごとの(s==1)なセル数をoutに保存 */
void num_in_rows(vector<int> rows, vector<int>& out, int col){
  int len = rows.size();
  for(int i=0;i!=len-1;++i){ // 行区間 = グループ番号
    int trow = rows[i], brow = rows[i+1];
    int tmp = 0;
    for(int row=trow;row!=brow;++row){
      tmp += s[row][col];
    }
    out[i] = tmp;
  }
  return;
}

/* 行区切りのvectorが与えられたとき，
   (s==1)なセル数<=k に必要な列区切り数のgreedy算出 */
int greedy(vector<int> rows){
  int l=0, lines=0, r=1;
  int groups = rows.size();
  vector<int> num(groups), num_tmp(groups);
  _DB(printf("=greed: "));
  for(int col=0;col!=W;++col){
    int check = 0;
    num_in_rows(rows, num_tmp, col);
    for(int i=0;i!=groups;++i ){
      if( num_tmp[i] > K ){  // 1colでNGなら終了
        return -1;
      }
    }
    for(int i=0;i!=groups;++i ){  // 積算での判定
      if( num[i]+num_tmp[i] > K ){
        check = 1;
        break;
      }
    }
    if(check){ // 積算だとNG
      l = r-1; // 1colではK超えなかったので，r-1で
      ++lines;
      num.swap(num_tmp); // 今回のcolを積算値に
      _DB(printf("%d ", l));
    } else { // OK
      for(int i=0;i!=groups;++i){
        num[i] += num_tmp[i];
      }
    }
  }
  _DB(printf("\n"));
  return lines;
}

/* bitの1になっている位置をvectorに追加
   ただし最下位bitを位置1とみなす */
void bit_to_vec(vector<int>& v,int bits){
  //vector<int> *p = new vector<int>();
  int b = 0x1;
  for(int i=1;i!=H;++i){
    if( bits&b ){
      v.push_back(i);
    }
    b <<= 1;
  }
  return;
}

int main(void){
  init_mat();
  int res = INT_MAX, g;
  for(int b=0x0;b!=(0x1<<H);++b){ // bit全探索 0~1111..1b (H-1個)
    vector<int> rows;
    rows.push_back(0);
    bit_to_vec(rows, b);
    rows.push_back(H);
    g = greedy(rows);
    if( g!=-1 ){
      res = min(res,g+rows.size()-2);
    }
    _DB(printf("main %x min: %d\n", b, res));
  }
  cout << res << endl;
}

/* 例
3 5 4
11100
10001
00111
答え 2
*/


Measured memory_bytes: 256
let num = require('fs').readFileSync('/dev/stdin', 'UTF-8');

let numSplit = num.split(" ");
let num1 = numSplit[0] - 0;
let num2 = numSplit[1] - 0;

let biggerNum = Math.max(num1, num2);
let smallerNum = Math.min(num1, num2);

console.log(gcd(biggerNum, smallerNum));

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




Measured memory_bytes: 15376
// Author :
// Date :
// Problem:
// Solution:
// Comment:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstring>

#define pp push
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

using namespace std;

void play(int n,int mm){
    int ans[105] = {0};
    int cur = -1;
    int day = 0;
    int q;
    
    for(int i = 0 ; i < n ; i ++){
        int m;
        
        cin >> m;
        for(int i = 0 ; i < m ; i++){
            cin >> q;
            ans[q]++;
        }
    }
    
    for(int i = 0 ; i < 103 ; i++){
        if(ans[i] > cur && ans[i] >=mm){
            cur = ans[i];
            day = i;
        }
    }
    
    cout << day << endl;
}

main(){
    int nn,mm;
    
    while(cin >> nn >> mm){
        if(nn == 0) break;
        play(nn,mm);
    }
    #ifdef GEREL
        for(;;);
    #endif

    return 0;
}

Measured memory_bytes: 1160
n, m = map(int, input().split())
ans = 1
for i in range(1, int(m ** .5) + 1):
    if m % i == 0:
        b = m // i
        if i * n <= m:
            ans = max(ans, i)
        if b * n <= m:
            ans = max(ans, b)
print(ans)

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

void diceS(int []);
void diceE(int []);
void diceW(int []);
void diceN(int []);

int main(){
	int d[6];
	string str;
	for(int i=0;i<6;i++) cin >> d[i];
	cin >> str;
	for(int i=0;i<str.size();i++){
		switch(str[i]){
			case 'S':
				diceS(d);
				break;
			case 'E':
				diceE(d);
				break;
			case 'W':
				diceW(d);
				break;
			case 'N':
				diceN(d);
				break;
		}
	}
	cout << d[0] << endl;

	return 0;
}

void diceS(int a[6]){
	int w;
	w=a[0];
	a[0]=a[4];
	a[4]=a[5];
	a[5]=a[1];
	a[1]=w;
}


void diceE(int a[6]){
	int w;
	w=a[0];
	a[0]=a[3];
	a[3]=a[5];
	a[5]=a[2];
	a[2]=w;
}

void diceW(int a[6]){
	int w;
	w=a[0];
	a[0]=a[2];
	a[2]=a[5];
	a[5]=a[3];
	a[3]=w;
}

void diceN(int a[6]){
	int w;
	w=a[0];
	a[0]=a[1];
	a[1]=a[5];
	a[5]=a[4];
	a[4]=w;
}

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

int main(){

  	vector<bool>a(82,false);
  	for(int i = 1; i < 10; ++i){
    	for(int j = 1; j < 10; ++j){
        	a[i*j] = true;
        }
    }
  
  	int n;
  	cin >> n;
  	
  	if(n > 81){
    	cout << "No\n";
      	return 0;
    }
  
  	if(a[n]) cout << "Yes\n";
  	else cout << "No\n";
  
	return 0;
}

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

int main(void){
	int n;
	cin>>n;
	int w[n];
	for(int i=0;i<n;i++)cin>>w[i];
	ll tmp=0,tmp2=0;
	ll res=1e9;
	for(int i=0;i<n;i++){
		tmp=0;tmp2=0;
		for(int j=0;j<i;j++){
			tmp+=w[j];
		}
		for(int j=i;j<n;j++){
			tmp2+=w[j];
		}
		res = min(res,abs(tmp-tmp2));
	}
	cout<<res<<endl;
}


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

int main(){
	int A,B,C;
  	cin >> A >> B >> C;
  	if(A == 5){
    	if((B==7 && C ==5)||(B==5 && C==7)){ cout << "YES" << endl;}
      	else {cout << "NO" << endl;}
        	
    }
  	else if(A ==7){
    	if(B ==5 && C ==5){
          	cout << "YES" << endl;
        }
      	else{cout << "NO" << endl;}
        	
    }
  	else{cout << "NO" << endl;}
}


Measured memory_bytes: 256
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    n,k = mi()
    print(min(abs(n-(n//k)*k),abs(n-(n//k+1)*k)))


main()





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

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

    int n;
    cin >> n;

    int two = 0, four = 0, other = 0;
    REP(i, n){
        int a;
        cin >> a;
        if(!(a % 4)) four++;
        else if(!(a % 2)) two++;
        else other++;
    }

    
	if(!two)
        cout << (four + 1 >= other ? "Yes" : "No") << endl;
    else cout << (four >= other ? "Yes" : "No") << endl;
    return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long int x;
  cin >> x;
  long long int ans = 1;

  for (int i = 2; i < x; i++) {
    long long int num = i;
    while (num < x) {
      num *= i;
      if (num <= x)
        ans = max(num, ans);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;



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

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



int main() {
	int i, j, k;
	//ll N, M, K;
	int N, M, K;
	long long H, W;
	cin >> H >> W;
	if (H == 1 || W == 1) {
		cout << "1";
		return 0;
	}
	ll ans = (H / 2 + H % 2) * (W / 2 + W % 2) + (H - H / 2 - H % 2) * (W - W / 2 - W % 2);

	cout << ans;
	return 0;

}


Measured memory_bytes: 256