akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  struct node *prev;
  int number;
  struct node *next;
};

typedef struct node* NodePointer;

NodePointer N;

void init(void);
void insert(int);
void delete(int);
void deleteFirst(void);
void deleteLast(void);
void printList(void);

int main(){
  int i, n, a;
  char c[12];

  scanf("%d",&n);

  init();

  for(i = 1; i <= n; i++){
    scanf("%s",c);

    if(strcmp(c, "deleteFirst") == 0) deleteFirst();

    else if(strcmp(c, "deleteLast") == 0) deleteLast();

    else if(strcmp(c, "insert") == 0 || strcmp(c, "delete") == 0){
      scanf("%d",&a);

      if(strcmp(c, "insert") == 0) insert(a);

      else delete(a);
    }
  }

  printList();

  return 0;
}

void init(void){
  N = malloc(sizeof(struct node));
  N->next = N;
  N->prev = N;
}

void insert(int a){
  NodePointer new;
  static int count = 0;

  new = malloc(sizeof(struct node));

  new->number = a;
  
  if(count == 0){
    new->next = N;
    N->next = new;
    new->prev = N;
    N->prev = new;
    count++;
  }

  else{
    new->next = N->next;
    N->next->prev = new;
    N->next = new;
    new->prev = N;
    count++;
  }
}

void delete(int a){
  int judge = 0;
  NodePointer x;
  NodePointer y; 
  
  for(y = N->next; y != N; y = y->next){
    if(y->number == a){
      judge = 1;
    }
  }
  
  if(judge == 1){
    y = N->next;

    while(y != N){
      if(y->number == a) break;
      y = y->next;
    }

    x = y->prev;
    x->next = y->next;
    x->next->prev = x;
    free(y);
  }
}

void deleteFirst(void){
  NodePointer x = N->next;
  N->next = x->next;
  x->next->prev = N;
}

void deleteLast(void){
  NodePointer x = N->prev;
  N->prev = x->prev;
  x->prev->next = N;
  free(x);
}

void printList(void){
  NodePointer x = N->next;
  int y = 1;

  while(x != N){
    if (y == 0) printf(" ");
    printf("%d", x->number);
    x = x->next;
    y = 0;
  }

  printf("\n");
}

Measured memory_bytes: 31852
function isLeap(year) {
	if (year % 400 == 0) return true;
	else if (year % 100 == 0) return false;
	else if (year % 4 == 0) return true;
	else return false;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

var strAll = '';
while (true) {
	var years = lines.shift().split(' ');
	var from = +years[0];
	var to = +years[1];

	if (from + to == 0)
		break;

	var str = '';
	for (var i = from; i <= to; i++) {
		if (isLeap(i)) {
			str += i + '\n';
		}
	}
	if (str.length == 0) {
		str += 'NA\n';
	}

	strAll += str + '\n';
}

strAll = strAll.substr(0, strAll.length - 2);
console.log(strAll);

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> p(N);
    rep (i, N) {
        cin >> p[i];
    }

    rep (k, N-1) {
        if (p[k] > p[k+1]) {
            break;
        }
        if (k == N-2) {
            YES;
            return 0;
        }
    }

    rep (i, N) {
        for (ll j = i+1; j < N; j++) {
            vector<ll> vec(N);
            copy(p.begin(), p.end(), vec.begin());
            ll tmp = vec[i];
            vec[i] = vec[j];
            vec[j] = tmp;
            rep (k, N-1) {
                if (vec[k] > vec[k+1]) {
                    break;
                }
                if (k == N-2) {
                    YES;
                    return 0;
                }
            }
        }
    }

    NO;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<cmath>
#include<functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void sort(int &a,int &b)
{
	if(a>b)
		swap(a,b);
}
void open(const char *s)
{
#ifndef ONLINE_JUDGE
	char str[100];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
	sprintf(str,"%s.out",s);
	freopen(str,"w",stdout);
#endif
}
int rd()
{
	int s=0,c;
	while((c=getchar())<'0'||c>'9');
	do
	{
		s=s*10+c-'0';
	}
	while((c=getchar())>='0'&&c<='9');
	return s;
}
int upmin(int &a,int b)
{
	if(b<a)
	{
		a=b;
		return 1;
	}
	return 0;
}
int upmax(int &a,int b)
{
	if(b>a)
	{
		a=b;
		return 1;
	}
	return 0;
}
ll a1[100010];
ll a2[100010];
int a[100010];
void add(ll *a,int x,int y,int v)
{
	a[x]+=v;
	a[y+1]-=v;
}
int main()
{
//	open("arc077e");
	int n,m;
	scanf("%d%d",&n,&m);
	int i;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(i>=2)
		{
			if(a[i]>=a[i-1])
			{
				add(a1,a[i-1]+1,a[i],-1);
				add(a2,a[i-1]+1,a[i],a[i]+1);
				add(a2,a[i]+1,m,a[i]-a[i-1]);
				add(a2,1,a[i-1],a[i]-a[i-1]);
			}
			else
			{
				add(a1,a[i-1]+1,m,-1);
				add(a2,a[i-1]+1,m,m+a[i]+1);
				add(a1,1,a[i],-1);
				add(a2,1,a[i],a[i]+1);
				add(a2,a[i]+1,a[i-1],a[i]+m-a[i-1]);
			}
		}
	}
	for(i=1;i<=m;i++)
	{
		a1[i]+=a1[i-1];
		a2[i]+=a2[i-1];
	}
	ll ans=0x7fffffffffffffffll;
	for(i=1;i<=m;i++)
		ans=min(ans,a1[i]*i+a2[i]);
	printf("%lld\n",ans);
	return 0;
}

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

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

