akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define M_PI 3.14159265358979
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include <algorithm>

using namespace std;

int main(){
	int  a[10];
	for (int i = 0; i < 10; i++){
		cin >> a[i];
	}
	sort(a, a + 10);
	reverse(a, a + 10);
	for (int i = 0; i < 3; i++){
		cout << a[i] << endl;
	}
}

Measured memory_bytes: 1176
#import decimal
#decimal.getcontext().prec==500 Floatの桁数を500まで増やす
#Decimal(c).sqrt() それで平方根を求める
#Decimal(1) / Decimal(7) 1/7

from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math
from fractions import gcd
import sys
#input = sys.stdin.readline

H,W,K=map(int,input().split())
mod=10**9+7
if W==1:
    print(1)
    exit()
dp=[[0 for i in range(W)] for h in range(H+1)]
dp[0][0]=1

for h in range(1,H+1):
    for i in range(2**(W-1)):
        #print(h,i)
        lst=[i>>m&1 for m in range(W-1)]
        for w in range(len(lst)-1):
            if lst[w]==lst[w+1]==1:
                break
        else:
            #print(h,lst)
            for w in range(W):
                if w>0 and lst[w-1]:
                    dp[h][w]+=dp[h-1][w-1]
                elif w<len(lst) and lst[w]:
                    dp[h][w]+=dp[h-1][w+1]
                else:
                    dp[h][w]+=dp[h-1][w]
        for _ in range(len(dp[0])):
            dp[h][_]%=mod
#print(sum(dp[-1]))
print(dp[-1][K-1]%mod)


Measured memory_bytes: 5136
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  vector<ll> s(n);
  REP(i,n)cin>>s[i];
  ll mx = 0;
  FOR(step,1,n-1) {
    ll sum = 0;
    set<int> a;
    for (int j = 1; (j+1)*step < n-1; ++j) {
      if (j*step*2 == n-1) break;
      if (a.count(n-1-j*step)) break;
      sum += s[j*step] + s[n-1-j*step];
      a.insert(j*step);
      mx = max(mx, sum);
    }
  }
  cout<<mx<<endl;
  return 0;
}


Measured memory_bytes: 3456
import sys
N, M = map(int, sys.stdin.readline().split())
LR = sorted([list(map(int,sys.stdin.readline().split())) for i in range(M)])
L = 1
R = 10 ** 5
for i in LR:
    L = max(L, i[0])
    R = min(R, i[1])
if R - L >= 0:
    print(R - L + 1)
else:
    print(0)

Measured memory_bytes: 28628
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

    ll n, a, b; cin>>n>>a>>b;

    if(a == 0){
        cout << 0 << endl;
        return 0;
    }

    ll sum = a + b;
    ll cnt = n / sum;

    cout << (cnt * a + min(a, (n - cnt * sum))) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cassert>
#include <string>
#include <set>
#include <map>
#include <random>
#include <bitset>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using ld = long double;

const int N = 1 << 18, MOD = 998244353;
ll x[N], p[N], r[N], pp;

