akhauriyash/Code-Regression huggingface dataset:
import itertools
K=int(input())
R=[]
C=[]
RCd={}
rflag=[ 0 for _ in range(8) ]
for i in range(K):
  r,c=map(int,input().split())
  R.append(r)
  C.append(c)
  RCd[r]=c
  rflag[r]=1

l=[ i for i in range(8) ]
P=itertools.permutations(l,8)
for p in P:
  p=list(p)
  flag=0
  for i in range(8):
    if rflag[i]==1 and p[i]!=RCd[i]:
      flag=1
      break
    for j in range(8):
      if i==j: continue
      if abs(i-j)==p[i]-p[j]:
        flag=1
        break
  #cleared
  if flag==1:continue
  for i in range(8):
    ans='........'
    print(ans[:p[i]]+'Q'+ans[p[i]+1:])
  exit()


Measured memory_bytes: 5668
#include <iostream>

using namespace std;

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

    int n;
    cin >> n;

    int pos[n];
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        pos[a-1] = i;
    }

    for (int i = 0; i < n; i++) {
        cout << pos[i] + 1 << (i == n - 1 ? '\n' : ' ');
    }

    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
     
    using namespace std;
    int main()
    {
        int n;
        cin >> n;
        for(int i=1;i<=9;i++){
            for(int j=1;j<=9;j++){
                if(n==i*j){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
        cout << "No" <<endl;
        return 0;
    }

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;



int main(int argc, char *args[]) {
	int a, b, k;
	cin >> a >> b >> k;
	if (b - a + 1 > 2 * k) {
		for (int i = 0; i < k; i++) {
			cout << a + i << endl;
		}
		for (int i = 0; i < k; i++) {
			cout << b - k + 1 + i << endl;
		}
	}
	else {
		for (int i = 0; i < b - a + 1; i++) {
			cout << a + i << endl;
		}
	}

	
}


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

constexpr int MAX_N = 1e5+9;

//int L[MAX_N];
//int R[MAX_N];


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

  int L{0}, R{MAX_N+1};

  for (int i{}; i < M; ++i) {
    int l, r; cin >> l >> r;
    L = max(L, l);
    R = min(R, r);
  }

  int ans = R - L + 1;
  cout << (ans > 0 ? ans : 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int a[1000];
	int i;

	scanf("%d", &n);

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

	/* DENIEDと出力するのは、偶数かつ、3または5の倍数以外の数字が存在するときのみ */
	for (i = 0; i < n; i++)
	{
		if ((a[i] % 2 == 0) && (a[i] % 3 != 0) && (a[i] % 5 != 0))
		{
				printf("DENIED\n");
				return 0;
		}	
	}
	
	printf("APPROVED\n");

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,c[9] = {},ans = 0;cin >> n;
  while(cin >> i){
    i /= 400;
    if(i>=8) c[8]++;
    else c[i] |= 1;
  }
  for(i=0;i<8;i++) ans += c[i];
  cout << ((c[8]) ? max(ans,1):ans) << " " << ans+c[8] << "\n";
}

Measured memory_bytes: 256
N = int(input())

k = [0 for i in range(81)]

A = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80]
B = [0, 9, 18, 27, 36, 45, 54, 63, 72, 1, 10, 19, 28, 37, 46, 55, 64, 73, 2, 11, 20, 29, 38, 47, 56, 65, 74, 3, 12, 21, 30, 39, 48, 57, 66, 75, 4, 13, 22, 31, 40, 49, 58, 67, 76, 5, 14, 23, 32, 41, 50, 59, 68, 77, 6, 15, 24, 33, 42, 51, 60, 69, 78, 7, 16, 25, 34, 43, 52, 61, 70, 79, 8, 17, 26, 35, 44, 53, 62, 71, 80]
for i in range(1, N+1):
    h = str(i)[0]
    t = str(i)[-1]
    if t!="0":
        k[(int(h)-1)*9 + int(t) - 1] += 1

ans = sum([k[a]*k[b] for a, b in zip(A, B)])
print(ans)

Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int N = 1005;
char str[N];


int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    scanf("%s", str);
    int n = strlen(str);
    set <char> s;
    for (int i = 0; i < n; i++)
        s.insert(str[i]);

    if (s.count('S') != s.count('N') || s.count('W') != s.count('E'))
        printf("No\n");
    else
        printf("Yes\n");



	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int X,Y;
    cin >> X >> Y;
    if(Y%2==1)
    {
        cout << "No" << endl;
        return 0;
    }
    if(2*X<=Y&&4*X>=Y)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
int main(){
  lli A,B,C=INF,D=0,E=0,F=0,G=0,H=0,N,M;
  cin >> N >> M;
  string S;
  rep(i,0,N){
    cin >> S;
    Out(S);
    Out(S);
  }
}

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

void solve(){
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n1) for(int i=0;i<n1;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
#define PI 3.141592653589793
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const ll inf=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vector<Pii> v[100001];
ll dp2[300000][60]={};
int main() {
		int h,a;
		cin>>h>>a;
		int r=h/a;
		if(h%a>0)r++;
		printf("%d",r);
	return 0;
}


Measured memory_bytes: 3968
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;

ll f(ll a, ll b, ll c) {
	ll x = a * b, y = a * c, z = b * c;
	if (x < y) return x < z ? x : z;
	else return y < z ? y : z;
}

int main(){
	ll a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) cout << 0 << endl;
	else cout << f(a, b, c) << endl;
	return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n =sc.nextInt();
    int num =0;
    for(int i=1;i<=9;i++) {
      for(int j=1;j<=i;j++) {
        if(i*j==n) {
          num++;
        }
      }
    }
    if(num != 0 ) System.out.println("Yes");
    if(num == 0 ) System.out.println("No");
}
}


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

char s[100005];
int main()
{
    int b,w;
	while(cin >> s)
	{
	    b = 0,w = 0;
	    int len = strlen(s);
	    bool bf = 0,wf = 0;
	    for(int i = 0;i < len;i++)
	    {
	        if(s[i] == 'B' && bf == 0)
	        {
	            b++;
	            bf = 1,wf = 0;
	        }
	        if(s[i] == 'W' && wf == 0)
	        {
	            w++;
	            wf = 1,bf = 0;
	        }
	    }
	    cout << b + w - 1<< endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>

int main()
{
	std::string const UPPER_ALPHABETS = "QWERTYUIOPASDFGHJKLZXCVBNM";

	std::string inputString;
	std::cin >> inputString;

	if (UPPER_ALPHABETS.find(inputString) != std::string::npos)
	{
		std::cout << 'A' << std::endl;
	}
	else
	{
		std::cout << 'a' << std::endl;
	}
}

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

/*-------------------------------Template---------------------------------------*/

#define shameem              ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll                   long long int
#define gcd(a,b)              __gcd(a,b)
#define lcm(a,b)             (a*b)/gcd(a,b)
#define pi                    2*acos(0.0)
#define testi                int t; cin>>t; while(t--)
#define testl                ll t; cin>>t; while(t--)
#define vi                   vector<int>
#define vl                   vector<ll>
#define pb                   push_back
#define mk                   make_pair

/*-------------------------------Print---------------------------------------*/

#define YES                  cout<<"YES"<<endl
#define NO                   cout<<"NO"<<endl
#define yes                  cout<<"yes"<<endl
#define no                   cout<<"no"<<endl

using namespace std;

void solve()
{
    string s;
    cin>>s;
    int l=s.size();
    char c=s[l-1];

    if(c=='e')
    {
        cout<<s<<"s"<<endl;
    }
    else if(c=='s')
    {
        cout<<s<<"es"<<endl;
    }
    else
    {
        cout<<s<<"s"<<endl;
    }

}
int main()
{
    shameem

   // testi

    //testl



    solve();

    return 0;
}



Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String str = sc.next();
		char[] kanrisya = new char[n + 1];
		kanrisya = str.toCharArray();
		int[] kanri = new int[n + 1];
		int[][] bunki = new int[n + 1][7];
		int ans = 0;
		for (int i = 0; i <= n; i++) {
			if (i == 0)
				kanri[i] = 1;
			else {
				if (kanrisya[i - 1] == 'J')
					kanri[i] = 1;
				else if (kanrisya[i - 1] == 'O')
					kanri[i] = 2;
				else 
					kanri[i] = 3;
			}
		}
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j < 7; j++) {
				if (i == 0 && j == 0)
					bunki[i][j] = 1;
				else
					bunki[i][j] = 0;
			}
		}
		for (int i = 1; i <= n; i++) {
			if (kanri[i] == 1) {
				bunki[i][0] = bunki[i - 1][0] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][6];
				bunki[i][3] = bunki[i - 1][0] + bunki[i - 1][1] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
				bunki[i][4] = bunki[i - 1][0] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
				bunki[i][6] = bunki[i - 1][0] + bunki[i - 1][1] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
			} else if (kanri[i] == 2) {
				bunki[i][1] = bunki[i - 1][1] + bunki[i - 1][3] + bunki[i - 1][5] + bunki[i - 1][6];
				bunki[i][3] = bunki[i - 1][0] + bunki[i - 1][1] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
				bunki[i][5] = bunki[i - 1][1] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
				bunki[i][6] = bunki[i - 1][0] + bunki[i - 1][1] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
			} else {
				bunki[i][2] = bunki[i - 1][2] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
				bunki[i][4] = bunki[i - 1][0] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
				bunki[i][5] = bunki[i - 1][1] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
				bunki[i][6] = bunki[i - 1][0] + bunki[i - 1][1] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
			}
			for (int k = 0; k < 7; k++) {
				bunki[i][k] %= 10007;
			}
		}
		for (int i = 0; i < 7; i++) {
			ans += bunki[n][i];
		}
		ans %= 10007;
		System.out.println(ans);
		return;
	}
}