int main(){
    int n,p[105],a,b;
    cin>>n>>a>>b;
    rep(i,n) cin>>p[i];
    int c1=0,c2=0,c3=0;
    rep(i,n){
        if(p[i]<a+1) c1++;
        else if(p[i]<b+1) c2++;
        else c3++;
    }
    cout<<min({c1,c2,c3})<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0,x,min=INT_MAX;
  cin>>n;
  for(int i=0;i<n;i++)
  { cin>>x;
    if(x<min){
        min=x;
        ans++;
    }
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>
#include<queue>
#include<deque>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000001
using namespace std;
typedef long long ll;

int n;
int a[10100];
int check[10100];

int main(){
  std::cin >> n;
  rep(i,1,n+1){
    std::cin >> a[i];
    check[i] = 0;
  }
  int res = 0;
  rep(i,1,n+1){
    for(ll j=2;j<MAX;j++){
      // std::cout << i<<' '<<a[i] <<' '<<j<< '\n';
      if(a[i]%2==0){
        res +=1;
        a[i] /= 2;
      }else{
        break;
      }
    }
  }
  std::cout << res << '\n';
}


Measured memory_bytes: 384
a = {}
n = int(input())
for i in range(n):
    s = input()
    if s not in a:
        a[s] = 1
    else:
        a[s] += 1
        
m = int(input())
for i in range(m):
    t = input()
    if t in a:
        a[t] -= 1

cnt = 0
for v in a.values():
    if v < 0:
        cnt += 1
        
if len(a) == cnt:
    print(0)
else:
    print(max(list(a.values())))

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

using namespace std;

int main(){
  int N;
  bool flag = true;
  cin >> N;
  long long int A[N+1];
  A[0] = 0;
  for(int i = 1;i < N+1;i++)cin >> A[i];
  sort(A,A + N+1);
  for(int i = 0;i < N;i++){
    if(A[i] == A[i+1]){
      flag = false;
      break;
    }
  }
  if(flag == true)cout << "YES";
  if(flag == false)cout << "NO";
  return 0;
}

Measured memory_bytes: 1792
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        //モンスターの体力
        int H = Integer.valueOf(s.next());
        //魔法の種類
        int N = Integer.valueOf(s.next());
        //体力減少
        int[] HPdown = new int[N+1];
        //魔法減少
        int[] MPcost = new int[N+1];
        //エラー値
        int error = 9999999;
		for(int i = 0; i < N; i++) {
			HPdown[i] = Integer.valueOf(s.next());
			MPcost[i] = Integer.valueOf(s.next());
		}
		//動的
        long[] dp = new long[20000];
        //整頓
        Arrays.fill(dp, Integer.MAX_VALUE);
        //初期値(0)設定
		dp[0] = 0;
        //魔法の種類だけくり返す
		for(int i = 0; i < N; i++) {
            //i=0
            //十分な数繰り返す
			for(int j = 0; j < 10000; j++) {
                //あるHP値への到達方法に対して
                dp[j+HPdown[i]] =
                 //既存の方法と、新しい方法、より低コストな方を選択
                 Long.min(dp[j+HPdown[i]], dp[j] + MPcost[i]);
			}
        }
        //目標値以上の到達方法のなかから、最小のものを選択
		for(int i = 10001; i >= 0; i--) {
			dp[i] = Long.min(dp[i], dp[i+1]);
		}
		System.out.println(dp[H]);
    }
}
    


    

