akhauriyash/Code-Regression huggingface dataset:
S = input()

#print('S=', S)

n = len(S)

#print('len(S)=', n)

list_S = list(S)

#print('list(S)=', list_S)

count = 0

for i in range((n-1)//2):
  if list_S[i] != list_S[n-1-i]:
    count += 1
if count > 0:
  print('No')
  exit()

list_left = list_S[0 : (n-1)//2]
#print('list_left=', list_left)
list_right = list_S[(n+3)//2-1 : n]
#print('list_right=', list_right)

n_edge = len(list_left)
#print('n_edge=', n_edge)

if n_edge % 2 == 1:
  for i in range((n_edge-1)//2):
    if list_left[i] != list_left[n_edge-1-i]:
      print('No')
      exit()

if n_edge % 2 == 0:
  for i in range(n_edge//2):
    if list_left[i] != list_left[n_edge-1-i]:
      print('No')
      exit()


print('Yes')


Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split(" ")))

#インデックス番号とセットにする

A2 = {}
num = []

for i in range(N):
    num.append(i+1)

A2 = dict(zip(num,A))

#人数でソート
A3 = sorted(A2.items(),key = lambda x:x[1])

for i in range(N):
    print(A3[i][0],end=" ")

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

int main() {
    ll N, M;
    cin >> N >> M;
    vector<vector<int>> edge(N);
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        A--;B--;
        edge[A].push_back(B);
        edge[B].push_back(A);
    }
    
    vector<bool> visited(N, false);
    ll bip = 0, unbip = 0;
    vector<int> color(N, 0);
    ll point = 0;
    for (int i = 0; i < N; i++) {
        if (visited[i]) continue;
        if (edge[i].empty()) {
            point++;
            visited[i] = true;
            continue;
        }
        queue<int> q;
        bool isbip = true;
        q.push(i);
        color[i] = 1;
        while (!q.empty()) {
            int now = q.front();
            q.pop();
            for (int nxt : edge[now]) {
                if (!visited[nxt]) {
                    visited[nxt] = true;
                    q.push(nxt);
                    color[nxt] = 3-color[now];
                }else {
                    if (color[nxt] == color[now]) {
                        isbip = false;
                    }
                }
            }
        }
        if (isbip) bip++;
        else unbip++;
    }
    
    cout << bip*bip*2 + unbip*unbip + bip*unbip*2 + N*point*2 - point*point << endl;
    return 0;
}

Measured memory_bytes: 7296
#include<iostream>
#include<cstring>

using namespace std;

typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t;
	cin>>s>>t;
	int m=s.length(), n=t.length();

	//first find length of longest common subsequence

	int dp[m+1][n+1];
	for(int i=0;i<=m;i++){
		for(int j=0;j<=n;j++){
			if(i==0 || j==0)
				dp[i][j] = 0;

			else if(s[i-1] == t[j-1])
				dp[i][j] = 1 + dp[i-1][j-1];

			else
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}

	int size = dp[m][n];
	int size_2 = size;

	char lcs[size+1];
	lcs[size] = '\0';
	int i=m;
	int j=n;

	while(i!=0 && j!=0){
		if(s[i-1] == t[j-1]){
			lcs[size-1] = s[i-1];
			i--;
			j--;
			size--;
		}

		else if(dp[i-1][j] > dp[i][j-1])
			i--;

		else
			j--;
	}

	cout<<lcs<<'\n';

	return 0;
}

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

def gcd(x,y):
  if x>y: x,y = y,x
  while x:
    x,y = y%x, x
  return y

def lcm(x,y):
  return x*y//gcd(x,y)

N = int(input())
ans = 1
for _ in range(N):
  ans = lcm(ans, int(input()))
print(ans)


Measured memory_bytes: 38492
#include <stdio.h>

int main()
{
    long n, input, x,  min = 0, max = 0, sum = 0;
    scanf("%ld\n", &n);
    if(n == 0)
    {
        printf("%ld %ld %ld\n", min, max, sum);
    }
    else
    {
        for(x = 1; x <= n; x++)
        {
            scanf("%ld", &input);
            if(x == 1)
            {
                min = input;
                max = input;
            }
            if(min > input)
            {
                min = input;
            }
            else if(max < input)
            {
                max = input;
            }

            sum = sum + input;
        }

        printf("%ld %ld %ld\n", min, max, sum);
    }
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

int main(){
    int n, l;

    // 入力
    std::cin >> n >> l;
    
    std::vector<std::string> s(n);
    std::string ans;
    rep(i, n){
        std::cin >> s[i];

        if(s[i].size() != l) return 0;
    }

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

    rep(i, n){
        ans += s[i];
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7

S = input()

print(S[:3])


Measured memory_bytes: 9120
#!/usr/bin/pypy
N=int(raw_input())

M = set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, 28, 30, 32, 35, 36, 40, 42, 45, 48, 49, 54, 56, 63, 64, 72, 81])

if N in M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 28012
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 1000 + 5 ; 
const int M = 1e4 + 5 ;
int H, n, a[N], b[N], dp[M] ; 
int F( int x ) {
	if( x == 1 ) return 1 ; 
	return 2ll * F( x / 2 ) + 1ll ; 
}
signed main()
{
	H = gi(), n = gi() ; 
	rep( i, 1, n ) a[i] = gi(), b[i] = gi() ; 
	memset( dp, 63, sizeof(dp) ), dp[0] = 0 ;
	for( re int i = 1; i <= n; ++ i ) {
		for( re int j = 0; j <= H; ++ j ) {
			dp[j] = min( dp[j], dp[max( 0ll, j - a[i] )] + b[i] ) ;
		}
	}
	printf("%lld\n", dp[H] ) ;
	return 0 ;
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    
   string a[n];
   string b[n];
   int i;
   for(i=0;i<n;++i)
     {
         cin>>a[i];
         b[i]=a[i];
     }
  
  sort(b,b+n);
  for(i=0;i<n-1;++i)
  {
    if(b[i]==b[i+1])
        break;
  }
  
  if(i<n-1)
     printf("No");
  
  else
  {
    for(i=0;i<n-1;++i)
    {
      if(a[i].back()==a[i+1].front())
           continue;
      
      else
         break;
    }
    
    if(i<n-1)
         printf("No");
    
    else
       printf("Yes");
     
    
  }
     
 
        
}
    
    


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
long long m,n;
  cin >> m >> n;
  
  long long p = m + n;
  if(p % 2 == 0){
    cout << p / 2 << endl;
  }
  else
    cout << "IMPOSSIBLE" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int infint = 1e9;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)2e3 + 7;
ll n, a, b;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n >> a >> b;
	if(a + b > n + 1 || a > n || b > n || a * b < n)
		return cout << -1, 0;
	
	for (int i = b; i >= 1; i--)
		cout << i << " ";
	
	ll q = b + 1;
	a--;
	while(q <= n)
	{
		int ptr = q;
		while(n - ptr >= a && ptr - q + 1 < b)
			ptr++;
		a--;
		for (int i = ptr; i >= q; i--)
			cout << i << " ";
		q = ptr + 1;
	}
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i,n) for (int i=0; i< (n); ++i)
typedef pair<int, int> P;
int dp[500+5][500+5];
int ans[500+5][500+5];

int main() {
  ll n, m, Q;
  cin >> n >> m >> Q;
  vector<ll> a(n);
  int l, r;
  rep(i,m) {
    cin >> l >> r;
    dp[l][r] += 1;
  }
  
  for (int l=n+1; l>=0; l--) {
    for (int r=0; r<=n; r++) {
      ans[l][r] = dp[l][r] + ans[l+1][r];
    }
  }
  for (int r=1; r<=n; r++) {
    for (int l=0; l<=n+1; l++) {
      ans[l][r] += ans[l][r-1];
    }
  }
  /*
  for (int r=0; r<=n; r++) {
    for (int l=0; l<=n; l++) {
      cout << ans[l][r] << " ";
    }
    cout << endl;
  }
  */
  int p, q;
  rep(i,Q) {
    cin >> p >> q;
    cout << ans[p][q] << endl;
  }
  return 0;
}


Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long A[] = new long[N+1];
		long result=0;
		for (int i=1;i<=N;i++) {
			for (int j=1;j*i<=N;j++) {
				A[j*i]++;
			}
		}
		for (int i=1;i<=N;i++) {
			result +=i*A[i];
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 116124
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

ll MOD = 1000000007;
ll A[505050], sum[505050],sum0[505050];

ll modpow(ll a, ll n) {
	ll res = 1;
	a %= MOD;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

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

	int N;
	cin >> N;
	for (int i = 1; i <= N; i++)cin >> A[i];
	for (int i = 1; i <= N; i++)sum[i] = sum[i-1] ^ A[i];
	for (int i = 1; i <= N; i++) { sum0[i] = sum0[i - 1] + (sum[i] == 0); }

	map<ll, ll>dp,dpsum,dpsum2;
	for (int i = 1; i <= N; i++) {
		if (sum[i] != 0) {
			ll cur = sum0[i] * dpsum[sum[i]] - dpsum2[sum[i]] + 1 + 8LL*MOD;
			cur %= MOD;
			dp[i] = cur;
			dpsum[sum[i]] += cur;
			dpsum2[sum[i]] += cur*sum0[i];
			dpsum[sum[i]] %= MOD;
			dpsum2[sum[i]] %= MOD;
			if (i == N) { puts(cur); return 0; }
		}
	}

	ll ans = modpow(2,sum0[N]-1);
	for (int i = 1; i <= N - 1; i++) { ans += dp[i]; ans %= MOD; }
	puts(ans);

	return 0;
}


Measured memory_bytes: 79232
n = int(input())
cnt = 0
ans = 1

for i in range(1,n+1):
    c = 0
    while True:
        if i%2 == 0:
            i //= 2
            c += 1
        else:
            if cnt < c:
                ans = i*2**c
                cnt = c
            break

print(ans)

Measured memory_bytes: 3060
n=int(input())
seq=input().split()
check=0
for i in range(n):
  if int(seq[i])%2==0:
    if int(seq[i])%3!=0 and int(seq[i])%5!=0:
      check+=1
if check==0:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 38384
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){

    vector<int> ans(4,0);
    int n;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        if(s=="AC")ans[0]++;
        else if(s=="WA")ans[1]++;
        else if(s=="TLE")ans[2]++;
        else ans[3]++;
    }
    cout<<"AC x "<<ans[0]<<endl;
    cout<<"WA x "<<ans[1]<<endl;
    cout<<"TLE x "<<ans[2]<<endl;
    cout<<"RE x "<<ans[3]<<endl;


return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>u,v,w;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    cin>>n>>m;
    k=0;
    for(i=0;i<n;i++)
    {
        cin>>o;
        v.PSB(o);
    }
    k=m;
    for(i=1;i<n;i++)
    {
     k+=min(m,(v[i]-v[i-1]));
    }
    cout<<k<<endl;



    return 0;

}