Measured memory_bytes: 17364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    ll max0=0,h,ans=0;
    rep(0,i,n){
        cin>>h;
        max0=max(h,max0);
        if(max0==h)++ans;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
M,D = map(int,input().split())

count = 0
for m in range(2,M+1):
	for d in range(22,D+1):
		d_list = list(str(d))
		if int(d_list[1])*int(d_list[0]) == int(m) and int(d_list[1])>=2 and int(d_list[0])>=2:
			count +=1

print(count)

Measured memory_bytes: 3060
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>
#include <queue>

using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(void)
{
  int N, M, tmp;
  long cost=0;

  scanf("%d %d",&N,&M);
  priority_queue<int> A;
  rep(i,N){
    scanf("%d",&tmp);
    A.push(tmp);
  }

  while(M>0){
    tmp = A.top();
    A.pop();
    A.push(tmp/2);
    M--;
  }

  rep(i,N){
    cost += A.top();
    A.pop();
  }

  printf("%ld\n",cost);
  return 0;
}

Measured memory_bytes: 892
/*
AizuOnline A0047
Cup Game
*/
#include <stdio.h>


main()
{
 char pos;
 char buf[100];

 pos = 'A';

 while(NULL != fgets(buf,4,stdin))
   { 
     if(buf[0] == pos)
       pos = buf[2];
     else if(buf[2] == pos)
       pos = buf[0];
   }

  printf("%c\n",pos);

return(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using ll = long long;

int main()
{
    int k, x;
    cin >> k >> x;
    if(500 * k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

typedef long long ll;
ll n, s, rs, a[N], ans[N];
int main()
{
	ll i;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf ("%lld", &a[i]);
		s += a[i];
	}
	for (i = 1; i < n; i += 2) {
		rs += a[i] * 2;
	}
	ans[0] = s - rs;
	a[n] = a[0];
	for (i = 1; i < n; i++) {
		ans[i] = (a[i - 1] * 2 - ans[i - 1]);
	}
	for (i = 0; i < n; i++) printf("%lld ", ans[i]);
    return 0;
}


Measured memory_bytes: 2816
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int k=sc.nextInt();
    String s=sc.next();

    if(s.length()<=k){
      System.out.println(s);
    }else{
      for (int i=0;i<k;i++) {
        System.out.print(s.charAt(i));
      }
      System.out.println("...");
    }


  }
}


Measured memory_bytes: 27076
N = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

a_cnt = 0
b_cnt = 0

for i in range(N):
    a = a_list[i]
    b = b_list[i]

    if a == b:
        continue
    elif a > b:
        a_cnt += a - b

    else:
        b_cnt += (b - a + 1) // 2
tmp = sum(b_list) - sum(a_list)
if a_cnt <= tmp and b_cnt <= tmp:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 4596
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer[] input = new Integer[3];
        input[0] = sc.nextInt();
        input[1] = sc.nextInt();
        input[2] = sc.nextInt();
        if((input[0] >= 1 && input[0] <= 10000) && (input[1] >= 1 && input[1] <= 10000) && (input[2] >= 1 && input[2] <= 10000)){
            if(input[1] < input[0]){
                int buffer = input[0];
                input[0] = input[1];
                input[1] = buffer;
            }
            if(input[2] < input[0]) {
                int buffer = input[0];
                input[0] = input[2];
                input[2] = buffer;
            }
            if(input[2] < input[1]){
                int buffer = input[1];
                input[1] = input[2];
                input[2] = buffer;
            }
        System.out.println(input[0] + " " + input[1] + " " + input[2]);
        }
    }
}