ll pw(ll x, ll k) {
	ll res = 1;
	for (int i = 30; i >= 0; i--) {
		res = res * res % MOD;
		if (k & (1 << i))
			res = res * x % MOD;
	}
	return res;
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll n, sum = 0;
	cin >> n;
	pp = 1 << n;
	rep(i, pp) {
		cin >> p[i];
		sum += p[i];
	}
	sum = pw(sum, MOD - 2);
	rep(i, pp) {
		p[i] = p[i] * sum % MOD;
		r[i] = MOD - 1;
	}
	p[0] = (p[0] + MOD - 1) % MOD;
	r[0] = pp - 1;
	rep(i, n)
		rep(j, pp) {
			if (j & (1 << i))
				continue;
			int j1 = j | (1 << i);
			p[j] = (p[j] + p[j1]) % MOD;
			p[j1] = (p[j] + (MOD - p[j1]) * 2) % MOD;
			r[j] = (r[j] + r[j1]) % MOD;
			r[j1] = (r[j] + (MOD - r[j1]) * 2) % MOD;
		}
	rep(i, pp)
		x[i] = r[i] * pw(p[i], MOD - 2) % MOD;
	ll r2 = pw(2, MOD - 2);
	for (int i = n - 1; i >= 0; i--)
		rep(j, pp) {
			if (j & (1 << i))
				continue;
			int j1 = j | (1 << i);
			x[j] = (x[j] + x[j1]) % MOD * r2 % MOD;
			x[j1] = (x[j] + MOD - x[j1]) % MOD;
		}
	for (int i = pp - 1; i >= 0; i--)
		x[i] = (x[i] + MOD - x[0]) % MOD;
	rep(i, pp)
		cout << x[i] << '\n';
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pii pair<long long,long long>
#define endl '\n'
#define N 100001
#define ll long long
int mod=1000000007;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
vector<int> parent(N),sz(N);
int modexp(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        
        return modexp((x*x)%M,n/2,M);
    else                             
        return (x*modexp((x*x)%M,(n-1)/2,M))%M;
}
void make_set(int s)
{
    parent[s]=s;
    sz[s]=1;
}
int find_parent(int p)
{
    if(p==parent[p])
    return p;
    return parent[p]=find_parent(parent[p]);
}
void union_set(int a,int b)
{
    a=find_parent(a);b=find_parent(b);
    if(a!=b)
    {
        if(a<b)
        swap(a,b);
        parent[b]=parent[a];
        sz[a]+=sz[b];
    }
}
vector<int> adj[N],dis(N),vis(N),indegree(N),topo;
int n,m;
void kahns()
{
    queue<int> q;
    for(int i=1;i<=n;i++)
    if(indegree[i]==0)
    q.push(i),dis[i]=0;
    while(!q.empty())
    {
        int temp = q.front();q.pop();
        topo.pb(temp);
        for(auto u:adj[temp])
        {
            indegree[u]--;
            if(indegree[u]==0)
            q.push(u);
        }
    }
}
void solve()
{
    cin>>n>>m;
    int x,y;
    dis.assign(n+1,INT_MIN);
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        adj[x].pb(y);indegree[y]++;
    }
    kahns(); int ans=0;
    for(int i=0;i<topo.size();i++)
    {
        int v=topo[i];
        for(auto u: adj[v])
        {
            if(dis[u]<dis[v]+1)
            dis[u]=dis[v]+1,ans=max(ans,dis[u]);
        }
    }
    cout<<ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test; test=1;
    while(test--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 10744
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back
#define M1 1000000007
#define M2 998244353
#define maxn 100000
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
#define PI 3.14159265358979323846
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define mini(x,y) (y + ((x - y) & ((x - y) >>(sizeof(int) * CHAR_BIT - 1))))
#define maxi(x,y) (x - ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))))
#define fr(j,a,b) for(j=a;j<b;j++)

lli power(lli x, lli y, lli p)
{   lli res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {   if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int main()
{
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli i, j, x, n, y, t, r, d;
    cin >> n;
    if (n % 2 == 0) {
        cout << "-1";
        return 0;
    }
    y = 7;
    t = 1;
    map<lli, lli> mp;
    while (mp[y] == 0) {
        mp[y] = 1;
        if (y % n == 0) {
            cout << t;
            return 0;
        }
        y = ((y * 10) + 7) % n;
        t++;
    }
    cout << "-1";
}

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

//Sample
int main()
{
    int N;
    cin >> N;
    if(N % 10 == 7 || N % 100 - N % 10 == 70 || N - N % 100 == 700)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int n,k;
    cin >> n >> k;

    vector<int> h(1);

    rep(i,n){
        int tmp;
        cin >> tmp;
        h.pback(tmp);
    }

    vector<int> cost(n + 1, INT_MAX);

    cost[1] = 0;

    for(int i = 1; i <= n - 1; i++){
        for(int j = i + 1; j <= n && j <= i + k; j++){
            int tmpcost = cost[i] + abs(h[j] - h[i]);
            cost[j] = min(cost[j], tmpcost);
        }
    }

    cout << cost[n] << endl;

    return 0;
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
#define shreyans ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define mod 1000000007 
#define MINI LLONG_MIN
using namespace std;
typedef long long ll;

ll dp[1000010],a[1000001];
int main(){
	
	shreyans
	ll n;cin>>n;
	for(ll i=0;i<n;i++)cin>>a[i];
	dp[0]=0; dp[1]=abs(a[1]-a[0]);
	for(ll i=2;i<n;i++)dp[i] = min(dp[i-1]+abs(a[i-1]-a[i]), dp[i-2]+abs(a[i-2]-a[i]));
	cout<<dp[n-1]<<"\n";
	
	return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 998244353;
const ld PI = acosl(-1);

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

    string N;
    cin >> N;
    int sum = 0;
    for (int i = 0; i < N.length(); ++i) {
        sum += N[i] - '0';
    }
    cout << (sum % 9 ? "No" : "Yes") << endl;

    return 0;
}


Measured memory_bytes: 3724
#include<stdio.h>
int main(){
    int N;
    int L;
    int sum;
    scanf("%d",&N);
    scanf("%d",&L);
    sum=(L+L+N-1)*N/2;
    if (L<=0&&0<=(L+N-1))
    {
    }else if (0<L)
    {
        sum=sum-L;
    }else if ((L+N-1)<0)
    {
        sum=sum-(L+N-1);
    }

    printf("%d",sum);
}

Measured memory_bytes: 128
n, k = map(int, input().split())
ans = 0
p = list(map(int, input().split()))
keep = sum(p[:k])
check = keep
for i in range(k, n):
    keep = keep + p[i] - p[i - k]
    if check <= keep:
        check = keep
re_ans = (check + k) / 2
print(re_ans)


Measured memory_bytes: 25060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,d;
	cin>>n>>d;
	int x[n][d];
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++)
			cin>>x[i][j];
	}
	int c=0;
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			int s=0;
			for(int k=0;k<d;k++)
				s+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			double d=(double)sqrt(s);
			int e=(int)sqrt(s);
			if(d==e)
				c++;
		}
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    ll cnt =0;
    for(ll i=0;i<n;i++){
        while(a[i]%2==0){
            cnt++;
            a[i]/=2;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define ft              first
#define sd              second
#define ll  		long long
#define pb              push_back
#define mkp           make_pair
#define pll             pair<ll,ll>
#define vll             vector<int>
#define mll             map<ll,ll>
#define pqg             priority_queue<ll>
#define pqs             priority_queue<ll,vll,greater<ll>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod          1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define MAXN   10000001
void online_judge()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}

void ISO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

set<pair<int,int>> s;
int main() {

	ISO();
	online_judge();

	int h, w, m;
	cin >> h >> w >> m;
	vector<int> x(w, 0), y(h, 0);
	map<pair<int, int>, int> bomb;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		x[b]++;
		y[a]++;
		bomb[make_pair(b, a)]++;
	}
	int maxX = 0, maxY = 0;
	for (int i = 0; i < w; i++) {
		maxX = max(maxX, x[i]);
	}
	for (int i = 0; i < h; i++) {
		maxY = max(maxY, y[i]);
	}
	vector<int> maxXs, maxYs;
	for (int i = 0; i < w; i++) {
		if (x[i] == maxX) {
			maxXs.push_back(i);
		}
	}
	for (int i = 0; i < h; i++) {
		if (y[i] == maxY) {
			maxYs.push_back(i);
		}
	}
	for (int xx : maxXs) {
		for (int yy : maxYs) {
			if (!bomb.count(make_pair(xx, yy))) {
				cout << maxX + maxY << endl;
				return 0;
			}
		}
	}
	cout << maxX + maxY - 1 << endl;

	//cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
	return 0;
}

Measured memory_bytes: 28516
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  char ABC;
  for(int i = 0;i < N;i++){
  cin >> ABC;
  if(i == M - 1){
    if(ABC == 'A') ABC = 'a';
    else if(ABC == 'B') ABC = 'b';
    else if(ABC == 'C') ABC = 'c';
    }
  cout << ABC;
  }
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] tenboudai = new int[N+1];
		for (int i = 0; i < N; i++) {
			tenboudai[i+1] = sc.nextInt();
		}
		HashSet<Integer> daturaku = new HashSet<Integer>();
		for (int i = 0; i < M; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (tenboudai[a] == tenboudai[b]) {
				daturaku.add(a);
				daturaku.add(b);
			} else {
				if(tenboudai[a] < tenboudai[b]) {
				daturaku.add(a);
				}else {
					daturaku.add(b);
				}

			}
		}
		System.out.print(tenboudai.length - daturaku.size()-1);

	}
}

