akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define en '\n'
const int MAXN = 1e6+69;
const int INF = 1e18;
const int mod = 1e9+7;
struct vl{
    int x,y;
    bool operator<(vl t)const{
        if(x==t.x)return (y<t.y);
        return x<t.x;
    }
};
map<int,int>mp;
int q;
int m,p,n,k;
int x,y,z;
int a[MAXN],b[MAXN];
int cnt;
set<int> s;
int luythua(int x, int y){
    if(y==0)return 1;
    if(y==1)return x%mod;
    int k = luythua(x,y/2);
    if(y%2==0)return k*k%mod;
    return k*k%mod*x%mod;
}
int fact[MAXN];
int comb(int k, int n){
    return fact[n]*luythua(fact[k],mod-2)%mod*luythua(fact[n-k],mod-2)%mod;
}
signed main(){                                                                                                                                                                                                                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>x>>y;
    if((x+y)%3!=0){
        cout<<0;
        return 0;
    }
    int k = (x+y)/3;
    fact[0]=1;
    for(int i=1;i<=1000000;i++){
        fact[i]=fact[i-1]*i%mod;
    }
    if(min(x,y)<k){
        cout<<0;
        return 0;
    }
    cout<<comb(min(x,y)-k,k)%mod;
}


Measured memory_bytes: 11468
import java.util.Scanner;

public class Main{
  public static void main(String args[]) {
    Scanner scan = new Scanner(System.in);
    int a= scan.nextInt();
    int b= scan.nextInt();
    int d = a/b;
    int r = a%b;
    double f1 = a;
    double f2 = b;
    double f = f1/f2;
    System.out.println(d + " " + r + " " + String.format("%.5f", f));
  }
}


Measured memory_bytes: 26400
#include<iostream>
#include<cmath>

using namespace std;
int main() {
	int n; cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; ++i)
		if ((int)log10((double)i) % 2 == 0) {
			++ans;
		}

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

Measured memory_bytes: 512
#include<stdio.h>

void check(char *,char *,char *);

int main(){
  int H,W,ans=0;
  scanf("%d%d",&H,&W);
  getchar();
  char s[H][W];
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      scanf("%c",&s[i][j]);
    }
    getchar();
  }

  for (int i = 0; i < H-1; i++){
      for (int j = 0; j < W-1; j++){
        if (s[i][j]!='.'){ check(&s[i][j],&s[i][j+1],&s[i+1][j]); }
        if (s[i+1][j+1]!='.'){ check(&s[i+1][j+1],&s[i+1][j],&s[i][j+1]); }
      }
  }
  
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      if(s[i][j]=='#'){
        ans = 1;
      }
    }
  }

  ans > 0 ? puts("No") : puts("Yes"); 

  return 0;
}

void check(char *a,char *b,char *c){
  if (*b!='.'){ *a='1'; *b='1';}
  if (*c!='.'){ *a='1'; *c='1';}
}


Measured memory_bytes: 1644
import numpy as np;from scipy.sparse import *;l=[];n,m=map(int,input().split())
for i in range(n):
  for j in input().split()[1:]:l.append((i,int(j)+n-1,1))
edge=np.array(l,dtype=np.int64).T;graph=csr_matrix(((edge[2],edge[:2])),(n+m,n+m));_,l=csgraph.connected_components(graph);print("NO"if 1 in l[:n]else"YES")

Measured memory_bytes: 35784
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n, d;
    cin >> n >> d;
    int x = 2 * d + 1;
    int ans = (n + x - 1) / x;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <queue>
#include <string>
#include <cstdlib>

using namespace std;

int main(){
    string s;
    cin >> s;

    int first, second;

    first = atoi(s.substr(0,2).c_str());
    second = atoi(s.substr(2,2).c_str());

    bool first_mm = false, second_mm = false;

    if(0<first && first<=12) first_mm = true;
    if(0<second && second<=12) second_mm = true;

    if(first_mm && second_mm) cout << "AMBIGUOUS" << endl;
    else if(first_mm) cout << "MMYY" << endl;
    else if(second_mm) cout << "YYMM" << endl;
    else cout << "NA" << endl;

    return 0;
}




Measured memory_bytes: 256
PROGRAM rectangleCutting
      IMPLICIT NONE
      real(16) :: w,h,x,y
      real(16) :: ans
      character(1) :: ans2
      
      
      read*,w,h,x,y
      
      ans = w*h/2_16
      
      if( x*2==w .and. y*2==h )then
        ans2 = '1'
      else
        ans2 = '0'
      end if
      
      print*,ans,ans2
      
      
      
      
      
      END PROGRAM

Measured memory_bytes: 2904
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
 
