akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);
	public void run() {
		dataset:while(sc.hasNext()){
			int n=sc.nextInt();
			if(n==0)break;
			int m=sc.nextInt()-1,g=sc.nextInt()-1,d=sc.nextInt();
			char[][] map=new char[d][n-1];
			for(int i=0;i<d;i++){
				map[i]=sc.next().toCharArray();
			}
			int[][] root=new int[d+1][n];
			int[] state=new int[n];
			for(int i=0;i<n;i++)state[i]=i;
			for(int i=0;i<d;i++){
				root[i]=Arrays.copyOf(state,n);
				for(int j=0;j<n-1;j++){
					if(map[i][j]=='1'){
						int x=state[j];
						state[j]=state[j+1];
						state[j+1]=x;
					}
				}
			}
			if(m ==state[g]){
				ln(0);
				continue dataset;
			}

			for(int i=0;i<d;i++){
				for(int j=0;j<n-1;j++){
					if(map[i][j]=='0' && (j==0 ||map[i][j-1]=='0') &&( j==n-2 || map[i][j+1]=='0')){
						if(root[i][j]==m && root[i][j+1]==state[g] || root[i][j]==state[g] && root[i][j+1]==m){
							ln((i+1) +" "+(j+1));
							continue dataset;
						}
					}
				}
			}
			ln(1);
			continue dataset;
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
	public static void pr(Object o) {
		System.out.print(o);
	}
	public static void ln(Object o) {
		System.out.println(o);
	}
	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>

const long long INF = 1LL<<60;

using namespace std;
typedef pair<long long,bool> Pair;

int main(){

long long N,W;
long long DP[110][100100];
long long w[110], v[110];

cin >> N >> W;

for(long long i=0;i<N;i++) cin >> w[i] >> v[i];

for (int i = 0; i < 110; ++i) for (int j = 0; j < 100100; ++j) DP[i][j] = INF;

DP[0][0] = 0;

for(long long i = 0;i < N;++i)
{
    for(long long sum_v = 0; sum_v < 100100;++sum_v){


        if(sum_v - v[i] >= 0){

            DP[i + 1][sum_v] = min(DP[i+1][sum_v], DP[i][sum_v-v[i]] + w[i]);

        }

        DP[i + 1][sum_v] = min(DP[i+1][sum_v],DP[i][sum_v]);

    }

}

long long res = 0;
for (long long sum_v = 0; sum_v < 100100; ++sum_v) {
    if (DP[N][sum_v] <= W) res = sum_v;
}

cout << res << endl;

return 0;

}   

Measured memory_bytes: 86400
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<long, long> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int main(){
    int M;
    cin>>M;
    vector<int>B(M+1),C(M+1,0),res;//Cはそのindexの倍数の総和
    REP(i,M){
        cin>>B[i+1];
    }
    REP(i,M){
        int index=M-i;
        int b=B[index];
        if(b==C[index]%2)continue;
        res.PB(index);
        for(int ii=1;ii*ii<=index;ii++){
            if(index%ii==0){
                C[ii]+=1;
                if(index/ii!=ii)C[index/ii]+=1;
            }
        }
    }
    SORT(res);
    cout<<SZ(res)<<endl;
    for(auto r:res)cout<<r<<" ";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3064
n = int(input())
a_arr = [0] + list(map(int,input().split()))
b_arr = a_arr

for i in range(1,n + 1)[::-1]:
    j = 2
    while (i*j <= n):
        b_arr[i] += b_arr[i*j]
        b_arr[i] %= 2
        j += 1

m = sum(b_arr)
print(m)
if m:
    ans = []
    for i in range(1,n+1):
        if b_arr[i]:
            ans.append(i)
    print(*ans)

Measured memory_bytes: 12724
def count(C, H, W):
    v = 0
    for h in range(H):
        for w in range(W):
            if C[h][w] == '#':
                v += 1
    return v

def main():
    H, W, K, = map(int, input().split())
    C = []
    for _ in range(H):
        C.append([c for c in input()])
    # print(H, W, K, C)
    ans = 0
    for h in range(2**H - 1):
        D = []
        for i in range(H):
            if (h >> i) & 1 == 1:
                D.append(['-' for w in range(W)])
            else:
                D.append([C[i][w] for w in range(W)])
        for w in range(2**W):
            E = []
            for a in range(H):
                E.append([D[a][b] for b in range(W)])
            for j in range(W):
                if (w >> j) & 1 == 1:
                    for k in range(H):
                        E[k][j] = '-'
            v = count(E, H, W)
            # print(h, w, v, D)
            if v == K:
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9208
#define KAKUSUKO
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int A, B;

int main() {

    cin >> A >> B;

    if (A >= 10) {
        cout << -1 << endl;
        return 0;
    }

    if (B >= 10) {
        cout << -1 << endl;
        return 0;
    }

    cout << A * B << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		
		char[] a = sc.next().toCharArray();
		char[] b = sc.next().toCharArray();
		char[] c = sc.next().toCharArray();
		
		if (a[a.length - 1] == b[0] && b[b.length - 1] == c[0]) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

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


Measured memory_bytes: 22484
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	string s;
	int ans = 0;
	vector<vector<int>> dp;
	vector<int> hoge;
	
	cin>>N;
	
	cin>>s;
	
	s += '0';
	
	for(int i = 0, c = 0; i < s.size(); i++){
		if(s[i] == '1') {
			c++;
		} else {
			hoge.push_back(c);
			c = 0;
		}
	}
	
	dp.resize(3, vector<int>(hoge.size()+1, -INF));
	
	dp[1][0] = 0;

	N = hoge.size();
	
	for(int i = 0; i < N; i++){
		if(i+1 < N && hoge[i+1] && hoge[i]) dp[0][i+1] = max(dp[0][i+1], dp[0][i] + hoge[i] - 1);
		if(i+1 < N && hoge[i+1]) dp[0][i+1] = max(dp[0][i+1], dp[1][i] + hoge[i]);
		if(i+1 < N && hoge[i+1]) dp[0][i+1] = max(dp[0][i+1], dp[2][i] + hoge[i]);
		
		dp[1][i+1] = max(dp[1][i+1], dp[0][i]);
		dp[1][i+1] = max(dp[1][i+1], dp[1][i]);
		dp[1][i+1] = max(dp[1][i+1], dp[2][i] + hoge[i]);
		
		if(i+1 < N  && hoge[i] >= 2) dp[2][i+1] = max(dp[2][i+1], dp[0][i]);
		if(i+1 < N && hoge[i+1]&& hoge[i])dp[2][i+1] = max(dp[2][i+1], dp[2][i] + hoge[i]-1);
		if(i+1 < N && hoge[i]) dp[2][i+1] = max(dp[2][i+1], dp[1][i]);
		
		
	}
	
	ans = max(ans,*max_element(dp[0].begin(), dp[0].end()));
	ans = max(ans,*max_element(dp[1].begin(), dp[1].end()));
	ans = max(ans,*max_element(dp[2].begin(), dp[2].end()));
	
	cout<<ans<<endl;

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i< N; i++) cin >> d[i];
 
    long long sum = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; N > j ; j++){
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;
  	return 0;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 
LL dk[19];

LL ff(LL ka,LL kb,LL s){
    return (ka-1)/s-(kb-1)/s;
}

LL f(LL a,LL b,LL k){
    return k*ff(a,b,1) + (4LL-k)*(ff(a,b,3)+ff(a,b,5))+k*ff(a,b,15);
}


int main(){
    LL s;cin >> s;
    dk[0] = 1LL;
    for (int i = 1; i < 19; i++) {
        dk[i] = dk[i-1] * 10LL;
    }
    LL N;
    vector<LL> S(20,0);
    for (int i = 0; i < 18; i++) {
        S[i+1] = S[i] + f(dk[i+1],dk[i],i+1);
        if(s<=S[i+1]){
            N=i+1;
            break;
        }
    }
    vector<vector<LL>> dp(N,vector<LL> (10,0));
    dp[0][0] = S[N-1];
    LL sum = dk[N-1];
    for (LL i = 0; i < N-1; i++) {
        vector<LL> dp2(11,0);
        dp2[0] = dp[i][0];
        for (LL j = 0; j < 10; j++) {
            dp2[j+1] = dp2[j] + f(sum+(j+1)*dk[N-1-i],sum+j*dk[N-1-i],N);
        }
        for (LL j = 0; j < 10; j++) {
            if(s <= dp2[j+1]){
                dp[i+1][0] = dp2[j];
                sum += j*dk[N-1-i];
                break;
            }
        }
    }
    LL res = s-dp[N-1][0];
    string ans="";
    for (int i = 0; i <= 20; i++) {
        if(sum%3==0&&sum%5==0) ans = ans + "FizzBuzz";
        else if(sum%3==0) ans = ans + "Fizz";
        else if(sum%5==0) ans = ans + "Buzz";
        else ans = ans + to_string(sum);
        sum++;
    }
    for (int i = 0; i < 20; i++) {
        cout << ans[i+res-1];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3276
<?php
$haveCardNum = trim(fgets(STDIN));
$cardCheckList = createCardCheckList();
 
for ($i = 0; $i < $haveCardNum; $i++) {
    list($mark, $num) = getSpacesByExplodeTrimInput();
    $cardCheckList[$mark][$num] = 'check';
}
 
foreach ($cardCheckList as $mark => $value) {
    for ($cardNum = 1; $cardNum <= 13; $cardNum++) {
        if (! isset($cardCheckList[$mark][$cardNum])) {
            echo sprintf('%s %d', $mark, $cardNum), PHP_EOL;
        }
    }
}
 
function getSpacesByExplodeTrimInput()
{
    return explode(' ', trim(fgets(STDIN)));
}
 
function createCardCheckList()
{
    foreach(array('S', 'H', 'C', 'D') as $mark) {
        $checkList["$mark"] = array_fill(1, 13, null);
    }
    return $checkList;
}

Measured memory_bytes: 15396
n = int(input())

for h in range(1, 3501):
    for w in range(h, 3501):
        bns = n * h * w
        bnb = 4 * h * w - n * (h + w)
        if bnb >= 1 and bns % bnb == 0:
            print(h, w, bns // bnb)
            exit()


Measured memory_bytes: 66628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m; cin >> n >> m;
    vector<pair<int,int>> key;
    rep(i,m) {
        int a, b; cin >> a >> b;
        int s = 0;
        rep(j,b) {
            int c; cin >> c;
            --c;
            s |= 1<<c;
        }
        key.emplace_back(s,a);
    }
    vector<int> dp(1<<n,INF);
    dp[0] = 0;
    rep(s,1<<n) {
        rep(i,m) {
            int t = s | key[i].first;
            int cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }
    int ans = dp.back();
    if(ans==INF) ans = -1;
    cout << ans << endl;

    return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] num = br.readLine().split(" ");
		Dice dice = new Dice(1, 4, 2);

		char[] dir = br.readLine().toCharArray();
		for (char c : dir) {
			switch (c) {
			case 'N':
				dice = dice.goNorth();
				break;
			case 'E':
				dice = dice.goEast();
				break;
			case 'W':
				dice = dice.goWest();
				break;
			case 'S':
				dice = dice.goSouth();
				break;
			default:
				break;
			}
		}
		System.out.println(num[Integer.parseInt(dice.getTop()) - 1]);
	}
}

class Dice {

	int top;
	int west;
	int south;

	public Dice(int top, int west, int south) {
		this.top = top;
		this.west = west;
		this.south = south;
	}

	public Dice goNorth() {
		return new Dice(south, west, 7 - top);
	}

	public Dice goEast() {
		return new Dice(west, 7 - top, south);
	}

	public Dice goWest() {
		return new Dice(7 - west, top, south);
	}

	public Dice goSouth() {
		return new Dice(7 - south, west, top);
	}

	public String getTop() {
		return String.valueOf(top);
	}
}

Measured memory_bytes: 24316
#include <iostream>

char jukuClass(int, int, int);
int main()
{
    while (true) {
        int number;
        std::cin >> number;
        if (number == 0) {
            break;
        }
        for (int i = 0; i < number; ++i) {
            int pm, pe, pj;
            std::cin >> pm >> pe >> pj;
            std::cout << jukuClass(pm, pe, pj) << std::endl;
        }
    }
    return 0;
}
char jukuClass(int pm, int pe, int pj)
{
    if (pm == 100 || pe == 100 || pj == 100) {
        return 'A';
    } else if ((pm + pe) / 2.0 >= 90) {
        return 'A';
    } else if ((pm + pe + pj) / 3.0 >= 80) {
        return 'A';
    } else if ((pm + pe + pj) / 3.0 >= 70) {
        return 'B';
    } else if (((pm + pe + pj) / 3.0 >= 50) && (pm >= 80 || pe >= 80)) {
        return 'B';
    } else {
        return 'C';
    }
}

Measured memory_bytes: 1148
#include<stdio.h>
#include<string.h>

#define M 1000001/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){
  return key % M/* your task */;
}
int h2(int key){
  return key % (M - 1) + 1/* your task */;
}

int find(char str[]){

  /* your task */
  int key,i,j;

  key = getKey(str);
  for(i=0;i<M;i++){
    j = (h1(key) +i * h2(key)) % M;
    if(H[j][0] == '\0') return 0;
    else if(strcmp(H[j],str) == 0){
      return 1;
      break;
    }
  }
}

int insert(char str[]){

  /* your task */
  int key,i,j;

  key = getKey(str);
  for(i=0;i<M;i++){
    j = (h1(key) +i * h2(key)) % M;
    if(H[j][0] == '\0'){
      strcpy(H[j],str);
      break;
    }
  }
  return 0;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);

    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  return 0;
}



Measured memory_bytes: 15464
import java.util.Scanner;
public class Main {
	
	public static void main(String[] arg) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		String s = sc.next();
		char []t = s.toCharArray();
		int max = 0;
		int count = 0;
		for(int i = 0; i < n ; i++) {
			if(t[i] == 'I') {
				count++;
				max = Math.max(count, max);
			}
			if(t[i] == 'D') {
				count--;
			}
		}
		System.out.println(max);
	}

}


Measured memory_bytes: 21716
/*AMETHYSTS*/
#pragma comment(linker, "/STACK:1000000000")
#include <cstdio>
#include <iostream>
#include <ctime>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <set>
#include <map>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <bitset>
#include <deque>
#include <stack>
#include <climits>
#include <string>
#include <queue>
#include <memory.h>
#include <unordered_map>
#include <random>
 
#define ll long long
#define ld double
#define pii pair <int, int>
#define forn(i, n) for (ll i = 0; i < (ll)n; i++)
#define mp make_pair
#define ui unsigned int
 
using namespace std;

int main() {
	ll a, b, c;

	cin >> a >> b >> c;

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << endl;
	} else {
		cout << min(min(b * c, a * c), a * b) << endl;
	}

	return 0;
}


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