Measured memory_bytes: 63288
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*

 */
int x;

int main(){
  cin>>x;
  if(x<1200)
    cout << "ABC\n";
  else
    cout<<"ARC\n";

  return 0;
}


Measured memory_bytes: 256
/**************erik****************/
#include<bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long  int ll;
typedef unsigned long long int ull;
//map<ll,ll> mp1;
//set<int> s1;
//set<int>::iterator it;
#define maxm(a,b,c)  max(a,max(c,b))
#define minm(a,b,c)  min(a,min(c,b))
#define f(i,n)  for(ll i=0;i<n;i++)
#define rf(i,n) for(ll i=n-1;i>=0;i--)
#define PI 3.14159265
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
    int n,m;
    cin>>n>>m;
    vector<vector<int>> vec(n);
    int dist[n+1];
    bool vis[n+1];
    for(int i=0;i<=n;i++){vis[i]=false;}
    f(i,m){
        int a,b;
        cin>>a>>b;
        vec[a-1].push_back(b-1);
        vec[b-1].push_back(a-1);
    }
    queue<int> q;
    q.push(0);
    dist[0]=0;
    while(!q.empty()){
        int x = q.front();
        q.pop();
        for(int i=0;i<vec[x].size();i++){
            int p = vec[x][i];
            if(vis[p]==false){
                vis[p]=true;
                dist[p]=x+1;
                q.push(p);
            }
        }
    }
    cout<<"Yes"<<endl;
    for(int i=1;i<n;i++){
        cout<<dist[i]<<endl;
    }
}