Measured memory_bytes: 2420
#include<cstdio>

int x, y;

int main() {
  scanf("%d %d", &x, &y);
  bool possible = false;
  for (int i = 0; i <= x; i++) {
    if (i * 2 + (x - i) * 4 == y) {
      possible = true;
    }
  }
  printf("%s\n", possible ? "Yes" : "No");
}


Measured memory_bytes: 1648
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;
string str;

char change(char c, int k){
    int idx = 0;
    rep(i, 52, str.size()){
        if(str[i] == c){
            idx = i; break;
        }
    }
    return str[idx - k];
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    rep(i, 0, 26) str += 'a' + i;
    rep(i, 0, 26) str += 'A' + i;
    str += str;
    while(1){
        cin >> n;
        if(n == 0) break;
        vector<int> a(n);
        rep(i, 0, n) cin >> a[i];
        string s;
        cin >> s;
        rep(i, 0, s.size()){
            s[i] = change(s[i], a[i % n]);
        }
        cout << s << endl;
    }
}


Measured memory_bytes: 3180
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    if (N % 2)
    {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    ll d = 10;
    while (N / d > 0)
    {
        ans += N / d;
        d *= 5;
    }
    cout << ans << endl;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(a-c) <= d) {
    cout << "Yes" << endl;
    return 0;
  }
  if (abs(a-b) <= d && abs(b-c) <= d) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main()
{
    int n;
    int x,y,k;
    int a,b;
    int t1,t2;

	a = b = t1 = 0;
	scanf("%d", &n);
	for(int i = 0;i < n;i++)
	{	
		scanf("%d %d %d", &t2, &x, &y);
		k = abs(a - x) + abs(b - y);
		
		if(t1 + k > t2){
            printf("No\n");
            return 0;
        }
		if(abs((t2-t1)-k)%2 != 0){
            printf("No\n");
            return 0;
        }

		a = x;
		b = y;
		t1 = t2;
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
import sys 
import numpy as np

readline = sys.stdin.readline 

N = int(input())

index = [0] * N

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x 
            if n <= N:
                index[n - 1] += 1


for i in index:
    print(i)

Measured memory_bytes: 27240
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  ns <- map (read::String->Int) . lines <$> getContents
  let timelist = zip ns $ map calcWaiting ns
  print $ (sum . map (uncurry (+))) timelist - (maximum . map snd) timelist

calcWaiting::Int->Int
calcWaiting x
  |mod x 10 == 0 = 0
  |otherwise     = 10 - mod x 10


Measured memory_bytes: 3684
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

N, T = map(int, input().split())
t = list(map(int, input().split()))

time = T
for i in range(1,N):
    if t[i] - t[i - 1] < T:
        time += t[i] - t[i - 1]
    else:
        time += T
print(time)

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
vector<string> s;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
vector<P> g[410];
ll counter = 0;
int h, w;

struct UnionFind
{
    vector<int> d;
    vector<int> bc;
    UnionFind(int n = 0) : d(n, -1),bc(n, 0) {}

    int root(int x)
    {
        if (d[x] < 0)
            return x;
        return d[x] = root(d[x]);
    }
    // 辺情報から2点をくっつける
    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
        {
            return false;
        }
        if (-d[x] < -d[y])
            swap(x, y); //y.size()が小でx.size()が大にしておきたい
        d[x] += d[y];
        d[y] = x;
        bc[x] += bc[y];
        bc[y] = 0;
        return true;
    }
    bool same(int x, int y) { return root(x) == root(y); }
    int size(int x) { return -d[root(x)]; }
};
int main()
{
    cin >> h >> w;
    s.resize(h);rep(i,h)cin >> s[i];
    UnionFind uf(h*w);
    rep(i, h)
    {
        rep(j, w)
        {
            if(s[i][j]=='#')uf.bc[w * i + j]++;
        }
    }
    rep(i, h)
        {
            rep(j, w)
            {
                for (int k = 0; k < 4; k++)
                {
                    int tx = i + dx[k];
                    int ty = j + dy[k];
                    if (tx < 0 || tx > h - 1 || ty < 0 || ty > w - 1)
                    {
                        continue;
                    }
                    if (s[i][j] == '#')
                    {
                        if (s[tx][ty] == '.')
                            uf.unite(w * i + j, w * tx + ty);
                    }
                    if (s[i][j] == '.')
                    {
                        if (s[tx][ty] == '#')
                            uf.unite(w * i + j, w * tx + ty);
                    }
                }
            }
        }

        ll ans = 0;
        for (int i = 0; i <= h * w - 1; i++)
        {
            if (uf.d[i] < 0)
            {
                ll num = (ll)uf.size(i);
                ans += (num - (ll)uf.bc[i]) * ((ll)uf.bc[i]);
            }
        }
        cout << ans << endl;
    }

Measured memory_bytes: 4756
K = int(input())
Q = [i for i in range(1, 10)]
k = 0
for q in Q:
  if k >= K:
    break
  r = q%10
  if r != 0:
    Q.append(q*10 + r - 1)
    k += 1
  Q.append(q*10 + r)
  k += 1
  if r != 9:
    Q.append(q*10 + r + 1)
    k += 1
print(Q[K-1])

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

int main() {
    long long a[100][100], b[100], c[100];
    int m, n;
    cin >> n >> m;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            c[i] += a[i][j] * b[j];
        }
    }

    for (int i = 0; i < n; i++) {
        cout << c[i] << endl;
    }
    return 0;
}



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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