int main() {
    int n;
    cin >> n;
    
    int a[n], b[n], c[n - 1];
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
        cin >> a[ctr1];
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
        cin >> b[ctr1];
    for (int ctr1 = 0; ctr1 + 1 < n; ++ctr1)
        cin >> c[ctr1];
     
    int rez = 0, last = n;
    for (int ctr1 = 0; ctr1 < n; ++ctr1) {
        rez += b[a[ctr1] - 1];
        if (last + 1 == a[ctr1] - 1)
            rez += c[last];
        last = a[ctr1] - 1;
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#define ll long long
#define maxn 4001000
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define rep(i,a,b) for(int i=a;i<=b;i++)
const ll P=1e9+7;
using namespace std;
const int N = 2e5 + 1000;
int main(){
	ll n;
	cin>>n;
	if(n & 1) cout<<0;
	else {
		n /= 2;
		ll sum = 0;
		while(n){
			n /= 5;
			sum += n;
		}
		cout<<sum;
	}
}

Measured memory_bytes: 256
import itertools, math
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]
orders = list(itertools.permutations(L))
d = 0
for order in orders:
    dist = 0
    for i in range(0,N-1):
        dist += math.sqrt((order[i][0]-order[i+1][0])**2 + (order[i][1]-order[i+1][1])**2)
    d += dist
print(d/len(orders))

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);
// const ll INF = 99;

pll keys[1005];

ll dp[15][(2LL << 15LL)];

int main() {
  fill(dp[0], dp[14], INF);
  dp[0][0] = 0;

  ll N, M;
  scanf("%lld %lld", &N, &M);

  for (ll i = 0; i < M; i++) {
    ll a, b;
    scanf("%lld %lld", &a, &b);

    ll capability = 0;
    for (ll j = 0; j < b; j++) {
      ll t;
      scanf("%lld", &t);
      capability |= 1LL << (t - 1);
    }
    keys[i].first = a;
    keys[i].second = capability;

    // cout << a << " " << capability << endl;
  }

  for (ll i = 0; i < N; i++) {
    ll box = (i + 1);

    for (ll status = 0; status < (2LL << (N - 1)); status++) {
      for (ll k = 0; k < M; k++) {
        dp[i + 1][status] = min(dp[i + 1][status], dp[i][status]);
        ll next_value = dp[i][status] + keys[k].first;
        ll next_status = status | keys[k].second;
        dp[i + 1][next_status] = min(dp[i + 1][next_status], next_value);

        // cout << "dp[i + 1][next_status]:" << dp[i + 1][next_status] << endl;
        // cout << "next_value:" << next_value << endl;
        // cout << "next_status:" << next_status << endl;
      }
    }
    // cout << i << endl;
  }

  // for (ll i = 0; i <= N; i++) {
  //   for (ll j = 0; j < (2LL << (N - 1)); j++) {
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << "" << endl;
  // }

  ll ans = dp[N][(1LL << N) - 1LL];
  if (ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}


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

    #define all(v) v.begin(),v.end()
    #define rall(v) v.rbegin(),v.rend()
    #define trav(i,a) for(auto i: a)
    #define ff first
    #define ss second
    #define eb emplace_back
    #define tc(t) ll t; cin>>t; while(t--)
    #define prec(n) fixed<<setprecission(n)
    #define mst(arr,value) memset(arr,value,sizeof(arr))
    
    const long long sz = (long long)1e5;
    const long long mx = (long long)2e5+5;
    const long long inf = (long long)1e18;
    const long long mod = (long long)1e9+7;
    
    #define f(i,n)     for(ll i=0;   i<n;  i++)
    #define fab(i,a,b) for(ll i=a;   i<b;  i++)
    #define fr(i,n)    for(ll i=n-1; i>=0; i--)
    #define fba(i,b,a) for(ll i=b-1; i>=a; i--)

    long long pw(long long x,unsigned long long y) { 
        if (y==0) return 1; 
        else if (y%2==0)  return pw(x,y/2)*pw(x,y/2); 
        else return x*pw(x,y/2)*pw(x,y/2);
    }
    ll comp(pair<string, ll> &a, pair<string, ll> &b) {
        if(a.ff == b.ff) {
            if(a.ss < b.ss) return 1;
            else return 0;
        }
        if(a.ff < b.ff)return 1;
        else return 0;
    }
    int main() {
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        ll a, b, ans = -1;
        cin >> a >> b;
        fab(i, 1, 1000001) {
            if((i * 8) / 100 == a and (i / 10) == b)
            {
                ans = i;
                break;
            }
        }
        cout << ans;
        return 0;
    }

Measured memory_bytes: 256
/******************************************
/@Author: LeafBelief
/@Date: 2020-04-04
/@Remark:    
/@FileName: yenmaxprofit
******************************************/
#include <bits/stdc++.h>
#define CSE(x,y) memset(x,y,sizeof(x))
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll , ll> pll;

const int maxn = 111111;

int main()
{
    //FAST;
    int n;
    while(cin >> n)
    {
        int ans  = 0;
        int a = n / 500;
        ans += a * 1000;
        n %= 500;
        int b = n / 5;
        ans += b * 5;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
const ll MOD=1000000007;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const vector<pll> dir={{0,1},{1,0},{-1,0},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}};
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm (ll a,ll b) {return a*b/gcd(a,b);}
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}

vector<ll> func,inv;
void init(ll n){
    func.resize(n+1);inv.resize(n+1);
    func[0]=1;
    rep(i,0,n) {func[i+1]=func[i]*(i+1)%MOD;}
    inv[n]=intpow(func[n],MOD-2);
    rrep(i,1,n+1) {inv[i-1]=inv[i]*i%MOD;}
}
ll comb(ll a,ll b) {return func[a]*inv[b]%MOD*inv[a-b]%MOD;}

inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return v[(size / 2) - 1] ;
}
template<class T> inline bool chmax(T& a,T b) {if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b) {if(a>b){a=b;return 1;} return 0;}