Measured memory_bytes: 10328
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
int now[1000];

int Solve(int num){
  Yes();
  cout << num << endl;

  int cnt = 1;
  for (int i = 0; i < num; i++){
    cout << num - 1;

    for (int j = 0; j < i; j++){
      cout << " " << now[j];
      now[j]++;
    }

    now[i] = cnt;
    for (int j = 0; j < num - 1 - i; j++){
      cout << " " << cnt;
      cnt++;
    }
    cout << endl;
  }

  return 0;
}

int main(){
  cin >> N;
  for (int i = 0; i < 1000; i++){
    int now = i * (i - 1);
    if (now == N * 2){
      Solve(i);
      return 0;
    }
  }
  No(); return 0;

  return 0;
}


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


void solve(long long N, std::vector<long long> a){
    long long ans = 0;
    for(long long i = 0;i < N;i++){
        if(ans + 1 == a[i]){
            ans++;
        }
    }
    
    if (ans >0){
        cout << N-ans << endl;
        return;
    }
    cout << -1 << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


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

int main() {
  vector<char>a(26);
  for(int i=0;i<26;i++){
    a.at(i)='A'+i;
  }
  string S;
  int N;
  cin >> N >> S;
  for(int i=0;i<S.size();i++){
    S.at(i)=a.at((S.at(i)-'A'+N)%26);
  }
  cout << S << endl;
}

Measured memory_bytes: 256
// abc064_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n;
  cin>>n;
  vi a(n);
  rep(i, n)
    cin>>a.at(i);

  sort(a.begin(),a.end());
  cout << a.at(n-1)-a.at(0) << endl;
  return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())

S = []
Snum = [[0 for j in range(W+2)] for i in range(H+2)]

def kabe_c(W):
    kabe = ""
    for j in range(W+2):
        kabe += " "
    return kabe
    
S.append(kabe_c(W))
for i in range(1,H+1):
    S.append(" "+input()+" ")
S.append(kabe_c(W))
    
for i in range(H+2):
    for j in range(W+2):
        if S[i][j] == "#":
            for k in range(i-1,i+2):
                for l in range(j-1,j+2):
                    Snum[k][l] += 1

for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j] == "#":
            print("#",end="")
        else:
            print(str(Snum[i][j]),end="")
    print("")

Measured memory_bytes: 3444
def main():
    S = input()
    N = len(S)
    ans = 0
    for bit in range(1<<(N-1)):
        pre = 0
        for i in range(N-1):
            if bit&(1<<i):
                ans += int(S[pre:i+1])
                pre = i + 1
        else:
            ans += int(S[pre:])
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 39024
def compute_zigzag_distance(c1,c2,size):
    m,n = size
    x1,y1 = c1
    x2,y2 = c2
    dis = 0

    if (x2 - x1)%2 == 0:
        return (x2 - x1)*n + (y2 - y1)*(1 - x1%2 * 2)
    elif (x2 - x1)%2 == 1:
        return (x2 - x1)*n + (n - y2 - y1 -1)*(1 - x1%2 * 2)
def print_zigzag_path(c1,c2,size):
    m,n = size
    x1,y1 = c1
    x2,y2 = c2
    x ,y  = x1 + 1,y1 + 1
    while (x,y)!=(x2 + 1,y2 + 1):
        print(str(x)+" "+str(y),end=" ")
        # Next point
        if x%2 == 1:
            if y==n:
                x += 1
            else:
                y += 1
        else:
            if y == 1:
                x += 1
            else:
                y -= 1
        print(str(x)+" "+str(y))
m,n = map(int,input().split())

odd_idx = []

for i in range(m):
    line = list(map(int,input().split()))
    
    for j in range(n)[::(1-i%2 * 2)]:
        if line[j]%2 == 1:
            odd_idx.append((i,j))
#print(odd_idx)
s = 0
for i in range(0,len(odd_idx)-1,2):
        
    tmp = compute_zigzag_distance(odd_idx[i],odd_idx[i+1],(m,n))
    #print(tmp)
    s += tmp
