akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
    int A1,A2;
    scanf("%d %d",&A1,&A2);

    if(A1== 1 && A2==2)
        printf("3\n");
    else if ( A1==1 && A2==3)
    printf("2\n");
    else if ( A1==2 && A2==3)
    printf("1\n");
     else if ( A2==1 && A1==3)
    printf("2\n");
    else if ( A2==2 && A1==3)
    printf("1\n");
     else if ( A2==1 && A1==2)
    printf("3\n");

    return 0;

}





Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll dp[20][10000][2][2];
bool ju(ll n){
  if((n/100)!=51) return false;
  if((n%10)!=3) return  false;
  return true;
}
int main(){
  string s;
  cin>>s;
  ll n=sz(s);
  memset(dp,0,sizeof(dp));
  dp[0][0][0][0]=1;
  rep(i,n){
    rep(j,10000)rep(k,10){
      ll nj=(j%1000)*10+k;
      {
        dp[i+1][nj][1][1]+=dp[i][j][1][1];
        if(ju(nj)){
          dp[i+1][nj][1][1]+=dp[i][j][0][1];
        }
        else dp[i+1][nj][0][1]+=dp[i][j][0][1];
      }
      if(k<(s[i]-'0')){
        dp[i+1][nj][1][1]+=dp[i][j][1][0];
        if(ju(nj)) dp[i+1][nj][1][1]+=dp[i][j][0][0];
        else dp[i+1][nj][0][1]+=dp[i][j][0][0];
      }
      if(k==(s[i]-'0')){
        dp[i+1][nj][1][0]+=dp[i][j][1][0];
        if(ju(nj)) dp[i+1][nj][1][0]+=dp[i][j][0][0];
        else dp[i+1][nj][0][0]+=dp[i][j][0][0];
      }
    }
  }
  ll ans=0;
  rep(i,10000){
    ans+=dp[n][i][1][0]+dp[n][i][1][1];
  }
  COUT(ans);
}


Measured memory_bytes: 9444
($N,$A,$B) = split" ",<STDIN>;

$sum=0;
for($i=1;$i<=$N;$i++){
	$S=($i/10000%10)+($i/1000%10)+($i/100%10)+($i/10%10)+($i%10);
	$sum+=$i if ($A<=$S && $S<=$B );
}
print $sum;


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.ABC064
{
    class ColorfulLeaderBoard
    {
        public static void Main()
        {
            var n = int.Parse(ReadLine().Trim());
            var a = ReadLine().Trim().Split(' ').Select(_ => int.Parse(_) / 400);
            var constColor = a.Where(_ => _ < 8).Distinct().ToArray().Length;
            var variableColor = a.Where(_ => _ >= 8).ToArray().Length;
            var min = constColor == 0 ? 1 : constColor;
            var max = constColor + variableColor;
            WriteLine(min.ToString() + ' ' + max.ToString());
        }
    }
}


Measured memory_bytes: 13280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int rs = (int) (a + Math.pow(a, 2) + Math.pow(a, 3));
		System.out.println(rs);
	}
}

Measured memory_bytes: 35836
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.conv;
import std.typecons;

void main() {
	auto ip = readAs!(int[]), H = ip[0], W = ip[1];
	string[] a = new string[](H);
	foreach(i; 0..H) {
		a[i] = rs();
	}
	'#'.repeat(W + 2).writeln;
	foreach(i; 0..H) {
		'#'.write;
		a[i].write;
		'#'.writeln;
	}
	'#'.repeat(W + 2).writeln;
}

// ===================================

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (isBasicType!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

int ri() {
	return readAs!int;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n, m, number, is_false;
  scanf("%d %d", &n, &m);
  int a[n];
  
  number = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);  
    number += a[i];
  }

  is_false = 0;
  for (int i = 0; i < n; i++) {
    if ( a[i] < (number / (double)(4 * m)) ) {
      is_false++;
    }
  }

  if (n - is_false >= m) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
long long ni(long long ta, vector<long long> & v) {

}
long long rui(long long n, long long k, long long p) {
	if (k == 0) {
		return 1;
	}
	else {
		long long a = rui(n, k / 2, p);
		if (k % 2 == 0) {
			return (a*a) % p;
		}
		return (((a*a) % p)*n) % p;
	}
}
int main(){
	int h, w, x, y;
	cin >> h >> w >> x >> y;
	if (h*w*(x + y) % 2 == 1) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}


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

using namespace std;

typedef long long ll;