int main(){
  ll a;
  cin>>a;
  string s;
  cin>>s;
  if(a<3200) cout<<"red";
  else cout<<s;
}

Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 

using namespace std; 

const long long mod=1e9+7;

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

    int res=0;
    vector<int> a(n),b(n-1);
    for(int i=0;i<n-1;i++) cin>>b[i];

    a[0]=b[0];
    a[n-1]=b[n-2];
    for(int i=0;i<n-2;i++) a[i+1]=min(b[i],b[i+1]);

    for(int i=0;i<n;i++){
        res+=a[i];
    }

    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
int main()
{
fast;
ll k,x;
cin>>k>>x;
vector<ll>ans;
ll h=x;
ll cnt=k;
while(x>=(ll)-1000000&&cnt>0)
{
    ans.pb(h);
    h--;
    cnt--;
}
cnt=k-1;
h=x+1;
while(x<=(ll)1000000&&cnt>0)
{
    ans.pb(h);
    h++;
    cnt--;
}
sort(ans.begin(),ans.end());
for(ll i=0;i<ans.size();i++)
{
    cout<<ans[i]<<" ";
}

return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b,k=map(int, input().split())
    if b-a+1<=2*k:
        for i in range(a,b+1):
            print(i)
    else:
        for i in range(k):
            print(a+i)
        for i in range(k):
            print(b-k+1+i)
resolve()

Measured memory_bytes: 3060
n = int(input())
h = list(map(int, input().split()))
for i in range(n):
    if i > 0:
        if h[i-1] < h[i]:
            h[i]+=-1
    else:
        h[i]+=-1
    if i > 0:
        if h[i-1] > h[i]:
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 14396
factor = int(input())
numbers = list(map(int,input().split()))

def selectionsort(array,n):
    counter = 0
    for i in range(len(array)):
        minj = i
        for j in range(i,len(array)):
            if array[j] < array[minj]:
                minj = j
        array[minj],array[i] = array[i],array[minj]
        if minj != i :
            counter += 1
    return counter

repetition = selectionsort(numbers,factor)
print(" ".join(list(map(str,numbers))))
print(repetition)



Measured memory_bytes: 5604
#include <iostream>
#include <deque>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,n) loop(i,0,n)

using namespace std;

typedef vector<int> vi;
int const inf = 1 << 28;

int main(){
    vi q, r;
    for (int i = 1;; i++){
        int pq = i*(i + 1)*(i + 2) / 6;
        q.push_back(pq);
        if (pq > 1e6 + 100) break;
    }

    int n = 1000000;

    vi dp1(n + 1, inf);
    vi dp2(n + 1, inf);
    dp1[0] = 0;
    dp2[0] = 0;
    rep(i, q.size()){
        rep(j, n + 1){
            if (j - q[i] >= 0){
                dp1[j] = min(dp1[j], dp1[j - q[i]] + 1);
            }
        }
        if(q[i]&1){
            rep(j, n + 1){
                if (j - q[i] >= 0){
                    dp2[j] = min(dp2[j], dp2[j - q[i]] + 1);
                }
            }
        }
    }

    int t;
    while (cin >> t && t){
        cout << dp1[t] << " " << dp2[t] << endl;
    }
}

Measured memory_bytes: 8852
"""何回でも同じ荷物を選べるナップザック問題"""
def main():
    H,N = map(int, input().split())
    A,B = [],[]
    for i in range(N):
        a,b = map(int, input().split())
        A.append(a)
        B.append(b)
    # dp[i][j] = i種類の魔法から、合計ダメージがj以上となるような魔力の最小値
    INF = float('inf')
    dp = [[INF]*(H+1) for _ in range(N+1)]
    dp[0][0] = 0
    for i in range(1,N+1):
        for j in range(H+1):
            dp[i][j] = min(dp[i][j], dp[i-1][j])
            if j-A[i-1]>=0:
                dp[i][j] = min(dp[i][j], dp[i-1][j-A[i-1]]+B[i-1])
                dp[i][j] = min(dp[i][j], dp[i][j-A[i-1]]+B[i-1])
            else:
                dp[i][j] = min(dp[i][j], B[i-1])
    print(dp[N][H])

main()


Measured memory_bytes: 288392
#define Z(V) for(v=360,m=g();--m;V+=sin(x*z))v-=x=g();V+=sin(v*z)
a;g(){scanf("%d",&a);a?a:exit(0);}
main(m,v,x){
  for(;;){double s=0,t=0,z=.01745329,e=.000001;
    Z(s);Z(t);
    puts(s>t+e?"1":s+e<t?"2":"0");
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  ll a;
  double b;
  cin >> a >> b;

  ll x = b * 100 + 0.0005;
  cout << a * x / 100 << endl;
  return 0;
}


Measured memory_bytes: 3700
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(void) {

  int i;
  int num[5];

  scanf("%d%d%d%d%d", &num[0], &num[1], &num[2], &num[3], &num[4]);

  for (i = 1; i <= 5; i++) {
    if ((num[i-1]!=i)&&(num[i-1]!=0)) {
      return -1;
    }
    if (num[i-1]==0) {
      printf("%d\n", i);
      return 0;
    }
  }

  return 0;
}


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

#define reint register int
#define coint const int

using namespace std;

coint SIZE = 100000 + 5;

int n, li[SIZE], lst[SIZE];

int main(void) {
    scanf("%d", &n);
    for (reint i = 1; i <= n; ++i) scanf("%d", &li[i]);
    for (reint i = n; i; --i) {
        lst[i] = i;
        if (i < n && li[i] >= li[i + 1]) lst[i] = lst[i + 1];
    }
    int ans = 0;
    for (reint i = 1; i <= n; ++i)
        ans = max(ans, lst[i] - i);
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 1024
fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val l = readLine()!!
    var r=0L
    var g=0L
    var b=0L
    var result = 0L
    for(i in 0..n-1){
        when(l[i]){
            'R'->r++
            'G'->g++
            'B'->b++
        }
    }
    result = r*g*b
    if(result==0L){
        println(0)
        return
    }
    for(i in 0..n-1){
        for(s in 0..n-1){
            val j = i+s+1
            val k = j+s+1
            if(k<=n-1&&l[i] != l[j] && l[j] != l[k] && l[k]!=l[i]){
                result --
            }
        }
    }
    println(result)
}

Measured memory_bytes: 36292
#include<stdio.h>

int main(){
    
    int n,b,f,r,v;
    int d[4][3][10]={{}};
    scanf("%d",&n);

    for(int i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        d[b-1][f-1][r-1]=d[b-1][f-1][r-1]+v;

    }
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                printf(" %d",d[i][j][k]);
                if(k==9){
                    printf("\n");
                }
            }
        }
        if(i!=3){
        printf("####################\n");
        }
    }
    
    
    return 0;
}