print(s)
for i in range(0,len(odd_idx)-1,2):    
    print_zigzag_path(odd_idx[i],odd_idx[i+1],(m,n))



Measured memory_bytes: 26872
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, A, B;
    cin >> N >> A >> B;

    ll count = 0;
    FOR(i, 0, N){
        ll t;
        cin >> t;

        if(A<=t && t < B){
            //
        }else{
            count++;
        }
    }

    p(count);
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    register int i;
    int n,m;
    scanf("%d%d",&n,&m);
    int c = n / 2;
    for(i = 0;i < m;i++){
        printf("%d %d\n",c+i+(!(n%2)&&(i+1)>c/2?1:0)+1,c-i);
    }
}

Measured memory_bytes: 1692
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int Rate(int rate){
	rate = (int)(rate/400);
	if (rate > 8) {
		return 8;
	}
	return rate;
}

int main(int argc, char const *argv[]) {
	int count,temp,color,over;
	color = over = 0;
	std::vector<int> v = {0,1,2,3,4,5,6,7};
	std::cin >> count;
	for (size_t i = 0; i < count; i++) {
		std::cin >> temp;
		temp = Rate(temp);
		if (temp == 8) {
			over++;
		}
		for (size_t j = 0; j < v.size(); j++) {
			if (temp == v[j]) {
				color++;
				v.erase(v.begin()+j);
				break;
			}
		}
	}
	if (color == 0 && over > 0) {
		std::cout << 1 << " " << color+over << '\n';
	}
	else{
		std::cout << color << " " << color+over << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    static long[] fact = new long[100];
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong()-1;
        
        String ans = String.valueOf((char)('a'+n%26));

        while(true){
            n/=26;
            if(n==0)break;
            n--;
            char ansc = (char)('a'+n%26);
            ans = ansc + ans;
            //System.out.println(ans);
            if(n==0)break;
        }
        System.out.println(ans);
    }
}




Measured memory_bytes: 39284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

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

const ll inf = 1LL<<60;

int main()
{
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  vector<ll> m(100010, 0);
  ll sum = 0;
  rep(i, n) {
    m[a[i]]++;
    sum += a[i];
  }
  ll q; cin >> q;
  for (int i=0; i<q; i++){
    ll b,c; cin>>b>>c;
    ll t = m[b];
    m[b] = 0;
    m[c] += t;
    sum += (c-b)*t;
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 4780
N = int(input())
P = [int(x) for x in input().split()]
#とりまリストに入れる。
answer = 0
for i in range(1,N-1):
  #iがN-2まででいい理由は次行で最終項目までカバーするから
  a,b,c = P[i-1:i+2]
  if b != min(a,b,c) and b != max(a,b,c):
    #三つのうち真ん中というのは最大でも最小でもないということ。
    answer += 1

print(answer)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b; cin >> a >> b;
  cout << (b%a==0 ? a+b : b-a) << "\n";
  return 0;
}


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

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int n;
    int i;
    int a1,a2,a3,a4;
    a1=0;
    a2=0;
    a3=0;
    a4=0;
    for(i=0;i<4;i++){
      cin >> n;
      if(n==1)a1=1;
      if(n==9)a2=1;
      if(n==7)a3=1;
      if(n==4)a4=1;
    }
    if(a1+a2+a3+a4==4){
      cout << "YES";
    }else{
      cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll ans = 0;
  while (1) {
    ll maxa = *max_element(a.begin(), a.end());
    if (maxa < n) {
      cout << ans << '\n';
      return 0;
    }
    ll mina = *min_element(a.begin(), a.end());
    if (mina >= n) {
      ll cnt = mina - n + 1;
      ans += n * cnt;
      rep(i, n) a[i] -= cnt;
    }
    ll cnt = 0;
    vector<ll> res(n, 0);
    rep(i, n) {
      res[i] = a[i] / n;
      cnt += res[i];
      a[i] %= n;
    }
    ans += cnt;
    rep(i, n) a[i] += cnt - res[i];
  }




  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll nc = b / c - (a - 1) / c;
  ll nd = b / d - (a - 1) / d;
  ll g = c / gcd(c, d) * d;
  ll ncd = b / g - (a - 1) / g;
  ll cup = nc + nd - ncd;
  ll ans = b - a + 1 - cup;
  cout << ans << endl;
}

Measured memory_bytes: 3596
import math

n = int(input())
a = [list(map(int,input().split())) for i in range(n)]

ans = 0

for i in range(n):
  for j in range(n):
    ans += math.sqrt((a[i][0]-a[j][0])**2+(a[i][1]-a[j][1])**2)/n
    
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int par[1000000];

void init(int N){
    rep(i,N) par[i] = -1;
}

int find(int a){
    if(par[a] < 0) return a;
    else{
        return par[a] = find(par[a]);
    }
}

void unite(int a, int b){
    a = find(a);
    b = find(b);
    if(a == b) return;
    else{
        if(par[a] > par[b]) swap(a,b);
        par[a] += par[b];
        par[b] = a;
    }
}

int size(int A) {
     return -par[find(A)];
}

bool same(int a, int b){
    return find(a) == find(b);
}


int main(){
    int N, M, K;
    cin >> N >> M >> K;
    vector<vector<int>> f_cnt(N);
    init(N);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--;b--;
        unite(a,b);
        f_cnt[a].push_back(b);
        f_cnt[b].push_back(a);
    }
    vector<vector<int>> block(N);
    rep(i,K){
        int c,d;
        cin >> c >> d;
        c--;d--;
        block[c].push_back(d);
        block[d].push_back(c);
    }
    rep(i,N){
        int ans = size(i) - f_cnt[i].size() - 1;
        for(auto v:block[i]){
            if(same(i,v)) ans--;
        }
        if(N-1 != i) cout << ans << " ";
        else cout << ans << endl;
    }
}