using namespace std;

int ans, N, K, niv[100009], t[100009];
bool ap[100009];
priority_queue < pair < int, int > > PQ;
vector < int > v[100009];

void dfs (int nod)
{
    for (auto it = v[nod].begin (); it != v[nod].end (); it ++)
        niv[*it] = niv[nod] + 1, dfs (*it);
}

void Fill (int nod)
{
    if (ap[nod]) return ;
    ap[nod] = 1;
    for (auto it = v[nod].begin (); it != v[nod].end (); it ++)
        Fill (*it);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &K);
for (int i=1; i<=N; i++)
    scanf ("%d", &t[i]);
ans = (t[1] != 1), t[1] = 1;
for (int i=2; i<=N; i++)
    v[t[i]].push_back (i);
dfs (1);
for (int i=2; i<=N; i++)
    PQ.push (make_pair (niv[i], i));
while (!PQ.empty ())
{
    pair < int, int > curr = PQ.top ();
    PQ.pop ();
    if (ap[curr.second] == 1) continue;
    if (curr.first <= K) break;
    int nod = curr.second, steps = K - 1;
    while (steps --) nod = t[nod];
    Fill (nod), ans ++;
}
printf ("%d\n", ans);

return 0;
}


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

int main() {
	int k;
	cin >> k;
	int c = 0, m=0;
	while(k--){
		int a, b;
		cin >> a >> b;
		if(a == b){
			c++;
			m = max(m,c);
		}else{
			c=0;
		}
	}
	if(m>=3){
		cout << "Yes" ;
	}else{
		cout << "No";
	}
	return 0;
}

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