Measured memory_bytes: 2076
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}


fn main() {
    let mut n: usize = read().unwrap();
    let k: usize = read().unwrap();
    let mut vec = Vec::new();
    if n == 0 {
        vec.push(String::from("0"));
    } else {
        while n > 0 {
            let reminder = n % k;
            n = n / k;
            vec.push(reminder.to_string());
        }
    }
    println!("{}", vec.concat().len());
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

//最大公約数,最小公倍数
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

int main(void){
    ll n, m;
    cin >> n >> m;

    ll a[n];
    ll lc = 1;
    rep(i, 0, n){
        cin >> a[i];
        lc = lcm(a[i] / 2, lc);
    }

    rep(i, 0, n){
        if(lc / (a[i] / 2) % 2 == 0){
            cout << 0 << endl;
            return 0;
        }
    }

    cout << m / lc - m / (lc * 2) << endl;
    return 0;
}


Measured memory_bytes: 1024
def main():
    n, l = map(int, input().split())
    m = [ i + l - 1 for i in range(1,n+1)]
    mabs = [abs(i) for i in m]

    eat = min(mabs)
    if eat in m:
        idx = m.index(eat)
    else:
        idx = m.index(-eat)
    print(sum(m)-m[idx])
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
n = int(input())
w = [input() for i in range(n)]
flag = 1

#重複

for i in range(n):
  for j in range(n):
    if i == j:
      continue
    if w[i] == w[j]:
      flag = flag *0
      break
    
for i in range(n):
  if i == 0:
    continue
  if w[i-1][-1] == w[i][0]:
    flag = flag * 1
  else:
    flag = flag * 0
    
if flag == 1:
  print("Yes")
else:
  print("No")


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

#define int long long

#define rep(i, n) for (signed i = 0; i < signed(n); i++)
#define REP(i, s, n) for (signed i = signed(s); i < signed(n); i++)
#define rrep(i, n) for (signed i = signed(s) - 1; i >= 0; i--)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, const T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

void calc() {
	string s; cin >> s;
	int n = s.size();
	V v(n);
	VV pos(26);
	rep(i, n) {
		v[i] = s[i] - 'a';
		pos[v[i]].push_back(i);
	}

	int ans = 1000000;
	rep(c, 26) {
		V dat = v;
		dat.push_back(c);
		rep(i, n) {
			bool all = true;
			rep(i, n) all = all && dat[i] == c;
			if (all) {
				ans = min(ans, (int)i);
				break;
			}

			rep(i, n) dat[i] = dat[i + 1] == c ? c : dat[i];
		}
	}
	cout << ans << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	calc();
#ifdef _MSC_VER
	system("pause");
#endif
}

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

using namespace std;

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

const long long MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int K, X;
  cin >> K >> X;
  for (int i = X - K + 1; i < X + K; ++i) {
    cout << i;
    if (i == X + K - 1) cout << endl;
    else cout << " ";
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long long read()
{
    long long x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            f=-1;
        }
        c=getchar();
    }
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
int n;
struct node
{
    long long num;
	long long a;
    long long tot;
}s[100503];
bool cmp(node a,node b)
{
    return a.num<b.num;
}
long long ji,ou;
int main()
{
    n=read();
    for(int i=1;i<=n;++i)
        s[i].num=read(),s[i].a=i;
    stable_sort(s+1,s+1+n,cmp);
    for(int i=1;i<=n;++i)
    {
        if(s[i].a%2==0)
		{
            if(i%2==0)
                continue;
            else
                ou++;			
		} 
        else
		{
            if(i%2!=0)
                continue;
            else
                ji++;			
		}     	
	} 
    long long h=min(ou,ji);
    cout<<h+abs(ou-ji);
}

Measured memory_bytes: 4864
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
using namespace std;

const long mod = 1000000007;
const long indlim = 5368709119;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
long mybase(long N, long B) { if (N == 0) return 0; string S = ""; while (N != 0) { string M = to_string(N % B); N -= N % B; N /= B; S = M + S; }return stol(S); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	string res = "Yes";
	long N, A, B, C, D; cin >> N >> A >> B >> C >> D;
	string S; cin >> S;
	//long slen = S.length();

	// ふぬけの判定

	for (int i = B + 1; i <= D;i++) if (S[i - 1] == '#' && S[i - 2] == '#') res = "No";

	// すぬけの判定
	// 追い越しは'.'三つで可能。判定はBとmin(C,D)の間
	for (int i = B + 1; i <= min(C, D); i++) if (S[i - 1] == '.' && S[i - 2] == '.' && S[i - 3] == '.') goto koko;

	S[D - 1] = '#';
koko:;
	for (int i = A + 1; i <= C; i++) if (S[i - 1] == '#' && S[i - 2] == '#') res = "No";

	cout << res << endl;

}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false);

	ll n, m;
	vll w;
	while (true) {
		cin >> n >> m;
		if (n == 0 && m == 0) break;
		vll v(n);
		ll ans = -1;
		rep(i, n) cin >> v[i];
		rep(i, n) {
			REP(j, i+1, n) {
				if (v[i] + v[j] <= m) {
					ans = max(ans, v[i] + v[j]);
				}
			}
		}
		if (ans == -1) cout << "NONE" << endl;
		else cout << ans << endl;

		
	}
	return 0;
}



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