Measured memory_bytes: 14588
#include <iostream>
#include <string.h>

using namespace std;

string s, t;

int tamanhos[3001][3001];

int caminho[3001][3001];

void print_subsequence(int tamanho_s, int tamanho_t){
    if(tamanho_s == 0 || tamanho_t == 0){
        return;
    }

    if(caminho[tamanho_s][tamanho_t] == 0){
        print_subsequence(tamanho_s - 1, tamanho_t - 1);
        cout << s[tamanho_s - 1];
    }else if(caminho[tamanho_s][tamanho_t] == 1){
        print_subsequence(tamanho_s - 1, tamanho_t);
    }else if(caminho[tamanho_s][tamanho_t] == 2){
        print_subsequence(tamanho_s, tamanho_t - 1);
    }
}

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

    int tamanho_s = s.size();
    int tamanho_t = t.size();

    for(int i = 0; i <= tamanho_s; i++){
        for(int j = 0; j <= tamanho_t; j++){
            tamanhos[i][j] = 0;
        }
    }

    for(int i = 1; i <= tamanho_s; i++){
        for(int j = 1; j <= tamanho_t; j++){
            if(s[i - 1] == t[j - 1]){
                tamanhos[i][j] = tamanhos[i - 1][j - 1] + 1;
                caminho[i][j] = 0;
            }else{
                int escolha_esquerda = tamanhos[i - 1][j];

                int escolha_cima = tamanhos[i][j - 1];

                if(escolha_esquerda >= escolha_cima){
                    tamanhos[i][j] = escolha_esquerda;
                    caminho[i][j] = 1;
                }else{
                    tamanhos[i][j] = escolha_cima;
                    caminho[i][j] = 2;
                }
            }
        }
    }

    print_subsequence(tamanho_s, tamanho_t);

    cout << endl;

    return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

LL gcd(LL a, LL b) {
    return ( b==0 ) ? a : gcd(b,a%b);
}

int main() {
    int n;
    LL s=1;
    cin >> n;
    for ( int i=0; i<n; i++ ) {
        LL a;
        cin >> a;
        s=a/gcd(a,s)*s;
    }
    cout << s << '\n';
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(reversed(sorted([int(i) for i in input().split()])))
ans = a[0]
n -= 2
i = 1
while n > 0:
    if n > 1:
        ans += a[i] * 2
        n -= 2
        i += 1
    else:
        ans += a[i]
        n -= 1
print(ans)

Measured memory_bytes: 31444
#!/usr/bin/env python3
import sys


def solve(N: int, h: "List[int]"):
    # [漸化式]
    # i+1かi+2の足場にしか行けないという事は、ゴールNから逆算して考えると、
    # N-1の足場にたどり着く最小コスト+|hN-1 - hN| と、
    # N-2の足場にたどり着く最小コスト+|hN-2 - hN| のうち、コストが小さい方が答えになる。
    # dp[i] = iの足場にたどり着くための最小コスト、と定義すれば良い。

    INF = 1001001001
    dp = [INF] * N
    for i in range(N):
        if i == 0:
            dp[i] = 0
        elif i == 1:
            dp[i] = dp[i-1] + abs(h[i-1] - h[i])
        else:
            dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]))
    print(dp[N-1])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, h)

if __name__ == '__main__':
    main()


Measured memory_bytes: 18060
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll a,b,c,k;