Measured memory_bytes: 39180
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
namespace Fact{
	long f[20000001];
	long rf[20000001];
	long pow(long N,long K){
		if(K == 0){
			return 1;
		}
		else if(K % 2 == 0){
			long t = pow(N,K/2);
			return t*t%mod;
		}
		else{
			return N*pow(N,K-1)%mod;
		}
	}
	void Fact(int N){
		for(int i=0;i<N+1;i++){
			if(i == 0){
				f[i] = 1;
			}
			else{
				f[i] = (f[i-1]*i)%mod;
			}
		}
		for(int i=N;i>=0;i--){
			if(i == N){
				rf[i] = pow(f[N],mod-2);
			}
			else{
				rf[i] = rf[i+1]*(i+1)%mod;
			}
		}
	}
	long GetFact(int N){
		return f[N];
	}
	long GetPerm(int N,int R){
		return f[N] * rf[N-R] % mod;
	}
	long GetConv(int N,int R){
		return ((f[N]*rf[R])%mod*rf[N-R])%mod;
	}
	long GetRev(int N){
		if(N == 0){
			return 1;
		}
		else{
			return rf[N] * f[N-1] % mod;
		}
	}
}
void Calc(){
	int H = rei();
	int W = rei();
	int K = rei();
	Fact::Fact(H+W);
	long ans = 0;
	for(int i=1;i<=K;i++){
		ans += ((i == 1 ? 0 : Fact::GetConv(H+W-2,i-2)*Fact::GetFact(i)%mod)*H%mod*W%mod+Fact::GetConv(H+W-1,i-1)*Fact::GetFact(i)%mod*(H+W)%mod+Fact::GetPerm(H+W,i)) % mod * Fact::GetPerm(H+W-i,K-i);
		ans %= mod;
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 312704
# -*- coding: utf-8 -*-

import bisect
import copy
import collections
import heapq
import itertools
import math
import numpy as np
from operator import itemgetter
import scipy.misc
import sys

"""
#### 入力例 ####
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())
"""


N=int(input())


def main():
    print((1000-N%1000)%1000)
    return
    

if __name__ == '__main__':
    main()


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

int main()
{
    //freopen("B.data", "r", stdin);
    string s;
    int K;
    cin>>K;
    cin>>s;
    //cout<<K<<" "<<s<<endl;
    if(s.length() <= K){
        cout<<s<<endl;
    }else{
        string ans;
        for(int i = 0 ; i < K ; ++i){
            char c = s.at(i);
            //cout<<c;
            ans.push_back(s.at(i));
        }
        ans.append("...");
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3632
def main
    circle = gets.chomp
    pattern = gets.chomp
    start_index_candidate = []
    circle.size.times do |index|
        if circle[index] == pattern[0]
            start_index_candidate.push(index)
        end
    end
    circle += circle
    start_index_candidate.each do |index|
        if circle.slice(index..index+pattern.size-1) == pattern
            puts "Yes"
            return
        end
    end
    puts "No"
    return
end

main()


Measured memory_bytes: 6880
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int x = Integer.parseInt(in.next());
            int ans = 0;

            for (int i = 1; i < 400; i++) {
                if ((i * x) % 360 == 0) {
                    ans = i;
                    break;
                }
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 35876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

template<class T> inline bool chmin(T &a,T b){
    if (a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){
        a=b;
        return true;
    }
    return false;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> s(N);
    rep(i,N) cin >> s[i];
    ll ans=0;
    rep2(i,1,N){
        ll sum=0;
        for (ll j=i;j<=N-1;j+=i){
            ll A=N-1-j,B=A-i;
            if (A<=B||B<=0) break;
            if (A%i==0&&A/i<=j/i) break;
            sum+=s[j]+s[N-1-j];
            chmax(ans,sum);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;


int main(){
  int w,h,n;cin >> w >> h >> n;
  int a[h][w]={0};
  /*auto print = [&](){
    rep(i,h){
      rep(j,w){
        cout << a[i][j];
      }
      cout << endl;
    }
  };*/
  for(int k=0;k<n;k++){
    int x,y,comand;
    cin >> x >> y >> comand;
    int bx,ex,by,ey;
    if(comand==1){
      bx = 0;
      by = 0;
      ex = x;
      ey = h;
    }
    else if(comand==2){
      bx= x;
      ex = w;
      by = 0;
      ey = h;
    }
    else if(comand==3){
      bx = 0;
      ex = w;
      by = 0;
      ey = y;
    }
    else{
      bx = 0;
      ex = w;
      by = y;
      ey = h;
    }
    REP(s,by,ey){
      REP(t,bx,ex){
        a[s][t] = 1;
      }
    }
  }
  int ans = 0;
  rep(i,h)rep(j,w){
    if(a[i][j]!=1)ans++;
  }
  cout << ans << endl;
}


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

const double EPS = 1e-9;
//??????????¨±???
bool equals(double a,double b){
    return (fabs(a-b) < EPS);
}


//???
class Point{
public:
    double x,y;
    Point (double x=0,double y=0) : x(x),y(y){}

    Point operator + (Point p){ return Point( x+p.x , y-p.y );}
    Point operator - (Point p){ return Point( x-p.x , y-p.y ); }
    Point operator * (double a){ return Point( a*x , a*y ); }
    Point operator / (double a){ return Point( x/a , y/a ); }


    bool operator == (const Point &p) const{
        return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
    }
};

//????????????
typedef Point Vector;

//??????
double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}
//??????
double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}
//Vector : ??´?????????
bool isOrthogonal(Vector a, Vector b){
    return equals(dot(a,b),0.0);
}

//Vector : ????????????
bool isParalell(Vector a,Vector b){
    return equals(cross(a,b),0.0);
}


void solve(){
    double p0x,p0y,p1x,p1y,p2x,p2y,p3x,p3y;
    cin>>p0x>>p0y>>p1x>>p1y>>p2x>>p2y>>p3x>>p3y;

    Vector v1(p0x-p1x,p0y-p1y);
    Vector v2(p2x-p3x,p2y-p3y);
    bool f = isOrthogonal(v1,v2);
    bool g = isParalell(v1,v2);

    if(f) cout << 1 << endl;
    else if(g) cout << 2 << endl;
    else cout << 0 << endl;
}

int main(){
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        solve();
    }
}

Measured memory_bytes: 3212
n = int(input())
li = [list(map(int,input().split())) for _ in range(n)]
li = sorted(li, key = lambda x:x[1])
sum = 0
for i in range(n):
  sum += li[i][0]
  if sum > li[i][1]:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 55264
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(S, s) S.find(s) != string::npos

int main() {
    int N;
    string S;
    cin >> N >> S;
    int r = 0, g = 0, b = 0;
    Rep(i, N) {
        if (S[i] == 'R') r++;
        else if (S[i] == 'G') g++;
        else if (S[i] == 'B') b++;
    }
    ll ans = (ll)r * g * b;
    for (int i = 0; i < N - 2; i++) {
        char a = S[i];
        for (int j = i + 1; 2 * j - i < N; j++) {
            char b = S[j];
            if (a == b) continue;
            char c = S[2 * j - i];
            if (c != a && c != b) ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextInt();
		long y = sc.nextInt();
		if (x % y != 0)
			System.out.println(x);
		else
			System.out.println("-1");
	}
}


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

public class Main {
	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		String s = sc.next();

		char[] chAry = new char[n];

		for (int i=0; i<n; i++){

			chAry[i] = s.charAt(i);

		}

		char[] chAryCopy = chAry.clone();

		Arrays.sort(chAryCopy);

		int cnt = 0;
		for (int i=0; i<n; i++){

			if (chAry[i] != chAryCopy[i]){
				cnt ++;
			}
		}
		System.out.println(cnt / 2);

	}


}

Measured memory_bytes: 41712
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Diagnostics.Contracts;
using System.Dynamic;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Net;
using System.Numerics;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = ReadInt();
            WriteLine((a) + (a * a) + (a * a * a));

        }


        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27084
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]
L = list(itertools.permutations(xy))
ans = 0
for i in L:
    dis = 0
    for l in range(N-1):
        dis += math.sqrt((i[l][0]-i[l+1][0])**2 + (i[l][1] - i[l+1][1])**2)
    ans += dis
print(ans / len(L))

Measured memory_bytes: 9972
import itertools

while True:
    # input
    n, x = map(int, input().split())
    
    # end judgment
    if n == x == 0:
        break

    # set number list
    n_list = [i for i in range(1,n+1)]
    
    # compute combination
    c_list = list(itertools.combinations(n_list, 3))
    
    # initialize count
    count = 0
    
    # count total
    for each_c in c_list:
        if sum(each_c) == x:
            count+=1
    
    # output
    print(count)


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

int main(){
  int n; cin >> n;
  string s; cin >> s;
  size_t size = s.size();

  rep(i,size){
    char a = s[i];
    rep(j,n){
      a++;
      if(a == '[') a = 'A';
    }
    cout << a;
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("O3")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

signed main(){
 std::string n;
 cin >> n;
 long long temp;
 temp += (n[0] - '0');

//cout << temp << ',' << n[0] << endl;
 for(int i = 1; n[i] != '\0'; i++){
   //cout << temp << ',' << n[i] - '0' << ',' << n[i] << endl;
   if((temp + n[i]-'0') % 9 == 0){
     temp = 0;
   }else{
     temp = temp + n[i]-'0';
   }
 }
 if((temp % 9 ==  0 ) && (temp == 0))
   cout << "Yes";
 else 
   cout << "No";
}



Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a,const void *b){
  return *(int *)a - *(int *)b;
}

int main(){
  int N=0,K=0;
  int sum=0;
  int p[1000]={0};

  scanf("%d %d",&N,&K);
  for(int i=0;i<N;i++) scanf("%d",&p[i]);
  qsort(p,N,sizeof(int),compare_int);
  for(int i=0;i<K;i++) sum += p[i];
  printf("%d\n",sum);


  return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	void operator()(vi&a, vi&b, vi&c) {
		map<int,int> m;
		int q=b.size();
		ll sum=0;

		for(auto ma:a)
		{
			m[ma]++;
			sum+=ma;
		}

		for(int i=0;i<q;i++)
		{
			sum+=(ll)(c[i]-b[i])*m[b[i]];
			m[c[i]]+=m[b[i]];
			m.erase(b[i]);
			cout << sum << "\n";
		}
	}
};

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

	for(;;)
	{
		int n, q;
		cin >> n;
		if(cin.fail()) break;
		vi a(n);
		for(auto&m:a) cin >> m;
		cin >> q;
		vi b(q), c(q);
		for(int i=0;i<q;i++) cin >> b[i] >> c[i];

		solve()(a, b, c);
	}
	return 0;
}


Measured memory_bytes: 7420
#include <iostream>

using namespace std;

long long x[11];

int main(){
  long long i,N,D,r;
  cin >> r >> D >> x[0];
  for (i=0;i<10;++i) {
    x[i+1] = x[i] * r -D;
    cout << x[i+1] << endl;
  }
  return 0;
}


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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
  int k, a, b;
  cin >> k >> a >> b;
  bool f = false;
  for (int i = a; i <= b; i++)
  {
    if (i % k == 0)
      f = true;
  }
  if (f)
    cout << "OK" << endl;
    else
      cout << "NG" << endl;
}

Measured memory_bytes: 3632
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var n = cin.ReadLong;
            var list = new List<long>();
            list.Add(cin.ReadLong);
            list.Add(cin.ReadLong);
            list.Add(cin.ReadLong);
            list.Add(cin.ReadLong);
            list.Add(cin.ReadLong);

            var first = list.OrderBy(t => t).ToList().First();
            if (first >= n) {
                WriteLine(5);
                return;
            }
            
            var sp = n/first;
            if (n%first != 0) {
                sp++;
            }
            WriteLine(sp+5-1);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 13524
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
using namespace std;

int main() {
	int n; cin >> n;
	vector<long long int> vec(100010,0); 
	REP(i, n) {
		cin >> vec[i];
	}

	sort(vec.begin(), vec.end(),greater<long long int>());

	int count = 1;
	long long int tate=0, yoko=0;
	for (int i = 1; i < n;i++) {
		if (vec[i] == vec[i - 1]) {
			if (tate){yoko = vec[i]; break;}
			tate = vec[i];
			i++;
		}
	}
	if (!tate||!yoko) { cout << 0 << endl; return 0; }
	cout << tate * yoko << endl;	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#define REP(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int, int> P;

int main(void) {
	int W, H;
	cin >> W >> H;

	vector< vector<int> > board(W+2, vector<int>(H+2));
	REP(i, W+2) REP(j, H+2) board[i][j] = 0;
	REP(i, H) REP(j, W) {
		cin >> board[j+1][i+1];
	}

	queue<P> que;
	que.push(P(0,0));
	map<P, int> used;
	used[P(0, 0)] = 1;
	board[0][0] = -1;

	while ( !que.empty() ) {
		P p = que.front(); que.pop();
		int x = p.first, y = p.second;

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

		if ( y & 1 ) {
			REP(i, 6) {
				dx[i] = -1 * dx[i];
				dy[i] = -1 * dy[i];
			}
		}

		REP(i, 6) {
			int n_x = x + dx[i], n_y = y + dy[i];
			if ( 0 <= n_x && n_x < W+2 && 0 <= n_y && n_y < H+2 ) {
				P n_p = P(n_x, n_y);
				if ( !used[n_p] && board[n_x][n_y] == 0) {
					que.push(n_p);
					used[n_p] = 1;
					board[n_x][n_y] = -1;
				}
			}
		}
	}

	// REP(i, H+2) {
	// 	if ( i & 1 ) printf("  ");
	// 	REP(j, W+2) {
	// 		printf("%4d", board[j][i]);
	// 	}
	// 	cout << endl;
	// }

	int sum = 0;
	REP(i, W+2) REP(j, H+2) {
		if ( board[i][j] == 1 ) {
			int dx[] = {-1,  0, -1, 1, -1, 0};
			int dy[] = {-1, -1,  0, 0,  1, 1};

			if ( j & 1 ) {
				REP(i, 6) {
					dx[i] = -1 * dx[i];
					dy[i] = -1 * dy[i];
				}
			}

			REP(k, 6) {
				int n_x = i + dx[k], n_y = j + dy[k];
				if ( board[n_x][n_y] == -1 ) {
					sum++;
				}
			}
		}
	}

	cout << sum << endl;
}

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

int main() {
    string s; cin >> s;
    int n = s.size();
    string k = "keyence";
    bool ans = false;
    for (int i=0; i<=n-7; ++i) {
        string ps = s.substr(i, 7);
        if (ps == k) ans = true;
    }
    for (int i=0; i<n; ++i) {
        for (int j=i; j<n; ++j) {
            string sf, sb;
            sf = s.substr(0, i);
            sb = s.substr(j, n-1+j);
            if (sf+sb == k) ans = true;
        }
    }
    cout << (ans ? "YES" : "NO") << endl;
}

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

int main(){
 int x, fx, N;
  cin >> N;
  x = N;
  
  while(x != 0){
    fx +=  x % 10;  
    x /= 10;
  }
  if(N % fx == 0){
  cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
       
           

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  // 標準入力高速化のおまじない
  // scanfとの同期を切る。以降紛らわしいのでscanf使用不可。
  ios::sync_with_stdio(false);
  // // cin前の自動flashをやめる
  cin.tie(nullptr);
  char x;
  cin >> x;
  char result = 'A';
  if(!isupper(x)){
    result = 'a';
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3644
{-# OPTIONS_GHC -O #-}

import Control.Monad
import Control.Monad.ST
import Data.List
import Data.Maybe
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap as M

main = do
    (n:m:_)<-map read.words<$>getLine::IO [Int]
    lrds <- replicateM m $ unfoldr (B.readInt.B.dropWhile(==' ')) <$> B.getLine :: IO[[Int]]
    --
    let res = solve n lrds
--    case res of
--        Nothing -> return ()
--        Just (uf,dt) -> print uf >> print dt
    --
    putStrLn $ case res of
        Nothing -> "No"
        Just (uf, dt) | chk uf dt -> "Yes"
        _ -> "No"
--
chk uf dt = all (\(a,b) -> (b-a) <= 1000000000) $ M.elems md
    where
        md = foldl (\m i -> M.alter (mf (dt V.! i)) (uf V.! i) m) M.empty [1..V.length uf-1]
        mf d Nothing = Just (min 0 d, max 0 d)
        mf d (Just (a,b)) = Just (min a d, max b d)
--
solve :: Int -> [[Int]] -> Maybe (V.Vector Int, V.Vector Int)
solve n lrds = runST $ do
    uf <- V.unsafeThaw $ V.fromList $ [0..n] :: ST s (VM.STVector s Int)
    dt <- VM.replicate (n+1) 0 :: ST s (VM.STVector s Int)
    --
    ins uf dt lrds
--
ins uf dt [] = do
    forM_ [1..VM.length uf-1] $ findUF uf dt
    uf' <- V.freeze uf
    dt' <- V.freeze dt
    return $ Just (uf',dt')

ins uf dt ((l:r:d:_):lrds) = do
    (lp,ld) <- findUF uf dt l
    (rp,rd) <- findUF uf dt r
    case (lp,rp) of
        (a,b) | a/=b -> VM.unsafeWrite uf rp l >> VM.unsafeWrite dt rp (d-rd) >> ins uf dt lrds
        (a,b) | rd-ld == d -> ins uf dt lrds
        _ -> return Nothing
--
findUF :: VM.STVector s Int -> VM.STVector s Int -> Int -> ST s (Int,Int)
findUF uf dt x = do
    p <- VM.unsafeRead uf x
    d <- VM.unsafeRead dt x
    if p == x
        then return (x,0)
        else do
                (f,v) <- findUF uf dt p
                VM.unsafeWrite uf x f
                VM.unsafeWrite dt x (d+v)
                return (f,d+v)

Measured memory_bytes: 65916
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    ll sol = 0;
    for (ll k = 1; k * k <= n; ++k)
        if (k * k <= n)
            sol = k * k;
    cout << sol;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

  if (b - a <= 0) {
	cout << "delicious" << endl;
  }
  else if (0 < b - a && b - a <= x) {
	cout << "safe" << endl;
  }
  else {
	cout << "dangerous" << endl;
  }

  return (0);
}

Measured memory_bytes: 256
k = int(input())
if k <= 9:
    print(k)
    exit()
a = [i for i in range(1, 10)]
cnt = 9
idx = 0
while cnt < k:
    a_ = str(a[idx])
    t = a_[-1]
    if t == "0":
        l_ = [0, 1]
    elif t == "9":
        l_ = [8, 9]
    else:
        l_ = [int(t)-1, int(t), int(t)+1]
    for i in l_:
        a.append(int(a_ + str(i)))
    cnt += len(l_)
    idx += 1
print(a[-(cnt-k+1)])

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

int main() {
  vector<char> s(3);
  cin >>s.at(0) >>s.at(1) >>s.at(2);
  sort(s.begin(), s.end());
  if (s.at(0)=='a' && s.at(1)=='b' && s.at(2)=='c'){
    cout <<"Yes" <<endl;
  }else{
    cout <<"No" <<endl;
  }
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> edge;

ll A[1000000];
ll B[1000000];
double C[100][100];
ll n;
bool comp(const ll& left, const ll& right) {
        return A[left] < A[right];
}

int main(){
    ll comb;
    double sum=0;
    cin >> n;

    for(ll i=0; i<n; i++){
        cin >> A[i] >> B[i];
    }
    comb = n;
    for(ll i=2; i<n; i++) comb *= i;

    for(ll i=0; i<n; i++){
        for(ll j=0; j<n; j++){
            double tmp1, tmp2;
            tmp1 = A[i]- A[j];            
            tmp2 = B[i]- B[j];
            C[i][j] = sqrt(tmp1*tmp1 + tmp2*tmp2);
            sum += C[i][j];
        }
    }
    sum = sum/2;
    cout << setprecision(12)<<(sum*2*(n-1))/(n*(n-1)) << endl;
    return 0;
}


Measured memory_bytes: 2304
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"

struct cust {
	int  m;
	int l;
	int k;
};
 
struct query {
	int type;
	int time;
	int id;
};
struct aa {
	int id;
	int time;
};
class Compare {
public:
	bool operator()(const query&l,const query&r) {
		return l.time==r.time?l.type==r.type?l.id>r.id:l.type>r.type:l.time > r.time;
	}
	bool operator()(const aa&l, aa&r) {
		return l.time > r.time;
	}
};

bool check(const int T, const vector<cust>&cus, const int n) {
	int waitnum = n;
	priority_queue<query,vector<query>,Compare>que;
	//vector<int>waits(cus.size());
	set<int>waits;
	for (int i = 0; i < cus.size(); ++i) {
		que.push(query{ 0,0,i });
	}
	while (!que.empty()) {
		query q(que.top());
		que.pop();
		if (q.type == 1) {
			auto it = waits.begin();
			if (it == waits.end()) {
				waitnum++;
			}
			else {
				const int cid = *it;
				const int nexttime = q.time + cus[cid].m;
				if (nexttime <= T) {
					waits.erase(it);
					que.push(query{ 1,nexttime,0 });
				}else {
					return false;
				}
				
			}
		}
		else if (q.type == 0) {
			const int cid = q.id;
			if (waitnum) {
				waitnum--;
				const int nexttime = q.time + cus[cid].m;
				if (nexttime <= T) {
					que.push(query{ 1,nexttime,0 });
				}else {
					return false;
				}
			}
			else {
				waits.emplace(cid);
				const int nexttime = q.time + cus[cid].l;
				que.push(query{ 2,nexttime,cid });
			}
		}
		else if (q.type == 2) {
			const int cid = q.id;
			auto it = waits.find(cid);
			if (it!=waits.end()) {
				waits.erase(it);
				const int nexttime = q.time + cus[cid].k;
				if (nexttime < T) {
					que.push(query{ 0,nexttime,cid });
				}
				else {
					return false;
				}
			}
			else {

			}
		}
	}
	return true;
}

int main() {
	while (1) {
		int N, T; cin >> N >> T;
		if (!N)break;
		vector<cust>cus;
		int totalm = 0;
		for (int i = 0; i < N; ++i) {
			int m, l, k; cin >> m >> l >> k;
			totalm += m;
			cus.push_back(cust{ m,l,k });
		}
		int amin = (totalm-1) / T + 1;
		for (int n = amin; n <= N; ++n) {
			if (check(T, cus, n)) {
				cout << n << endl;
				break;
			}
		}
	}
	
	return 0;
}

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

using namespace std;
using ll = long long int;

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

    ll a, b, c;
    cin >> a >> b >> c;
    ll i;
    for(i=0; i<100; i++) {
        if(a&1 || b&1 || c&1) break;
        ll pa = a, pb = b, pc = c;
        a = (pb+pc)/2;
        b = (pc+pa)/2;
        c = (pa+pb)/2;
    }
    cout << (i == 100 ? -1 : i) << endl;
}


Measured memory_bytes: 256
<?php
list($n, $m, $v, $p) = ints();
$a = ints();
rsort($a);
$ok = $p - 1;
$ng = $n;
while (abs($ok - $ng) > 1) {
    $mid = intdiv($ok + $ng, 2);
    // mid に m 人全員が投票しても p 番目のスコアを超えない場合は採用される可能性なし
    if ($a[$mid] + $m < $a[$p - 1]) {
        $ng = $mid;
        continue;
    }
    // mid の採用の可能性に影響しない投票数を数える
    $cnt = 0;
    for ($i = 0; $i < $n; ++$i) {
        if ($i === $mid) continue;
        // 大きい順に p-1 個については全力投票してもok
        if ($i < $p - 1) $cnt += $m;
        // 残りについては a[mid]+m を超えない範囲の人数が投票してもok
        else $cnt += min($m, $a[$mid] + $m - $a[$i]);
    }
    if ($cnt >= $m * ($v - 1)) $ok = $mid;
    else $ng = $mid;
}
echo $ok + 1;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 27268
l=list(input().split())  ##文字も数字も入る
stack=[]

for x in l: ##リストの長さ文だけ繰り返し
    if x in ['+','-','*']: ##←知らなかった判定方法
        t=str(stack.pop()) ##末尾取り出し
        r=str(stack.pop())
        c=r+x+t
        stack+=[int(eval(c))] ##eval:入力した式の入力

    else:
        stack+=[int(x)] ##[]の意味?>リストに追加

print(stack.pop())



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

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

  vector<pair<int, int> > data;
  int a, b;

  for(int i = 0;i < n;i++){
    cin >> a >> b;
    data.push_back(make_pair(a, 1));
    data.push_back(make_pair(b+1, -1));
  }

  data.push_back(make_pair(2000000000, 0));

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

  int now = 0;
  int cnt = 0;
  int ans = 0;
  for(int i = 0;i < data.size();i++){
    if(now != data[i].first){
      ans = max(ans, cnt);
      cnt += data[i].second;
      now = data[i].first;
    }else{
      cnt += data[i].second;
    }
  }

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


Measured memory_bytes: 4932
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A>> B>> C>> D;
  
  if((A+B) < (C+D)){
    cout << "Right" << endl;
  }
  
  if((A+B) == (C+D)){
    cout << "Balanced" << endl;
  }
  
  if((A+B) > (C+D)){
    cout << "Left" << endl;
  }
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def checker():
    ans = [0] * 10001
    for a in range(1, 101):
        for b in range(1, 101):
            for c in range(1, 101):
                n = a * a + b * b + c * c + a * b + b * c + c * a
                if n > 10000:
                    continue
                else:
                    ans[n] += 1
    return ans


def main():
    N = int(input().strip())
    ans = checker()
    for n in range(1, N + 1):
        print(ans[n])
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 67992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
const int mod = 1000000007, mod2 = 998244353, inf = 0x3f3f3f3f;
const int maxn = 1e6 + 5;
int cnt[1005], a[10005];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a, b;
  	cin >> a >> b;
  	cout << max({a + a - 1, b + b - 1, a + b}) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, 0, n) cin >> v[i];
  sort(v.begin(), v.end());
  int max_val = v[n - 1];

  int ans = 0, med = 1e9 * 2, half = (max_val + 1) / 2;
  rep(i, 0, n - 1) {
    int diff = abs(half - v[i]);
    if (med > diff) {
      ans = v[i];
      chmin(med, diff);
    }
  }
  cout << max_val << " " << ans << endl;
}


Measured memory_bytes: 640
def main():
    s_long = input()
    s_shor = input()

    ans = len(s_shor)
    max_len = len(s_long) - len(s_shor) + 1


    for i in range(max_len):
        cnt = 0

        for j in range(len(s_shor)):

            short = s_shor[j]
            longg = s_long[i + j]
            
            if (short != longg):
                cnt += 1
        
        ans = min(ans, cnt)
        
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9028
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

////////////////////////////////////////////////////////


int main() {
    ll n; cin >> n;
    Vl a(n);
    rep(i, 0, n) cin >> a[i];
    set<ll> st;
    rep(i, 0, n) st.insert(a[i]);
    if(sz(st)%2 != 0) co(sz(st));
    else co(sz(st)-1);

    return 0;
}


Measured memory_bytes: 5760
import java.util.*;

public class Main {

    private static final char BLACK = '#';
    private static final char WHITE = '.';

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

    public void execute() {
        Scanner sc = new Scanner(System.in);
        final int H = sc.nextInt();
        final int W = sc.nextInt();
        sc.nextLine();

        char[][] board = new char[H][W];

        int whiteCells = 0;
        for (int i = 0; i < H; i++) {
            String s = sc.nextLine();
            for (int j = 0; j < W; j++) {
                board[i][j] = s.charAt(j);
                if (board[i][j] == WHITE) {
                    whiteCells += 1;
                }
            }
        }

        final Point start = new Point(0, 0);
        final Point goal = new Point(H - 1, W - 1);

        int minSteps = bfs(start, goal, board);

        System.out.println(minSteps > 0 ? whiteCells - minSteps : minSteps);
        sc.close();
    }

    private int bfs(Point start, Point goal, char[][] board) {
        int h = board.length;
        int w = board[0].length;
        boolean[][] visited = new boolean[h][w];

        Queue<Point> fifo = new LinkedList<>();
        start.turn = 1;
        fifo.add(start);
        visited[start.x][start.y] = true;
        while (!fifo.isEmpty()) {
            Point p = fifo.poll();

            if (p.equals(goal)) {
                return p.turn;
            }

            List<Point> moves = new ArrayList<>();
            moves.add(new Point(p.x + 1, p.y));
            moves.add(new Point(p.x - 1, p.y));
            moves.add(new Point(p.x, p.y + 1));
            moves.add(new Point(p.x, p.y - 1));

            for (Point moveTo : moves) {
                if (moveTo.x >= 0 && moveTo.y >= 0 && moveTo.x < h && moveTo.y < w && !visited[moveTo.x][moveTo.y] && board[moveTo.x][moveTo.y] == WHITE) {
                    visited[moveTo.x][moveTo.y] = true;
                    moveTo.turn = p.turn + 1;
                    fifo.add(moveTo);
                }
            }
        }

        return -1;
    }


    class Point {
        public final int x;
        public final int y;
        public int turn;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public boolean equals(Object obj) {
            if (!(obj instanceof Point)) {
                return false;
            }
            Point that = (Point) obj;
            return (this.x == that.x && this.y == that.y);
        }

        @Override
        public int hashCode() {
            return Objects.hash(this.x, this, y);
        }
    }
}

Measured memory_bytes: 21844
A,B,K = map(int,input().split())
ans = set()
for a in range(A,A+K):
    if a > B: break
    ans.add(a)
for a in range(B,B-K,-1):
    if a < A: break
    ans.add(a)
for a in sorted(ans):
    print(a)

Measured memory_bytes: 3060
import collections
n=int(input())
arr=input().split(" ")
arr_s=set(arr)
a=0
arr_e=[0 for i in range(int(n/2))]
arr_o=[0 for i in range(int(n/2))]
for i in range(int(n/2)):
    arr_e[i]=arr[a]
    arr_o[i]=arr[a+1]
    a+=2
ce=collections.Counter(arr_e).most_common()
co=collections.Counter(arr_o).most_common()
if len(arr_s)==1:
    print(int(n/2))
else:
    if ce[0][0]!=co[0][0]:
        print(n-ce[0][1]-co[0][1])
    else:
        print(n-max(ce[0][1]+co[1][1],ce[1][1]+co[0][1]))

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

vector < int > v;

bool check(int n, int m, int mid){
    return (m/mid>=n && m%mid==0);
}

int cal(int n, int m){
    int ans=0;
    for(int i=1; i*i<=m; i++){
        if(m%i==0){
             if(check(n,m,i))ans=max(ans,i);
             if(check(n,m,m/i))ans=max(ans,m/i);
        }
    }
    return ans;
}

int main(){

    int n,m;
    cin>>n>>m;
    int ans=cal(n,m);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628