/*

pre[i] - pre[j]*10^(i-j) = 0 mod p
[j+1,i] is a substr

pre[i]^(-i) - pre[j]*10^(-j) = 0 mod p 

*/


typedef long long LL;
const int M=2e5+5;
const int MP=10005;

char s[M];
int cnt[MP];

int qp(int x,int n,int m)
{
	int ans=1;
	x%=m;
	while(n)
	{
		if(n&1) ans=ans*x%m;
		x=x*x%m;
		n>>=1; 
	}
	return ans;
}

int main()
{
	int n,p;
	scanf("%d%d%s",&n,&p,s);
	int sum=0;
	LL ans=0;

	if(p==2||p==5)
	{
		for(int i=0;i<n;i++)
		{
			if((s[i]-'0')%p==0)
				ans+=i+1;
		}
		printf("%lld\n",ans);
		return 0;
	}

	int rev=qp(10,p-2,p);
	cnt[0]=1;
	LL now=1;
	for(int i=0;i<n;i++)
	{
		sum=(sum*10+s[i]-'0')%p;
		now*=rev;
		now%=p;
		ans+=cnt[sum*now%p];
		//cout<<" "<<sum*now%p<<endl;
		cnt[sum*now%p]++;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
	// your code goes here
	long long a,b,c ,ans;
	cin>>a>>b>>c;
	if(c<=a+b)
	{
	    cout<<c+b<<endl;
	}
	else 
	{
	    cout<<a+2*b+1<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if( (a < b) && (b < c)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}



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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;


void solve(){
    int k, a, b;
    cin>>k>>a>>b;
    rep(i, a, b){
        if(i%k == 0){
            cout<<"OK";
            return;
        }
    }
    cout<<"NG";
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;
long long gcd(long long a, long long b){
    if(b==0) return a;
    return gcd(b, a%b);
}
long long N;
string s; 
int main() {
    cin >> N;
    int ans=0;
    for(int i=1; i<=N; i+=2){
        int cnt=0;
        int tm = i;
        for(int j=1; j<=N; ++j){
            if(tm%j==0) cnt++;
        }
        if(cnt==8) ans++;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
int n,lim;
ll dp[100100];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
	n=read();lim=read();
	memset(dp,0x3f,sizeof(dp));dp[0]=0;
	int sum=0;
	rep(i,1,n)
	{
		int w=read(),v=read();
		per(j,sum,0) dp[j+v]=min(dp[j+v],dp[j]+w);
		sum+=v;
	}
	per(i,sum,0)
		if (dp[i]<=lim) {printf("%d",i);return 0;}
	return 0;
}


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

int main(void){
  int n; cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  int m; cin >> m;
  vector<string> t(m);
  rep(i,m) cin >> t[i];
  
  int ans = 0;
  rep(i,n){
    int x = 0;
    rep(j,n){
      if(s[i]==s[j]){
	x++;
      }
    }
    rep(j,m){
      if(s[i]==t[j]) x--;
    }
    ans = max(ans,x);
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
N=int(input())
S=list(input())
T=list(input())
state=[]
lim=1000000007
i=0
while i<N:
    if S[i] == T[i]:
        state.append(0)
        i+=1
    else:
        state.append(1)
        i+=2
if state[0]==0:
    ans=3
else:
    ans=6
for i in range(1,len(state)):
    if state[i] == 1 and state[i-1] == 1:
        ans = (ans * 3) % lim
    elif state[i] == 1 and state[i-1] == 0:
        ans = (ans * 2) % lim
    elif state[i] == 0 and state[i-1] == 1:
        pass
    elif state[i] == 0 and state[i-1] == 0: 
        ans = (ans * 2) % lim
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 1000000000
#define mp make_pair
#define pb push_back

typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int,int> pii;
typedef long long ll;

int main() {
  string digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ?";
  while (1) {
    int N, M, Q;
    cin >> N >> M >> Q;
    if (N == 0 && M == 0 && Q == 0) {
      break;
    }
    vbb relationships(M, vb(N, true));
    string switches = "";
    for (int s = 0; s < N; s++) {
      switches += "0";
    }

    for (int i = 0; i < Q; i++) {
      string S, B;
      cin >> S >> B;
      for (int s = 0; s < N; s++) {
        int bit = ((switches[s] - '0') + (S[s] - '0')) % 2;
        switches[s] = bit + '0';
      }

      for (int s = 0; s < N; s++) {
        for (int b = 0; b < M; b++) {
          if (switches[s] == '0' && B[b] == '0') {
            continue;
          }
          relationships[b][s] = relationships[b][s] && switches[s] == '1' && B[b] == '1';
        }
      }
    }

    for (int i = 0; i < M; i++) {
      int sw = 36;
      for (int j = 0; j < N; j++) {
        if (relationships[i][j]) {
          if (sw != 36) {
            sw = 36;
            break;
          }
          sw = j;
        }
      }
      cout << digits[sw];
    }
    cout << endl;
  }
}

Measured memory_bytes: 1284
O = list(input())
E = list(input())
lo = len(O)
le = len(E)
if lo > le:
  for i in range(le):
    print(O[i]+E[i],end="")
  print(O[-1])
else:
  for i in range(le):
    print(O[i]+E[i],end="")

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

int main(){
  int N,M;cin>>N>>M;
  int X[M];
  for(int i=0;i<M;i++){
    cin>>X[i];
  }
  if(N>=M){
    cout<<0<<endl;
    return 0;
  }
  sort(X,X+M);
  int D[M-1];
  for(int i=0;i<M-1;i++){
    D[i]=X[i+1]-X[i];
  }
  sort(D,D+M-1);
  int cnt=0;
  for(int i=0;i<M-N;i++){
    cnt+=D[i];
  }
  cout<<cnt<<endl;
  return 0;
}

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

int main(){
  int a,b,c,d;
  int ans;
  cin >> a >> b >> c >> d;
  if(a>=b){
    ans = b;
  }else{
    ans = a;
  }
  if(c>=d){
    ans = ans+d;
  }else{
    ans = ans + c;
  }

  cout << ans << endl;

}





Measured memory_bytes: 256
s=input()
count=0
for i in range(len(s)):
  if(i%2==0 and s[i]=='g'):
    count=count
  if(i%2==0 and s[i]=='p'):
    count=count-1
  if(i%2==1 and s[i]=='g'):
    count=count+1
  if(i%2==1 and s[i]=='p'):
    count=count

print(count)

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

#define FOR(x,y,z) for(int x=y,x##_=z;x<=x##_;++x)
#define DOR(x,y,z) for(int x=y,x##_=z;x>=x##_;--x)
#define FOR_(x,y,z,s) for(int x=y,x##_=z;x<=x##_;x+=s)
#define FOR__(x,y,z) for(int x=y,x##_=z;x<=x##_;x<<=1)
#define EOR(x,y) for(int x##_=head[x],y=edge[x##_].e;x##_;y=edge[x##_=edge[x##_].to].e)
#define EGOR(x,y,z) for(int x##_=head[x],y=edge[x##_].e,z=edge[x##_].c;x##_;y=edge[x##_=edge[x##_].to].e,z=edge[x##_].c)

#define clr(x,y) memset(x,y,sizeof(x))
#define szf(x) sizeof(x)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)

#define read2(x,y) read(x),read(y)
#define read3(x,y,z) read(x),read(y),read(z)
#define read4(x,y,z,w) read3(x,y,z),read(w)
#define reads(str) sf("%s",str)

#define ts (*this)
#define sf scanf
#define pf printf

#define ll long long
#define ull unsigned long long
#define db double
#define ct clock_t
#define ck() clock()
#define rd rand()
#define rmx RAND_MAX
#define RD T*(rd*2-rmx)


using namespace std;

template<class T>bool tomin(T &x,T y){return x>y?x=y,1:0;}
template<class T>bool tomax(T &x,T y){return x<y?x=y,1:0;}
template<class T>void read(T &x){
	char c;
	x=0;
	int f=1;
	while(c=getchar(),c<'0'||c>'9')if(c=='-')f=-1;
	do x=(x<<3)+(x<<1)+(c^48);
	while(c=getchar(),c>='0'&&c<='9');
	x*=f;
}

const db Pi=acos(-1);
const int maxn=1e5+5;
int A[maxn];
int main(){
	srand(time(NULL));
	int n;
	read(n);
	ll res=0,f=1;
	FOR(i,1,n){
		read(A[i]);
		res=(A[i]<<=1)-res;
		f=-f;
	}
	res/=(1-f);
	FOR(i,1,n){
		pf("%d ",res);
		res=A[i]-res;
	}
	return 0;
}


Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;

            int sq = 0;
            int di = 0;

            while ((s = Console.ReadLine()) != null)
            {
                var array = s.Split(',').Select(int.Parse).ToArray();

                if (isSq(array)) sq++;
                else
                    if (array[0] == array[1]) di++;
            }
            Console.WriteLine(sq);
            Console.WriteLine(di);
        }

        static bool isSq(int[] a)
        {
            return a[0] * a[0] + a[1] * a[1] == a[2] * a[2];
        }
    }
}

Measured memory_bytes: 5912
import java.io.*;

class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    
    for (int i = 1; i < str.length(); i++) {
      if (str.charAt(i) == str.charAt(i-1)) {
        System.out.println("Bad");
        return;
      }
    }
    System.out.println("Good");
  }
}

Measured memory_bytes: 21072
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define pb push_back
#define fu(i,a,j) for(int i=a;i<j;i++)
#define fd(i,a,j) for(int i=a;i>=j;i--)
#define SYNC ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define MOD 1000000
#define MOD2 1000000021
#define INF 1e9
#define N 2
#define M_PI 3.14159265358979323846
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<string> vs;

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); };
int n, m, k, t;
int dr[] = { 0, 1, 0, -1, -1,1,1,-1 };
int dc[] = { 1, 0, -1, 0, 1,1,-1,-1 };