#define boost ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

using namespace std;
using LL = long long;

constexpr int MAXN = 2e5 + 5;

template <typename T>
inline void read(T &x) {
    int f = 1;
    x = 0;
    char ch = getchar();
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}
LL a, b, n;
string s;
int main() {
    // freopen("test.in", "r", stdin);
    // freopen("test.out", "w", stdout);
    boost;
    cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3600
public class Main {

    public static void main(String... args) throws Exception {
        var inputText = AtCoderReader.readInputText();
        var k = Integer.parseInt(inputText);

        if (k % 2 == 0) {
            System.out.println(-1);
            return;
        } else if (k % 5 == 0) {
            System.out.println(-1);
            return;
        }

        int L;
        if (k % 7 == 0) {
            L = 9 * k / 7;
        } else {
            L = 9 * k;
        }

        int mod = 1;
        for (int i = 1; true; i++) {
            mod = (10 * mod) % L;
            if (mod == 1) {
                System.out.println(i);
                return;
            }
        }
    }

    public static class AtCoderReader {
        public static String readInputText() {
            try (var input = System.in) {
                return new String(System.in.readAllBytes()).trim();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
}

Measured memory_bytes: 32376
// finish date: 2019/2/28

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


//足し算
int add(int a, int b) {
    return (int) (((ll) a + b + bigmod) % bigmod);
}

//掛け算
int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}


vvi matrix_mul(vvi X, vvi Y) {
    vvi A(X.size(), vi(Y[0].size(), 0));
    rep(i, X.size()) rep(j, Y[0].size()) rep(k, X[0].size()) A[i][j] = add(A[i][j], mul(X[i][k], Y[k][j]));
    return A;
}


vvi modpowM_sum(vvi a, int N, ll K) {
    int k = 1;
    vvvi A;
    A.push_back(a);
    while ((1LL << k) <= K) {
        A.push_back(matrix_mul(A[k - 1], A[k - 1]));
        k++;
    }

    vvi mat(N, vi(N, 0));
    rep(i, N) mat[i][i] = 1;
    rep(i, k) {
        if (K & (1LL << i)) {
            mat = matrix_mul(mat, A[i]);
        }
    }
    return mat;
}

int main() {
    int N;
    ll K;
    cin >> N >> K;
    vvi a(N, vi(N));
    rep(i, N) rep(j, N) cin >> a[i][j];
    vvi mat = modpowM_sum(a, N, K);
    int total = 0;
    rep(i, N) rep(j, N) total = add(total, mat[i][j]);
    cout << total << endl;


    return 0;
}

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

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

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int N, K; cin >> N >> K;
    vec a(N);
    rep(i, N) cin >> a[i];
    int res = 1e+9;
    sort(all(a));
    rep(i, N-K+1){
        res = min(res, a[i+K-1]-a[i]);
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4736
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    h,w=map(int,input().split())
    A=[[int(_) for _ in input().split()] for i in range(h)]
    ans=[]
    for i in range(h):
        if i%2==0:
            for j in range(w):
                if A[i][j]%2==1:
                    if j<w-1:
                        A[i][j+1]+=1
                        A[i][j]-=1
                        ans.append((i+1,j+1,i+1,j+2))
                    else:
                        if i+1==h:break
                        A[i+1][j]+=1
                        A[i][j]-=1
                        ans.append((i+1,j+1,i+2,j+1))
        else:
            for j in range(w-1,-1,-1):
                if A[i][j]%2==1:
                    if j>0:
                        A[i][j-1]+=1
                        A[i][j]-=1
                        ans.append((i+1,j+1,i+1,j))
                    else:
                        if i+1==h:break
                        A[i+1][j]+=1
                        A[i][j]-=1
                        ans.append((i+1,j+1,i+2,j+1))
    print(len(ans))
    for a in ans:
        print(*a)

if __name__=='__main__':
    main()

Measured memory_bytes: 26560
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError("n is int-type.")
    if n < 2:
        raise ValueError("n is more than 2")
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data

p_list = get_sieve_of_eratosthenes(10**3)

def factorization_counta(n):
    arr = []
    temp = n
    for i in p_list:
        if i * i > n:
            break
        elif temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append(cnt)
            
    if temp != 1:
        arr.append(1)
    if arr == []:
        arr.append(1)
    return arr

def get_number_comb(arr):
    ans = 1
    for i in arr:
        ans *= (i + 1)
    return ans

# 約数の数 == その数に掛け算でなるための組み合わせの数

def main(N):
    ans = 1
    for n in range(2, N):
        ans += get_number_comb(factorization_counta(n))
    print(ans)


if __name__ == '__main__':
    N = int(input())
    main(N)

Measured memory_bytes: 68412
#include <iostream>

using namespace std;

int t[300000];
int c[300000];

int main()
{
    int x, y, a, b, cnum;
    cin >> x >> y >> a >> b >> cnum;

    for (int i = 0; i < a; ++i)
    {
        cin >> t[i];
        c[i] = 1;
    }

    for (int i = a; i < a + b; ++i)
    {
        cin >> t[i];
        c[i] = 2;
    }

    for (int i = a+b; i < a+b+cnum; ++i)
    {
        cin >> t[i];
        c[i] = 0;
    }

    int n = a+b+cnum;

    for (int gap = n/2; gap > 0; gap /= 2)
    {
        for (int i = gap; i < n; ++i)
        {
            for (int j = i - gap; j >=0 && t[j] < t[j+gap]; j -= gap)
            {
                swap(t[j], t[j+gap]);
                swap(c[j], c[j+gap]);
            }
        }
    }


    int ca = 0, cb = 0, ct = 0;
    int64_t sum = 0;

    for (int i = 0; i < n && ct < x+y; ++i)
    {
        if (c[i] == 1 && ca < x)
        {
            sum += t[i];
            //cout << "c=1, ca =" << ca << ", +" << t[i] << "\n";
            ca++;
            ct++;
        }
        else if (c[i] == 2 && cb < y)
        {
            sum += t[i];
                        //cout << "c=2, cb=" << cb << ",+" << t[i] << "\n";
            cb++;
            ct++;
        }
        else if (c[i] == 0)
        {
            sum += t[i];
                       // cout << "+" << t[i] << "\n";
            ct++;
        }
    }

    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 2560
/*#pragma GCC optimize("Ofast") 
#pragma GCC target("avx,avx2,fma") 
#pragma GCC optimization("unroll-loops") */

#include<bits/stdc++.h>   
#include<tr1/unordered_map>
#define ll long long int   
#define pb push_back
#define mkp make_pair 
#define mod 1000000007 
#define maxn 100001 
#define ff first
#define ss second
using namespace std;    


int main(){    
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);     
  int n; 
  cin>>n;  
  ll arr[n];
  for(int i=0;i<n;++i) 
       cin>>arr[i]; 
  ll ans=0; 
  for(int i=1;i<n;++i){  
         if(arr[i]<arr[i-1]) 
             ans+=arr[i-1]-arr[i],arr[i]=arr[i-1];
     } 
    cout<<ans<<"\n";
  
  return 0;
}


Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,k;
	cin>>n>>k;
	ll a[1000010];
	ll sum=0;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	ll ans=1;
	vector<ll>sel;
	for(ll i=1;i<=sqrt(sum);i++){
		if(sum%i!=0){
			continue;
		}
		sel.push_back(i);
		sel.push_back(sum/i);
	}
	for(ll i=0;i<sel.size();i++){
//		cout << sel[i]<<" ";
		vector<ll>b;
		ll sum2=sel[i]*n;
//		cout << sum2 ;
		for(ll j=0;j<n;j++){
			ll now=a[j]%sel[i];
			b.push_back(now);
			sum2-=now;
			if(now==0){
				sum2-=sel[i];
			}
		}
//		cout <<"k"<< sum2 <<endl;
		if(sum2<=k){
			ans=max(ans,sel[i]);
			continue;
		}
		sort(b.begin(),b.end());
		ll sum3=0;
		for(ll j=0;j<n;j++){
			sum3+=b[j];
			if(b[j]!=0){
				sum2-=sel[i]-b[j];
			}
		//	cout <<"s"<< sum2<< " ";
			if(max(sum2,sum3)<=k){
				ans=max(ans,sel[i]);
				break;
			}
		}
	//	cout <<endl;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
/*lcm(gcd(N1, M), gcd(N2, M), ..., gcd(Nk, M)) = gcd(lcm(N1, ..., Nk), M)
gcd(lcm(N1, M), lcm(N2, M), ..., lcm(Nk, M)) = lcm(gcd(N1, ..., Nk), M).

If gcd(N1, N2) = 1, then
gcd(N1·N2, M) = gcd(N1, M)·gcd(N2, M)
lcm(N1·N2, M) = lcm(N1, M)·lcm(N2, M)/M.

lcm(M, N, P) · gcd(M, N) · gcd(N, P) · gcd(P, M) = NMP · gcd(N, M, P).
*/
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    int h,w;
    cin>>h>>w;
    bool ch[h][w];
    char a[h][w];
    int cnt=0;
    REP(i,h)
    {
        REP(j,w)
        {cin>>a[i][j];if(a[i][j]=='#')cnt++;}
    }
    if(cnt== h+w-1)
    cout<<"Possible";
    else
    {
        cout<<"Impossible";
    }
    
  }  
  return 0;
}
/* Look for:
* 0 based or 1 based indexing
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (int vs ll?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

Measured memory_bytes: 256
f = lambda: list(map(int,input().split()))
mod = 10**9+7

n = int(input())
a = sorted(f())
if n&1:
    if all([a[i] == i+i%2 for i in range(n)]):
        print(2**(n//2)%mod)
    else:
        print(0)
else:
    if all([a[i] == i+(i+1)%2 for i in range(n)]):
        print(2**(n//2)%mod)
    else:
        print(0)


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

const int N = 410;
const int M = 100010;

std::bitset <N> set[N];
bool flag[N];
int n, m;
int x[M], y[M];

int main(){
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++ i){
		scanf("%d%d", &x[i], &y[i]);
	}
	for (int i = 1; i <= n; ++ i){
		set[i][i] = 1;
		for (int j = m; j; -- j){
			if (set[i][x[j]] && set[i][y[j]]){
				flag[i] = true;
				break;
			}
			if (!set[i][x[j]] && !set[i][y[j]]){
				continue;
			}
			set[i][x[j]] = set[i][y[j]] = 1;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; ++ i){
		for (int j = i + 1; j <= n; ++ j){
			if (flag[i] || flag[j]){
				continue;
			}
			ans += (set[i] & set[j]).none();
		}
	}
	return printf("%d\n", ans), 0;
}

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

const int N = 1001;
const int modulo = 1e9 + 7;
char a[N][N];
long long dp[N][N] = {0};
int n, m; 

void result()
{
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			if((i+j)==0 || a[i][j]=='#')
				continue;
			if(i)
				dp[i][j] += dp[i-1][j];
			if(j)
				dp[i][j] += dp[i][j-1];
			dp[i][j] %= modulo;

		}
	}
	cout << dp[n-1][m-1] << endl;
}
int main()
{
	cin >> n >> m;                                   
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			cin >> a[i][j];
		}
	}
	result();	
	return 0;
}




Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
long long dp[110][100010];

int main(void){
    int n, wei;
    cin >> n >> wei;
    vector<long long> w(n+10), v(n+10);
    for(int i=1;i<=n;++i) cin >> w[i] >> v[i];
    for(int i=1;i<=n;++i){
        for(int j=0;j<=wei;++j){
            if(j-w[i] >= 0){
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout << dp[n][wei] << endl;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a, b, k; cin >> a >> b >> k;
  for(int i = 0; i < k; i++){
    if(a&1) a--;
    b += a/2;
    a /= 2;
    swap(a, b);
  }
  if(k&1) swap(a, b);
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define PP std::pair<int,int>
#define LL long long
int N;
int A, B;
std::vector<int> a;
int main() {
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		int tmp;
		std::cin >> tmp;
		a.push_back(tmp);
	}
	std::sort(a.rbegin(), a.rend());
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0)A += a[i];
		else B += a[i];
	}std::cout << A - B << std::endl;
	return 0;
}

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

const int MAX = 1000001; 
struct Query 
{ 
	int l, r, idx; 
}; 
bool cmp(Query x, Query y) 
{ 
	return x.r < y.r; 
} 
 
void update(int idx, int val, int bit[], int n) 
{ 
	for (; idx <= n; idx += idx&-idx) 
		bit[idx] += val; 
} 

int query(int idx, int bit[], int n) 
{ 
	int sum = 0; 
	for (; idx>0; idx-=idx&-idx) 
		sum += bit[idx]; 
	return sum; 
} 

void solve(int arr[], int n, Query queries[], int q) 
{ 
	int bit[n+1]; 
	memset(bit, 0, sizeof(bit)); 
	int prev_visit[MAX]; 
	memset(prev_visit, -1, sizeof(prev_visit)); 

	int ans[q]; 
	int query_counter = 0; 
	for (int i=0; i<n; i++) 
	{ 
		if (prev_visit[arr[i]] !=-1) 
			update (prev_visit[arr[i]] + 1, -1, bit, n); 

		prev_visit[arr[i]] = i; 
		update(i + 1, 1, bit, n); 
		while (query_counter < q && queries[query_counter].r == i) 
		{ 
			ans[queries[query_counter].idx] = 
					query(queries[query_counter].r + 1, bit, n)- 
					query(queries[query_counter].l, bit, n); 
			query_counter++; 
		} 
	} 
	for (int i=0; i<q; i++) 
		cout << ans[i] << endl; 
} 

// driver code 
int main() 
{ 
    int i,j,n,q,low,high;
    int a[500005]; 
    cin>>n>>q;
    for(i=0;i<n;i++)
        cin>>a[i];
	// int a[] = {1, 1, 2, 1, 3}; 
	// int n = sizeof(a)/sizeof(a[0]); 
	Query queries[500005];
    for(i=0;i<q;i++)
    {
        cin>>low>>high;
        queries[i].l = low-1; 
        queries[i].r = high-1; 
        queries[i].idx = i; 
    }
	sort(queries, queries+q, cmp); 
	solve(a, n, queries, q); 
	return 0; 
} 


Measured memory_bytes: 19312
def main():
    N = int(input())
    D = tuple(map(int, input().split()))
    M = int(input())
    T = tuple(map(int, input().split()))

    d = dict()
    for i in D:
        d[i] = d.get(i, 0) + 1

    t = dict()
    for i in T:
        t[i] = t.get(i, 0) + 1

    for key, val in t.items():
        if key in d.keys():
            d[key] -= val
            if d[key] < 0:
                ans = 'NO'
                break
        else:
            ans = 'NO'
            break
    else:
        ans = 'YES'

    print(ans)

main()


Measured memory_bytes: 56788
/*  Kadai4_2
    saitomo   */

#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979
//10^-9以下の誤差になるよう十分に PIを定義

int main(void){
    double len_h,len_m,hour,min;
    //左から順に時針の長さ、分針の長さ、時、分
    scanf("%lf%lf%lf%lf",&len_h,&len_m,&hour,&min);
    double angle,ans;
    //時針と分針の間の角度、答え
    angle=(0.5*(60*hour+min)-6*min)*PI/180;
    /*時針は1分に0.5度、分針は1分に6度動くことを利用し、差をとってからradに直している。
  　この際、cos(x)=cos(-x)より、正負は考えなくて良い*/
    ans=sqrt(len_h*len_h+len_m*len_m-2*len_h*len_m*cos(angle));
    //余弦定理の利用
    printf("%.10lf\n",ans);    

    return 0;
}


Measured memory_bytes: 2496
using System;

namespace AtCoder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());

            int bigcoin = input /500;

            input = input - 500* bigcoin;

            int smallcoin = input / 5;

            Console.WriteLine(1000 * bigcoin + 5 * smallcoin);






        }
    }


}


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