int readint(){
	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=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int cys=998244353;
int n;
char s[2005];
int sum[2005],d[4005][4005];

int mod(int x){return x>=cys?x-cys:x;}

int main(){
	scanf("%s",s+1); n=strlen(s+1);
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+s[i]-'0';
	d[0][0]=1;
	for(int i=1;i<=2*n;i++){
		for(int j=sum[min(n,i)];j>=0;j--){
			if(i-j<=2*min(n,i)-sum[min(n,i)]) d[i][j]=d[i-1][j];
			if(j>=1) d[i][j]=mod(d[i][j]+d[i-1][j-1]);
		}
	}
	cout<<d[2*n][sum[n]]<<endl;
	return 0;
}

Measured memory_bytes: 61312
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-10;
const vi emp;

vi a(6);

int main(){
	for(auto i=a.begin();i!=a.end();i++) cin>>*i;
	sort(a.begin(),a.begin()+4);
	sort(a.begin()+4,a.end());
	cout<<a[1]+a[2]+a[3]+a[5]<<endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e6+5;

int n, b=0, f=0;
int a[N];

int calc(int m)
{
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans+=abs(a[i]-(m+i));
	}
	return ans;
}

int ternary_search(int lo, int hi)
{
	while(lo<hi-2)
	{
		int m1=(lo*2+hi)/3;
		int m2=(lo+2*hi)/3;
		if(calc(m1)>calc(m2))
			lo=m1;
		else
			hi=m2;
	}
	int ans=calc(lo);
	for(int i=lo-2;i<=lo+2;i++)
		ans=min(ans, calc(i));
	return ans;
}

int32_t main()
{
	IOS;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int ans=ternary_search(-2e9, 2e9);
	cout<<ans;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int a[3],temp,i,j;
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  for(i=0;i<2;i++){
    for(j=0;j<2;j++){
      if(a[j]>a[j+1]){
	temp=a[j];
	a[j]=a[j+1];
	a[j+1]=temp;
      }
    }
  }
  printf("%d %d %d\n",a[0],a[1],a[2]);
  return(0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
constexpr int mod = 1e9+7;

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> broken(n+1, false);
  rep(i,m) {
    int a;
    cin >> a;
    broken[a] = true;
  }

  vector<int> dp(n+1,0);
  dp[0] = 1;
  rep(i,n) {
    dp[i] %= mod;
    if (!broken[i+1]) dp[i+1] += dp[i];
    if (!broken[i+2]) dp[i+2] += dp[i];
  }
  cout << dp[n] % mod << endl;
  return 0;
}

Measured memory_bytes: 3728
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		//標準入力の読み込み
		Scanner sc = new Scanner(System.in);
		//入力値を格納
		int lcA = sc.nextInt();
		int lcB = sc.nextInt();
		int lcC = sc.nextInt();
		int disD = sc.nextInt();
		
		//2点間の距離判定
		//C地点とA地点で直接会話可能か
		boolean isTalkableBetWeenCAndA = Math.abs(lcA - lcC) <= disD;
		//B地点とA地点で直接会話可能か
		boolean isTalkableBetWeenAAndB = Math.abs(lcB - lcA) <= disD;
		//A地点とB地点で直接会話可能か
		boolean isTalkableBetWeenBAndC = Math.abs(lcB - lcC) <= disD;;
		
		if (isTalkableBetWeenCAndA || (isTalkableBetWeenAAndB && isTalkableBetWeenBAndC) ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
// #include<bits/stdc++.h>
// using namespace std;
 
// const int N = 10000, MAXI = 100000, D = 10;
 
// int main() {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
//     srand(time(nullptr));
//     int tc = 100, flag = 1;
//     cout << tc << "\n";
//     while (tc--)
//     {
//     	cout << rand()%D + 1 << " " << rand()%D + 1 << " " << rand()%D + 1 << " " << rand()%D + 1;

//     	cout << "\n~\n";
    	
//     }
 
//     return 0;
// }
 
 
 
 
 
 
 
 
//---------------------------------------------//
 
 
 
/*
#define int long long 
#define mod (int)(1e9+9)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 */ 
 
 
 
 
 
 
//  /* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
//#define int long long
#define mod (int)(1e9+7)
#define N 100005

vector<int> gr[N];

int n, m, indeg[N], vis[N], ans[N];


void dfs(int ch, int par, int lvl)
{
	vis[ch] = 1;
	for(auto i:gr[ch]){
		if(vis[i]==0){
			dfs(i, ch, lvl+1);
		}
		ans[ch] = max(ans[ch], ans[i]+1);
	}
}

// Driver code to test above functions
int32_t main()
{
    
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);


    cin >> n >> m;
    memset(indeg, 0, sizeof indeg);
    memset(vis, 0, sizeof vis);

    for(int i=1;i<=m;i++)
    {
    	int x, y;
    	cin >> x >> y;
    	gr[x].push_back(y);
    	indeg[y]++;
    }

    for(int i=1;i<=n;i++)
    {
    	if(indeg[i]==0 and vis[i]==0)
    		dfs(i, 0, 0);
    }

    int res = 0;
    for(int i=1;i<=n;i++)
    	res = max(res, ans[i]);

    cout << res;
    
    return 0;
 
} 

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    double cx = 0;
    double cy = 0;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        cx += x[i];
        cy += y[i];
    }
    cx /= n;
    double gradient = 0.1;
    double max_dist;
    for (int ctr = 0; ctr < 1000000; ++ctr) {
        int max_ind = -1;
        max_dist = 0;
        for (int i = 0; i < n; ++i) {
            double dx = cx - x[i];
            double dy = cy - y[i];
            double curr_dist = dx * dx + dy * dy;
            if (curr_dist > max_dist) {
                max_dist = curr_dist;
                max_ind = i;
            }
        }
        cx += (x[max_ind] - cx) * gradient;
        cy += (y[max_ind] - cy) * gradient;
        gradient *= 0.999;
    }
    cout << sqrt(max_dist) << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
typedef vector<vector<int> > VVI;
const int INF = 1e9;
const double EPS = 1e-6;

int main()
{
	int W, D;
	while (cin>>W>>D, W) {
		vector<int> hw(W), hd(D);
		rep(i, W) cin>>hw[i];
		rep(i, D) cin>>hd[i];
		
		for (int i=0; i<W; i++) {
			for (int j=0; j<D; j++) {
				if (hw[i] == hd[j]) {
					hd[j] = 0;
					break;
				}
			}
		}
		
		int ans=0;
		rep(i, W) ans+=hw[i];
		rep(i, D) ans+=hd[i];
		cout << ans << endl;
	}
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(z) for(int i=1;i<=z;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
#define mod  1000000007
#define cl(n,m) (n-1)/m  + 1 ;
#define T() int TT; cin>>TT; while(TT--)
#define P pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
const int N = 2e6 + 5 ;

signed main(){
	int a, b  ;
	cin >> a >> b ;
	if( a*b <=0 ) cout << "Zero\n" ;
	else if( a+ b <0 ){
		if( abs(b-a)&1 ) cout <<"Positive\n" ;
		else cout <<"Negative\n" ;
	}
	else cout << "Positive\n" ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

int main(void)
{
    string str;
    cin >> str;

    str[5] = ' ';
    str[13] = ' ';
    cout << str << endl;
    return (0);
}

Measured memory_bytes: 256
n = int(input())
ai = [int(i) for i in input().split()]

ans = 1

ai.sort(reverse=True)

if ai[n-1] == 0:
    print(0)
    exit()

for i in range(n):
    ans *= ai[i]
    if ans > 10**18:
        print(-1)
        exit()
    
print(ans)

Measured memory_bytes: 21716
import sys

input=sys.stdin.buffer.readline


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

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')


def main():
	n=II()
	XY=[LI() for _ in range(n)]
	
	A=[]
	B=[]
	for x,y in XY:
		A.append(x+y)
		B.append(x-y)
	
	A.sort()
	B.sort()
	a=A[-1]-A[0]
	b=B[-1]-B[0]
	
	print(max(a,b))










if __name__=="__main__":
	main()


Measured memory_bytes: 62336
def ABC144_20191027_B():    
    n = int(input())
    flag =False
    for i in range(1,10):
        for j in range(1,10):
            if n == i * j:
                flag = True
                break
    if flag == True:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    ABC144_20191027_B()

Measured memory_bytes: 2940
# -*- coding: utf-8 -*-
def solve():
    N, A, B, C, D = map(int, input().split()) 
    S = input()
    if "##" in S[A-1:C] or "##" in S[B-1:D]:
        return "No"
    if C > D and not "..." in S[B-2:D+1]:
        return "No"

    return 'Yes'

if __name__ == '__main__':
    print(solve())



Measured memory_bytes: 3572
k, n = map(int, input().split())
A = list(map(int, input().split()))

n -= 1
d_right = A[n] - A[0]
d_left = d_right

for i in range(1, n):
	d = k - A[i] + A[i - 1]
	if d < d_right:
		d_right = d

for j in range(0, n):
	l = k + A[j] - A[j + 1]
	if l < d_left:
		d_left = l

print(min(d_left, d_right)) 

Measured memory_bytes: 25836
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fr(i,n,x) for(int i=0;i<n;i+=x)
#define pb push_back
#define ff first
#define ss second 

int main(){	
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  	int n;
  	cin>>n;
  	n=n%1000;
  	if(n>0)
  	n=1000-n;
  	cout<<n;
  		
	
}


Measured memory_bytes: 3680
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			int len = s.length;
			int[] count = new int[26];

			for (int i = 0; i < len; i++) {
				count[s[i]-'a']++;
			}

			long ans = 1;
			int tmpLen = len;
			for (int i = 0; i < len; i++) {
				ans += tmpLen - count[s[i]-'a'];
				tmpLen--;
				count[s[i]-'a']--;
			}

			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

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

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

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i = 0; i < N; i++){
    cin >>vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int ans = 0;
  int anl = 0;
  
  for (int i = 0; i < N; i+=2){
    ans += vec.at(i);
  }
  for (int i = 1; i < N; i +=2){
    anl += vec.at(i);
  }
  
  cout << ans - anl << endl;
  
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP(x)	make_pair(x)
 
#define debug(_x)		cerr << #_x << '=' << _x << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << _x << ' ' << #_y << '=' << _y << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << _x << ' '; cerr << endl;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;
 
const int INF = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;

//MODULAR ARITHMATIC
const int mmod = 1000000007;

//ADD
int add(int a, int b, int m=mmod) {
	a %= m;
	a += b;
	a %= m;
	return a;
}

//SUB
int sub(int a, int b, int m=mmod) {
    return (a%m - b%m + m)%m;
}

//MUL
int mul(int a, int b, int m=mmod) {
	return ((a%m) * (b%m) % m);
}

//POW
int pow(int a, int b, int m=mmod) {
    a %= m;
    int r = 1;
    while (b) {
		if (b&1) r = r*a%m;
		b >>= 1;
		a = a*a%m;
    }
    return r;
}

//INV
int inv(int a, int m=mmod) {
	return pow(a, m-2, m);
}

int32_t main() {
	FAST_IO;

	int n, k;
	cin >> n >> k;
	
	int a[k+5];
	int ans = 0;
	for (int i = k; i >= 1; i--) {
		int cnt = pow(k/i, n);
		for (int j = i+i; j <= k; j+=i) {
			cnt = sub(cnt, a[j]);
		}
		a[i] = cnt;
		ans = add(ans, mul(i, cnt));
	}
	cout << ans << endl;
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


Measured memory_bytes: 4420
import math
line = raw_input()
N, K = [int(s) for s in line.split(' ')]
ret = []
if K % 2 == 1:
    count = N // K
    print count * count * count
else:
    k = K / 2
    count = int(math.ceil(N / k))
    odds = count // 2
    evens = count - odds
    all_counts = odds * odds * odds + evens * evens * evens
    print all_counts


Measured memory_bytes: 2568
while true
        input = STDIN.gets.split(' ')
        h = input[0].to_i
        w = input[1].to_i

        break if (h == 0 && w == 0)

        h.times {|i|
                w.times {|j|
                        print "#"
                }
                print "\n"
        }
        print "\n"

end

Measured memory_bytes: 6096
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
typedef long long lint;

namespace utils{
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=c=='-'&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	int a=nxi(),b=nxi(),c=nxi(),x=nxi(),y=nxi();
	int n=std::min(x,y);
	if(a+b<=2*c){
		printf("%d\n",a*x+b*y);
	}else{
		printf("%d\n",n*c*2+(x-n)*std::min(a,c*2)+(y-n)*std::min(b,c*2));
	}
	return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x << " " << x << '\n';
#define int long long
signed main()
{
   int n,cnt=0;
   cin >> n;
   for(int i=1;i<=n;i++)
   {
       string s = std::to_string(i);
       if(s.size()&1) cnt++;
   }
   cout << cnt;
}


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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    FOREACH(x, v) { cout << x << " "; }                                        \
    cout << "\n";

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N;
map<char, ll> name;

int main() {
    cin >> N;
    REP(i, N) {
        SCIN(s);
        name[s[0]]++;
    }
    ll ans = 0;
    string ma = "MARCH";
    REP(i, 5) FOR(j, i + 1, 5) FOR(k, j + 1, 5) {
        ans += name[ma[i]] * name[ma[j]] * name[ma[k]];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>

int main() {
	int alice, bob;
	std::string result;
	std::map<int,int> mp;
	mp[1] = 13;
	mp[2] = 0;
	mp[3] = 1;
	mp[4] = 3;
	mp[5] = 4;
	mp[6] = 5;
	mp[7] = 6;
	mp[8] = 7;
	mp[9] = 8;
	mp[10] = 9;
	mp[11] = 10;
	mp[12] = 11;
	mp[13] = 12;

	std::cin >> alice >> bob;

	mp[alice]>mp[bob]? result = "Alice" : mp[alice] < mp[bob] ? result = "Bob" : result = "Draw";

	std::cout << result << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}
 
int main() {
    int n;
    cin >> n;
    vector<double> X(n);
    vector<string> U(n);
    rep(i,n) {
        cin >> X[i] >> U[i];
    }
    double total =0;
    rep(i,n) {
        if (U[i] == "BTC") {
            total += X[i]*380000.0;
        } else {
            total += X[i];
        }
    }
    cout << total << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  	int  k;cin>>k;
  cout<<arr[k-1]<<endl;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
#define MK make_pair
const ll E=1e18+7;
const ll MOD=1000000007;

class SCC{
private:
    vector<vector<ll>> E;
    vector<vector<ll>> rev;
    ll V;
    vector<ll> v;
    vector<ll> group;
    
    void dfs(ll where,ll &count){
        v[where]=-2;
        for(int i=0;i<E[where].size();i++){
            ll t=E[where][i];
            if(v[t]!=-1){continue;}
            dfs(t,count);
        }
        v[where]=count;
        count++;
    }
    
    void first(){
        ll count=0;
        for(int i=0;i<V;i++){
            if(v[i]==-1){dfs(i,count);}
        }
    }
    
    void rev_dfs(ll where,ll count){
        group[where]=count;
        for(int i=0;i<rev[where].size();i++){
            ll t=rev[where][i];
            if(group[t]!=-1){continue;}
            rev_dfs(t,count);
        }
    }
    
    void second(){
        vector<pll> number;
        for(int i=0;i<V;i++){
            number.push_back({v[i],i});
        }
        sort(number.begin(),number.end(),greater<pll>());
        ll count=0;
        for(int i=0;i<V;i++){
            ll where=number[i].S;
            if(group[where]==-1){
                rev_dfs(where,count);
                count++;
            }
        }
    }
    
    void clear(ll a){
        for(ll i=a;i<V;i++){
            v[i]=-1;
            group[i]=-1;
        }
    }
    
public:
    SCC(ll V=0):V(V){
        v.resize(V,-1);
        E.resize(V);
        rev.resize(V);
        group.resize(V,-1);
    }
    
    void add_edge(ll from,ll to){
        E[from].push_back(to);
        rev[to].push_back(from);
    }
    
    void add_node(){
        V++;
        v.resize(V);
        E.resize(V);
        rev.resize(V);
        group.resize(V);
    }
    
    void add_node(ll number){
        V+=number;
        v.resize(V);
        E.resize(V);
        rev.resize(V);
        group.resize(V);
    }
    
    vector<ll> solve(){
        clear();
        first();
        second();
        return group;
    }
    
    //グラフの形を保ったまま初期化
    void clear(){
        for(int i=0;i<V;i++){
            v[i]=-1;
            group[i]=-1;
        }
    }
};


int main(){
    ll v,e;
    cin>>v>>e;
    SCC scc(v);
    for(int i=0;i<e;i++){
        ll s,t;
        cin>>s>>t;
        scc.add_edge(s,t);
    }
    vector<ll> group=scc.solve();
    ll q;
    cin>>q;
    while(q--){
        ll a,b;
        cin>>a>>b;
        if(group[a]==group[b]){cout<<1<<endl;}
        else{cout<<0<<endl;}
    }
    
    
    return 0;
}



Measured memory_bytes: 4812
#include <cstdio>
using namespace std;
int N; char S[105];
int main() {
  scanf("%d\n%s\n", &N, S+1);
  int cnt[2][105] = {0};
  for(int i = 1; i <= N; ++i) {
    if(S[i] == '(') {
      cnt[0][i] = cnt[0][i-1]+1;
      cnt[1][i] = cnt[1][i-1];
    } else {
      if(cnt[0][i-1] > 0) {
        cnt[0][i] = cnt[0][i-1]-1;
        cnt[1][i] = cnt[1][i-1];
      } else {
        cnt[0][i] = cnt[0][i-1];
        cnt[1][i] = cnt[1][i-1]+1;
      }
    }
  }
  for(int i = 0; i < cnt[1][N]; ++i) printf("%c", '(');
  printf("%s", S+1);
  for(int i = 0; i < cnt[0][N]; ++i) printf("%c", ')');
  printf("\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N, K, Q, tmp; cin >> N >> K >> Q;
    vector<int> A, points(N, K);
    rep (i, 0, Q) {
        int a; cin >> a;
        points[a-1] += 1;
    }

    rep (i, 0, points.size()) {
        if (points[i]-Q >= 1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1024
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    adj = [[] for _ in range(n)] #頂点数, 場合によって変える
    for _ in range(m):
        a,b = map(int, input().split())
        adj[a-1].append(b-1)
    s,t = map(int, input().split())
    s -= 1
    t -= 1

    d1 = [inf]*n
    d2 = [inf]*n
    d0 = [inf]*n
    d0[s] = 0
    d = deque([[s, 0]])
    while d:
        v, hosuu = d.popleft()
        hosuu += 1
        for nv in adj[v]:
            if hosuu%3==1 and d1[nv]>hosuu:
                d1[nv] = hosuu 
                d.append([nv, hosuu])
            if hosuu%3==2 and d2[nv]>hosuu:
                d2[nv] = hosuu
                d.append([nv, hosuu])
            if hosuu%3==0 and d0[nv]>hosuu:
                d0[nv] = hosuu
                d.append([nv, hosuu])
    if d0[t]==inf:
        print(-1)
    else:
        print(d0[t]//3)

if __name__ == '__main__':
    main()

Measured memory_bytes: 64748
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let m: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av = vec![true; n + 1];
    for _ in 0..m {
        av[read::<usize>(&mut stdin_lock, &mut buf, b'\n')] = false;
    }

    let mut tbl = vec![0i32; n + 1];
    tbl[0] = 1;
    for i in 1..n + 1 {
        let p2 = if i >= 2 && av[i - 2] { tbl[i - 2] } else { 0 };
        let p1 = if i >= 1 && av[i - 1] { tbl[i - 1] } else { 0 };
        tbl[i] = (p2 % 1_000_000_007 + p1 % 1_000_000_007) % 1_000_000_007;
    }
    print!("{}", tbl[n]);
}


Measured memory_bytes: 4352
#include<iostream>

using namespace std;

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

	int ans=0;

	for(int i=1;i<=n;i=i+2)
	{
		int count=0;
		for(int j=1;j<=i;j++)
			if(i%j==0)count++;
		if(count==8)
			ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#C
import itertools
N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

l = [i+1 for i in range(N)]
p_list = list(itertools.permutations(l, N))
p_list.sort()
a = p_list.index(P)
b = p_list.index(Q)
 
print(abs(a-b))
#print(p_list)


Measured memory_bytes: 8052
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#define ll long long
using namespace std;
const int N=200005;
 
inline int read(){
    int x=0; char ch=getchar();
    for(;!isdigit(ch);ch=getchar());
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
    return x;
}
 
int n,px,py;
ll a[N],ans=1e18,tot,now,mx,mn;
 
inline void update(){
    if(now<mn) mn=now;
    else if(now>mx) mx=now;
}
 
inline void solve(){
    for(int i=1;i<=n;i++){
        while(px<i&&a[px+1]*2ll<=a[i]) px++;
        while(py<n&&a[py+1]*2ll<=tot+a[i]) py++;
         
        for(int u=px+1;u>=px;u--)
            for(int v=py+1;v>=py;v--){
                mx=mn=a[u];
                 
                now=a[i]-a[u],update();
                now=a[v]-a[i],update();
                now=tot-a[v],update();
                 
                ans=min(ans,mx-mn);
            }
    }
}
 
int main(){
    n=read();
    for(int i=1;i<=n;i++) a[i]=a[i-1]+(ll)read();
    a[n+1]=a[n+2]=tot=a[n];
    solve(),printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1792
/*
author: orthodoxparadox
09-Jan-2019
10:50:00
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define dbl long double
#define int ll
#define ll long long
#define pii pair<int, int>
#define fup(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define fnu for(ll i = 0; i < n; i++)
#define rev(Y) reverse(all(Y))
#define oiint ostream_iterator<int>(cout, " ") 
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define onlyunique(v) v.erase(unique(all(v)), v.end()); //only for sorted vector
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef __APPLE__
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define dbg(...)
#endif
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(int i=0;i<v.size();++i) x<<v[i]<<" ";return x;} 
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;} 
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
struct pair_hash {inline std::size_t operator()(const std::pair<int, int> & v) const {return v.first*31+v.second;}};
const int mod = 1e9 + 7;

int takemod(int a){return ((a%mod)+mod)%mod;}

int fast_exp(int base, int expo) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;}
	return res;}

int modinv(int a){return takemod(fast_exp(takemod(a), mod-2));}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	#ifdef __APPLE__
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
	clock_t t1, t2;
	t1 = clock();

	int n;
	cin >> n;
	int h[n+1];
	for(int i = 0; i < n; i++) cin >> h[i+1];
	h[0] = h[1];
	int dp[n+1];
	dp[0] = 0;
	dp[1] = 0;
	for(int i = 2; i <= n; i++)
	{
		dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
		dbg(i, dp[i]);
	}
	cout << dp[n];
	t2 = clock(); cerr << "time taken: " << (t2-t1)/(dbl)CLOCKS_PER_SEC;
	return 0;
}

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

#define int long long

main() {
    int n; cin >> n;
    int lr[] = {-1, 1};
    vector<int> ord;
    vector<int> a(n), w(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i) ord.push_back(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> w[i];
    }
    int ans = 1000000007;
    do {
        int tmp = 0;
        vector<int> cnd{0};
        for (int i = 0; i < n - 1; i++) cnd.push_back(ord[i]);
        for (int i = 0; i < n; i++) {
            if (a[cnd[(i + n + lr[a[cnd[i]]]) % n]] != a[cnd[i]]) {
                tmp += w[cnd[i]];
            }
        }
        ans = min(ans, tmp);
    } while (next_permutation(ord.begin(), ord.end()));
    cout << ans << endl;
}


Measured memory_bytes: 3136
N,X=map(int,input().split())
a,p=[1],[1]
for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)
def f(n,x):
    if n==0:return 0 if x<=0 else 1
    elif x<=1+a[n-1]:return f(n-1,x-1)
    else:return p[n-1]+1+f(n-1,x-2-a[n-1])
print(f(N,X))

Measured memory_bytes: 38384
A,B=map(int,input().split())
flag = True
res = 0
for i in range(2000):
  n8 = int(i * 0.08)
  n10 = int(i* 0.1)
  if n8 == A and n10 == B:
    flag = False
    res = i
    break
  elif n10 == A and n8 == B:
    flag=False
    res = i
    break
  else:
    pass
if flag:
  print(-1)
else:
  print(res)

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

using ll=long long;
using namespace std;

int main(){
    int k,n;
    cin>>k>>n;
    vector<int> a(n);
    vector<int> ans(n,0);
    
    for(int i=0;i<n;i++)
        cin>>a[i];
    
    for(int i=0;i<n;i++){
        if(i!=n-1)
            ans[i]=a[i+1]-a[i];
        else
            ans[i]=k-a[i]+a[0];
    }
    
    sort(ans.begin(),ans.end());
    
    int ans1=0;
    for(int i=0;i<n-1;i++)
        ans1 +=ans[i];
    
    cout<<ans1<<endl;
}

Measured memory_bytes: 1792
N, M = list(map(int, input().split()))
kens = [[] for _ in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    kens[x - 1].append((y, i))

ans = [[]for i in range(M)]
for i,ken in enumerate(kens):
    ken = sorted(ken)
    ken_number = i + 1
    for j, city in enumerate(ken):
        output_order = city[1]
        rank = j + 1
        ans[output_order] = "%06d%06d" % (ken_number,rank)
for i in ans:
    print(i)


Measured memory_bytes: 35936
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


n = str_inp()
ans = 0
for i in n:
    ans += int(i)
    ans %= 9
if ans == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 78628
#include <bits/stdc++.h>
#define rep(i, n)                                                              \
    for (int64_t i = 0; i < (int64_t)(n); i++)                                 \
        ;
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;
using namespace std;
int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t k, x;
    cin >> k >> x;
    string res = 500 * k >= x ? "Yes" : "No";
    cout << res << endl;
    // return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <iostream>
// #include <algorithm>
// #include <string>
// #include <vector>
// #include <queue>
// #include <stack>
// #include <set>
// #include <map>

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a;i >= n;i--)
#define INF 999999999
#define pb(a) push_back(a)

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
using namespace std;

typedef pair<int, int> pii;
typedef long long int ll;
typedef vector<pii> VP;

int main(void) {
    int c,d; cin >> c >> d;
    int a = min(c,d);
    int b = max(c,d);
    if(a <= 0 && b >= 0) cout << "Zero" << endl;
    else if(a > 0 && b > 0) cout << "Positive" << endl;
    else {
        if(abs(a - b) % 2 == 0) cout << "Negative" << endl;
        else cout << "Positive" << endl; 
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
           Scanner scanner = new Scanner(System.in);
           int a = scanner.nextInt();
           int b = scanner.nextInt();
           if((a * b) % 2 == 0) {
               System.out.println("Even");
           }else {
               System.out.println("Odd");
           }
    }
}


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

int main(){
  ll N,A,minus=0,ans=0,Min=10e9;
  bool zero=false;
  cin >>N;
  
  for(int i=0; i<N; i++){
    cin >> A;
    if(A<0) minus++;
    else if(A==0)zero=true;
    if(abs(A)<Min)Min=abs(A);
    ans+=abs(A);
  }
  
  if(minus%2==1&&zero==false)ans-=Min*2;
  
  cout<< ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

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


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long N;
	cin>>N;
	long long h[N];
	for(int i=0;i<N;i++)cin>>h[i];
	int x=0;
	int ans=0;
	for(int i=0;i<N;i++){
		if(x<h[i]){
			ans+=h[i]-x;
			x=h[i];
		}else if(x>h[i]){
			x=h[i];
		}
	}
	cout<<ans<<endl;
}

	


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, 0)
	}

	var a, b int
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b)
		a--
		b--
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	d := make([]int, n)
	for i := 0; i < n; i++ {
		d[i] = -1
	}
	d[0] = 0

	q := make([]int, 0)
	q = append(q, 0)
	for len(q) > 0 {
		v := q[0]
		q = q[1:]

		for _, u := range g[v] {
			if d[u] > -1 {
				continue
			}
			d[u] = v + 1
			q = append(q, u)
		}
	}

	for i := 0; i < n; i++ {
		if d[i] == -1 {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
	for i := 1; i < n; i++ {
		fmt.Println(d[i])
	}
}


Measured memory_bytes: 19092
N,K = map(int,input().split())

height = []
for i in range(N):
  height.append(int(input()))
                
height.sort()
dif = [0]*(N-1)
for i in range(N-1):
  dif[i] = height[i+1]-height[i]

diflist = [dif[0]]*(N-1)
for i in range(1,N-1):
  diflist[i] = diflist[i-1] + dif[i]

diflist.insert(0,0)
ans = 10**10
for i in range(N-K+1):
  pro = diflist[i+K-1]-diflist[i]
  ans = min(ans,pro)
  
print(ans)


Measured memory_bytes: 14928
n=int(input())
lamp=[]
status=1
count=0
possible=0
for i in range(n):
  p=int(input())
  lamp.append(p)
while status!=2:
  if lamp[status-1]!=0:
    var=lamp[status-1]
    lamp[status-1]=0
    status=var
    count+=1
  else:
    possible+=1
    break
if possible==0:
  print(count)
else:
  print(-1)


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

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

char s;
int count = 0;
for (int i = 0; i < N; i++) {
    cin >> s;
    if (s =='Y') {
        count++;
    }
}
if (count > 0) {
    cout << "Four" << endl;
}
else {
    cout << "Three" << endl;
}
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k - x == 0:
                ans += 1
print(ans)


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

struct Team{int point,id;};
bool operator<(Team a,Team b){return a.point!=b.point?a.point>b.point:a.id<b.id;};

int main()
{
  int N,A,B,C,D;
  cin>>N;
  vector<Team>team(N);
  for(int i=0;i<N;i++){
    team[i].id=i;
  }
  for(int i=0;i<N*(N-1)/2;i++){
    cin>>A>>B>>C>>D;
    A--;
    B--;
    if(C>D){
      team[A].point+=3;
    }else if(C<D){
      team[B].point+=3;
    }else{
      team[A].point++;
      team[B].point++;
    }
  }

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

  int r=1;
  vector<int>rank(N);
  rank[team[0].id]=r;
  for(int i=1;i<N;i++){
    r++;
    rank[team[i].id]=r;
    if(team[i].point==team[i-1].point)rank[team[i].id]=rank[team[i-1].id];
  }

  for(int i=0;i<N;i++){
    cout<<rank[i]<<endl;
  }
}

Measured memory_bytes: 0