int main() {
	SYNC;
	string s;
	cin >> s;
	if (s == "ABC")
		cout << "ARC\n";
	else
		cout << "ABC\n";
	return 0;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <iostream>

using namespace std;

#define N 8
#define FREE  -1
#define NOT_FREE  1

int row[N], col[N];
int lowerLeft[N * 2 - 1], lowerRight[N * 2 - 1];
bool X[N][N];

void init() {
	for (int i = 0; i < N; ++i) {
		row[i] = FREE;
		col[i] = FREE;
	}
	for (int i = 0; i < N * 2 - 1; ++i) {
		lowerLeft[i] = FREE;
		lowerRight[i] = FREE;
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			X[i][j] = false;
		}
	}
}

void printBoard() {
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (X[i][j])
				if (row[i] != j)
					return;
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (row[i] == j) {
				cout << "Q";
			} else {
				cout << ".";
			}
		}
		cout << endl;
	}
}

void backTrack(int i) {
	if (i == N) {
		printBoard();
		return;
	}

	for (int j = 0; j < N; ++j) {
		if (col[j] == NOT_FREE || lowerLeft[i + j] == NOT_FREE || lowerRight[i - j + N - 1] == NOT_FREE)
			continue;
		row[i] = j;
		col[j] = lowerLeft[i + j] = lowerRight[i - j + N - 1] = NOT_FREE;
		backTrack(i + 1);
		row[i] = col[j] = lowerLeft[i + j] = lowerRight[i - j + N - 1] = FREE;
	}
}