using namespace std;

int main()
{
    map<int,double>m;
    map<int,double>:: iterator itr;
    double n,t,a,h[1001],chk[1001];
    cin>>n;
    cin>>t>>a;
    for(int i=0; i<n; i++)
    {
        cin>>h[i];
        double equ=t-(.006*h[i]);
        if(equ>=a)
            m[i+1]=equ-a;
        else
            m[i+1]=a-equ;
    }
    double res=100000;
    for(itr=m.begin(); itr!=m.end(); itr++)
    {
        res=min(res,itr->second);
    }
    for(itr=m.begin(); itr!=m.end(); itr++)
    {
        if(itr->second==res)
        {
            cout<<itr->first;
            break;
        }
    }
    return 0;
}


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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;

    if(a<b && b<c)
        cout<<a<<" "<<b<<" "<<c<<endl;
    else if(a>b && b>c)
        cout<<c<<" "<<b<<" "<<a<<endl;
    else if(a<b && b>c)
        cout<<c<<" "<<a<<" "<<b<<endl;
    else if (a>b && b<c)
        cout<<b<<" "<<c<<" "<<a<<endl;
    else if (a==b && b<c)
        cout<<a<<" "<<b<<" "<<c<<endl;
    else if (a==b && b>c)
        cout<<c<<" "<<b<<" "<<a<<endl;
    else if (a>b && b==c)
        cout<<b<<" "<<c<<" "<<a<<endl;
    else if (a<b && b==c)
        cout<<a<<" "<<b<<" "<<c<<endl;
    else if (a==b && b==c)
        cout<<a<<" "<<b<<" "<<c<<endl;

    return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#define REP(i,n) for(i=0;i<n;i++)
