akhauriyash/Code-Regression huggingface dataset:
/*
▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄██████████████▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐

*/
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <iomanip>


using namespace std;


#define ll long long
#define ld long double
#define null NULL
#define prev prev228

const int N = 228228;

bool can[N];

vector<int> g[N];

signed main() {
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; ++i) {
		int u, v;
		cin >> u >> v;
		if (u == n) {
			can[v] = true;
		}
		if (v == n) {
			can[u] = true;
		}
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for (int v : g[1]) {
		if (can[v]) {
			puts("POSSIBLE");
			return 0;
		}
	}
	puts("IMPOSSIBLE");
	return 0;
}

















Measured memory_bytes: 12784
#include <stdio.h>
#include <stdlib.h>
int main()
{
  int *A,i,j,k,N,v;

  scanf("%d",&N);
  A = (int *)malloc(N * sizeof(int));
  for(i = 0 ; i < N ; i++) scanf("%d",&A[i]);
  
  for(i = 1 ; i < N ; i++){
    for(k=0 ; k < N-1 ; k++) printf("%d ",A[k]);
    printf("%d\n",A[k]);
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--; }
    A[j+1] = v;
  }
  
 for(k=0 ; k < N-1 ; k++) printf("%d ",A[k]);
    printf("%d\n",A[k]);
 
      
  return 0;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std ;
const int N = 1e7 + 4;
void FastInputOutput()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline ll LLD()
{
    ll ret;
    scanf("%lld", &ret);
    return ret;
}
inline int D()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
void bin( int x )
{
    if(!x)
        return;
    bin( x / 2 );
    cout << x % 2 ;
}
bool checkPrimeNumber(int n)
{
    bool flag = true;
    for(int j = 2 ; j <= n ; ++j)
    {
        if (n % j == 0)
        {
            flag = false;
            break;
        }
    }
    return flag;
}
bool cmp(string last, string first)
{
    if(last.size() < first.size())
        return 1;
    return 0;
}
int calculateDigit(int n)
{
    double temp = (double)(n);
    double a = 0.39908-(0.434294 * n);
    double b = log10( n ) ;
    double c = ( n + 0.5 ) * b ;
    double ans = c - abs( a ) ;
    return ceil(ans) ;
}
int findDigits(int n)
{
    double E = 2.71828182845904523536;
    double PI = 3.141592654;

     if (n < 0)
        return 0;
    if (n <= 1)
        return 1;

    double x = ((n * log10(n / E) +
                 log10(2.0 * PI * n) /
                 2.0));

    return floor(x) + 1;
}
ll fact(ll n){
ll ans = 1 ;
for(ll i = 1 ; i <= n ; ++i)
    ans *= i ;
return ans ;
}
int main()
{
    FastInputOutput() ;
    ll num, digit, a = 0;
    cin >> num ;
    ll temp = num ;

    do{
         digit = num % 10;
         a = (a * 10) + digit;
         num = num / 10;
     } while (num != 0);

     if(a == temp)
        cout << "Yes" << endl ;
     else
        cout << "No" << endl ;
}


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

int main() {
  
  int s1s2s3;
  
  cin >> s1s2s3;
  
  cout << s1s2s3 / 100 + s1s2s3 % 100 / 10 + s1s2s3 % 10 << endl;
}

Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
T, X, Y = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))

t, x, y = 0, 0, 0
ok = True
for i in range(N):
    dt = T[i] - t
    d = abs(x - X[i]) + abs(y - Y[i])
    if not (dt >= d and (dt - d) % 2 == 0):
        ok = False
    t = T[i]
    x = X[i]
    y = Y[i]
if ok:
    print('Yes')
else:
    print('No')


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

using namespace std;

int main() {

	long long n;

	cin >> n;

	int a = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a % 2 == 0 && (a % 3 != 0 && a % 5 != 0)) {
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<vector<int>> Z(N);
  for(int i=1;i<N;i++){
    int x;
    cin >> x;
    Z.at(x-1).push_back(i+1);
  }
  for(int i=0;i<N;i++)
    cout << Z.at(i).size() << endl;
  
}

Measured memory_bytes: 14032
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    int n;
    cin >> n;
    int ans = 0;
    for(int i=1; i<n; i++){
        if(pow(2,i)>n){
            ans = pow(2,i);
            break;
        }
    }
    if(n==1){
        cout << 1 <<endl;
    }else{
        cout << ans/2 <<endl;
    }
}