int main() {

	init();

	int k;
	scanf("%d", &k);
	for (int i = 0; i < k; ++i) {
		int r, c;
		scanf("%d %d", &r, &c);
		X[r][c] = true;
	}

	backTrack(0);

	return 0;
}

Measured memory_bytes: 3212
using System;

class P
{
    static void Main(string[] _)
    {
        _ = Console.ReadLine().Split(' ');
        int n = int.Parse(_[0]);
        int m = int.Parse(_[1]);
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++)
        {
            _ = Console.ReadLine().Split(' ');
            a[i] = int.Parse(_[0]);
            b[i] = int.Parse(_[1]);
        }

        int[] c = new int[m];
        int[] d = new int[m];
        for (int i = 0; i < m; i++)
        {
            _ = Console.ReadLine().Split(' ');
            c[i] = int.Parse(_[0]);
            d[i] = int.Parse(_[1]);
        }

        for (int i = 0; i < n; i++)
        {
            int index = int.MinValue;
            int min = int.MaxValue;
            for (int j = 0; j < m; j++)
            {
                if (min > Math.Min(min, Math.Abs(a[i] - c[j]) + Math.Abs(b[i] - d[j])))
                {
                    min = Math.Min(min, Math.Abs(a[i] - c[j]) + Math.Abs(b[i] - d[j]));
                    index = j + 1;
                }
            }
            Console.WriteLine(index);
        }
    }
}

Measured memory_bytes: 11220
let rec solve acc i n =
  if n <= i * i + i then acc
  else solve
    ( acc +
      (if (n - i) mod i = 0 then (n - i) / i else 0) +
      (if (n / i) = (n mod i) then i else 0) ) (i + 1) n

let () = Scanf.scanf "%d" @@ fun n ->
  Printf.printf "%d\n" @@ solve 0 1 n

Measured memory_bytes: 512
import numpy as np

N= int(input())
Ax = list(map(int, input().split(" ")))

Ax = np.array(Ax)
r = np.average(Ax)
Dx = list(map(lambda x:abs(r-x), Ax))
m = min(Dx)
r = Dx.index(m)

print(r)



Measured memory_bytes: 21508
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let mut aa = vec![0; n];
    for i in 0..n {
        aa[i] = read::<i64>()
    }
    let mut left = vec![0; n];
    left[0] = 0;
    left[1] = (aa[0] - 0).abs();
    for i in 2..n {
        left[i] = (aa[i - 1] - aa[i - 2]).abs() + left[i - 1]
    }

    let mut right = vec![0; n];
    right[n - 1] = 0;
    right[n - 2] = (aa[n - 1] - 0).abs();
    for i in 2..n {
        right[n - i - 1] = (aa[n - i] - aa[n - i + 1]).abs() + right[n - i]
    }

    println!("{}", left[0] + right[0] + aa[1].abs());
    for i in 1..n - 1 {
        println!("{}", left[i] + right[i] + (aa[i + 1] - aa[i - 1]).abs())
    }
    println!("{}", left[n - 1] + right[n - 1] + aa[n - 2].abs());
}