int main(){
  cin >> a >> b >> c >> k;
  if(a >= k){
    cout << k << endl;
  }else if(a+b >= k){
    cout << a << endl;
  }else{
    cout << a-(k-a-b) << endl;
  }

  return 0;
}


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

int main() {
  int N,M;
  cin >> N;
  cin >> M;
  vector<int> A(N);
  int total = 0;
  for(int i=0;i<N;i++) {
  	int a;
    cin >> a;
    A[i] = a;
    total += a;
  }
  
  int count = count_if(A.begin(), A.end(), 
           [&total, &M](int i)->bool{return ((double)i>=(double)total/4/M);});
  cout << (count >= M ? "Yes":"No") << endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc093/tasks/arc094_b

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int Q_MAX = 100;
const int A_I_MAX = 1e9;
const int B_I_MAX = 1e9;

int Q;
int A[Q_MAX];
int B[Q_MAX];

ll sqrt_floor(ll x) {
  int lo = 0;
  int hi = A_I_MAX;
  while (hi - lo > 1) {
    ll mi = (lo + hi) / 2;
    if (mi * mi <= x) lo = mi;
    else hi = mi;
  }
  return lo;
}

int f(ll a, ll b) {
  ll ab = a * b - 1;
  ll c = sqrt_floor(ab);
  int ret = c * 2;
  if (ab < c * (c + 1)) ret--;
  if (a != b) ret--;
  return ret;
}

void solve() {
  REP(i, Q) {
    printf("%d\n", f(A[i], B[i]));
  }
}

void input() {
  scanf("%d", &Q);
  REP(i, Q) scanf("%d%d", A + i, B + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

S = input()
N = len(S)
ans = [0]*N

LRlist = []
isR = True
tmp = 0
for s in S:
    if s == 'R':
        if isR:
            tmp += 1
        else:
            isR = True
            LRlist.append(tmp)
            tmp = 1
    else:
        if not isR:
            tmp += 1
        else:
            isR = False
            LRlist.append(tmp)
            tmp = 1

LRlist.append(tmp)

L = len(LRlist)
itr = 0
for i in range(0,L,2):
    Ln = LRlist[i]
    Rn = LRlist[i+1]
    ans[itr+Ln-1] += (Ln+1)//2 + Rn//2
    ans[itr+Ln]   += Ln//2 + (Rn+1)//2

    itr += Ln + Rn

print(' '.join(map(str,ans)))


Measured memory_bytes: 12388
#include <iostream>
#include <string>
using namespace std; 
int n; 
string s; 

int c(char ch, int a)
{
    if (a == 1)
    {
        if (ch == 'Z')
            return 'A'; 
        return ch + 1; 
    }
    if (a == 0)
    	return ch; 
    return c(c(ch, 1), a - 1); 
}

int main()
{
    cin >> n >> s; 
    for (int i = 0; i < s.size(); ++i)
    {
        s[i] = c(s[i], n); 
        cout << s[i]; 
    }
    return 0; 
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long k, a, b;
	cin >> k >> a >> b;
	if (b < a + 2) cout << 1 + k << endl;
	else {
		int ans = 1;
		if (a - 1 > 0) k -= a - 1, ans += a - 1;
		cout << ans + (k % 2) + k / 2 * (b - a) << endl; 
	}
	return 0;
}


Measured memory_bytes: 256
// abc136d.cpp : Gathering Children
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)

int main(){
  string S; cin>>S;
  int n = S.length();

  vi divpoint, group;
  bool high_low = false; // low
  up(i,0,n,1){
    if(!high_low && S[i]=='R'){ // ↑
      divpoint.push_back(i); // グループの切れ目
      high_low = true; // hi
    }
    else if(high_low && S[i]=='L'){ // ↓
      group.push_back(i); // グループの集合場所（L側）
      high_low = false; // low
    }
  }
  divpoint.push_back(n);

  vi ans(n);
  up(i,0,group.size(),1){
    int gn = divpoint[i+1] - divpoint[i];
    int o = gn/2;
    if(gn%2 && divpoint[i]%2) o++;
    int e = gn-o;
    int L = group[i]%2? o:e;
    int R = group[i]%2? e:o;
    ans[group[i]-1] = R; // R
    ans[group[i]] = L; // L
  }

  ot(ans[0]); up(i,1,n,1) cout<<" "<<ans[i]; ot("\n");

}

Measured memory_bytes: 1532
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) a.begin(), a.end()
typedef long long int ll;
using namespace std;

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

    int n;
    cin >> n;

    if (n % 2 == 0) {
        cout << n << endl;
    } else {
        cout << n * 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  vector<int> b(N - 1); rep(i, N - 1) cin >> b[i];

  vector<int> a;
  a.push_back(b[0]);
  for (int i = 0; i + 1 < N - 1; ++i){
    if (b[i] < b[i + 1]) a.push_back(b[i]);
    else a.push_back(b[i + 1]);
  }
  a.push_back(b[N - 2]);
  int ans = 0;
  rep(i, N) ans += a[i];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (c <= a + b) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*

/**
 * Created by murakami on 2018/04/28.
 */

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val a = scanner.nextInt()
    val b = scanner.next()
    val c = scanner.nextInt()

    if (b == "+") {
        print(a + c)
    } else {
        print(a - c)
    }
}

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

using namespace std;

#define ll long long
#define MOD 1000000007

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

    int n;
    cin>>n;

    int ar[n][3];
    for (int i = 0; i <n; ++i) {
        for (int j = 0; j <3; ++j) {
            cin>>ar[i][j];
        }
    }

    for(int i = n-2;i>=0;i--){
        for(int j=0;j<3;j++){
            int ans =0 ;
            for(int k =0;k<3;k++){
                if(k!=j)
                 ans = max(ans,ar[i+1][k]);
            }
                ar[i][j] += ans;
        }
    }
    cout<<*max_element(ar[0],ar[0]+3);


    return 0;
}

