akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  while(cin>>n,n){
    vector<Int> rs(n),ws(n);
    for(Int i=0;i<n;i++) cin>>rs[i]>>ws[i];
    Int sum=0;
    for(Int r:rs) sum+=r;
    Int k=max_element(rs.begin(),rs.end())-rs.begin();
    if(rs[k]*2<=sum){
      for(Int w:ws) sum+=w;
      cout<<sum<<endl;
      continue;
    }

    using BS = bitset<1010>;
    BS dp(1);

    for(Int i=0;i<n;i++)
      if(i!=k) dp|=dp<<ws[i];

    Int dif=rs[k]*2-sum;
    for(Int i=dif;i>=0;i--){
      if(dp[i]){
        sum+=dif-i;
        break;
      }
    }
    for(Int w:ws) sum+=w;
    cout<<sum<<endl;
  }
  return 0;
}



Measured memory_bytes: 3104
N,X = map(int,input().split())
A = list(map(int,input().split()))

from collections import Counter

for i in range(N):
    A[i] -= X

A0 = A[0]
ans = []
ans2 = []
for i in range(1,int(abs(A0)**.5)+1):
    if A0%i==0 and i not in ans:
        ans.append(i)

ans2 = ans.copy()
for a in ans:
    if abs(A0//a) not in ans:
        ans2.append(abs(A0//a))

Ans = 1
for a in ans2:
    for i in range(N):
        if A[i]%a==0:
            continue
        else:
            break
    else:
        Ans = max(Ans,a)

print(Ans)

Measured memory_bytes: 14380
import math

towns = int(input()) # 町の数
total_between_town = 0 # 各町間距離の合計
x_axis = [] # x軸の座標
y_axis = [] # y軸の座標

# 座標の読み込み
for i in range(towns):
  str = input()
  x_axis.append(int((str.split())[0]))
  y_axis.append(int((str.split())[1]))

# 各座標間の距離を算出し、各町間距離の合計を算出する
for i in range(towns):
  for j in range(i + 1, towns):
    len = math.sqrt((x_axis[i]- x_axis[j]) ** 2 + (y_axis[i]- y_axis[j]) ** 2)
    total_between_town = total_between_town + len

# 全経路の距離合計 = (各町間距離の合計) * {((地点数) - 1) * (経路の数) / (2町の組み合わせ)}
route = math.factorial(towns) # 経路数
pairs = int(towns * (towns - 1) // 2) # 2つの町の組み合わせ総数
total_length = total_between_town * (towns - 1) * route / pairs # 全経路の距離合計
average_length = total_length / route # 各経路の距離平均

# 結果出力
print(average_length)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;

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

    int ans = 0 ;

    if (n < 10) ans = n;
    if (n >= 10 && n < 100 ) ans = 9;
    if (n >= 100 && n < 1000 ) ans = 9 + n - 99;
    if (n >= 1000 && n < 10000 ) ans = 909;
    if (n >= 10000 && n < 100000 ) ans = 909 + n - 9999;
    if (n == 100000 ) ans = 90909;

    cout << ans << endl;
    


    return 0;
}

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

int main() {
	int n,k,v[60],i,j,x,sl[60]={0},sr[60]={0},ans=0;
	cin >> n >> k;
	for(i=1;i<=n;i++) cin >> v[i];
	for(i=1;i<=n;i++) {
		sl[i]=sl[i-1]+v[i];
		sr[i]=sr[i-1]+v[n+1-i];
	}
	for(i=1;i<=min(n,k);i++){
		for(j=0;j<=i;j++){
			int keep;
			vector<int> vv;
			keep=sl[j]+sr[i-j];
			for(x=1;x<=j;x++) vv.push_back(v[x]);
			for(x=1;x<=(i-j);x++) vv.push_back(v[n+1-x]);
			sort(vv.begin(),vv.end());
			for(x=0;x<k-i;x++){
				if(vv[x]>=0) break;
				keep=keep-vv[x];
			}
			ans=max(ans,keep);
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

using ll = long long;


int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(3 * n);
    for (int& x : a) {
        cin >> x;
    }
    sort(a.rbegin(), a.rend());
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += a[2 * i + 1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
n = int(input())
a = list(map(lambda x: int(x) - 1, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

res = 0
prev = -1
for i in range(n):
    curr = a[i]
    res += b[curr]
    if prev > - 1 and prev == curr - 1:
        res += c[prev]
    prev = curr

print(int(res))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)

void chmax(ll& a, ll b) { a = max(a, b); }
void chmin(ll& a, ll b) { a = min(a, b); }


int modnum = 2019;

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

    // 右側から見ていきたいのでreverseしておく
    reverse(s.begin(), s.end());

    // xが10の冪乗管理
    // totは0桁目から足して行って2019で割ったあまり
    int x = 1, tot = 0;
    vector<int> cnt(modnum);
    ll ans = 0;
    rep(i, n) {
        cnt[tot]++;
        tot += (s[i]-'0')*x;
        tot %= modnum;
        ans += cnt[tot];
        x = x*10%modnum;
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
struct val
{
    int a,b,c;
};
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
val arr[n];
for(int i=0;i<n;i++)
{
    cin>>arr[i].a>>arr[i].b>>arr[i].c;
}
int dp[n][3]={};
dp[0][0]=arr[0].a;
dp[0][1]=arr[0].b;
dp[0][2]=arr[0].c;
for(int i=1;i<n;i++)
{
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i].a;
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr[i].b;
    dp[i][2]=max(dp[i-1][1],dp[i-1][0])+arr[i].c;
}
int ans=max(dp[n-1][0],dp[n-1][1]);
ans=max(ans,dp[n-1][2]);
cout<<ans<<endl;
















    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
    int n,a,b;
    cin >> n;
    vector<pair<int,int>> v(n);
  for(int i=0;i<n;i++){
    cin >> a >> b;
    pair<int,int> p=make_pair(a+b,a-b);
    v[i]=p;
  }
  sort(v.begin(),v.end());
  int ans=1;
  int now=0;
  now=v[0].first;
  for (int i=1;i < n;i++){
    if (v[i].second < now) continue;
    else {
        ans++;
        now = v[i].first;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

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

use std::cmp::{min, max};

fn main() {
    let a = read::<i64>();
    let b = read::<i64>();
    let c = read::<i64>();
    let mut x = read::<i64>();
    let mut y = read::<i64>();

    let m = min(x, y);
    let a1 = 2*c*max(x, y);
    let a2 = 2*c*m + (x-m)*a + (y-m)*b;
    let a3 = x*a + y*b;



    println!("{}", min(a1, min(a2, a3)));
}

Measured memory_bytes: 4352
"use strict";

var main = function main(input) {
  var N = parseInt(input.split("\n")[0], 10);
  var d = input.split("\n").slice(1, input.split("\n").length - 1).filter(function (elem, idx, self) {
    return self.indexOf(elem) === idx;
  });
  console.log(d.length);
};

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    int answer = 0;
    for (int i = 1; i <= n; i++) {
      int num = i;
      int sum = 0;
      while(num > 0) {
        sum += num % 10;
        num /= 10;
      }
      if (a <= sum && sum <= b) {
        answer += i;
      }
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 35620
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Array.Sort(a);
        var k = int.Parse(Console.ReadLine().Trim());
        a[2] <<= k;
        Console.WriteLine(a[0] + a[1]  + a[2]);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N, Gudge;
  cin >> N;
   Gudge = "No";
  
  for(int i = 0;i < 2; i++){
    if(N.at(i) == N.at(i + 1)){
      if(N.at(i + 1) == N.at(i + 2)){
      Gudge = "Yes";
      }
    }
  }
  cout << Gudge << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
s=[0]*60
m=10**9+7
for i in a:
    t=bin(i)[2:][::-1]
    for i in range(len(t)):
        if t[i]=="1":
            s[i]+=1
c=0
for i in range(60):
    c=(c+s[i]*(n-s[i])*pow(2,i,m))%m
print(c)


Measured memory_bytes: 122808
#include <bits/stdc++.h>
using namespace std;
int a[105],MAX,X,i,ansx[1005],ansy[1005],cnt,n;
int main()
{
	scanf("%d",&n);
	for (i=1; i<=n; i++) scanf("%d",&a[i]);
	MAX=-1; 
	for (i=1; i<=n; i++)
	  if (abs(a[i])>MAX) {MAX=abs(a[i]); X=i;}
	if (a[X]>=0)
	{
		if (X!=2) {ansx[++cnt]=X; ansy[cnt]=2; ansx[++cnt]=X; ansy[cnt]=2;}
		for (i=3; i<=n; i++)
		{
			ansx[++cnt]=i-1; ansy[cnt]=i;
			ansx[++cnt]=i-1; ansy[cnt]=i;
		}
	} else 
	{
		if (X!=n-1) {ansx[++cnt]=X; ansy[cnt]=n-1; ansx[++cnt]=X; ansy[cnt]=n-1;}
		for (i=n-2; i>=1; i--)
		{
			ansx[++cnt]=i+1; ansy[cnt]=i;
			ansx[++cnt]=i+1; ansy[cnt]=i;
		}
	}
	cout<<cnt<<endl;
	for (i=1; i<=cnt; i++) printf("%d %d\n",ansx[i],ansy[i]);
	return 0; 
}

Measured memory_bytes: 256
// https://github.com/PabloMessina/Competitive-Programming-Material/blob/master/Codejam_template.cpp
#pragma GCC optimize("Ofast") // OPTIONAL: for faster execution
#include <bits/stdc++.h>      // import everything in one shot
using namespace std;
// defines
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define invrep(i, a, b) for (int i = b - 1; i >= a; --i)
#define umap unordered_map
#define uset unordered_set
// typedefs
typedef unsigned int uint;
typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
// -------------------------------

int const max_ = 1000000, min_ = -1000000;

int main()
{
    // OPTIONAL: for faster input/output (only if using cin/cout)
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int X, K;
    cin >> K >> X;
    // cout << max(min_, X - K) << endl;
    // cout << min(max_, X + K) << endl;
    rep(i, max(min_, X - K) + 1, min(max_, X + K))
    {
        cout << i << " ";
    }
    return 0;
}

Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,k,a,num[50],ans=0;

int main()
{
	cin>>n>>m;
	rep(i,n)
	{
		cin>>k;
		rep(j,k)
		{
			cin>>a;
			num[a]++;
		}
	}
	repn(i,m) if(num[i]==n) ans++;
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int l,n,m,i,ans,a=100;
	while(scanf("%d",&l)!=EOF){
		if(l==0)break;
		ans=0;a=100;
		for(i=1;i<=12;i++){
			scanf("%d%d",&n,&m);
			ans+=n-m;
			if(ans>=l && a>i)a=i;
		}
		if(a==100)printf("NA\n");
		else printf("%d\n",a);
	}
	return 0;
}

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

int main() {
	string S;
	cin >> S;
	int sum = 0;

	for (int i = 0; i < 4; i++) {
		if (S.at(i) == '+')
			sum++;
		else
			sum--;
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    V = list(map(int, input().split()))
    C = list(map(int, input().split()))

    ans = 0
    for v, c in zip(V, C):
        ans += max(0, v-c)
    print(ans)
    return 0


if __name__ == '__main__':
    main()

Measured memory_bytes: 38640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

static const double PI = acos(-1.0);

class Vec2
{
public:
    Vec2( double _x, double _y ) : x(_x), y(_y) {}

    double length() const { return sqrt(x*x + y*y); }
    double arg() const {
        if ( length() == 0 ) return 0.0;
        return atan2(y, x);
    }
    Vec2 normalize() const {
        if ( length() == 0 ) return *this;
        return Vec2(x/length(), y/length());
    }

    Vec2 operator+( const Vec2& rhs ) const { return Vec2(x+rhs.x, y+rhs.y); }
    Vec2 operator-( const Vec2& rhs ) const { return Vec2(x-rhs.x, y-rhs.y); }
    Vec2 operator*( double s ) const { return Vec2(x*s, y*s); }
    double dot( const Vec2& rhs ) const { return x*rhs.x + y*rhs.y; }
    double cross( const Vec2& rhs ) const { return x*rhs.y - y*rhs.x; }

private:
    double x;
    double y;
};

double DiffAngle( const Vec2& A, const Vec2& B )
{
    double d = fabs(A.arg()-B.arg());
    if ( d > PI ) d = 2*PI-d;
    return d;
}

vector<Vec2> IntSegCircle( const Vec2& A, const Vec2& B, double r )
{
    vector<Vec2> IntPoint;
    Vec2 D = B - A;
    Vec2 DU = D.normalize();
    Vec2 H = A - DU*(A.dot(DU));
    double h = H.length();
    if ( h >= r )
        return vector<Vec2>();

    double l = sqrt(r*r - h*h);
    double pa = (A-H).dot(DU), pb = (B-H).dot(DU);
    if ( pa < -l && -l < pb ) {
        IntPoint.push_back(H - DU*l);
    }
    if ( pa < l && l < pb ) {
        IntPoint.push_back(H + DU*l);
    }
    return IntPoint;
}

double IntTriCircle( const Vec2& A, const Vec2& B, double r )
{
    vector<Vec2> Int = IntSegCircle( A, B, r );
    if ( Int.empty() ) {
        return min( 0.5*r*r*DiffAngle(A,B), 0.5*A.length()*B.length()*sin(DiffAngle(A,B)) );
    } else if ( Int.size() == 1 ) {
        double area = 0.0;
        if ( A.length() > r ) {
            area += 0.5*r*r*DiffAngle(A,Int[0]);
        } else {
            area += 0.5*A.length()*r*sin(DiffAngle(A,Int[0]));
        }
        if ( B.length() > r ) {
            area += 0.5*r*r*DiffAngle(B,Int[0]);
        } else {
            area += 0.5*B.length()*r*sin(DiffAngle(B,Int[0]));
        }
        return area;
    } else {
        return 0.5*r*r*(sin(DiffAngle(Int[0],Int[1])) + DiffAngle(A,B) - DiffAngle(Int[0],Int[1]));
    }
}

double solve( int R, const vector<Vec2>& Poly )
{
    double sum = 0.0;
    for ( int r = 1; r <= R; r++ ) {
        double area = 0.0;
        for ( size_t i = 0; i < Poly.size()-1; i++ ) {
            double coef = Poly[i].cross(Poly[i+1]) > 0 ? 1.0 : -1.0;
            area += coef * fabs(IntTriCircle(Poly[i], Poly[i+1], r));
            area -= coef * fabs(IntTriCircle(Poly[i], Poly[i+1], r-1));
        }
        if ( r%2==0 ) {
            area = (2*r-1)*PI - area;
        }
        sum += area;
    }
    return sum;
}

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

    vector<Vec2> Poly;
    for ( int i = 0; i < N; i++ ) {
        double x, y;
        cin >> x >> y;
        Poly.push_back( Vec2(x,y) );
    }
    Poly.push_back( Poly.front() );

    printf( "%.10f\n", solve( R, Poly ) );
    return 0;
}


Measured memory_bytes: 1372
n,m=map(int,input().split())
xyz=[list(map(int,input().split())) for i in range(n)]

ans=0
for i in [-1,1]:
  for j in [-1,1]:
    for k in [-1,1]:
      l=[]
      for x,y,z in xyz:
        l.append(i*x+j*y+k*z)
      l.sort(reverse=True)
      ans=max(ans,sum(l[:m]))
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
using namespace std;

int		main(void)
{
	vector<int> s(3);

	cin >> s[0];
	cin >> s[1];
	cin >> s[2];
	sort(all(s));
	cout << s[0] * s[1] / 2 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  char s[101] = {0};
  char cmp[101] = {0};
  int num[101] = {0};

  scanf("%s", s);

  //  printf("strlen = %lu\n", strlen(s));
  for(int cnt = 0; cnt < strlen(s); cnt++){
    if(cnt == 0){
      cmp[0] = s[0];
    }
    //    printf("■ cnt = %d\n", cnt);
    for(int n = 0; n < strlen(cmp); n++){
      //      printf("cmp[%d] = %c, s[%d] = %c\n", n, cmp[n], cnt, s[cnt]);
      if(cmp[n] == s[cnt]){
	num[n]++;
	//	printf("match\n");
	break;
      }
      else if(n == strlen(cmp) - 1){
	cmp[n + 1] = s[cnt];
	//	printf("cmp[n] = %c  %lu no same\n", cmp[n], strlen(cmp));
	num[n+1]++;
	break;
      }
    }
  }

  for(int cnt = 0; cnt < strlen(cmp); cnt++){
    //    printf("cmp[%d] = %c, num[%d] = %d\n", cnt, cmp[cnt], cnt, num[cnt]);
    if(num[cnt] % 2 == 0){
      if(cnt == strlen(cmp)-1){
	printf("Yes");
      }
    }else{
      printf("No");
      break;
    }
  }
  
  printf("\n");
  
}


Measured memory_bytes: 128
D, N = map(int, input().split())

num = [n for n in range(1, 102) if n % 100 != 0]

if D == 0:
  print(num[N-1]) 
if D == 1:
  print(num[N-1]*100)
if D == 2:
  print(num[N-1]*10000)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	private static int solve(long n) {

		int ret = 0;

		String s = String.valueOf(n);
		int l = s.length();

		boolean f = false;
		for (int i = 0; i < l; i++) {

			int m = s.charAt(i) - '0';

			if (1 == l) {
				ret += m;

			} else if (f) {
				ret += 9;

			} else {

				if (i + 1 < l && '9' == s.charAt(i + 1)) {
					ret += m;

				} else if (i + 1 < l && '9' != s.charAt(i + 1)) {
					ret += m - 1;
					f = true;

				} else {
					ret += m;
				}

			}

		}

		return ret;

	}

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {

			long n = sc.nextLong();

			int result = solve(n);

			System.out.println(result);

		}

	}

}


Measured memory_bytes: 23380
import Control.Monad

main=do
  n <- getLine
  let x = read n :: Int

  when (x==1)$do
    putStrLn "Hello World"
  when (x==2)$do
    m <- getLine
    l <- getLine
    let y=read m :: Int
    let z=read l :: Int
    print (y+z)


Measured memory_bytes: 508
import sys
input = sys.stdin.readline

def floyd_warshall(dist):
    v = len(dist)
    for k in range(v):
        for i in range(v):
            for j in range(v):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
floyd_warshall(c)
A = [list(map(int, input().split())) for _ in range(H)]
ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] != -1:
            ans += c[A[i][j]][1]
print(ans)

Measured memory_bytes: 40284
inp = map(str, raw_input().split())
s = []
for i in inp:
    if   i == "+": s.append( s.pop(-2) + s.pop(-1) )
    elif i == "-": s.append( s.pop(-2) - s.pop(-1) )
    elif i == "*": s.append( s.pop(-2) * s.pop(-1) )
    else: s.append(int(i))
print s[0]

Measured memory_bytes: 4220
// std = c++14
#include <iostream>
using namespace std;

// 計数ソート
void keisu_sort(int n, int* A, int max, int* B) {
    int C[max + 1]; // カウンタ数列
    for (int i = 0; i <= max; i++)
        C[i] = 0;

    // `C[i]`に`i`の出現数を記録
    for (int j = 0; j <= n - 1; j++)
        C[A[j]]++;

    // `C[i]`に`i`以下の数の出現数を記録
    for (int i = 1; i <= max; i++)
        C[i] += C[i - 1];

    // test
    /*
    cout << "C: ";
    for (int i = 0; i <= max; i++) {
        cout << C[i] << ' ';
    } cout << endl;
    */

    // ここまでOK -----

    for (int j = n - 1; j >= 0; j--) {
        B[C[A[j]] - 1] = A[j];
        C[A[j]]--;
    }
}

int main() {
    // 入力
    int n; cin >> n;
    int A[n];
    for (int i=0; i<n; i++)
        cin >> A[i];

    // 最大値を求めておく
    int max = 0;
    for (int i=0; i<n; i++)
        if (max < A[i])
            max = A[i];
    //cout << "max: " << max << endl;

    // 計数ソート
    int B[n]; for (int i = 0; i < n; i++) B[i] = 0;
    keisu_sort(n, A, max, B);

    // 出力
    for (int i=0; i<n; i++) {
        cout << B[i];
        if (i == n - 1)
            cout << endl;
        else
            cout << ' ';
    }
}


Measured memory_bytes: 18748
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
#include<regex>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl; }
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;



int main(void) {
	LL N, K;
	cin >> N >> K;

	vector<LL> A(N);
	rep(i, N) cin >> A[i];

	LL ans = 0;
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			if (A[i] > A[j]) {
				ans++;
			}
		}
	}

	//各セクションごとの転倒数を数える
	ans *= K;
	ans %= MOD;

	//ソートすることで添え字は自分より小さい数字が各セクションに幾つあるかを示す
	sort(ALL(A));

	LL p = 0;
	for (LL i = 1; i < N; i++) {

		//直前の数字と異なっていればピポットを動かす
		if (A[i] != A[i-1]) {
			p = i;
		}

		LL tmp = K * (K - 1) / 2;
		tmp %= MOD;
		ans += (p * tmp) % MOD;
		ans %= MOD;
	}

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

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

def main():
    # 整数の入力
    n = int(input())
    # スペース区切りの整数の入力
    plans = []
    for i in range(n):
        a, b, c = map(int, input().split())
        plans.append((a, b, c))

    # 各点がそもそも妥当な場所かどうか
    for x in plans:
        if (x[0] + x[1] + x[2]) % 2 == 1:
            print("No")
            return

    # その時刻に各点に移動可能かどうか
    pre_p = (0, 0, 0)
    for p in plans:
        time_diff = p[0] - pre_p[0]
        x_diff = abs(p[1] - pre_p[1])
        y_diff = abs(p[2] - pre_p[2])
        if time_diff < x_diff + y_diff:
            print("No")
            return
        pre_p = p

    print("Yes")


main()


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int A, B;
    cin >> A >> B;
    cout << max({A + B, A - B, A*B}) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;

int main() {
  string S;
  cin >> S;
  int m = stoi(S.substr(5, 2));
  if (m <= 4) {
	  cout << "Heisei" << endl;
	}
  else {
	  cout << "TBD" << endl;
	}
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        while(true) {
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();

            if(m==-1 && f==-1 && r==-1){
                break;
            }

            if(m==-1 || f==-1){
                System.out.println("F");
            }else if(m+f>=80){
                System.out.println("A");
            }else if(65<=m+f && m+f<80){
                System.out.println("B");
            }else if(50<=m+f && m+f<65){
                System.out.println("C");
            }else if(30<=m+f && m+f<50){
                if(50<=r){
                    System.out.println("C");
                }else{
                    System.out.println("D");
                }
            }else{
                System.out.println("F");
            }
        }
    }
}



Measured memory_bytes: 26440
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int N,M,X,Y;
    cin>>N>>M>>X>>Y;
    vector<int> xz;
    vector<int> yz;
    xz.push_back(X);
    yz.push_back(Y);
    REP(i,N){
        int a;cin>>a;
        xz.push_back(a);
    }
    REP(i,M){
        int a;cin>>a;
        yz.push_back(a);
    }
    int maxx=*max_element(xz.begin(),xz.end());
    int miny=*min_element(yz.begin(),yz.end());
    cout<<(maxx<miny?"No War":"War")<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a;
    int b;
    int c;

    scanf("%d %d %d",&a,&b,&c);

    if(a < b && b < c){
        printf("Yes\n");
    }

    else{
        printf("No\n");
    }

    return 0;
}





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

int D;
vector<int> c(26);
vector<vector<int>> s(365, vector<int>(26));
vector<int> last(26,0);

long long dec(int d){
	long long res = 0;
	for (int i=0; i<26; i++) res += c[i]*(d-last[i]);
	return res;
}
	

int main(){
	cin >> D;
	for (int i=0; i<26; i++) cin >> c[i];

	for (int i=0; i<D; i++){
		for(int j=0; j<26; j++){
			cin >> s[i][j];
		}
	}
	

	long long sat = 0;
	for (int d=0; d<D; d++){
		int t;
		cin >> t;

		sat += s[d][t-1];
		last[t-1] = d+1;
		sat -= dec(d+1);
		cout << sat << endl;
	}

	return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.println(a%3==0 || (b%3==0 || (a+b)%3==0) ? "Possible" : "Impossible");
  }
}


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

using ll = long long;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

const ll INF = (ll)1e16;

using namespace std;

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

    int H, W;
    cin >> H >> W;

    vector<string> S(H);
    for (int r = 0; r < H; ++r) {
        cin >> S[r];
    }

    vector<vector<int>> light(H, vector<int>(W));
    for (int r = 0; r < H; ++r) {
        int prevWall = -1, d = 0;
        for (int c = 0; c < W; ++c) {
            if (S[r][c] == '#') {
                for (int i = prevWall + 1; i < c; ++i) {
                    light[r][i] += d;
                }
                prevWall = c;
                d = 0;
            } else {
                ++d;
            }
        }
        for (int i = prevWall + 1; i < W; ++i) {
            light[r][i] += d;
        }
    }

    for (int c = 0; c < W; ++c) {
        int prevWall = -1, d = 0;
        for (int r = 0; r < H; ++r) {
            if (S[r][c] == '#') {
                for (int i = prevWall + 1; i < r; ++i) {
                    light[i][c] += d - 1;
                }
                prevWall = r;
                d = 0;
            } else {
                ++d;
            }
        }
        for (int i = prevWall + 1; i < H; ++i) {
            light[i][c] += d - 1;
        }
    }

    int ans = 0;
    for (int r = 0; r < H; ++r) {
        for (int c = 0; c < W; ++c) {
            ans = max(ans, light[r][c]);
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
	int N;
	cin >> N;
	int64_t ans = 0;
	int maxA = 0;
	rep(i, N) {
		int A, B;
		cin >> A >> B;
		if (A > maxA) {
			ans = A + B;
			maxA = A;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
n, q = map(int, input().split())
s = input()
t = [0] * (n + 1)
nl = set(range(n))
for i in nl:
    t[i + 1] = t[i] + (1 if s[i:i + 2] == 'AC' else 0)
ql = set(range(q))
for i in ql:
    l1, l2 = map(int, input().split())
    ans = t[l2-1] - t[l1-1]
    print(ans)

Measured memory_bytes: 24840
#include<stdio.h>
#include<algorithm>
using namespace std;
int v[210000];
int L[210000];
int R[210000];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<a;i++){
		v[i]=1;
		L[i]=(i+a-1)%a;
		R[i]=(i+1)%a;
	}
	int now=0;
	for(int i=0;i<b;i++){
		int d;scanf("%d",&d);
		if(d%2){
			for(int j=0;j<d;j++)now=L[now];
			v[now]=0;
			int l=L[now];
			int r=R[now];
			R[l]=r;
			L[r]=l;
			now=r;
		}else{
			for(int j=0;j<d;j++)now=R[now];
			v[now]=0;
			int l=L[now];
			int r=R[now];
			R[l]=r;
			L[r]=l;
			now=r;		
		}
	}
	for(int i=0;i<c;i++){
		int d;scanf("%d",&d);
		printf("%d\n",v[d]);
	}
}

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

using namespace std;

int main() {

	string s, t;
	cin >> s >> t;

	bool h = false;

	int ssz = s.size();
	int tsz = t.size();

	for (int i = ssz-1-(tsz-1); i >= 0; i--) {
		bool h2 = true;
		for (int j = 0; j < t.size(); j++) {
			if (s[i+j] == '?' || s[i+j] == t[j]) {

			}
			else {
				h2 = false;
			}
		}
		if (h2) {
			for (int j = 0; j < t.size(); j++) {
				s[i + j] = t[j];
			}
			h = true;
			break;
		}
	}

	if (h) {
		for (int i = 0; i < ssz; i++) {
			if (s[i] == '?') {
				s[i] = 'a';
			}
		}
		cout << s << endl;
	}
	else {
		cout << "UNRESTORABLE" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <iostream>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
#define all(v) (v).begin(),(v).end()
#define rep(x,y) for(ull i = (x);i<=(y);(x)++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
int dir[8][2] = {-1,0,1,0,0,1,0,-1,-1,-1,-1,1,1,-1,1,1};
int dir2[4][2] = {0,1,1,0,0,-1,-1,0};
const ll eps = -3000;

int N,K,Q;
int id;
unordered_map<int,int> mp;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin>>N>>K>>Q;
    for(int i = 1;i<=Q;i++){
        cin>>id;
        mp[id]++;
    }
    for(int i = 1;i<=N;i++){
        int t = K-Q+mp[i];
        if(t>0) cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}

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

using namespace std;
const int N = 1e6+100;
typedef long long ll;
const ll mod = 1000000007;
ll f[N];
bool vis[N];
int main(){
	ll n,m,x;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>x;vis[x]=1;
	}
	f[0]=1;
	f[1]=1;
	if(vis[1]) f[1]=0;
	for(int i=2;i<=n;i++){
		if(vis[i]) f[i]=0;
		else f[i]=(f[i-1]%mod+f[i-2]%mod)%mod;
	}
	cout<<f[n]%mod<<endl;
	return 0;
}


Measured memory_bytes: 1152
dp = [0 for i in range(100001)]
dp[100] = 1
dp[101] = 1
dp[102] = 1
dp[103] = 1
dp[104] = 1
dp[105] = 1
for i in range(106,100001):
    dp[i] = max(dp[i-100],dp[i-101],dp[i-102],dp[i-103],dp[i-104],dp[i-105])
X = int(input())
print(dp[X])

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<pii> xy(n);
    REP(i,n) cin >> xy[i].first >> xy[i].second;
    double ans = 0;
    int count = 0;
    vector<int> v(n);
    iota(ALL(v),0);

    do
    {
        REP(i,n-1) {
            ans += sqrt(pow(xy[v[i+1]].first - xy[v[i]].first,2) + pow(xy[v[i+1]].second - xy[v[i]].second,2));
        }

        count++;
    } while (next_permutation(ALL(v)));
    ans /= count;

    cout << fixed << setprecision(10) << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  vector<double> p(N + 1, 0.0);
  for (int i = 1; i <= N; i++) {
    cin >> p.at(i);
  }

  vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0.0));
  dp.at(1).at(0) = 1 - p.at(1);
  dp.at(1).at(1) = p.at(1);

  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      if (j == 0) {
        dp.at(i).at(j) += dp.at(i - 1).at(j) * (1 - p.at(i));
      } else {
        dp.at(i).at(j) += dp.at(i - 1).at(j - 1) * p.at(i) + dp.at(i - 1).at(j) * (1 - p.at(i));
      }
    }
  }

  double ans = 0.0;
  for (int i = N/2 + 1; i <= N; i++) {
    ans += dp.at(N).at(i);
  }

  cout << fixed << setprecision(10) << ans << endl;

  return 0;
}

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

int main() {
    int N;
    cin >> N;
    int a[N];
    for (int i=0; i<N; ++i) {
        cin >> a[i];
    }
    int max = a[0];
    int min = a[0];
    for (int i=1; i<N; ++i) {
        if(a[i]>max) max = a[i];
        if(a[i]<min) min = a[i];
    }
    map<int, int> m;
    for (int i=0; i<N; ++i) {
        m[a[i]] += 1;
    }
    int cnt_max = 0;
    for(int x=min; x<=max; ++x) {
        int cnt = m[x-1] + m[x] + m[x+1];
        if(cnt > cnt_max) cnt_max = cnt;
    }
    cout << cnt_max << endl;
}

Measured memory_bytes: 5376
import java.io.*;

class Main{
        static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        public static void main(String[] args) throws IOException{
                int n1 = Integer.parseInt(br.readLine());
                int[] a1 = new int[n1];
                String[] s1 = br.readLine().split(" ");
                for(int i=0; i<n1; i++)
                        a1[i] =  Integer.parseInt(s1[i]);
                int n2 = Integer.parseInt(br.readLine());
                int[] a2 = new int[n2];
                String[] s2 = br.readLine().split(" ");
                for(int i=0; i<n2; i++)
                        a2[i] = Integer.parseInt(s2[i]);

                int ans = 0;
                for(int i: a2){
                        int l = 0;
                        int r = n1;
                        int m = (r-l)/2;
                        while (r>l+1){
                                if(a1[m] == i){
                                        ans++;
                                        break;
                                }
                                if(a1[m]>i)
                                        r=m;
                                else
                                        l=m;
                                m=(r+l)/2;
                        }
                }
                System.out.println(ans);
        }
}

Measured memory_bytes: 46824
#include <iostream>
#include <math.h>
using namespace std;

// max(Bの桁数)
int calc_keta(long B) {
  int keta = 0;
  while (B > 0) { // n が 0 になるまで
    ++keta;
    B /= 10;
  }
  return keta;
}

int main() {
    long N;
    cin >> N;
 
    int min = calc_keta(N);
    //cout << min <<endl;
    //cout << N << " " << sqrt(N) << endl;
    for (long A = 1; A <= sqrt(N); ++A) { // c: Aピザ購入枚数
       long B = N/A;
       if (A*B==N & calc_keta(B)<min){
       	// cout << "A " << A << " B " << B << endl;
       	min = calc_keta(B);
       } 

    }
    cout << min << endl;
}

Measured memory_bytes: 256
def abc094C():
    n = int(input())
    x = input().split()
    x = list(map(int, x))
    y = x.copy()
    y.sort()
    nums = y[int(n / 2 - 1): int(n / 2 + 1)]
    for i in range(n):
        tf = nums[0] >= x[i]
        print(nums[tf])


abc094C()

Measured memory_bytes: 25224
n = int(input())
a = [[[0]*11 for j in range(4)]for k in range(5)]
for i in range(0, n):
    b, f, r, v = map(int, input().split())
    a[b][f][r] += v


for i in range(1, 5):
    for j in range(1, 4):
        for k in range(1, 11):
            print(" %d" % (a[i][j][k]), end="")
        print()
    if not i == 4:
        print('#' * 20)



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

typedef long long LL;

int main(){
//	freopen("in.txt", "r", stdin); 
	LL a,b,c;
	cin >> a >> b >> c;
	if(a + b >= c) {
		cout << (b + c) << endl;
	} else {
		cout << (a + 2LL*b + 1LL) << endl;
		//cout << (a + 2LL*b + 1LL)　<< endl;
	} 
	return 0;
} 

Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
    return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
    return *((char*)a) > * ((char*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    uint64_t N, M;

    scanf("%"PRIu64" %"PRIu64, &N, &M);

    if (2 * N < M) {
        printf("%"PRIu64, N + (M - 2 * N) / 4);
    }
    else {
        printf("%"PRIu64, M / 2);
    }

    return 0;
}


Measured memory_bytes: 128
S = input()
T = input()


dp = [[0] * (len(T) + 1) for i in range(len(S) + 1)]
dp2 = [[(0, 0)] * (len(T) + 1) for i in range(len(S) + 1)]
for i, s in enumerate(S, start=1):
    for j, t in enumerate(T, start=1):
        if s == t:
            dp[i][j] = dp[i - 1][j - 1] + 1
            dp2[i][j] = (i - 1, j - 1)
        elif dp[i - 1][j] > dp[i][j - 1]:
            dp[i][j] = dp[i - 1][j]
            dp2[i][j] = (i - 1, j)
        else:
            dp[i][j] = dp[i][j - 1]
            dp2[i][j] = (i, j - 1)

ans = ''
s, t = len(S), len(T)
while (s > 0) and (t > 0):
    if S[s - 1] == T[t - 1]:
        ans += S[s - 1]
    ns, nt = dp2[s][t]
    s, t = ns, nt

print(ans[::-1])


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

int main() {
  vector<char> C(9);
  for (int i = 0; i < 9; i++) {
    cin >> C.at(i);
  }
  cout << C.at(0) << C.at(4) << C.at(8);
  
  
  
}

Measured memory_bytes: 256
N, Q = list(map(int, input().split()))
s = list(input())

D = [0 for i in range(N)]

ql = []
for i in range(Q):
	t, d = list(input().split())
	ql.append([t, d])

x = 0
y = N - 1
for i in range(Q):
	if ql[-1 - i][1] == "L":
		if y < N - 1:
			if ql[-1 - i][0] == s[y + 1]:
				D[y + 1] = 0
				y += 1
		if x < N:
			if ql[-1 - i][0] == s[x]:
				D[x] = 1
				x += 1

	else:
		if x > 0:
			if ql[-1 - i][0] == s[x - 1]:
				D[x - 1] = 0
				x -= 1
		if y >= 0:
			if ql[-1 - i][0] == s[y]:
				D[y] = 1
				y -= 1

print(N - sum(D))

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

int main(){
    int n,k;
    cin>>n;
    cin>>k;
    vector<int> v;
    vector<int> dp(n,0);
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        v.push_back(a);
    }
    for(int i=1;i<n;i++){
        int mini=INT_MAX;
        for(int j=max(0,i-k);j<i;j++){
            mini=min(mini,abs(v[i]-v[j])+dp[j]);
        }
        dp[i]=mini;
       // cout<<dp[i]<<" ";
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1276
from math import *
n=int(input())
l=list(map(int,input().split()))
s=ceil(sum(l)/n)
ss=s-1
c=0
x=0
for i in range(n):
    c+=(s-l[i])**2
for i in range(n):
    x+=(ss-l[i])**2
print(min(c,x))


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

Measured memory_bytes: 9028
using System;
using System.Linq;

namespace oasobi
{
    static class MainClass
    {
        public static void Main()
        {
            string S = Console.ReadLine();
            int N = S.Length;

            string mae = S.Substring(0, (N - 1) / 2);
            string usiro = S.Substring((N + 1) / 2);

            var reva = new string(mae.Reverse().ToArray());
            var revb = new string(usiro.Reverse().ToArray());

            if(reva.Equals(mae) && revb.Equals(usiro) && revb.Equals(mae))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int count;
  while(true)
  {
    count=0;
    for(int i=2;i*i<=n;i++)
    {
      if(n%i==0)
      {
        count=1;
        break;
      }
    }
    if(count==0)
    {
      cout<<n<<endl;
      break;
    }
    else
    {
      n++;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>

bool isGoodInteger(int thousands, int hundreds, int tens, int ones){
	if(thousands == hundreds && hundreds == tens) return true;
	if(hundreds  == tens     && tens     == ones) return true;
	return false;
}

int main(void){
	int N, thousands, hundreds, tens, ones;
	scanf("%d", &N);

	//Nの各桁を求める
	thousands = N / 1000;
	N = N % 1000;
	hundreds = N / 100;
	N = N % 100;
	tens = N / 10;
	N = N % 10;
	ones = N;
	if(isGoodInteger(thousands, hundreds, tens, ones))
		printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
    long long n;
    cin >> n;
    long long minMove = n-1;
    for (long long i=2; i*i<=n; i++) {
        if (n%i == 0) {
            minMove = i + n/i - 2;
        }
    }
    cout << minMove << endl;
}

Measured memory_bytes: 256
#
# abc065 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
3
1
2"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4
3
4
1
2"""
        output = """-1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5
3
3
4
2
4"""
        output = """3"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    a = [0] + [int(input()) for _ in range(N)]
    A = [0] * (N+1)

    p = 1
    ans = 0
    while True:
        A[p] += 1
        if A[p] == 2:
            ans = "-1"
            break
        ans += 1
        p = a[p]
        if p == 2:
            break

    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 20952
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int N, K;
vector<int> G[101];

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

  cin >> N >> K;

  rep(i, N-1){
    G[0].push_back(i+1);
  }
  int r = ((N-1)*(N-2))/2 - K;
  if (r < 0){
    cout << -1 << endl;
    return 0;
  }
  int cnt = 1;
  while(r>0){
    for(int i=cnt+1; i< N; i++){
      G[cnt].push_back(i);
      r--;
      if (r==0) break;
    }
    cnt++; 
  }

  cout << (N*(N-1))/2 - K << endl;
  rep(i, N){
    if (G[i].size() == 0) break;
    rep(j, G[i].size()){
      int t = G[i][j];
      cout << i+1 << ' ' << t +1 << endl;
    }
  }

}

Measured memory_bytes: 384
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
Inf = 10 ** 10
Maxv = 3 * (10 ** 5)

num_even = []
num_odd = []
for i in 1..Maxv do
  num_even[i-1] = i
  num_odd[i-1] = i
end

for i in 1..N do
  j = lines[1][i-1]
  if i % 2 == 0 then
    num_even[j-1] += Inf
  else
    num_odd[j-1] += Inf
  end
end
  
num_even.sort!.reverse!
num_odd.sort!.reverse!

if num_even[0] % Inf != num_odd[0] % Inf then
  puts N - (num_even[0] / Inf) - (num_odd[0] / Inf)
else
  if (num_even[0] / Inf) + (num_odd[1] / Inf) < (num_odd[0] / Inf) + (num_even[1] / Inf) then
    puts N - (num_odd[0] / Inf) - (num_even[1] / Inf)
  else
    puts N - (num_even[0] / Inf) - (num_odd[1] / Inf)
  end
end

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  int n;
  while (cin >> n) {
    vector<lli> v(n);
    cin >> v;
    sort(v.begin(), v.end());
    lli sum = accumulate(v.begin(), v.end(), 0LL);
    sum -= v.back();
    cout << (v.back() < sum ? "Yes" : "No") << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256