string s, t;

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

	cin >> s >> t;
	forn (i, s.size())
		if (s[i] != t[i]) {
			cout << "No" << endl;
			return 0;
		}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb push_back
#define sortv(v) sort(v.begin(), v.end())
#define mod1 1000000007
#define mod2 998244353
#define debug(x) cout<<#x<<" : "<<x<<endl

// void solve()
// {
	
// }

int main()
{
	optimize

	int a,b,c,k;
	cin>>a>>b>>c>>k;

	lli ans = 0;

	// vector<int>v = {a,b,c};

	int x = k>a?a:k;
	ans += (lli)x;
	k-=x;

	if(k != 0)
	{
		// break;
	
	int y = k>b?b:k;
	k-=y;
	}
	if(k != 0)
	{	// break;
	int z = k>c?c:k;
	ans -= (lli)z;
	k-=z;
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 3648
import java.util.Scanner;
public class Main{
	
    int high;
    int low;
    int sa = 0;
	
	public void solve(){
        Scanner sc = new Scanner(System.in);
		
        for(int i=0;i<7;i++){
            high = sc.nextInt();
            low = sc.nextInt();
            sa = high-low;
            System.out.println(sa);
        }
    }
    public static void main(String args[]){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17312
# B - Golden Apple
# https://atcoder.jp/contests/abc134/tasks/abc134_b

def calculate_number_of_worker(tree, range)   
    tmp = tree % ((range * 2) + 1)

    if tmp == 0
        tree / ((range * 2) + 1)
    else
        tree / ((range * 2) + 1) + 1
    end
end

n,d= gets.chomp.split(" ").map(&:to_i)

p calculate_number_of_worker(n,d)

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    ll N,M,K;
    cin >> N >> M >> K;
    vector<ll> A,B;
    A.push_back(0);
    B.push_back(0);
    rep(i,N) {
        ll a;
        cin >> a;
        A.push_back(a+A[i]);
    }
    rep(i,M) {
        ll b;
        cin >> b;
        B.push_back(b+B[i]);
    }

    ll amax = upper_bound(A.begin(),A.end(),K) - A.begin();
    amax--;
    ll ans = amax;


    for (ll i=0; i<=amax; i++) {
        ll res = K-A[i];
        ll bmax = upper_bound(B.begin(),B.end(),res) - B.begin();
        bmax--;
        ans = max(ans,bmax+i);
    }

    cout << ans << endl;

}


Measured memory_bytes: 7992
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#define re register
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define MAXN 3007
#define ll long long
using namespace std;
typedef unsigned long long ull;
#define ms(arr) memset(arr, 0, sizeof(arr))
const int inf = 0x3f3f3f3f;
ll c[MAXN][MAXN];
ll g[MAXN][MAXN];
ll n,mo;
inline ll niubide_power(ll k,ll x,ll mod)
{
	ll ans=1;
	while(x) {
		if(x&1ll) ans=ans*k%mod;
		k=(k*k%mod);
		x>>=1;
	}
	return ans;
}
int main()
{
	cin>>n>>mo;
	for(re int i=1;i<=n;i++){
		c[i][0]=1;c[i][i]=1;
		for(int j=1;j<i;j++)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%mo;
	}
	for(int i=0;i<=n;i++){
		g[i][0]=1;
		for(int j=1;j<=i;j++)
			g[i][j]=(g[i-1][j-1]+g[i-1][j]*(j+1)%mo)%mo;
	}
	ll ans=0;
	for(int i=0;i<=n;i++){
		ll k=c[n][i];
		if(i&1) k=(mo-k)%mo;
		ll kind=niubide_power(2,n-i,mo);
		ll x=niubide_power(2,n-i,mo-1);
		x=niubide_power(2,x,mo);
		ll cnt=0,y=1;
		for(int j=0;j<=i;j++){
			cnt=(cnt+(g[i][j]*y)%mo)%mo;
			y=kind*y%mo;
		}
		ans=(ans+(k*cnt)%mo*x%mo)%mo;
	}
	cout<<ans;
}

Measured memory_bytes: 139776
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define N 200001
#define M 3333333
#define INF 0x3f3f3f3f
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
const int mod=1000000007;
vector<int> a[N],id[N];
map<int,int> s;
int n,x,y,m,all,col[N];
bool vis[N];
int cnt,head[N],nxt[M],to[M];
int sum[N],top,st[N];
void dfs(int u)
{
	vis[u]=1;
	if(!sum[col[u]])st[++top]=col[u];
	++sum[col[u]];++all;
	for(int i=head[u],v;i;i=nxt[i])
		if(!vis[v=to[i]])
			dfs(v);
}
int main()
{
	re(n),re(x),re(y);
	for(int i=1;i<=n;++i)
	{
		int c,w;
		re(c),re(w);
		if(!s[c])s[c]=++m;
		c=s[c];
		a[c].push_back(w);
	}
	n=0;
	a[0].push_back(INF);
	int mn1=0,mn2=0;
	for(int i=1;i<=m;++i)
	{
		sort(a[i].begin(),a[i].end());
		if(a[i][0]<a[mn1][0])
			mn2=mn1,mn1=i;
		else if(a[i][0]<a[mn2][0])
			mn2=i;
		for(int j=0;j<a[i].size();++j)id[i].push_back(++n),col[n]=i;
		for(int j=1;j<a[i].size();++j)
			if(a[i][0]+a[i][j]<=x)
				add_edge(id[i][0],id[i][j]),
				add_edge(id[i][j],id[i][0]);
	}
	for(int i=1;i<=m;++i)
		if(i!=mn1)
			for(int j=0;j<a[i].size();++j)
				if(a[mn1][0]+a[i][j]<=y)
					add_edge(id[mn1][0],id[i][j]),
					add_edge(id[i][j],id[mn1][0]);
	if(mn2)
	for(int i=1;i<=m;++i)
		if(i!=mn2)
			for(int j=0;j<a[i].size();++j)
				if(a[mn2][0]+a[i][j]<=y)
					add_edge(id[mn2][0],id[i][j]),
					add_edge(id[i][j],id[mn2][0]);
	static int fac[N],ifac[N],inv[N];
	fac[0]=ifac[0]=inv[0]=inv[1]=1;
	for(int i=1;i<=n;++i)
	{
		if(i>1)inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
		fac[i]=1ll*fac[i-1]*i%mod;
		ifac[i]=1ll*ifac[i-1]*inv[i]%mod;
	}
	int ans=1;
	for(int i=1;i<=n;++i)
		if(!vis[i])
		{
			dfs(i);
			ans=1ll*ans*fac[all]%mod;
			for(int j=1;j<=top;++j)
				ans=1ll*ans*ifac[sum[st[j]]]%mod,sum[st[j]]=0;
			all=0;
			top=0;
		}
	printf("%d\n",ans);
}


Measured memory_bytes: 39680
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 200005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int primes[505], counter = 0, mark[1200];
int arr[MAX*10];
int cntPrimes[1000005];
bool found;

void genSieve()
{
    int limit = sqrt(1020);
    mark[1] = 1;
    for(int i = 4; i < 1020; i += 2)
        mark[i] = 1;

    primes[counter++] = 2;
    for(int i = 3; i < 1020; i += 2){
        if(!mark[i]) {
            primes[counter++] = i;
            if(i <= limit) {
                for(int j = i * i; j < 1020; j += i * 2)
                    mark[j] = 1;
            }
        }
    }
}

void factorize(int n)
{
    int idx = 0, pf = primes[idx];
    while(pf * pf <= n) {
        if(n % pf == 0) {
            while(n % pf == 0) {
                n /= pf;
            }
            if(cntPrimes[pf] > 0) {
                found = true;
                return;
            }
            cntPrimes[pf]++;
        }
        pf = primes[++idx];
    }

    if(n != 1) {
        if(cntPrimes[n] > 0) {
            found = true;
            return;
        }
        cntPrimes[n]++;
    }
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    genSieve();
    //cout<<counter<<endl;
    int n;

    cin>>n;

    int g = 0;
    for(int i = 0; i < n; i++) {
        cin>>arr[i];
        if(!found)
            factorize(arr[i]);
        g = __gcd(g, arr[i]);
    }

    if(!found)
        cout<<"pairwise coprime"<<endl;
    else if(g == 1)
        cout<<"setwise coprime"<<endl;
    else
        cout<<"not coprime"<<endl;

    return 0;
}



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

void fnInput(int& rnTrgSu, int& rnTrgKin)
{
  cin >> rnTrgSu >> rnTrgKin;
}

int fnRcsSch(int nPos, int nTrgSu, int nTrgKin, vector<int>& rvnMoneyCnt)
{
  const vector<int> cnvnMoney{10000, 5000, 1000};

  if (nTrgSu == 0 && nTrgKin == 0) return  1;
  if (nTrgKin <  0)                return -1;
  if (nPos == rvnMoneyCnt.size())  return  0;

  if (nPos == rvnMoneyCnt.size() - 1)
  {
    rvnMoneyCnt[nPos] = nTrgSu;
    return fnRcsSch(nPos + 1, 0, nTrgKin - cnvnMoney[nPos] * nTrgSu, rvnMoneyCnt);
  }
  else
    for (int i = 0; i <= nTrgSu; i++)
    {
      rvnMoneyCnt[nPos] = i;
      for (int i = nPos + 1; i < rvnMoneyCnt.size(); i++)
        rvnMoneyCnt[i] = 0;

      int nReslt = fnRcsSch(nPos + 1, nTrgSu - i, nTrgKin - cnvnMoney[nPos] * i, rvnMoneyCnt);
      if      (nReslt ==  1)  return 1;
      else if (nReslt == -1)  break;
    }

  return 0;
}

int fnExhSch(int nTrgSu, int nTrgKin)
{
  vector<int> vnMoneyCnt(3);

  if (fnRcsSch(0, nTrgSu, nTrgKin, vnMoneyCnt))
  {
    for (int i = 0; i < vnMoneyCnt.size(); i++)
    {
      if ( i )  cout << " ";
      cout << vnMoneyCnt[i];
    }
    cout << endl;
  }
  else
    cout << -1 << " " << -1 << " " << -1 << endl;
}

int main()
{
  int nTrgSu, nTrgKin;
  
  fnInput(nTrgSu, nTrgKin);
  fnExhSch(nTrgSu, nTrgKin);

  return 0;
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())
tmp = [K] * N
for _ in range(Q):
    a = int(input())
    tmp[a-1] += 1
for i in range(N):
    tmp[i] -= Q
    if tmp[i] > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 7752
#include <iostream>

int main(int argc, const char * argv[]) {
    int a, b, c;
    int s, m , l;
    std::cin >> a >> b >> c;
    if (a < b) {
        s = a;
        l = b;
    } else {
        s = b;
        l = a;
    }
    if (c < s) {
        m = s;
        s = c;
    } else if (l < c) {
        m = l;
        l = c;
    } else {
        m = c;
    }
    std::cout << s << " " << m << " " << l << std::endl;
    return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
/* vector<int> A(N);
vector<pair<int, int> > tasks; ＃ソートした場合、１つ目でソート
tie(b, a) = p.at(i); #pair を分割
tasks.emplace_back(b, a) ＃配列 tasks の最後に (b, を追加
x の二乗 : pow(x, 2.0)
小さい順 : sort(v.begin(), v.
*/
int main() {
  int N, count=1, ans=0,ans2=1;
  cin >> N;
  vector<string> A(N);
  rep(i,N){
  	cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  
  rep(i,N-1){
  	if(A.at(i)==A.at(i+1)){
    	count++;
      	ans=count;
      if(ans>=ans2){
      	ans2=ans;
      }
    }
    if(A.at(i)!=A.at(i+1)){
    	ans=count;
      	count=1;
      if(ans>=ans2){
      	ans2=ans;
      }
    }
  }
    
    count=1;
    
    if(ans2==1){
      rep(i,N){
       cout << A.at(i) << endl;
      }
    }
    if(ans2>=2){
      rep(i,N-1){
        if(A.at(i)==A.at(i+1)){
          count++;
          if(count==ans2){
          	cout << A.at(i) << endl;
          }
    	}
   		else count=1;
     }
   }
   
}
  


Measured memory_bytes: 15104
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function Main(input){
    var args = input.split('\n');
    var N = parseInt(args[0].split(' ')[0], 10);
    var K = parseInt(args[0].split(' ')[1], 10);
    var a = args[1].split(' ').map(a => parseInt(a, 10));
    a.sort( (a,b) => (a<b ? -1 : 1) );
    var total = 0;

    for(var i=0; i<K; i++){
        total += a.pop();
    }

    console.log(total);
}

Measured memory_bytes: 7372
#include <iostream>
#include <stack>
#include <string>
#include <sstream>

inline int toInt(std::string s) {
    int v;
    std::istringstream sin(s);
    sin >> v;
    return v;
}
 
int main () {
  std::string s;
  std::stack<int> st;
  while (std::cin >> s) {
        if (s[0]>='0' and s[0]<='9') {
            st.push(toInt(s));
        }
        else {
            int a = st.top();
            st.pop();
            int b = st.top();
            st.pop();
            switch(s[0]) {
            case '+':
                st.push(a + b);
                break;
            case '-':
                st.push(b - a);
                break;
            case '*':
                st.push(a * b);
                break;
            }
        }
    }
  std::cout<<st.top()<<'\n';
    return 0;
}



Measured memory_bytes: 3184
#include<algorithm>
#include<iostream>
#include<string.h>
#include<sstream>
#include<stdio.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define  mem(a,b) memset(a,b,sizeof(a))

const int mo=1000000007;
const int inf=0x3f3f3f3f;
double pi=3.14159265358979323846;
double e= 2.71828182845904523536;
typedef long long ll;
using namespace std;
int main()
{
	int x,y;
	cin>>x>>y;
	if(x%y==0)
	{
		cout<<-1<<endl;
		exit(0);
	}
	for(int i=2*x;;i+=x)
	{
		if(i%y!=0)
		{
			cout<<i<<endl;
			exit(0);
		}
	}
    return 0;
}




Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓

int N;
int board[101][101];
int main()
{
  int W,H;
  int x,y;
  int s,t;
  while(cin>>N,N){
    cin>>W>>H;
    for(int i = 0;i <=100;i++){
      for(int j = 0;j <=100;j++){
	board[i][j] = 0;
      }
    }
    for(int i = 0;i < N;i++){
      cin>>x;
      cin>>y;
      board[y][x] = 1;
    }
    cin>>s;
    cin>>t;
    int ans1;
    int ans = 0;
    for(int i = 0;i<=H;i++){
      for(int j = 0;j <=W;j++){
	ans1 = 0;
	for(int y = 1+i;y <=t+i;y++){
	  for(int x =1+j;x <=s+j;x++){
	    if(x >=1&&x <=W&& y >=1&&y <=H){
	      if(board[y][x]==1){
		ans1++;
	      }
	    }
	  }
	}
	ans = max(ans1,ans);
      }
    }
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include<stdio.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<stack>
#include<string.h>
using namespace std;
char b[200],bb[200];
int map[200][200];
int main() {
	int i, l,j,s,e,cnt=0;
	scanf("%s", b+1);
	l = strlen(b + 1);
	s = 1; e = l;
	while (1) {
		if (s > e) break;
		if (b[s] != b[e]) cnt++;
		s++; e--;
	}
	printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 128
def merge(A, left, mid, right):
    global cnt
    L = A[left:mid] + [10000000000]
    R = A[mid:right] + [10000000000]

    i = j = 0

    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1

        else:
            A[k] = R[j]
            j += 1

        cnt += 1

def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left + right)//2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)


n = int(input())
lst = list(map(int, input().split()))
cnt = 0

mergeSort(lst, 0, n)
print(*lst)
print(cnt)


Measured memory_bytes: 61644
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  vector<int> v(4);
  for (int i = 0; i < 4; ++i) {
    char c; cin >> c;
    v[i] = c - '0';
  }

  for (int i = 0; i < (1 << 3); ++i) {
    bitset<3> b(i);
    int sum = v[0];
    string S = to_string(v[0]);
    for (int i = 0; i < 3; ++i) {
      if (b.test(i)) {
        sum += v[i + 1];
        S += "+" + to_string(v[i + 1]);
      } else {
        sum -= v[i + 1];
        S += "-" + to_string(v[i + 1]);
      }
    }
    if (sum == 7) {
      cout << S << "=7" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
a = ['#' * (w+2)] + ['#' + input() + '#' for i in range(h)] + ['#' * (w+2)]
for i in range(h+2):
    a[i] = list(a[i])

d = [(1, 0), (0, 1), (-1, 0), (0, -1)]
q = deque([])
for i in range(1, h+1):
    for j in range(1, w+1):
        if a[i][j] == '#':
            q.append((i, j, 0))

ans = 0
while q:
    i, j, c = q.popleft()
    for di, dj in d:
        if a[i+di][j+dj] == '.':
            a[i+di][j+dj] = '#'
            q.append((i+di, j+dj, c+1))
    ans = max(ans, c)

print(ans)


Measured memory_bytes: 165596
#include <bits/stdc++.h>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<endl
using namespace std;


int main() {
	SPEED;
	//freopen("in.txt", "r", stdin);
	ll n; cin >> n;
	print((2 * n) / __gcd(2LL, n));
	
	return 0;
}


Measured memory_bytes: 256
// May this submission get accepted
#pragma GCC optimize ("O3")
#pragma GCC target("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll n = inp1;
    ll k = inp1;
    vector<ll> p = inp(n);
    vector<ll> s(n+1, 0);
    REP(i, n) s[i+1] = s[i] + p[i];
    ll smax = -INF;
    REP(i, n-k+1) {
        chmax(smax, s[i+k] - s[i]);
    }
    cout << fixed << setprecision(30) << (ld)(smax + k) / 2 << endl;
    
}

Measured memory_bytes: 3456
#include <iostream>

using namespace std;

int ar[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int ac[8] = {1, 1, 0, -1, -1, -1, 0, 1};

char a[55][55];
int n, m;

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

	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			cin >> a[i][j];

	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			if (a[i][j] != '#')
			{
				int ii, jj, count = 0;
				for (int k = 0; k < 8; ++k)
				{
					ii = i + ar[k];
					jj = j + ac[k];

					if (ii > 0 && ii <= n && jj > 0 && jj <= m)
						if (a[ii][jj] == '#')
							++count;
				}

				a[i][j] = count + '0';
			}

	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
			cout << a[i][j];
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N = input()
lst = list(map(int, input().split()))
count = 0
c = 0
start = lst[0]

for i in lst[1:]:
  if i > start:
    count = max(count, c)
    c = 0
  else:
    c += 1
  start = i
count = max(count, c)
print(count)


Measured memory_bytes: 14252
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <queue>
#include <random>
#include <map>
#include <set>
#include <boost/multiprecision/cpp_int.hpp>

#pragma warning(disable:4996)

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> pix(h);
  for (auto&& v : pix) {
    cin >> v;
  }
  cout << string(w + 2, '#') << endl;
  for (auto&& v : pix) {
    cout << '#' << v << '#' << endl;
  }
  cout << string(w + 2, '#') << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill( (T*)array, (T*)(array+N), val ); }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7
int main() {
    int n,k;
    cin>>n>>k;
    vector<int> p(n);
    REP(i,n){
        cin>>p[i];
    }
    sort(all(p));
    ll sum=0;
    REP(i,k){
        sum+=p[i];
    }
    cout<<sum<<endl;
    return 0;
}

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

int main()
{
  int n,k,ans;
  ans=0;
  cin>>n>>k;
  vector<int> price(n);
  for(int i=0;i<n;i++)
  {
    cin>>price.at(i);
  }
  sort(price.begin(),price.end());
  for(int i=0;i<k;i++)
  {
    ans+=price.at(i);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
n = int(input())
a_list = list(map(int, input().split()))

change_cnt_fron_right = 0
change_cnt_fron_left = 0

for i in range(n-1):
    if a_list[i] == a_list[i+1]:
        change_cnt_fron_right += 1
        a_list[i + 1] = 0
        #print(a_list)

print(change_cnt_fron_right)
# print(min(change_cnt_fron_left, change_cnt_fron_right))

Measured memory_bytes: 2940
package main
import (
  "fmt"
)
 
func main(){
  var k int
  var s string
  fmt.Scan(&k)
  fmt.Scan(&s)
  if len(s) <= k {
    fmt.Printf("%s\n", s)
  } else {
    fmt.Printf("%s\n", s[:k] + "...")
  }
}

Measured memory_bytes: 1836
#include<stdio.h>
int main(void)
{
	int x, y, z;
	scanf("%d", &x);
	scanf("%d", &y);

	while ((x != 0) || (y != 0))
	{
		if (x > y)
		{
			z = y;
			y = x;
			x = z;

		}

		printf("%d %d\n", x, y);

		scanf("%d", &x);
		scanf("%d", &y);

	}


	return 0;
}


Measured memory_bytes: 2032
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

A = int(input())
B = int(input())

s = [1,2,3]
s.remove(A)
s.remove(B)
print(s[0])

Measured memory_bytes: 77116
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int a,b,c; cin >> a >> b >> c;
  int x; cin >> x;
  while(x--){
    if(b<=a)
      b *= 2;
    else if(c<=b)
      c *= 2;
  }
  if((a<b) && (b<c))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<list>

using namespace std;

int main(){
  int n;
  cin >> n;
  string c;
  int num;
  list<int>::iterator itr;
  list<int>lst;
  itr = lst.begin();
  for(int i=0;i<n;i++){
    cin >> c;
    if(c=="deleteFirst") lst.pop_front();
    else if(c=="deleteLast") lst.pop_back();
    else cin >> num;
    if(c=="insert") lst.push_front(num);
    
    else if(c=="delete"){
      for(itr=lst.begin();itr!=lst.end();itr++){
	if(*itr==num){
	  lst.erase(itr);
	  break;
	}
      }
    }    
  }
  int point=0;
  int cont=0;
  for(itr=lst.begin();itr!=lst.end();itr++) point+=1;
    
  for(itr=lst.begin();itr!=lst.end();itr++){
    if(cont==point-1){
      cout << *itr << endl;
      break;
    }
    cout << *itr <<" ";
    cont++;
  }
  return 0;
}

Measured memory_bytes: 34344
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Integral Rectangles
// 2013/08/13
public class Main{
	Scanner sc=new Scanner(System.in);

	int h, w;

	void run(){
		for(;;){
			h=sc.nextInt();
			w=sc.nextInt();
			if((h|w)==0){
				break;
			}
			solve();
		}
	}

	void solve(){
		int ww=200, hh=200;
		for(int i=1; i<200; i++){
			for(int j=1; j<i; j++){
				if(comp(i, j, w, h)>0&&comp(i, j, ww, hh)<0){
					ww=i;
					hh=j;
				}
			}
		}
		println(hh+" "+ww);
	}

	int comp(int w1, int h1, int w2, int h2){
		if(w1*w1+h1*h1!=w2*w2+h2*h2){
			return (w1*w1+h1*h1)-(w2*w2+h2*h2);
		}else{
			return h1-h2;
		}
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 20476