Measured memory_bytes: 26284
import sys
read=sys.stdin.read
readline=sys.stdin.readline

a,b,c,d,e,f=map(int,readline().split())

def searints(m,n,l):#m<=n
  mask=(1<<l+1)-1
  s=sum([1<<n*i for i in range(1,l//n+1)])&mask
  for i in range(1,l//m+1):
    s=(s+1<<m*i|s) &mask
  return [x for x in range(0,l+1) if ((s+1)>>x)&1==1]

w=searints(100*a,100*b,f)
s=searints(c,d,f)
candidates=[(100*y/(x+y),x+y,y) for x in w for y in s if e*x>=100*y and x*y>0 and x+y<=f]
if candidates:
  print(*max(candidates)[1:])
else:
  print(100*a,0)

Measured memory_bytes: 9928
import math
a, b, x=map(int, input().split())
area=x/a

if area<=a*b/2:
    bottom=2*area/b
    print(math.degrees(math.atan(b/bottom)))
else:
    empty=a*b-area
    right=2*empty/a
    print(math.degrees(math.atan(right/a)))



Measured memory_bytes: 3188
#include <cctype>
#include <iostream>
#include <string>
#include <algorithm>

int main() {
  std::string S;
  std::cin >> S;

  if (S[0] != 'A') {
    std::cout << "WA" << std::endl;
  } else if (std::count(S.begin()+2, S.end()-1, 'C') != 1) {
    std::cout << "WA" << std::endl;
  } else {
    for (size_t i = 1; i < S.length(); ++i)
      if (!(S[i] == 'C' || islower(S[i])))
        return (std::cout << "WA" << std::endl), 0;
    std::cout << "AC" << std::endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
int n;
int arr[N];
int cnt[N];
int ans;
int main(){
    scanf("%d" , &n);
    memset(cnt , 0 , sizeof(cnt));
    for(int i = 1 ; i <= n ; ++i){
        scanf("%d" , arr + i);
        ++cnt[arr[i]];
    }
    int tot = 0;
    for(int i = 0 ; i < N ; ++i){
        tot += min(1 , cnt[i]);
        ans += max(0 , cnt[i] - 1);
    }
    tot -= ans & 1;
    printf("%d\n" , tot);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int A,B;
  cin >> A >> B;
  int res = 1;
  int ans = 0;
  while (res < B) {
    ans++;
    res += A-1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
typedef pair<int,int> pii;
#define mp make_pair
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
ll n,x;
int main()
{
	scanf("%lld%lld",&n,&x);
	printf("%lld\n",3ll*(n-__gcd(n,x)));
	return 0;
}


Measured memory_bytes: 256
x = list(map(int, input().split()))
y = list(map(int, input().split()))
y = [i/2+0.5 for i in y]
max_value = 0
value = sum(y[:x[1]])
for i in range(x[1], x[0]):
  max_value = max(max_value, value)
  value += y[i]
  value -= y[i-x[1]]
max_value = max(max_value, value)
print(max_value)


Measured memory_bytes: 77448
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC097B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var Number = new List<int>();
            var max = 0;

            for (var i = 1; i <= N; i++)
                for(var j = 2; j <= 10; j++)
                {
                    Number.Add((int)(Math.Pow(i, j)));
                }

            for (var i = 0; i < Number.Count; i++)
            {
                if(Number[i] <= N && Number[i] > 0)
                {
                    max = Math.Max(Number[i], max);
                }
            }
            Console.WriteLine(max);
        }
    }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

string S;

string solve() {
    REP (i, S.size()) {
        if (S[i] == 'R' && i%2 == 1) return "No";
        if (S[i] == 'L' && i%2 == 0) return "No";
    }
    return "Yes";
}

int main() {
    cin >> S;
    cout << solve() << endl;
}

Measured memory_bytes: 256
/*
 * @Author       : nonameless
 * @Date         : 2020-09-19 20:05:42
 * @LastEditors  : nonameless
 * @LastEditTime : 2020-09-19 20:06:35
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define sz(x) (int)x.size()
#define toStr(name) (#name)
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
const double eps = 1e-6;
const double PI  = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll LNF  = 0x3f3f3f3f3f3f3f3f;
inline int gcd(int a, int b) { return b ? gcd(b,a % b):a;}
inline ll  gcd(ll  a, ll  b) { return b ? gcd(b,a % b):a;}
inline int lcm(int a, int b) { return a * b / gcd(a, b); }

template<class T>
inline void read(T &x){
    x = 0;
    int f = 1;
    char c = getchar();
    while(c < '0' || c > '9')   { if(c == '-') f = -1;  c = getchar(); }
    while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
    x = x * f;
}

template<class T>
inline void out(string a, T x){ cout << a << " = " << x << endl; }


int main(){

    int n; cin >> n;
    int cnt = 0, mark = 0;
    for(int i = 1; i <= n; i ++){
        int x, y; cin >> x >> y;
        if(x == y) cnt ++;
        else cnt = 0;
        if(cnt == 3) mark = 1;
    }
    if(mark == 1) puts("Yes");
    else puts("No");
    return 0;
}


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

int main(){
  int n; cin >>n;
  ll ans = 0;
  for(int i = 1; i<=n; ++i){
    for(int j = i; j<=n; j+=i) ans += j;
  }
  cout << ans << endl;
  return 0; 
}


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

int main() {
  int n;
  cin >> n;
  int m;
  m = n/7 ;
  bool y = true;
  
  for(int i = 0; i< m+1; i++){
    if((n - 7*i)% 4 == 0){
      cout << "Yes" << endl;
      y = false;
      break;
    }
  }
  
  if(y){
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
s = input()

ans = True
if len(set(s)) != 2:
    ans = False
else:
    a, b = list(set(s))
    if s.count(a) == s.count(b) == 2:
        pass
    else:
        ans = False

print("Yes" if ans else "No")


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

void print_seven(string& n);
bool eq_seven(string& n, char op, string eq, int val, int depth);

int main()
{
    string n;
    cin >> n;
    print_seven(n);
    return 0;
}

bool eq_seven(string& n, char op, string eq, int val, int depth)
{
    bool found = false;
    if (depth == 0)
    {
        val = n[0] - '0';
        eq += n[0];
    }
    depth++;
    if (op == '+')
    {
        val += n[depth] - '0';
        eq += "+";
        eq += n[depth];
    }
    if (op == '-')
    {
        val -= n[depth] - '0';
        eq += "-";
        eq += n[depth];
    }
    if (depth == 3)
    {
        if (val == 7)
        {
            cout << eq << "=7" << endl;
            found |= true;
        }
    }
    else
    {
        if (found) return true;
        found |= eq_seven(n, '+', eq, val, depth);
        if (found) return true;
        found |= eq_seven(n, '-', eq, val, depth);      
    }
    return found;
}

void print_seven(string& n)
{
    if(!eq_seven(n, '+', "", 0, 0)) 
        eq_seven(n, '-', "", 0, 0);
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
	int a, b;
	while (cin>>a>>b)
	{
		if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
		{
			cout << "Possible" << endl;
		}
		else
			cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	char S[100001]; int i = 0 , Slen = 0, count = 0;

	scanf("%s", S);

	while (S[i] != 0) {
		Slen++;
		i++;
	}
	for (i = 1; i < Slen; i++) {
		if (S[i] != S[i - 1])count++;
	}
	printf("%d", count);
	scanf("%d", &count);
}

Measured memory_bytes: 256
// 車両入れ替え

#include <iostream>
using namespace std;

int main() {
    int pos = -1;
    int input;
    int senro[100];

    while (cin >> input) {
        if (input != 0) {
            pos++;
            senro[pos] = input;
        } else if (input == 0) {
            if (pos >= 0) {
                cout << senro[pos] << "\n";
                pos--;
            } else {
                cout << "error???" << "\n";
                return 1;
            }
        }
    }
    return 0;
}


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

int main(){
    string s, t;
    cin >> s >> t;
    vector<string> ans;
    rep(i, s.size() - t.size() + 1){
        string u = s;
        bool ok = true;
        for (int j = i; j < i + t.size(); j++){
            if (u[j] != '?' && u[j] != t[j - i]){
                ok = false;
                break;
            }else if (u[j] == '?') {
                u[j] = t[j-i];
            }
        }
        if(ok){
            rep(k, u.size()){
                if (u[k] == '?') u[k] = 'a';
            }
            ans.push_back(u);
            
        }
        
    }
    if (ans.size()){
        sort(ALL(ans));
        cout << ans[0] << "\n";
    }else {
        cout << "UNRESTORABLE\n"; 

    }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    char a[101], b[101], c[101];
    int  i=0, n, cnt=0;

    scanf("%d", &n);
    scanf("%s", a);
    scanf("%s", b);
    scanf("%s", c);
    
    while(a[i] != '\0'){
        if(a[i] != b[i] && a[i] != c[i] && b[i] != c[i]){
            cnt=cnt+2;
        }
        else if(a[i] == b[i] && a[i] == c[i] && b[i] == c[i]){
            cnt=cnt;
        }
        else{
            cnt++;
        }
        i++;
    }

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


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;
void init();
#ifdef DEBUG_BUILD
#define DBG(expr) cout << #expr << " = " << expr << endl;
#else
#define DBG(expr)
#endif
#define UNREACHABLE() do { \
        cerr << "[Oops] UNREACHABLE: at line " << __LINE__ << endl; \
        __builtin_unreachable(); \
        exit(123); \
    } while (0)
#define ECHO(expr) cout << expr << endl;
#define REP(var, num) for(ll var = 0; var < num; var++)
#define REP_FROM(var, from, num) for(ll var = from; var < num; var++)
#define MAX_OF(type) numeric_limits<type>::max()
#define MIN_OF(type) numeric_limits<type>::min()
#define SORT(vec) sort(vec.begin(), vec.end())
#define REVERSE(vec) reverse(vec.begin(), vec.end())
#define T_FIRST(tuple) (std::get<0>(tuple))
#define T_SECOND(tuple) (std::get<1>(tuple))
#define T_THIRD(tuple) (std::get<2>(tuple))
typedef signed long long ll;
typedef unsigned long long ull;

void solve() {
    ll n;
    cin >> n;
    ll ans = 0;
    vector<ll> vs(n);
    REP(i, n) {
        cin >> vs[i];
    }
    vector<ll> cs(n);
    REP(i, n) {
        cin >> cs[i];
    }

    REP(i,n) {
        ans += max(0LL, vs[i] - cs[i]);
    }

    ECHO(ans)
}

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

#ifdef INPUT_FILE
    if (!freopen(INPUT_FILE, "r", stdin)) {
        perror("freopen");
        exit(1);
    }
#endif

    solve();
    return 0;
}

Measured memory_bytes: 256
while True:
    a,b,c = map(int, input().split())
    if a==b==c==-1:
        break
    if a==-1 or b==-1:
        print("F")
        continue
    if a+b>=80:
        print("A")
        continue
    if 65<= a+b <80:
        print("B")
        continue
    if 50<= a+b <65:
        print("C")
        continue
    if 30<= a+b <50:
        if c >= 50:
            print("C")
            continue
        else:
            print("D")
            continue
    print("F")



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

typedef pair<string,string>P;

int n,ans;
string s;
map<pair<string,string> ,int>M;


signed main(){
	cin>>n>>s;
	string t=s.substr(n);
	r(i,(1<<n)){
		int x=__builtin_popcount(i);
		string y="",z="";
		r(j,n){
			if((1<<j)&i)y+=t[j];
			else z+=t[j];
		}
		reverse(y.begin(),y.end());
		reverse(z.begin(),z.end());
		M[P(y,z)]++;
	}
	t=s.substr(0,n);
	r(i,(1<<n)){
		int x=__builtin_popcount(i);
		int z=n-x;
		string y="",Z="";
		r(j,n){
			if((1<<j)&i)y+=t[j];
			else Z+=t[j];
		}
		if(y>Z)swap(y,Z);
		ans+=M[P(y,Z)];
		ans+=M[P(Z,y)];

	}
	cout<<ans/2<<endl;
}

Measured memory_bytes: 72320
from time import time
start=time()
from copy import deepcopy
from random import randint

d=int(input())
c=list(map(int,input().split())) #scoreを減らす
s=[] #scoreを増やす
for i in range(d):
    t=list(map(int,input().split()))
    s.append(t)
last=[0]*26 #それぞれのコンテストが最後に行われたのは何日目か
ans_lst=[]

for i in range(1,d): #364日、1日目ならi=1
    temp_best=-100000000
    for j in range(26): #それぞれの日において、26個のコンテストを順番にピックアップ
        temp=s[i-1][j]
        for k in range(26): #ピックアップされていないコンテストは、スコアを減らす
            if j!=k:
                temp-=(c[k]*(i-last[k]))
        temp_last=deepcopy(last)
        temp_last[j]=i
        for k in range(26):
            temp+=s[i][k]
            for l in range(26):
                if k!=l:
                    temp-=(c[l]*(i+1-temp_last[l]))
        if temp>temp_best:
            temp_best=temp
            rem=j
    ans_lst.append(rem)
    last[rem]=i
    
temp_best=-100000000 #365日目は、次の日のことは考えなくてよい
for j in range(26): #26個のコンテストを順番にピックアップ
    temp=s[i-1][j]
    for k in range(26): #ピックアップされていないコンテストは、スコアを減らす
        if j!=k:
            temp-=(c[k]*(i-last[k]))
    if temp>temp_best:
        temp_best=temp
        rem=j
ans_lst.append(rem) #AtCoder運営お疲れ様です

score=0
las=[0]*26
for i in range(d):
    for j in range(26):
        las[j]+=1
    score+=s[i][ans_lst[i]]
    las[ans_lst[i]]=0
    for j in range(26):
        score-=c[j]*las[j]

for q in range(1,25):
    for p in range(d-q):
        las=[0]*26
        temp_score=0
        temp_ans_lst=deepcopy(ans_lst)
        temp_ans_lst[p],temp_ans_lst[p+q]=temp_ans_lst[p+q],temp_ans_lst[p]
        for i in range(d):
            for j in range(26):
                las[j]+=1
            temp_score+=s[i][temp_ans_lst[i]]
            las[temp_ans_lst[i]]=0
            for j in range(26):
                temp_score-=c[j]*las[j]
        if temp_score>score:
            score=temp_score
            ans_lst=temp_ans_lst

while time()-start<1.9:
    las=[0]*26
    temp_score=0
    temp_ans_lst=deepcopy(ans_lst)
    a=randint(0,d-2)
    b=randint(0,d-2)
    temp_ans_lst[a],temp_ans_lst[a+1]=temp_ans_lst[a+1],temp_ans_lst[a]
    temp_ans_lst[b],temp_ans_lst[b+1]=temp_ans_lst[b+1],temp_ans_lst[b]
    for i in range(d):
        for j in range(26):
            las[j]+=1
        temp_score+=s[i][temp_ans_lst[i]]
        las[temp_ans_lst[i]]=0
        for j in range(26):
            temp_score-=c[j]*las[j]
    if temp_score>score:
        score=temp_score
        ans_lst=temp_ans_lst

for i in ans_lst:
    print(i+1)

Measured memory_bytes: 90260
#n = int(input())
#a,b = map(int,input().split())
a_L = list(map(int,input().split()))
k = int(input())

a_L = sorted(a_L,reverse=True)
a_L[0] = a_L[0] * 2**k

#print(a_L)
print(sum(a_L))

Measured memory_bytes: 38256
#include <stdio.h>
#include<string.h>
#include<ctype.h>
int main(void){
    char w[11];
    char t[1001];
    int count=0,i;
    
    scanf("%s",w);   //1行目に探す単語の読み込みを行う
    
    while(1){
        scanf("%s",t);
        if(strcmp(t,"END_OF_TEXT") ==0) 
        break;    
        
        for(i=0;i<strlen(t);i++)
        t[i]=tolower(t[i]);     //小文字に変換
        
        if(strcmp(w,t)==0)
        count++;
        
    }
    printf("%d\n",count);
    return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

string zfill_cityname(const int pi, const int yi) {
    stringstream ss;
    ss << setw(6) << setfill('0') << pi;
    ss << setw(6) << setfill('0') << yi;
    return ss.str();
}


int main() {
    int N, M, pi, yi, prev_pi, yi_cnt;
    string name_i;
    cin >> N >> M;

    vector<tuple<int, int, int> > tuple_pyi(M);
    vector<pair<int, string> > ans(M);

    for (int i=0; i<M; i++) {
        cin >> pi >> yi;
        tuple_pyi[i] = make_tuple(pi, yi, i);
    }
    sort(tuple_pyi.begin(), tuple_pyi.end());

    for (int i=0; i<M; i++) {
        if ((i==0) || (prev_pi != get<0>(tuple_pyi[i])))  yi_cnt = 1;
        name_i = zfill_cityname(get<0>(tuple_pyi[i]), yi_cnt);
        ans[i] = make_pair(get<2>(tuple_pyi[i]), name_i);
        prev_pi = get<0>(tuple_pyi[i]);
        yi_cnt++;
    }

    sort(ans.begin(), ans.end());
    for (int i=0; i<M; i++) {
        cout << ans[i].second << endl;
    }

    return 0;

}


Measured memory_bytes: 8960
#include<stdio.h>
#include<string.h>
int main(){
  int unused __attribute__((unused));
  int K, i;
  char S[101];

  unused = scanf("%d", &K);
  unused = scanf("%s", S);

  if(strlen(S) <= K) printf("%s", S);
  else{
    for(i=0; i<K; i++) printf("%c", S[i]);
    printf("...");
  }
  return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define X first
#define Y second
using namespace std;

void era(bool *table){
	for(int i = 2; i <= 50000; i++){
		if(table[i]){
			for(int j = i*2; j <= 50000; j+=i){
				table[j] = false;
			}
		}
	}
}

int main(){
	bool table[50001];
	memset(table, true, sizeof(table));
	table[0] = false;
	table[1] = false;
	era(table);
	int n;
	while(cin >> n && n != 0){
		int count = 0;
		for(int i = 2; i <= n; i++){
			if(!table[i]) continue;
			if(table[n-i]) count++;
			if(i==n-i) count++;
		}
		cout << count/2 << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <algorithm>
using namespace std;
long long qSum[200003],n, num;
int main()
{
    cin>>n;
    for (int i = 1; i <= n; ++i)
    {
        cin>>num;
        qSum[i] = num+qSum[i-1];
    }
    sort(qSum, qSum+(n+1));
    long long sum = 0;
    long long k = 1;
    for (int i = 1; i <= n; i++)
    {
        if(qSum[i] != qSum[i-1]){
            sum = sum + k*(k-1)/2;
            k = 1;
        } else {
            k++;
        }
    }
    cout<<sum+k*(k-1)/2;
    return 0;
}

Measured memory_bytes: 1792
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
                String[] tokens = line.split(" ");
                int a = Integer.parseInt(tokens[0]);
                int b = Integer.parseInt(tokens[1]);
                int c = Integer.parseInt(tokens[2]);
                if(a==b){
                    System.out.println(c);
                }else if(b==c){
                    System.out.println(a);
                }else if(a==c){
                    System.out.println(b);
                }
            }
        }
    }
}


Measured memory_bytes: 20692
#include <iostream>
using namespace std;
int main()
{
    int h, w;
    string s[50];
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        cin >> s[i];
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#'){
                if(i + 1 <  h){
                    if(s[i+1][j] == '#') continue;
                }
                if(0 <= i - 1){
                    if(s[i-1][j] == '#') continue;
                }
                if(j + 1 <  w){
                    if(s[i][j+1] == '#') continue;
                }
                if(0 <= j - 1){
                    if(s[i][j-1] == '#') continue;
                }
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(){
  string N;
  cin >> N;
  
  string ans;
  if(N[0]==N[1] and N[1]==N[2]) ans="Yes";
  else if(N[1]==N[2] and N[2]==N[3]) ans="Yes";
  else ans = "No";
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int n;
int arr[100005][4];
int dp[100005][4];
int fun(int day, int flag)
{
    if (day == n)
        return 0;
    if (dp[day][flag] != -1)
        return dp[day][flag];
    int maxi = 0;
    if (flag == 0)
    {
        maxi = max(maxi, arr[day][1] + fun(day + 1, 1));
        maxi = max(maxi, arr[day][2] + fun(day + 1, 2));
        maxi = max(maxi, arr[day][3] + fun(day + 1, 3));
    }
    else if (flag == 1)
    {
        maxi = max(maxi, arr[day][2] + fun(day + 1, 2));
        maxi = max(maxi, arr[day][3] + fun(day + 1, 3));
    }
    else if (flag == 2)
    {
        maxi = max(maxi, arr[day][1] + fun(day + 1, 1));
        maxi = max(maxi, arr[day][3] + fun(day + 1, 3));
    }
    else
    {
        maxi = max(maxi, arr[day][1] + fun(day + 1, 1));
        maxi = max(maxi, arr[day][2] + fun(day + 1, 2));
    }
    return dp[day][flag] = maxi;
}
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        for (int j = 1; j < 4; j++)
        {
            cin >> arr[i][j];
        }
    }
    memset(dp, -1, sizeof(dp));
    cout << fun(0, 0);
}

Measured memory_bytes: 9600
(defconstant +color-unknown+ -1)
(defconstant +color-white+ 0)
(defconstant +color-black+ 1)

(defun solve ()
  (let*  ((n (next-int))                 ; 頂点の数
          ;; 根を除いて各頂点にはたった1つの親頂点があるので、辺の数は
          ;; 「頂点の数-1」になる。
          (from (make-array (1- n)))     ; 番号が小さいほうの頂点
          (to (make-array (1- n)))       ; 番号が大きいほうの頂点
          (w (make-array (1- n))))       ; 辺の長さ
    (loop for i below (1- n)
         do
         ;; 0ベース配列の添字にしたいので、各頂点番号をデクリメントしておく。
         (setf (aref from i) (1- (next-int)))
         (setf (aref to i) (1- (next-int)))
         (setf (aref w i) (next-int)))

    (let ((g (pack-wu n from to w))
          (color (make-array n :initial-element +color-unknown+))
          (stack nil)) ; 頂点の色。


      (push (list 0 +color-white+) stack)
      (loop while stack
         do
         (destructuring-bind (now mod) (pop stack)
           (if (= (aref color now) +color-unknown+)
               (progn
                 (setf (aref color now) mod)
                 (loop for edge across (aref g now)
                    do
                      (destructuring-bind
                            (next-vertex length) edge
                        (when (= (aref color next-vertex) +color-unknown+)
                          (push (list next-vertex (mod (+ mod length) 2)) stack))))))))

      (loop for i below n
           do
           (format t "~A~%" (aref color i))))))

(defun next-int ()
  (read))

;; 各頂点についてその接続情報を収めた表 g を生成して返す。
;; g[頂点番号][各辺] = (list 辺の長さ 接続先の頂点)
(defun pack-wu (n from to w)
  (let ((sup (length from)) ; 辺の数
        (g (make-array n))
        (p (make-array n :initial-element 0))) ; 各頂点の次数(接続している辺の数)

    ;; 各頂点の次数を数える。各辺は、2つの頂点の次数をそれぞれ1つずつ
    ;; 増やす。
    (loop for i below sup
       do
         (incf (aref p (aref from i)))
         (incf (aref p (aref to i))))

    (loop for i below n
       do
       ;; g[i] に頂点 i 接続している辺の情報を収める配列を割り当てる。
         (setf (aref g i) (make-array (aref p i))))

    ;; 各頂点の持つ辺の情報を配列の後ろから格納する。
    (loop for i below sup
       do
         (let ((v (aref from i))
               (u (aref to i))
               (len (aref w i)))

           (decf (aref p v))
           (setf (aref (aref g v) (aref p v)) (list u len))

           (decf (aref p u))
           (setf (aref (aref g u) (aref p u)) (list v len))))

    g))

(solve)


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

Measured memory_bytes: 1024
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

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

def dfs(pos):
    global n,m,x,a,ca,ans
    if pos==n:
        res = 0
        comp = [0] * m
        for i in range(n):
            if a[i]:
                res += ca[i][0]
                for j in range(1,m+1):
                    comp[j-1] += ca[i][j]
        for i in range(m):
            if comp[i]<x:
                return
        ans = min(ans,res)
        return
    a[pos] = 0
    dfs(pos+1)
    a[pos] = 1
    dfs(pos+1)

def main():
    global n,m,x,a,ca,ans
    n,m,x = readInt()
    ca = []
    for i in range(n):
        ca.append(readInt())
    ans = INF
    a = [0] * n
    dfs(0)
    if ans==INF:
        print(-1)
    else:
        print(ans)
    return

if __name__=='__main__':
    main()


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

using namespace std;

vector <pair<int,int>> adj[100001][3];
int dist[100001][3];

void dijkstra(int start)
{
	priority_queue <pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> pque;
	for(int i=0;i<=100000;i++)
	{
		fill(dist[i],dist[i]+3,1e9);
	}
	dist[start][0] = 0;
	pque.push(make_pair(dist[start][0],make_pair(start,0)));

	while(!pque.empty())
	{
		int now = pque.top().second.first;
		int step = pque.top().second.second;
		pque.pop();

		for(auto it : adj[now][step])
		{
			int next = it.first;
			int nextstep = it.second;
			if(dist[next][nextstep] > dist[now][step] + 1)
			{
				dist[next][nextstep] = dist[now][step] + 1;
				pque.push(make_pair(dist[next][nextstep],make_pair(next,nextstep)));
			}
		}
	}
}
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n,m,a,b,s,t;

	cin >> n >> m;

	for(int i=0;i<m;i++)
	{
		cin >> a >> b;
		adj[a][0].push_back(make_pair(b,1));
		adj[a][1].push_back(make_pair(b,2));
		adj[a][2].push_back(make_pair(b,0));
	}

	cin >> s >> t;

	dijkstra(s);

	if(dist[t][0]==1e9)
	{
		cout << -1 << '\n';
	}
	else
	{
		cout << dist[t][0]/3 << '\n';
	}

	return 0;
}


Measured memory_bytes: 17792
import java.util.Scanner;

public class Main {

	private static Scanner sc;

	public static void main(String[] args) {

		sc = new Scanner(System.in);

		int b = sc.nextInt() % 500;

		if (b <= sc.nextInt()) {
			 System.out.print("Yes");
		} else {
			 System.out.print("No");
		}
	}

}


Measured memory_bytes: 25300
'use strict'
const Main = (arg) => {
  let input = arg.trim().split('\n');
  let N = input[0].split(' ').map(Number)[0];
  let X = input[0].split(' ').map(Number)[1];
  let Arr = input[1].split(' ').map(Number);
  // console.log({ N, X, Arr });

  let D = [0];
  for (let i = 1; i <= N; i++) {
    D[i] = D[i - 1] + Arr[i - 1];
  }
  // console.log({ D });
  let Ans = 0;
  for (let i = 1; i <= N + 1; i++) {
    if (D[i - 1] <= X) {
      Ans += 1;
    }
  }

  console.log(Ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

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

    int n;
    cin >> n;
    vector<int> V(n, 0);
    for (int i = 1; i < n; ++i) {
        int A;
        cin >> A;
        --A;
        ++V.at(A);
    }
    for (int i = 0; i < n; ++i) {
        cout << V.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int n, m, l[100005], r[100005], i, j, a, b;
    cin>>n>>m;
    for(i=0; i<m; i++)
    {
        cin>>l[i]>>r[i];
    }
    sort(l, l+m);
    sort(r, r+m);
    b=r[0]-l[m-1];
    if(b<0)
    {
        a=0;
    }
    else
    {
        a=b+1;
    }
    cout<<a;
    return 0;
}

Measured memory_bytes: 5080
using System;
using System.Collections.Generic;
using System.Linq;

class AtCoderCS {
    static void Main(string[] args) {
        int K = int.Parse(Console.ReadLine());
        int[] AB = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        int A = AB[0], B = AB[1];

        bool ans = false;
        for (int i = A; i <= B; i++)
            if (i % K == 0)
                ans = true;

        Console.WriteLine(ans ? "OK" : "NG");      
    }
}

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


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

int main()
{
	int n,m;
	cin>>n>>m;
	if(n>=13)
	{
		cout<<m;
	}
	if(n>=6 && n<=12)
	{
		cout<<m/2;
	}
	if(n<=5)
	{
		cout<<"0";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define inRange(x,a,b) (a <= x && x < b)
int di[8] = {0,0,1,-1,1,1,-1,-1};
int dj[8] = {1,-1,0,0,1,-1,1,-1};

int main(){
    int h, w;
    cin >> h >> w;
    char mat[h][w];
    int wcnt = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> mat[i][j];
            wcnt += (mat[i][j]=='.');
        }
    }
    vector<vector<int>> d(h, vector<int>(w, 1<<30));
    priority_queue<pair<int,pair<int,int>>> pq;
    pq.push({-1,{0,0}});
    while(!pq.empty()){
        auto p = pq.top();  pq.pop();
        int cost = -p.first, i = p.second.first, j = p.second.second;
        if(d[i][j] <= cost) continue;
        d[i][j] = cost;
        for(int k = 0; k< 4; k++){
            int ni = i+di[k], nj = j+dj[k];
            if(inRange(ni,0,h)&&inRange(nj,0,w)&&mat[ni][nj]=='.'&&d[ni][nj] > cost+1){
                pq.push({-(cost+1), {ni,nj}});
            }
        }
    }
    cout << (d[h-1][w-1]==1<<30 ? -1 : wcnt-d[h-1][w-1]) << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

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

	t1 := string([]rune(s)[:n/2])
	t2 := string([]rune(s)[n/2:n])

	if t1 == t2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512