Measured memory_bytes: 4048
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const double PI = 3.1415926535897932384626433832795;
const int mod = 1000000007;
int n;
vector<vector<int>> g;

void dfs(vector<int> &d, int cur, int depth ,int pre = -1) {
  d[cur] = depth;
  depth++;
  for (int v: g[cur]) {
    if (v == pre) continue;
    dfs(d, v, depth, cur);
  }
}

int main() {
  int n, u, v;
  cin >> n >> u >> v;
  --u; --v;
  g.resize(n);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<int> tdist(n), adist(n);
  dfs(tdist, u, 0);
  dfs(adist, v, 0);

  int goal = -1;
  int dist = -1;
  rep(i, n) {
    int curdist = adist[i];
    if (tdist[i] < adist[i] && curdist >= dist) {
      
      goal = i;
      dist = curdist;
    }
  }
  dist--;
  cout << dist << endl;


}

Measured memory_bytes: 14612
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll gcd(ll n,ll m){
    n = max(n,m);
    m = min(n,m);
    if(n%m == 0)return m;
    return gcd(m,n%m);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int main(){
    int n,q;cin >> n >> q;
    string s;cin >> s;
    int memo[100001];
    int sum = 0;
    rep(i,n-1){
        if(s[i] == 'A' && s[i+1] == 'C')sum++;
        memo[i+1] = sum;
    }
    rep(i,q){
        int l,r;
        cin >> l >> r;
        l--;r--;
        cout << memo[r]-memo[l] <<endl;
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
inline long long read();
using namespace std;
int main()
{
	string s;cin>>s;
	int ans=0;
	for(int i=0;i<s.length();i++)
	{
		ans+=s[i]-'0';
	}
	if(s.length()>1)ans=max(ans,(int)(s.length()-1)*9+s[0]-'1');
	if(s.length()==1)ans=max(ans,(int)s[0]-'0');
	cout<<ans;
}

Measured memory_bytes: 256
/*input
3
1000000 999999 999998
*/

// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{ll res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(ll* a, ll* b){shuffle(a,b,grndm);}

ll n; 
map<ll,ll> p; 

void insert(ll val) {
	ll sq = sqrtl(val) + EPS;
	for(ll i = 2; i <= sq; i++) {
		ll cnt = 0;
		while(!(val % i)) {
			cnt++;
			val /= i;
		}
		if(cnt) {
			p[i] = max(p[i], cnt);
		}
		if(val == 1) {
			break;
		}
	}
	if(val > 1) {
		p[val] = max(p[val], (ll)1);
	} 
}

vector<ll> v;

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	cin >> n;
	for(ll i = 0; i < n; i++) {
		ll a; cin >> a;
		v.push_back(a);
		insert(a);
	}
	ll lcm = 1;
	for(auto val: p) {
		lcm = (lcm * power(val.first, val.second, MOD)) % MOD;
	}
	ll sum = 0;
	for(auto val: v) {
		sum = (sum + (lcm * power(val, MOD - 2, MOD)) % MOD) % MOD;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		long n = Long.parseLong(br.readLine());

		long ans = modpow(10, n, 1000000007) % 1000000007;
		ans -= 2 * modpow(9, n, 1000000007) % 1000000007;
		ans += modpow(8, n, 1000000007) % 1000000007;
		ans = (ans + 1000000007) % 1000000007;
		System.out.println(ans % 1000000007);
	}

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

Measured memory_bytes: 32432
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;
typedef vector<LL> VEC;


const LL INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}

LL kaijo(LL n){
    LL ans=1;
    for(LL i=1;i<=n;++i){
        (ans*=i)%=MOD;
    }
    return ans;
}


int main(){
    LL n;
    cin>>n;
    LL by4=0,by2=0,by1=0;
    for(int i=0;i<n;++i){
        LL a;
        cin>>a;
        if(a%4==0)by4++;
        else if(a%2==0)by2++;
        else by1++;
    }
    if((by2==0&&by1<=by4+1)||(by2>0&&by1<=by4))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

// ===============================================================================

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

  // s…0だったらどうなるか
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    v[i] -= (i + 1);
  }
  sort(v.begin(), v.end());

  ll b = v[v.size() / 2], ans = 0;
  for (int i = 0; i < n; i++) {
    ans += abs(v[i] - b);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int N;
    read(N);

    bool disable[105][105] {};
    reps(i, 1, N) disable[i][i] = true;

    int j = N - (N&1);
    reps(i, 1, N) {
        if (j < 0) break;
        disable[i][j--] = true;
    }

    print((N * N + 1) / 2 - N);
    reps(i, 1, N) reps(j, i+1, N) {
        if (!disable[i][j]) print(i, j);
    }

    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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N;
  cin >> N;
  vector<int> vec(N);
  REP(i, N) {
    cin >> vec[i];
  }
  int m = vec[0];
  int ans = 0;
  REP(i, vec.size()) {
    if (vec[i] >= m) {
      ans++;
    }
    m = max(m, vec[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,a,b,c;
  cin >> N;
  
  a=N/100;
  b=N%100/10;
  c=N%100%10;
  if(a==7||b==7||c==7){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
}

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

using namespace std;

int main(void) {
  string str;
  int i, answer;
  // get input
  cin >> str;
  // count rainy day
  answer = 0;
  for(i = 0; i < str.size(); i++) {
    if(str[i] == 'R') {
      answer++;
      if(i > 0 && str[i-1] == 'S') {
        answer = 1;
      }
    }
  }
  // disp answer
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int a, b, c, d, x, y;

signed main() {
	cin >> a >> b >> c >> d;
	x = c-a, y = d-b;
	cout << c-y << ' ' << d+x << ' ' << a-y << ' ' << b+x << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

void insertionSort(int *,int );
void trace(int *, int);
int main() {
  int N,i ,j;
  int A[1000];
  scanf("%d",&N);
  for(i = 0; i < N; i++)
    scanf("%d",&A[i]);
  trace(A,N);
  insertionSort(A,N);
  return 0;
}
void trace(int A[],int N){
  int i;
  for(i = 0; i < N; i++){
    if(i > 0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}

void insertionSort(int A[],int N){
  int j,k,key;
  for(j = 1; j < N; j++){
    key = A[j];
    k = j - 1;
    while(k >= 0 && A[k] > key){
      A[k+1] = A[k];
      k--;
    }
    A[k+1] = key;
    
    trace(A,N);
  }
}




Measured memory_bytes: 2048
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

ll n, m;

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

    ll swp = n; n = min(n, m); m = max(swp, m);

    if(n == 1){
        if(m == 1) cout << 1 << endl;
        else cout << m - 2 << endl;
    }
    else{ cout << (n - 2) * (m - 2) << endl; }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int D[200001];
pair<int, int> E[400001];
int H[200001];
void dfs(int A, int B) {
	if (D[A] == 0) {
		D[A] = B;
		for (int k = H[A]; k; k = E[k].second) {
			dfs(E[k].first, B + 1);
		}
	}
}


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


	int N;
	cin >> N;
	int k = 1;
	rep(i, N - 1) {
		int a, b;
		cin >> a >> b;
		E[k] = mp(a, H[b]);
		H[b] = k;
		k++;
		E[k] = mp(b, H[a]);
		H[a] = k;
		k++;
	}

	dfs(1, 1);
	int saidai = 0;
	rep1(i, N) {
		if (saidai < D[i]) {
			saidai = D[i];
			k = i;
		}
	}

	memset(D, 0, sizeof(D));
	dfs(k, 1);
	saidai = 0;
	rep1(i, N) saidai = max(saidai, D[i]);
	saidai++;

	if (saidai % 3 == 0) co("Second");
	else co("First");

	cin >> N;

	Would you please return 0;
}

Measured memory_bytes: 11264
/*input
abracadabra
avadakedavra
*/

//sometimes it's the people who no one imagines anything of 
//who do the things that no one can imagine.

//code author: iamxlr8

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define N 300005
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() 
{
    off;
    string s,t;
    cin>>s>>t;
    ll m=s.size();
    ll n=t.size();
    ll dp[m+1][n+1];
    for(ll i=0;i<=m;i++)
    {
        for(ll 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]);
        }
    }

    ll len=dp[m][n];
    string ans="";
    ll i=m,j=n;
    while(len>0&&i>0&&j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans+=s[i-1];
            len--;
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        {
            i--;
        }
        else
        {
            j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}

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


int main (){

string s;
  
  cin>>s;
  
  for(int i=0;i<s.size();i++){
	if(i%2==0&&(s.at(i)=='R'||s.at(i)=='U'||s.at(i)=='D')){
    }
    else if(i%2==1&&(s.at(i)=='L'||s.at(i)=='U'||s.at(i)=='D')){
    }
    
   else{
     cout<<"No"<<endl;
     exit(0);

   }
    
  }
  
  cout<<"Yes"<<endl;
  
}


Measured memory_bytes: 256
import java.util.BitSet;
import java.util.HashMap;
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        BitSet gdp = gdp(300000);
        while(true){
            int n = in.nextInt();
            if(n == 1) return;
            StringBuilder sb = new StringBuilder();
            sb.append(n+": ");
            for(int i=gdp.nextSetBit(0); i!=-1 && i<=n; i=gdp.nextSetBit(i+1)){
                if(n%i==0) sb.append(i+" ");
            }
            System.out.println(sb.toString().trim());
        }
    }
     
    public static BitSet gdp(int max){
        BitSet gdn = new BitSet(max+1);
        for(int i=1; i<=max; i++){
            int mod = i%7;
            if(mod == 6 || mod == 1) gdn.set(i);
        }
        BitSet gdp = (BitSet)gdn.clone();
        gdp.clear(1);
        for(int i=gdn.nextSetBit(2); i!=-1; i=gdn.nextSetBit(i+1)){
            for(long j=gdn.nextSetBit(2); j!=-1 && j*i<=max; j=gdn.nextSetBit((int)j+1)){
                gdp.clear((int)j*i);
            }
        }
        return gdp;
    }
}

Measured memory_bytes: 31416
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int n,m,i;
  ll x[100005]={},y[100005]={},xs,ys;
  const int mod=1e9+7;
  
  cin >> n >> m;
  for (i=0;i<n;i++) cin >> x[i];
  for (i=0;i<m;i++) cin >> y[i];
  
  xs=0;
  for (i=1;i<n;i++) xs=(xs+(x[i]-x[i-1])*i%mod*(n-i)%mod)%mod;
  
  ys=0;
  for (i=1;i<m;i++) ys=(ys+(y[i]-y[i-1])*i%mod*(m-i)%mod)%mod;
  
  cout << xs*ys%mod << endl;
  
  return 0;
}

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

using ll = long long;

void read(){

}

template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}

template<typename T>
void read_vec(vector<T>& v, size_t n){
    for(size_t i = 0; i < n; i++){
        T t;
        cin >> t;
        v.push_back(t);
    }
}

int main(){
    ll a;
    string s;
    read(a, s);
    if(a >= 3200) {
        cout << s;
    }
    else {
        cout << "red";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


const int INF = INT_MAX;

void solve( int n ) {
    int A[n+1], K[n+1], T[n+1];
    int BG[n+1];
    for ( int i = 0; i <= n; ++ i ) {
        A[i] = 5 * i;
    }
    for ( int i = 0; i <= n; ++ i ) {
        K[i] = ( i % 5 == 1 ) ? 5 : 2;
    }
    for ( int i = 0; i <= n; ++ i ) {
        T[i] = 17 * ( i % 2 ) + 3 * ( i % 3 ) + 19;
    }
    int U[17]; 
    fill( U, U+17, -1 );
    queue <int> Q;
    int cnt = 0;
    bool used[n+1];
    fill( used, used+n+1, false );
    for ( int t = 0; cnt <= n; ++ t ) {
        for ( int i = 0; i <= n; ++ i ) {
            if ( A[i] <= t ) {
                Q.push( i );
                A[i] = INF;
                BG[i] = t;
            }
        }
        for ( int i = 0; i < 17; ++ i ) {
            if ( U[i] == -1 ) continue;
            int id = U[i];
            if ( T[id] <= t ) {
                U[i] = -1;
                if ( ! used[id] ) {
                    cnt ++;
                    used[id] = true;
                }
            }
        }
        while ( ! Q.empty() ) {
            int id = Q.front();
            int k = K[id];
            bool flag2 = false;
            for ( int i = 0; i + k - 1 < 17; ++ i ) {
                bool flag = true;
                for ( int j = 0; j < k; ++ j ) {
                    if ( U[i+j] != -1 ) flag = false;
                }
                if ( flag ) {
                    for ( int j = 0; j < k; ++ j ) {
                        U[i+j] = id;
                    }
                    if ( n == id ) {
                        cout << t - BG[id] << endl;
                        return;
                    }
                    T[id] += t;
                    Q.pop();
                    flag2 = true;
                    break;
                }
            }
            if ( ! flag2 ) break;
        }
    }
    cout << endl;
}

int main() {
    int n;
    while ( cin >> n ) solve( n );
    return 0;
}

Measured memory_bytes: 0
# ['表面', '南面', '東面', '西面', '北面', '裏面']
dice1 = [int(d) for d in input().split()]
Q = int(input())

R1 = [
    [0, 1, 2, 3, 4, 5], # 移動なし
    [3, 1, 0, 5, 4, 2], # 東へ1
    [2, 1, 5, 0, 4, 3], # 西へ1
    [4, 0, 2, 3, 5, 1], # 南へ1
    [1, 5, 2, 3, 0, 4], # 北へ1
    [5, 4, 2, 3, 1, 0]  # 北へ2
]

R2 = [0, 3, 1, 4, 2, 5] # 水平回り1

for _ in range(Q):
    F, S = map(int, input().split())
    for r1 in R1:
        dice2 = [dice1[i] for i in r1]
        for _ in range(4):
            dice2 = [dice2[i] for i in R2]
            if dice2[0] == F and dice2[1] == S:
                print(dice2[2])


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

int main(){
  int N;
  int W[110];
  int sum=0;
  
  cin >> N;
  for(int i=0;i<N;++i){
    cin >> W[i];
    sum += W[i];
  }
  
  int S1=0;
  int res=100000;
  
  for(int i=0;i<N;++i){
    S1 += W[i];
    if(res > abs( (sum - S1)-S1)) res=abs(sum-2*S1);
  }
  
  cout << res << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;
const int INF=1001001001;

int main() {
  string s;
  int64_t k;
  cin>>s>>k;
  int t=0;char r; 
  for(int i=0;i<s.size();i++){
    if(s[i]!='1'){t=i;r=s[i];break;}
  }
  if(t+1<=k){cout<<r<<endl;}
  else{cout<<1<<endl;}
  return 0;  
}

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, r = 1, st = 0;//-1 dec, 0 sin, 1 cre
    cin >> n;
    vector<int> d(n);
    for (int &i : d) cin >> i;
    for (int i = 1; i < n; i++) {
        if (st != 0 && (st > 0 && d[i] < d[i-1] || st < 0 && d[i] > d[i-1])) {st = 0, r++; continue;}
        if (d[i] > d[i-1] && !st) st = 1;
        else if (d[i] < d[i-1] && !st) st = -1;
    }
    cout << r << "\n";
    return 0;
}

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

using namespace std;

const int kMaxN = 100000;

long long dp1[kMaxN + 1], max1[kMaxN + 1];
long long dp2[kMaxN + 1], max2[kMaxN + 1];
long long dp3[kMaxN + 1], max3[kMaxN + 1];
long long dp4[kMaxN + 1], max4[kMaxN + 1];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	vector<pair<long long, long long> > v;
	int n;
	long long c;
	cin >> n >> c;
	for (int i = 0; i < n; ++i) {
		long long a, b;
		cin >> a >> b;
		v.push_back(make_pair(a, b));
	}
	long long sum = 0;
	long long last_pos = 0;
	long long maxx1 = 0, maxx2 = 0, maxx3 = 0, maxx4 = 0;
	for (int i = 0; i < n; ++i) {
		sum += v[i].second - (v[i].first - last_pos);
		dp1[i] = sum;
		last_pos = v[i].first;
		dp3[i] = dp1[i] - v[i].first;
		maxx1 = max(maxx1, dp1[i]);
		maxx3 = max(maxx3, dp3[i]);
		max1[i] = maxx1;
		max3[i] = maxx3;
	}
 	sum = 0;
	last_pos = c;
	long long ans = 0;
	for (int i = n - 1; i >= 0; --i) {
		sum += v[i].second - (last_pos - v[i].first);
		dp2[i] = sum;
		last_pos = v[i].first;
		dp4[i] = dp2[i] - (c - v[i].first);
		maxx2 = max(maxx2, dp2[i]);
		maxx4 = max(maxx4, dp4[i]);
		max2[i] = maxx2;
		max4[i] = maxx4;
	}
	for (int i = 0; i < n - 1; ++i) {
		ans = max(ans, max(max1[i] + max4[i + 1], max2[i + 1] + max3[i]));
	}
	ans = max(ans, max(max1[n - 1], max2[0]));
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 8176
#include <iostream>
#include <vector>
#include <set>
#include <map>

#pragma GCC optimize ("-O3")
#define rep(i, initial_value, max_value) for (int i{initial_value}; i < max_value; ++i)
#define fore(i, a) for(auto &i:a)
#define each(i, c) \
  for( \
      __typeof((c).begin()) i{(c).begin()}, __typeof((c).end()) end{(c).end()}; \
      i != end; \
      ++i \
  )
#define dbg(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()

using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
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; }

// ===

void _main() {
  ll n;
  cin >> n;

  ll ans;
  if (n % 2 == 0) {
    ans = n / 2 - 1;
  } else {
    ans = (1 + n) / 2 - 1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 888
#include <stdio.h>
#include <string.h>
int main(void) {
    int cnum,snum,i;
    char dic[62],be,af,str;
    while (1) {
        scanf("%d\n",&cnum);
        if (cnum==0) break;
        for (i=0; i<62; i++) dic[i]='.';
        for (i=0; i<cnum; i++) {
            scanf("%c %c\n",&be,&af);
            if (isdigit(be)!=0) {
                dic[be-'0']=af;
            } else if (islower(be)!=0) {
                dic[be-'a'+10]=af;
            } else {
                dic[be-'A'+36]=af;
            }
        }
        scanf("%d\n",&snum);
        for (i=0; i<snum; i++) {
            scanf("%c\n",&str);
            if (isdigit(str)!=0) {
                if(dic[str-'0']!='.') str=dic[str-'0'];
            } else if (islower(str)!=0) {
                if(dic[str-'a'+10]!='.') str=dic[str-'a'+10];
            } else if (isupper(str)!=0) {
                if(dic[str-'A'+36]!='.') str=dic[str-'A'+36];
            }
            printf("%c",str);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 576
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
vector<bool> prime;
void make(int num){
    prime.resize(num,false);
    for(int i=0;i<num;i++){
      if((i+1)%7==1||(i+1)%7==6)prime[i]=true;
    }
    prime[0]=false;
    for(int i=0;i*i<num;i++){
        if(prime[i]){
            for(int j=2;(i+1)*j<=num;j++){
                prime[(i+1)*j-1]=false;
            }
        }
    }
}
int main(){
  make(500000);
  V<ll> tmp;
  for(int i=0;i<300500;i++)if(prime[i])tmp.emplace_back(i+1);
  while(1){
    ll n;
    cin>>n;
    if(n==1)return 0;
    cout<<n<<':';
    for(int i=0;i<tmp.size();i++)if(n%tmp[i]==0)cout<<" "<<tmp[i];
    cout<<"\n";
  }
}


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

bool prime(int x) {
	int c = sqrt(x);
	for (int i = 2;i < c + 1;i++) {
		if (x%i == 0)
			return false;
	}
	return true;
}

vector<int> ans;

void solve(int N) {
	int a = 11;
	while (1) {
		if (prime(a)) {
			ans.push_back(a);
		}
		a += 20;
		if (ans.size() == N)
			break;
		if (prime(a)) {
			ans.push_back(a);
		}
		a += 10;
		if (ans.size() == N)
			break;
	}
	return;
}

int main() {
	int N;
	cin >> N;
	solve(N);
	for (int i = 0;i < N;i++) {
		cout << ans[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>

using namespace std;


int main() {
	string S;

	cin >> S;

	if (S == "ABC") {
		cout << "ARC" << endl;
	}
	else
		cout << "ABC" << endl;
}


Measured memory_bytes: 3104
#include<iostream>

int main(){
	int a, b, c, d;
	std::cin >> a >> b >> c >> d;

	int taka = (a-1) / d;
	int aoki = (c-1) / b;
	if(taka >= aoki){
		std::cout << "Yes" << std::endl;
	}else{
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3572
use std::io::*;
use std::str::FromStr;
use std::cmp::min;
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let a:i32 = read();
    let b:i32 = read();
    let c:i32 = read();
    if a+b==c||a+c==b||b+c==a{
	println!("Yes");
    }else{
	println!("No");
    }
}


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

const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
bool ans[2200]={false};
int main() {
    int n;cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int m;cin >> m;
    for(int bit = 0;bit <(1<<n);bit++){
	int x=0;
	for(int j=0;j<n;j++){
	    if(bit & (1<<j))x += a[j];
	}
	ans[x] = true;
    }
    for(int i=0;i<m;i++){
	int b;cin >> b;
	if(ans[b])printf("yes\n");
	else printf("no\n");
    }	
    
    return 0;
}



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

using namespace std;

using ll = int_fast64_t;
constexpr ll llmax = INT_FAST64_MAX; // std::numeric_limits<int_fast64_t>::max()
constexpr ll llmin = INT_FAST64_MIN; // std::numeric_limits<int_fast64_t>::min()
using ull = uint_fast64_t;
constexpr ull ullmax = UINT_FAST64_MAX; // std::numeric_limits<uint_fast64_t>::max()

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(A);
    scanInt(B);
    scanInt(C);
    if (A == B && B == C){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  	public static int pow1(int a, int b) {
      	long res = a;
      	for( int i = 0; i < b - 1; i++ ) {
          	res = res * a % 1000000007;
        }
      	return (int)res;
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int a = sc.nextInt();
        //if(a > 10) System.exit(1);
      	int i = pow1(10, a);
      	int j = pow1(9, a) * 2 % 1000000007;
      	int k = pow1(8, a);
      	
      	long l = i - j + k;
      	l %= 1000000007;
      	if(l < 0) {
        	l += 1000000007;
        }
        System.out.println(l);
    }
}

Measured memory_bytes: 35632
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}
signed main() {
  int n;
  cin>>n;
int t;
int ans=0;
  rep(i,n){
    cin>>t;
    if(i%2==0){
      if(t%2==1){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> v;
    for (int i = 0; i < n; i++) {
        int z;
        scanf("%d", &z);
        v.push_back(z-1);
    }

    int nowIdx = 0, ct = 0;
    for (;;) {
        if (nowIdx == 1) {
            printf("%d\n", ct);
            break;
        }
        if (ct >= n) {
            printf("-1\n");
            break;
        }
        ct++;
        nowIdx = v[nowIdx];
    }
}

Measured memory_bytes: 892
#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 N,K;
    cin >> N >> K;
    vector<ll> V(N);
    rep(i,N){
        cin >> V[i];
    }

    ll res = 0;
    for(int a = 0; a <= min(N,K); a++){
        for(int b = 0;a+b <= min(N,K); b++){
            vector<ll> v;
            ll sum = 0;
            rep(i,a){
                v.push_back(V[i]);
                sum += V[i];
            }
            rep(j,b){
                v.push_back(V[N-j-1]);
                sum += V[N-j-1];
            }
            sort(v.begin(),v.end());
            rep(i,min(K-a-b,(int)v.size())){
                if(v[i]<0)sum -= v[i];
            }
            res = max(res,sum);
        }
    } 
    cout << res << endl;   
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

    string s;
    cin >> s;

    int i = 0;
    for(i = 0; i < s.length(); i++)
    {
    	s[i] = (s[i] - 65 + n) % 26 + 65;
    }
    cout << s << endl;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    long prev;
    long ans;
    foreach (_; 0 .. N)
    {
        long A = lread();
        if (0 < prev && A != 0)
        {
            ans++;
            A--;
        }
        ans += A / 2;
        prev = A & 1;
    }
    writeln(ans);
}


Measured memory_bytes: 1276
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, p;
  cin >> n >> p;
  vector<long long> a(n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    int w, b;
    cin >> w >> b;
    a[i] = 1LL * (100 - p) * w + 1LL * b * p;
    sum -= 1LL * b * p;
  }
  sort(a.rbegin(), a.rend());
  for (int i = 0; i < n; i++) {
    sum += a[i];
    if (sum >= 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}

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

int main(){
 int n; cin >> n;
 int dp[110000][5];
  dp[0][0] = 0;
  dp[0][1] = 0;
  dp[0][2] = 0;
 vector<int> A,B,C;
  for(int i=0;i<n;i++){
  int a,b,c; cin >> a >> b >> c;
    A.push_back(a);
    B.push_back(b);
    C.push_back(c);
  }
  for(int i=0;i<n;i++){
  	dp[i+1][0] = max(dp[i][1],dp[i][2])+A[i];
  	dp[i+1][1] = max(dp[i][0],dp[i][2])+B[i];
  	dp[i+1][2] = max(dp[i][0],dp[i][1])+C[i];
  }
  cout << max({dp[n][0],dp[n][1],dp[n][2]}) << endl;
}


Measured memory_bytes: 3820
function Main(input: any) {
	const inputs = input.split('\n')
    const nums = inputs[0]
    const values = inputs[1].split(' ')
    const conts = inputs[2].split(' ')

    let val = 0
    for (let i = 0; i<nums; i++) {
		const div = (values[i] - conts[i])
		if (div > 0) {
          val += div
        }
    }
  	console.log(val)
}

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

Measured memory_bytes: 7372
#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<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 100005;
int n;
ll a[MX], sum[MX], res, acu;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	for (int i = 0; i <= n; i++)
		cin >> a[i];

	for (int i = n; i >= 0; i--)
		sum[i] = a[i] + sum[i + 1];

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

		if (a[i] > acu) {
			cout << -1 << endl;
			return 0;
		}

		acu -= a[i];
		acu *= 2;
		acu = min(acu, sum[i + 1]);
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 5216
#include<bits/stdc++.h>
using namespace std;
int jumpsrec(int n,int * arr){
    if(n<=1)return 0;
    int q1 = INT_MAX;
    int q2 = INT_MAX;
    if(n-1>=0){
        q1 = jumpsrec(n-1,arr+1) + abs(arr[1] - arr[0]);
    }
    if(n-2>=0){
        q2 = jumpsrec(n-2,arr+2) + abs(arr[2] - arr[0]);
    }
    return min(q1,q2);
}
int jumpsDP(int n,int * arr,int * dp){
    dp[0] = 0;
    dp[1] = 0;
    int q1 = INT_MAX;
    int q2 = INT_MAX;
    if(dp[n]!=-1){
        return dp[n];
    }
    if(n-1>=0){
        q1 = jumpsDP(n-1,arr+1,dp) + abs(arr[1] - arr[0]);
    }
    if(n-2>=0){
        q2 = jumpsDP(n-2,arr+2,dp) + abs(arr[2] - arr[0]);
    }
    dp[n] = min(q1,q2);
    return dp[n];
}
int main()
{
    int n;
    cin>>n;
    int arr[n],dp[n+1];
    for(int i=0;i<n;i++) cin>>arr[i];
    for(int i=0;i<=n;i++){
        dp[i] = -1;
    }
    cout<<jumpsDP(n,arr,dp);
}

Measured memory_bytes: 5760
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){ll ans=1,l=2;rep(i,0,min(n-r,r)){ans*=(n-i);while(ans%l==0&&l<=min(r,n-r)){ans/=l;l++;}}return ans;}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}//素数の時true
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n; 
 cin>>n;
 ll ans=0;
 for(i=1;i*i<n;i++){
  if(!(n%i)&&n/i!=i+1)ans+=(n/i-1);
 }
 pr(ans);
return 0;}

/*
m*X+X=N
X*(m+1)=N
m+1=N/X
但しm<X

8->1,2,4,8
(8-1)+(4-1)
(8/1-1)+(8/2-1)=10

16->1,2,4,8,16
(16-1)+(8-1)=22

sqrt(n)より大きいの約数pの(p-1)の総和
->sqrt(n)より小さい約数pの(n/p-1)の総和
*/


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

int main(){
  int N, M; cin >> N >> M;
  vector<int> x(M);
  if(N >= M){
    cout << 0 << endl;
    return 0;
  }
  for(int i = 0; i < M; i++) cin >> x[i];
  sort(x.begin(), x.end());
  int ans = x[M - 1] - x[0];
  vector<int> l(M - 1);
  for(int i = 0; i < M - 1; i++){
    l[i] = x[i + 1] - x[i];
  }
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  for(int i = 0; i < N - 1; i++) ans -= l[i];
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        //        int k = sc.nextInt();
        //        ArrayList<Integer> list = new ArrayList<Integer>();
        //
        int c1 = 0;
        int c2 = 0;
        int c3 = 0;
        int c4 = 0;

        for (int i = 0; i < 3; i++) {
            int num = sc.nextInt();

            if (num == 1) {
                c1++;
            } else if (num == 2) {
                c2++;
            } else if (num == 3) {
                c3++;
            } else {
                c4++;
            }

            num = sc.nextInt();

            if (num == 1) {
                c1++;
            } else if (num == 2) {
                c2++;
            } else if (num == 3) {
                c3++;
            } else {
                c4++;
            }

            if (c1 == 3 || c2 == 3 || c3 == 3 || c4 == 3) {
                System.out.println("NO");
                return;
            }
        }

        sc.close();

        System.out.println("YES");

    }
}


Measured memory_bytes: 21844