#define REP1(i,n) for(i=1;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
typedef long long ll;
using namespace std;
int main(){
	int D, G, p[11], c[11];
	cin >> D >> G;
	for (int i = 0; i < D; ++i){
		cin >> p[i] >> c[i];
	}

	int ans = 1e9;
	for (int mask = 0; mask < (1 << D); ++mask){
		int s = 0, num = 0, rest_max = -1;
		for (int i = 0; i < D; ++i){
			if (mask >> i & 1){
				s += 100 * (i + 1) * p[i] + c[i];
				num += p[i];
			}
			else{
				rest_max = i;
			}
		}
		if (s < G){
			int s1 = 100 * (rest_max + 1);
			int need = (G - s + s1 - 1) / s1;
			if (need >= p[rest_max]){
				continue;
			}
			num += need;
		}
		ans = min(ans, num);
	}
	cout << ans << endl;
}

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

int main() {
  char N;
  cin >> N;
  
  string str = "abcdefghijklmnopqrstuvwxyz";
    
    for (int i = 0; i < str.size(); i++) {
      if (N == str.at(i)) {
        cout << str.at(i+1) <<endl;
        break;
      }
    }
      
}


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

int n;
string s[55];

int main(){
	cin >> n;
	for(int i=0; i < n; i++) cin >> s[i];
		string ans = "";
	for(char c = 'a';c<='z';c++){
		int mini = 100;
		for(int i = 0;i<n;i++){
			int cnt = 0;
			for(int j=0;j<s[i].size();j++){
				if(s[i][j] == c) cnt++;
			}
		mini = min(mini,cnt);
		}
		for(int i = 0;i<mini;i++){
			ans += c;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>  //min, max, sort, unique, fill
#include <cstring>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>  //pair, swap,
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using VI = vector<ll>;
using VB = vector<bool>;
using VP = vector<P>;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) for (ll i = 0; i < (n); i++)

static const ll kIntMax = numeric_limits<ll>::infinity();
static const double kFloatMax = numeric_limits<double>::infinity();

vector<ll> vi;

VI G[200];
ll match[200];
bool used[200];

bool dfs(int v) {
  used[v] = true;
  for (int i = 0; i < G[v].size(); i++) {
    ll u = G[v][i], w = match[u];
    if (w < 0 || !used[w] && dfs(w)) {
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int main() {
  ll n;
  cin >> n;
  VP r(n, make_pair(0, 0)), b(n, make_pair(0, 0));
  REP(i, n) cin >> r[i].first >> r[i].second;
  REP(i, n) cin >> b[i].first >> b[i].second;

  REP(i, n) {
    REP(j, n) {
      if (r[i].first < b[j].first && r[i].second < b[j].second) {
        G[i].push_back(j + 100);
        G[j + 100].push_back(i);
      }
    }
  }

  ll res = 0;
  REP(i, 200) match[i] = -1;
  for (int v = 0; v < 200; v++) {
    if (match[v] < 0) {
      REP(i, 200) used[i] = false;
      if (dfs(v)) {
        res++;
      }
    }
  }
  cout << res << endl;
  return 0;
}


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

int main(){
	double v;
	int h;
	int ans;
	double g=9.8;

	while(scanf("%lf",&v)!=EOF){
		ans=1;
		h=5*(ans-1);
		while(2*g*h<v*v){
			ans++;
			h=5*(ans-1);
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    rep (i, H) {
        string S;
        cin >> S;
        cout << S << endl;
        cout << S << endl;
    }

    return 0;
}


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

public class Main{ 
	
	static class FastReader{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

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

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

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

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

	public static void main(String[] args) 
	{ 
        FastReader sc = new FastReader(); 
        //PrintWriter out = new PrintWriter(System.out); 

        int n = sc.nextInt();
        
       	double[] arr = new double[n+10];
        double[][] dp = new double[n+10][n+10];

        for(int i=1;i<=n;i++){
        	arr[i] = sc.nextDouble();
		}
        
        dp[1][0] = 1.0 - arr[1];
        dp[1][1] = arr[1];

        for(int i=1;i<n;i++){
        	for(int j=0;j<=n;j++){
        		if(j>i) continue;
        		dp[i+1][j] += dp[i][j]*(1.0 - arr[i+1]);
        		dp[i+1][j+1] += dp[i][j]*(arr[i+1]);
        	}
        }
        
        double ans = 0.0;
        for(int i=(n+1)/2; i<=n; i++){
        	ans += dp[n][i];
        }
        System.out.println(ans);
        
	}
}


Measured memory_bytes: 131784
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numba
def main():
    @numba.njit
    def solve(n):
        r = 0
        for i1 in range(1, n + 1):
            y = n // i1
            r += y * (y + 1) // 2 * i1
        return r
    no = int(input())
    print(solve(no))


if __name__ == '__main__':
    main()

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int x;
	cin >> x;
	cout << (x >= 30 ? "Yes" : "No") << endl;
    
    return 0;
}



Measured memory_bytes: 3544