Measured memory_bytes: 7292
using System;

class D {
    public static void Main() {
        Console.ReadLine();
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var minSeen = int.MaxValue >> 1;
        var maxProfit = 0;
        var argmaxSize = 0;
        foreach (var i in a) {
            var profit = i - minSeen;
            if (maxProfit < profit) {
                maxProfit = profit;
                argmaxSize = 1;
            } else if (maxProfit == profit) ++argmaxSize;
            if (i < minSeen) minSeen = i;
        }
        Console.WriteLine(argmaxSize);
    }
}


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

int main() {
    int n;
    cin >> n;
    vector<tuple<string, int, int>> res(n);
    for (int i = 0; i < n; i++) {
        string city;
        int score;
        cin >> city >> score;
        res.at(i) = make_tuple(city, - score, i + 1);
    }

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

    for (tuple<string, int, int> t : res) {
        int num;
        tie(ignore, ignore, num) = t;
        cout << num << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
using namespace std;

int main(){
  int a,b; cin >> a >> b;
  int d = a/b;
  int r = a%b;
  double f = (double)a/b;
  cout << d << " " << r << " ";
  printf("%.10f\n", f);
  return 0;
}



Measured memory_bytes: 3228
# coding: utf-8
import queue

row, col = map(int, input().split(' '))
maze = [list(input()) for _ in range(row)]

                
def BPS(si, sj):
    done = [[0 for _ in range(col)] for _ in range(row)]
    q = queue.Queue()
    q.put((si, sj, 0))
    around = [[1, 0], [0, 1], [-1, 0], [0, -1]]
    maxv = 0
    while not q.empty():
        i, j, cnt = q.get()
        done[i][j] = 1
        for ar in around:
            di, dj = ar[0], ar[1]
            i_n, j_n = i + di, j + dj
            if (i_n >= 0 and i_n < row and j_n >= 0 and j_n < col) == False:
                continue
            if maze[i_n][j_n] == '#':
                continue
            if done[i_n][j_n] == 1:
                continue
            if done[i_n][j_n] == 2:
                continue
            maxv = max(maxv, cnt + 1)
            q.put((i_n, j_n, cnt + 1))
            done[i_n][j_n] = 2
        
    return maxv
            
            
def main():        
    maxv = 0
    for i in range(row):
        for j in range(col):
            if maze[i][j] == '#':
                continue
            maxv = max(maxv, BPS(i,j))
    print(maxv)
                    
                
                    
    
main()


Measured memory_bytes: 3952
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <vector>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100000+5
#define MOD 20190823
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline void read(int &f){
    f=0;
    ll x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
int n;
char s[16];
void DFS(int pos,char c){
    if(pos==n+1){
        printf("%s\n", s+1);
        return ;
    }
    for(int i='a';i<=min(c,'z');i++){
        s[pos]=i;
        if(i==c){
            DFS(pos+1,c+1);
        }
        else{
            DFS(pos+1,c);
        }
    }
}
int main(){
    read(n);
    DFS(1,'a');
}

Measured memory_bytes: 1536
#include<stdio.h>
int main()
{
    int i=1,t,a,s=1000000000,l=0;
    scanf("%d",&t);
    for(i=1;i<=t;i++)
        {
            scanf("%d",&a);
            if(a>l)
            l=a;
            if(a<s)
            s=a;
        }
    printf("%d\n",l-s);
}


Measured memory_bytes: 128
// ※※※ 解答不能 ※※※
// IO2I839氏.
// https://atcoder.jp/contests/caddi2018/submissions/3843974
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
LL A[1 << 18], c[1 << 18], pr[1 << 18], su[1 << 18];
vector<int> S;

int main() {
    int N;
    scanf("%d", &N);
    repx(i, 1, N + 1) scanf("%lld", &A[i]);
    for(int k : {0, 1}){
        S.clear();
        S.push_back(0);
        repx(i, 1, N + 1) c[i] = A[i];
        repx(i, 1, N + 1){
            while(S.back() && c[S.back()] < c[S.back() + 1]){
                if(S[S.size() - 2] + 1 != S.back()) c[S[S.size() - 2] + 1] *= 4;
                c[S.back()] *= 4;
                pr[i] += S.back() - S[S.size() - 2];
                if(c[S.back()] >= c[S.back() + 1]) S.pop_back();
            }
            pr[i] += pr[i - 1];
            S.push_back(i);
        }
        reverse(A + 1, A + N + 1);
        swap(pr, su);
    }
    LL ans = 1e18;
    rep(i, N) ans = min(ans, 2 * pr[i] + i + 2 * su[N - i]);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 9592
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[])
{
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = 0; i < k; i++)
    {
        if (i % 2 == 0)
        {
            a /= 2;
            b += a;
        }
        else
        {
            b /= 2;
            a += b;
        }
    }
    cout << a << " " << b;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int N,a,b;

scanf("%d",&N);
  
  if(N==1)
    printf("Hello World\n");
  
  else if(N==2){
   scanf("%d",&a);
   scanf("%d",&b);
     
  printf("%d",a+b);
  }
  
  return 0;}
  
  





Measured memory_bytes: 256