Measured memory_bytes: 1408
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
s = sum(B)
for i in range(len(A)-1):
   # print(A[i], A[i+1]-1, C[i+1], i)
    if A[i] == A[i+1]-1:
        s+=C[A[i]-1]
print(s)


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vpii = vector<pair<int, int>>;

int main()
{
  string s;
  cin >> s;
  ll k=s.size();
  ll cnt_0 = 0,cnt_1 = 0;
  for (int i = 0; i < k;i++){
    if(s[i]=='0')
      cnt_0++;
      else
        cnt_1++;
     
      
  }
  cout << min(cnt_0, cnt_1) * 2 << endl;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef int64_t ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);


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

  string s;
  cin >> s;

  // xx, or xyx を含まないこと
  // -> xyzxyzxyz のループを作るしかない
  int num_a = 0;
  int num_b = 0;
  int num_c = 0;
  rep(i, s.size()) {
    if (s[i] == 'a') num_a++;
    else if (s[i] == 'b') num_b++;
    else if (s[i] == 'c') num_c++;
  }

  if (max(num_a, max(num_b, num_c)) - min(num_a, min(num_b, num_c)) <= 1) {
    puts("YES");
  } else {
    puts("NO");
  }

  return 0;
}


Measured memory_bytes: 512
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

int main() {
	int n, k, d, a, ans = 0;
	cin >> n >> k;
	int cnt[100] = {};
	for (int i = 0; i < k; ++i) {
		cin >> d;
		for (int j = 0; j < d; ++j) {
			cin >> a;
			cnt[a - 1] += 1;
		}
	}
	for (int i = 0; i < n; ++i) {
		ans += cnt[i] == 0;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N, K; cin >> N >> K;
    ll R, S, P; cin >> R >> S >> P;
    string T; cin >> T;
    string res;
    REP(i, N) {
        if (i < K) {
            if (T[i] == 'r') res.push_back('P');
            else if (T[i] == 's') res.push_back('R');
            else if (T[i] == 'p') res.push_back('S');
        }
        else {
            if (T[i] == 'r'){
                if(res[i-K] != 'P') res.push_back('P');
                else if (i+K < N && T[i+K] == 's') res.push_back('S');
                else res.push_back('R');
            }
            else if (T[i] == 's'){ 
                if(res[i-K] != 'R') res.push_back('R');
                else if (i+K < N && T[i+K] == 'p') res.push_back('P');
                else res.push_back('S');
            }
            else if (T[i] == 'p') {
                if(res[i-K] != 'S') res.push_back('S');
                else if (i+K < N && T[i+K] == 'r') res.push_back('R');
                else res.push_back('P');
            }
        }
    }
    ll ans = 0;
    REP(i,N) {
        if (T[i] == 'r' && res[i] == 'P') ans += P;
        else if(T[i] == 's' && res[i] == 'R') ans += R;
        else if(T[i] == 'p' && res[i] == 'S') ans += S;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
gets
t, a = gets.split.map(&:to_i)
idx = 0
m = nil
gets.split.map.with_index do |e, i|
  abs = (a - (t - e.to_i * 0.006)).abs
  if m.nil? || m > abs
    m = abs
    idx = i
  end
end
puts idx+1


Measured memory_bytes: 1788