akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  vector<int> ls(M);
  F0R(i, N) {
    int k;
    cin >> k;
    F0R(j, k) {
      int a;
      cin >> a;
      a--;
      ls[a]++;
    }
  }
  int r = 0;
  F0R(i, M) {
    if (ls[i] == N) r++;
  }
  cout << r;
}
#endif


Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main(void)
{
  int A,B,C,D;
  int left,right;
  
  cin>>A>>B>>C>>D;
  left=A+B;
  right=C+D;

  if(left>right)
    cout<<"Left"<<endl;
  else if(left<right)
    cout<<"Right"<<endl;
  else
    cout<<"Balanced"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    if a == b and b == c:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 5608
import sys
import fractions
input = sys.stdin.readline


mod = 10 ** 9 + 7
N = int(input().strip())
A = list(map(int, input().strip().split(" ")))

lcm = 1
for a in A:
    lcm = a // fractions.gcd(a, lcm) * lcm

print(sum([lcm // a for a in A]) % mod)

Measured memory_bytes: 264632
#include<bits/stdc++.h>
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};

ll gcd(ll a2,ll b2){
	ll t;
	while(b2!=0){
		t=a2%b2;
		a2=b2;
		b2=t;
	}
	return a2;
}
int main() {

	ll x,y;
	cin>>x>>y;
	cout<<gcd(x,y)<<endl;

	return 0;
}



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

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 650055;
const int K = 700 ;
int x[N], y[N], t[N];
vector < int > r[N];
set < int > s1, s2;
map < int, int > mx, my;
vector < pair < int, int > > p;
int sum (int r)
{
	int result = 0;
	for (; r >= 0; r = (r & (r+1)) - 1)
		result = (result + t[r]) % mod;
	return result;
}

void inc (int i, int delta)
{
	for (; i < N; i = (i | (i+1)))
		t[i] = (t[i] + delta) % mod;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> x[i];
    for (int j = 1; j <= m; j++) cin >> y[j];
    int c = 1;
    for (int j = 1; j < m; j++){
        while(x[c] < y[j] && c <= n) c++;
        while(x[c] < y[j + 1] && c <= n){
            p.pb({x[c] - y[j], y[j + 1] - x[c]});
            c++;
        }
    }
    for (auto i: p){
        s1.insert(i.F);
        s2.insert(i.S);
    }
    int cnt1, cnt2;
    cnt1 = 0;
    cnt2 = 0;
    for (auto i: s1){
        cnt1++;
        mx[i] = cnt1;
    }
    for (auto i: s2){
        cnt2++;
        my[i] = cnt2;
    }
    for (int i = 0; i < p.size(); i++){
        p[i].F = mx[p[i].F];
        p[i].S = my[p[i].S];
        r[p[i].S].pb(p[i].F);
    }
    inc(0, 1);
    for (int i = 1; i <= cnt2; i++){
        sort(r[i].begin(), r[i].end());
        r[i].erase(unique(r[i].begin(), r[i].end()), r[i].end());
        reverse(r[i].begin(), r[i].end());
        for (auto j: r[i]){
            inc(j, sum(j - 1));
        }
    }
    cout << sum(cnt1);
}


Measured memory_bytes: 49008
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;
	std::vector<LL>a(N);
	rep(i, N) in >> a[i];

	bool lose = true;
	rep(i, N)
	{
		if (a[i] % 2 == 1)
		{
			lose = false;
			break;
		}
	}
	out << (lose ? "second" : "first") << std::endl;
}


Measured memory_bytes: 1152
#encoding=utf-8

import sys
import math
printf = sys.stdout.write

while True:
    new_mean = 0
    x = input()
    if x == 0:
        break

    exam = map(int, raw_input().split())
    ave = float(sum(exam))/len(exam)

    for i in range(len(exam)):
        mean = ((exam[i] - ave)**2)
        new_mean += mean/len(exam)
        
    print math.sqrt(new_mean)

Measured memory_bytes: 6524
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    x, a, b = gets.chomp.split.map(&:to_i)

    if b <= a
      puts "delicious"
    elsif b - a <= x
      puts "safe"
    else
      puts "dangerous"
    end
  end
end

if __FILE__ == $0
  Solver.new.main
end


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

int p[10][10]={0};
int h,w,c;
int count_max=0;
int maxx;

void count_panel(int x, int y, int p[10][10]){
	int prev=p[x][y];
	p[x][y] = 0;
	maxx++;
	if(p[x-1][y]==prev) count_panel(x-1,y,p);
	if(p[x][y-1]==prev) count_panel(x,y-1,p);
	if(p[x+1][y]==prev) count_panel(x+1,y,p);
	if(p[x][y+1]==prev) count_panel(x,y+1,p);
}

void change_color(int color, int x, int y, int p[10][10]){
	int prev=p[x][y];
	p[x][y]=color;
	if(p[x-1][y]==prev) change_color(color,x-1,y,p);
	if(p[x][y-1]==prev) change_color(color,x,y-1,p);
	if(p[x+1][y]==prev) change_color(color,x+1,y,p);
	if(p[x][y+1]==prev) change_color(color,x,y+1,p);
}

void change_panel(int color, int p[10][10],int count){
	int p2[10][10]={0};
  int i,j;
	for(i=1;i<=h;i++) for(j=1;j<=w;j++) p2[i][j]=p[i][j];
	if(!count){
		maxx=0;
		if(p2[1][1]!=c)change_color(c,1,1,p2);
		count_panel(1,1,p2);
		if(count_max<maxx) count_max=maxx;
		return;
	}
  if(p2[1][1]!=color) change_color(color,1,1,p2);
	for(i=1;i<=6;i++) change_panel(i,p2,(count-1));
}


int main(){
	int i,j;

	while(cin>>h, cin>>w,	cin>>c, h!=0){
	 	count_max=0;
		for(i=0;i<10;i++) for(j=0;j<10;j++) p[i][j]=0;
		for(i=1;i<=h;i++) for(j=1;j<=w;j++) cin>>p[i][j];
		for(i=1;i<=6;i++) change_panel(i,p,4);
		cout<<count_max<<endl;
	}
	return 0;
}

Measured memory_bytes: 872
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

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

    cout << n * n * n << endl;
}

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 MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

ll gcd(ll a, ll b){
  if (a%b == 0){
    return(b);
  }else{
    return(gcd(b, a%b));
  }
}
ll lcm(ll a, ll b){
  return a * (b / gcd(a, b));
}

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

  vector<ll> T(N);
  REP(i, N) cin >> T[i];
  
  ll ans = T[0];
  REP(i,N){
    ans = lcm(ans,T[i]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
int x[4],y[4];
  cin>>x[0]>>y[0]>>x[1]>>y[1];
  int a=(y[1]-y[0]);
  int b=(x[1]-x[0]);
 // cout<<b<<endl;
  x[2]=x[1]-a;
  y[2]=y[1]+b;
  x[3]=x[2]-b;
  y[3]=y[2]-a;
  rep(i,2,4){
   cout<<x[i]<<" "<<y[i]<<" "; 
  }
  cout<<endl;
}










Measured memory_bytes: 256
#include <stdio.h>

void insertionSort(int A[1001], int N) {
    int i, j;
    int v;

    for (i = 1; i < N; i++) {
        for (j = 0; j < N; j++) {
            printf("%d", A[j]);
            if (j != N-1)
                printf(" ");
            else
                printf("\n");
        }

        v = A[i];
        j = i-1;
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
    }
}

int main() {
    int N, A[1001];
    int i;

    scanf("%d", &N);

    for (i = 0; i < N; i++)
        scanf("%d", &A[i]);

    insertionSort(A, N);

    for (i = 0; i < N; i++) {
        printf("%d", A[i]);
        if (i != N-1)
            printf(" ");
        else
            printf("\n");
    }

    return 0;
}

Measured memory_bytes: 1788
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
ll gcd(ll a,ll b){//最大公約数
	if(b==0)return a;
	return gcd(b,a%b);
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int N;
	cin>>N;
	VI A(N);
	REP(i,N)cin>>A[i];
	SORT(A);
	ll B;
	int co=0;
	FOR(i,1,N){
			if(A[i]%A[0]>co){
				B=A[i];
				co=A[i]%A[0];
			}
		if(i==N-1 && co==0)B=A[i];
	}
	ll ans=gcd(A[0],B);
	cout<<ans<<endl;
	return 0;
}




















Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String[] s = readLine().split(" ");
		int a = Integer.parseInt(s[0]);
		int b = Integer.parseInt(s[1]);
		if(b%a==0){
			System.out.println(a+b);
		}else{
			System.out.println(b-a);
		}
		return;
	}

	private static String readLine(){
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try{
			return reader.readLine();
		}catch(Exception e){
			return e.getMessage();
		}
	}
}


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


int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif

	int n,k;
	cin>>n>>k;
	int dp[n];
	int h[n];
	for(int i=0; i<n; i++)
	{
		int temp;
		cin>>temp;
		h[i] = temp;	
	}
	dp[0] = 0;
	for(int i=1; i<n; i++)
	{
		int l = INT_MAX;
		for(int j=1; j<=k;j++)
		{
			if(i-j>=0)
			{
				l = min(l, dp[i-j]+abs(h[i-j]-h[i]));
			}
			else
				break;
		}
		dp[i] = l;
	}
	// for (int i = 0; i < n; ++i)
	// {
	// 	cout<<i<<" "<<h[i]<<" "<<dp[i]<<endl;
	// }
	cout<<dp[n-1];

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  vector<int> b;
  for (int i = 0; i < N; i++){
    b.push_back(a[i]);
    if (i >= 2){
      if (b[b.size() - 3] == b[b.size() - 2] && b[b.size() - 2] == b[b.size() - 1]){
        b.pop_back();
      }
    }
  }
  int M = b.size();
  array<int, 5> cnt{0, 0, 0, 0, 0};
  for (int i = 0; i < M - 3; i++){
    if (b[i] < b[i + 1] && b[i + 1] == b[i + 2] && b[i + 2] > b[i + 3]){
      cnt[0]++;
    }
    if (b[i] > b[i + 1] && b[i + 1] == b[i + 2] && b[i + 2] < b[i + 3]){
      cnt[1]++;
    }
    if (b[i] < b[i + 1] && b[i + 1] == b[i + 2] && b[i + 2] < b[i + 3]){
      cnt[2]++;
    }
    if (b[i] > b[i + 1] && b[i + 1] == b[i + 2] && b[i + 2] > b[i + 3]){
      cnt[2]++;
    }
  }
  for (int i = 0; i < M - 2; i++){
    if (b[i] < b[i + 1] && b[i + 1] > b[i + 2]){
      cnt[3]++;
    }
    if (b[i] > b[i + 1] && b[i + 1] < b[i + 2]){
      cnt[4]++;
    }
  }
  cout << cnt[0] << ' ' << cnt[1] << ' ' << cnt[2] << ' ' << cnt[3] << ' ' << cnt[4] << endl;
}


Measured memory_bytes: 3828
#include <iostream>

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

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N) {
  cout << N*N*N << endl;
}

int main() {
  ll N;
  cin >> N;
  solve(N);
  return 0;
}


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

using namespace std;
#define BUF (100005)
#define ll long long 

ll n,c;

ll dp_r[BUF];
ll dp_l[BUF];

ll x[BUF];
ll v[BUF];

ll ans = 0;

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

	for(int i = 1; i<=n; i++){
		cin >> x[i] >> v[i];
	}

	//rotate tokei
	ll sum=0;
	dp_r[0] = 0;
	for(int i=1; i<=n;i++){
		sum+=v[i];
		dp_r[i] = max( dp_r[i-1] , sum - x[i]);
	}

	//rotate han-tokei
	sum=0;
	dp_l[n+1]=0;
	for(int i=n;i>0;i--){
		sum+=v[i];
		dp_l[i] = max(dp_l[i+1], sum - (c-x[i]));
	}
	ans = max(dp_r[n], dp_l[1]);

	//rotate tokei to i and reverse.
	sum = 0;
	for(int i=1;i<n;i++){
		sum+=v[i];
		ll tmp = sum-2*x[i] + dp_l[i+1];
		ans = max(tmp,ans);
	}

	//rotate han-tokei to i and reverse.
	sum = 0;
	for( int i=n;i>1;i--){
		sum+=v[i];
		ll tmp = sum-2*(c-x[i]) + dp_r[i - 1];
		ans = max(tmp,ans);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
#define mod 200003
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using vvb=vector<vector<bool>>;
using vb= vector<bool>;
ll f(ll a,ll b,ll p){
	if(b==0) return 1;
	if(b%2==0){
		ll t=f(a,b/2,p);
		return t*t%p;
	}
	return a*(f(a,b-1,p))%p;
} 

//__builtin_popcount()
signed main(){
	ll n, x; cin>>n>>x;
	vl a(n);
	rep(i,0,n)cin>>a[i];
	ll ans=0;
	rep(i,1,n){
		if(a[i-1]+a[i]>=x){
			ll k=a[i-1]+a[i]-x;
			ans+=k;
			if(a[i]>=k)a[i]-=k;
			else{
				k-=a[i];
				a[i]=0;
				a[i-1]-=k;
			}
		}
	}
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 4048
#エイシング プログラミング コンテスト 2019 -C Alternating Path
"""
s(#に限る),g(.に限る)の座標を任意に定めたとき、
4近傍で#.#.#.と交互に移動できるものの数を求めよ
(但し、s,gが同一でそのような道が複数あっても、1つしかカウントしない)
各#から何回.を通れるかをdfsで求めれば良い。
ちなみに、その時に#を通れば、その#は今dfsを行っている#と同じだけの組み合わせ
を持つので、端折って良い。
"""
import sys
from collections import deque
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
H,W = map(int,readline().split())
maze = []
for _ in range(H):
    maze += [list(readline().rstrip().decode())]
used = [[0]*W for _ in range(H)]
def dfs(y,x):
    white = 0
    black = 1
    deq = deque([(y,x)])
    used[y][x] = 1
    while deq:
        fr = deq.pop()
        for go in [(0,1),(1,0),(0,-1),(-1,0)]:
            if 0 <= fr[0]+go[0] < H and 0 <= fr[1]+go[1] < W:
                if not used[fr[0]+go[0]][fr[1]+go[1]]:
                    if maze[fr[0]][fr[1]] != maze[fr[0]+go[0]][fr[1]+go[1]]:
                        deq.append((fr[0]+go[0],fr[1]+go[1]))
                        used[fr[0]+go[0]][fr[1]+go[1]] = 1
                        if maze[fr[0]+go[0]][fr[1]+go[1]] == ".":
                            white += 1
                        else:
                            black += 1
    
    return white * black
ans = 0
for i in range(H):
    for j in range(W):
        if not used[i][j] and maze[i][j] == "#":
            ans += dfs(i,j)

print(ans)

Measured memory_bytes: 55516
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
  cin >> a;
    vector<int> A(a);
    for(int i = 0;i<a;i++){
        cin >> A.at(i);
        if(A.at(i) == i+1)
            A.at(i) = 0;
        else    
            A.at(i) = 1;
    }
    int count = 0;
    for(int i = 0;i<a;i++)
        count += A.at(i);
    if(count == 0 || count == 2)
        cout << "YES" << endl;
    else
    {
        cout << "NO" << endl;
    }
    
    

}


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

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		String s=sc.next();
		if(s.equals("ABC"))System.out.println("ARC");
		else System.out.println("ABC");
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
		public int[] nextArr(int n) throws IOException{
			int arr[]=new int[n];
			for(int i=0;i<n;i++)arr[i]=nextInt();
			return arr;
		}

	}
}

Measured memory_bytes: 25428
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <complex>
using namespace std;
#define INF 100000000

typedef long long ll;
typedef complex<double> xy_t;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
xy_t P[110];
double cross_product(xy_t a, xy_t b) {return (conj(a)*b).imag();}

int main(void) {
    int N = 0;
    double x, y;
    while (~scanf("%lf,%lf", &x, &y)) {
        P[N++] = xy_t(x, y);
    }
    double sum = 0.0;
    for (int i = 0; i+2 < N; i++) {
        xy_t a = P[0], b = P[(i+1)%N], c = P[(i+2)%N];
        xy_t x = b-a, y = c-a;
        sum += abs(cross_product(x, y));
    }
    printf("%.10lf\n", abs(sum) / 2);
    return 0;
}

Measured memory_bytes: 1228
n = int(input())
s = input()
count1 = 0  # (
count2 = 0  # )
ans = s
for i in range(n):
    if s[i] == "(":
        count1 += 1
    else:
        if count1 > 0:
            count1 -= 1
        else:
            count2 += 1

print("("*count2 + s + ")"*count1)

Measured memory_bytes: 38512
package main

import (
	"fmt"
	"math"
)

func main() {
	var x int
	fmt.Scanf("%d", &x)

	year := 0
	total := 100.0
	for total < float64(x) {
		total = math.Floor(total * 1.01)
		year++
	}

	fmt.Printf("%d\n", year)
}

Measured memory_bytes: 1824
#include <stdio.h>

int main(void)
{
    char acronym[4];
    for (int i = 0; i < 3; i++)
    {
        char str[11];
        if (scanf("%s", str) != 1) return 1;
        char initial = str[0];
        if (initial >= 'a' && initial <= 'z')
            initial -= 'a' - 'A';
        acronym[i] = initial;
    }
    acronym[3] = '\0';

    puts(acronym);

    return 0;
}


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

using namespace std;

int main()
{
    int n1,n2,n3;
    scanf("%d %d %d",&n1,&n2,&n3);
    if(n1==n2)
        printf("%d",n3);
    else if(n1==n3)
        printf("%d",n2);
    else if(n2==n3)
        printf("%d",n1);

    /*
    long long int ans=0;
    int a,b;
    scanf("%d %d",&a,&b);
    int A[b],B[a];
    fill(A,A+b,a);
    fill(B,B+a,b);
    if(a>b)
    {
        int i=0;
        for(i;i<b;i++)
        {
            ans+=(A[i]-B[a]);
        }
        for(i;i<a;i++)
        {
            ans+=B[i];
        }
        printf("%lld",ans);
    }
    else if(b>a)
    {
        int i=0;
        for(i;i<a;i++)
        {
            ans+=(A[i]-B[a]);
        }
        for(i;i<b;i++)
        {
            ans-=B[i];
        }
        printf("%lld",ans);
    }
    else
        printf("0");
    /*
    int n;
    scanf("%d",&n);
    string x;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x[x.size()-1]=='s'||x[x.size()-1]=='o'||x[x.size()-1]=='x'||(x[x.size()-1]=='h'&&x[x.size()-2]=='c'))
        {
            cout<<x<<"es"<<endl;
        }
        else if(x[x.size()-1]=='f')
        {
            for(int i=0;i<x.size()-1;i++)
                cout<<x[i];

            cout<<"ves"<<endl;
        }
        else if(x[x.size()-1]=='e'&&x[x.size()-2]=='f')
        {
            for(int i=0;i<x.size()-2;i++)
                cout<<x[i];
            cout<<"ves"<<endl;
        }
        else if(x[x.size()-1]=='y')
        {
            for(int i=0;i<x.size()-1;i++)
                cout<<x[i];
            cout<<"ies"<<endl;
        }
        else
            cout<<x<<"s"<<endl;

        //cout<<">>"<<x<<endl;
    }
    /*
    int n;
    scanf("%d",&n);/*
    for(int i=2;i<=n;i+=4,c++)
        cout<<i<<"  "<<c<<endl;

    int c=2,x=1;
    while(c+3<=n)
    {
        c+=3;
        x++;
    }
    printf("%d",x);
    /*
    if(n%10==9)
    {
       // cout<<"00"<<endl;
       n++;
        stringstream x;
        x<<n;
        string c;
        x>>c;
        for(int i=0;i<c.size();i++)
            if(c[i]=='0')
                c[i]='1';
        cout<<c;
    }
    else
        printf("%d",n+1);
    /*
    string x;
    cin>>x;
    if(x.size()%2==0)
        printf("Or not.");
    else
        printf("Odd.");
    /*
        if(x[0]-'0'==9)
            {
                x[0]='9';
                for(int i=1;i<x.size();i++)
                    {
                        if(x[i]-'0'>4) x[i]=(9-(x[i]-'0'))+'0';
                    }
            }
            else
            {
                for(int i=0;i<x.size();i++)
                    {
                         if(x[i]-'0'>4) x[i]=(9-(x[i]-'0'))+'0';
                    }
            }
    cout<<x;*/
    return 0;
}


Measured memory_bytes: 256
from math import ceil
n, k = map(int, input().split())
a = list(map(int, input().split()))
def c(x):
    cnt=0
    for i in a:
        cnt += i // x
    return cnt<=k
l, r = 0, max(a)
for i in range(100):
    mid = (l + r) / 2
    if c(mid):
        r = mid
    else:
        l = mid
print(ceil(l))

Measured memory_bytes: 93860
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector <int> a(N);
  for (int i=0; i<N; i++) {
    cin >> a.at(i);
  }
  
  int k = 0;
  int c = 0;
  int s = 1;
  while (k<N) {
    s = a.at(s-1);
    if (s == 2) {
      c = k+1;
      break;
    }
    k++;
  }
  
  if (c > 0) {
    cout << c << endl;
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 640
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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 (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

ll f(ll n,ll k){
  // cout<<n<<" "<<k<<endl;
  if(k==1)return -1;
  if(k==2)return 1;
  if(n<k)return n;
  if(n%k==0)n=n/k;
  else n=n-k;
  return f(n,k);
}

bool check(ll x,ll m){
  if(m==1)return false;
  if(x%m==0)return check(x/m,m);
  else return x%m==1;
}

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool solve(){
  set<ll>ans;
  ll n;cin>>n;
  for(auto&&k : divisor(n-1)){
    if(check(n,k))ans.insert(k);
  }
  for(auto&&k : divisor(n)){
    if(check(n,k))ans.insert(k);
  }
  cout<<ans.size()<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    val s = readLine()!!
    var ans = 0L
    for (i in 0 until (1 shl (s.length - 1))) {
        var x = 0L
        var cur = 0
        for (j in 0 until s.length - 1) {
            if (i shr j and 1 == 1) {
                x += s.slice(cur..j).toLong()
                cur = j + 1
            }
        }
        x += s.slice(cur until s.length).toLong()
        ans += x
    }
    println(ans)
}


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

#define FIO ios_base::sync_with_stdio(0); cin.tie(0);
#define T() int tt; cin >> tt; rep1(qq,1,tt)
#define rep(i,start,lim) for(int i=start;i<lim;i++)
#define rep1(i,start,lim) for(int i=start; i<=lim; ++i)
#define repd(i,start,lim) for(int i=start;i>=lim;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define br cout<<"\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define eps (1e-6)
#define what_is(x) cerr << #x << " is " << x << "\n";
#define int long long int
#define infll 9e18
#define inf 1e12

#define lnode (2 * node + 1)
#define rnode (2 * node + 2)

using namespace std;

typedef pair<int, int> pii;

const int N = 300005;

int n;

int32_t main(){

  FIO
  //cout << fixed << setprecision(10);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  cin >> n;
  if(n == 2) return cout << 1, 0;
  vector<int> divs;
  for(int i = 2; i * i <= n; ++i){
    if(n % i != 0) continue;
    divs.pb(i);
    if(i != (n / i)) divs.pb(n / i);
  }
  int res = 0;
  for(int div : divs){
    int K = div, N = n;
    while(N >= K && (N % K == 0)){
      N /= K;
    }
    if(N % K == 1) ++res;
  }
  ++res; // n itself
  ++res; // n - 1 itself
  n--;
  for(int i = 2; i * i <= n; ++i){
    if(n % i != 0) continue;
    ++res;
    if(i * i != n) ++res;
  }
  cout << res << '\n';
  
	return 0;
}




Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N, K;
    string S;
    cin >> N >> K >> S;
    K--;
    if(S[K] == 'A') S[K] = 'a';
    if(S[K] == 'B') S[K] = 'b';
    if(S[K] == 'C') S[K] = 'c';
    cout << S;
}

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

int main(void){
    int N, K, sum = 0;
    cin >> N >> K;
    for(int i=0; i<N; i++){
        int x;
        cin >> x;
        sum += 2 * min(x, K-x);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main(){
  ll n;
  cin>>n;
  v(ll) a(n),b(n);
  rep(i,n) cin>>a[i]>>b[i];
  ll ans=0;
  drep(i,n){
    if((ans+a[i])%b[i]==0) continue;
    ans+=b[i]-((ans+a[i])%b[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4804
#include <bits/stdc++.h>
using namespace std;
typedef pair<char, int> P;

void bubble_sort(vector<P>& c, int n) {
  int flag = 1;
  while (flag) {
    flag = 0;
    int i = 0;
    for (int j = n - 1; j >= i + 1; j--) {
      if (c[j].second < c[j-1].second) {
        swap(c[j], c[j - 1]);
        flag = 1;
      }
    }
    i++;
  }
}

void selection_sort(vector<P>& c, int n) {
  for (int i = 0; i < n; i++) {
    int minj = i;
    for (int j = i; j < n; j++) {
      if (c[j].second < c[minj].second) {
        minj = j;
      }
    }
    swap(c[i], c[minj]);
  }
}

void print(const vector<P>& c, int n) {
  for (int i = 0; i < n; i++) {
    cout << (i ? " " : "") << c[i].first << c[i].second;
  }
  cout << "\n";
}

int main() {
  int n;
  cin >> n;
  vector<P> bubble;
  for (int i = 0; i < n; i++) {
    char s;
    int t;
    cin >> s >> t;
    bubble.emplace_back(s, t);
  }
  vector<P> selection(bubble);
  bubble_sort(bubble, n);
  print(bubble, n);
  cout << "Stable\n";
  selection_sort(selection, n);
  print(selection, n);
  if (bubble == selection) cout << "Stable\n";
  else cout << "Not stable\n";
}


Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {
	
	static Scanner sc = new Scanner(System.in);
	static int n;
	static int num;
	static int max;
	public static void main(String[] args) {
	
		while(true) {
			n = sc.nextInt();
			int ans = solve(n);
			if(ans!=-1) {
				System.out.println(ans);
			}else {
				return;
			}
		}
	}

	private static int solve(int N) {
		if(N==0) {
			return -1;
		}else {
			num = 0;
			int[] win = new int[N+1];
			int[] lose = new int[N+1];
			int[][] table = new int[N+1][N+1];
			Boolean B = false;
			max = N/2;
			int m = sc.nextInt();
			for(int i=0;i<m;i++) {
				int w = sc.nextInt();
				int l = sc.nextInt();
				table[w][l] = 1;
				table[l][w] = -1;
				win[w]++;
				lose[l]++;
				if(win[w]>max||lose[l]>max) {
					B = true;
				}
			}
			if(B) {
				return 0;
			}
			check(win,lose,table,1,2);
			return num;
			
		}
		
	}

	private static void check(int[] ws, int[] ls, int[][] tb,int a,int b) {
		if(a==n-1&&b==n) {
			num++;
		}else {
			if(tb[a][b]!=0) {
				if(b!=n) {
					check(ws,ls,tb,a,b+1);
				}else {
					check(ws,ls,tb,a+1,a+2);
				}
				
			}else {
				if(ws[a]<max&&ls[b]<max) {
					ws[a]++;
					ls[b]++;
					if(b!=n) {
						check(ws,ls,tb,a,b+1);
					}else {
						check(ws,ls,tb,a+1,a+2);
					}
					ws[a]--;
					ls[b]--;
				}
				if(ws[b]<max&&ls[a]<max) {
					ws[b]++;
					ls[a]++;
					if(b!=n) {
						check(ws,ls,tb,a,b+1);
					}else {
						check(ws,ls,tb,a+1,a+2);
					}
					ws[b]--;
					ls[a]--;
				}
			}
				
		}
		
		
	}
	 
}


Measured memory_bytes: 31300
import itertools
while 1:
    n,x=map(int,raw_input().split())
    if n==0 and x==0:
        break
    else:
        answer=0
        l=range(1,n+1)
        for ele in itertools.combinations(l,3):
            if sum(ele)==x:
                answer+=1
        print answer

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end()))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int h[550][110000];
signed main() {
    int N;
    cin >> N;
    vint V(N + 1), W(N + 1);
    reps(i, N) { cin >> V[i] >> W[i]; }
    int m = min(bit(9), N + 1);
    vector<vpint> WV(m);
    for (int i = 1; i < m; i++) {
        vint Vc, Wc;
        int v = i;
        while (v > 0) { Vc.push_back(V[v]), Wc.push_back(W[v]), v >>= 1; }
        rep(j, bit(Vc.size())) {
            int Vcc = 0, Wcc = 0;
            rep(k, Vc.size()) { if (j & bit(k)) { Vcc += Vc[k], Wcc += Wc[k]; }}
            WV[i].push_back({Wcc, Vcc});
        }
        sort(all(WV[i]));
        for (int j = 1; j < WV[i].size(); j++) { chmax(WV[i][j].second, WV[i][j - 1].second); }
        int c = WV[i].size() - 1;
        for (int j = 110000 - 1; j >= 0; j--) {
            while (WV[i][c].first > j) { c--; }
            h[i][j] = WV[i][c].second;
        }
    }
    int Q;
    cin >> Q;
    rep(i, Q) {
        int v, L;
        cin >> v >> L;
        int ans = 0;
        vint Vc, Wc;
        while (v >= m) { Vc.push_back(V[v]), Wc.push_back(W[v]), v >>= 1; }
        rep(j, bit(Vc.size())) {
            int Vcc = 0, Wcc = 0;
            rep(k, Vc.size()) { if (j & bit(k)) { Vcc += Vc[k], Wcc += Wc[k]; }}
            if (Wcc > L) { continue; }
            chmax(ans, h[v][L - Wcc] + Vcc);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 449116
n = gets.to_i
lengthOfLines = gets.to_s

arrayOfLines = []
arrayOfLines = lengthOfLines.split(" ")
arrayOfLines.map!{|x| x.to_i}


arrayOfLines.sort!
maxLength = arrayOfLines.max
arrayOfLines.pop

if maxLength < arrayOfLines.inject(:+) then
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;
  bool t = true;
  rep(i,s.size()) {
    if (i == a){
      if (s[i] != '-') t = false; 
    } else if (!(0 <= s[i] - '0' && s[i] - '0' <= 9)) t = false;
  }
  cout << (t? "Yes": "No") << endl;
}

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

Measured memory_bytes: 3596
N = int(input())
a = list(map(int, input().split()))

ans = 0
num = -1
for i in range(N):
    cnt = 0
    if(i <= num):
        continue
    for j in range(i+1, N):
        if(a[i] == a[j]):
            cnt += 1
            num = j
        else:
            break
    if(cnt%2 == 0):
        ans += cnt//2
    else:
        ans += cnt//2+1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

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; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
#define inf 1e12+7
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll ans = inf;
    for(ll i = 1; i <= sqrt(n); i++){
        ll j = n / i;
        if(n%i == 0){
            ans = min(ans, i-1+j-1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    #r = stdin.readline()[:-1]
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    t = [int(stdin.readline()) for i in range(4)]
    #n = int(r)
    #a = r.split()
    #a,b,c = r.split()
    #a = list(map(int, r.split()))
    #a,b,c,d = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    res = 0
    for i in range(t[0]):
        if i < t[1]:
            res += t[2]
        else:
            res += t[3]

    print(res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
a,b = ma()
k2 = abs(b-a)
if k2%2==0:
    print(k2//2+min(b,a))
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 9420
#include<stdio.h>
int main(void){
	int x[3000];
	int y[3000];
	int i = 0,j = 0;
	int change;
	
	while(1){
		scanf("%d %d",&x[i],&y[i]);
		if((x[i] == 0)&&(y[i] == 0)){
			break;
		}
		i++;
	}
	while(1){
		if((x[j] == 0)&&(y[j] == 0)){
			break;
		}
		if(x[j]>y[j]){
			printf("%d %d\n",y[j],x[j]);
		}else{
		printf("%d %d\n",x[j],y[j]);
		}
		j++;
	}
	
	return 0;
}


Measured memory_bytes: 2032
#include <stdio.h>
#include <stdint.h>
#include <set>

int N;

std::multiset <int, std::less <int> > list;

int main(){
  scanf("%d", &N);
  for(int i = 0; i < 3 * N; i++){
    int tmp;
    scanf(" %d", &tmp);
    list.insert(tmp);
  }
  auto q = list.rbegin();
  int64_t count = 0;
  for(int i = 0; i < N; i++){
    ++q;
    count += *q;
    ++q;
  }
  printf("%lld\n", count);
  return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h,w;
    while(cin>>h>>w){
        string c;
        for(int i=0;i<w+2;i++) cout<<"#";
        cout<<endl;
        for(int i=0;i<h;i++){
            cin>>c;
            cout<<"#"<<c<<"#"<<endl;
        }
        for(int i=0;i<w+2;i++) cout<<"#";
        cout<<endl;
    }

    return 0;
 
}

Measured memory_bytes: 256
program main;
var
    h1, s1, h2, s2 : integer;
begin
    readln(h1, s1, h2, s2);
    while (h1 > 0) and (h2 > 0) do begin
        h1 := h1 - s2;
        h2 := h2 - s1;
        if h2 <= 0
            then writeln('Yes')
            else if h1 <= 0
                then writeln('No');
    end;
end.


Measured memory_bytes: 1372
/*
[ ( ^ _ ^ ) ]
*/

// problem: atc/dp_s

import java.io.*;
import java.util.*;


public class Main {
    int INF = (int)1e9;
    long MOD = 1000000007;


    void solve(InputReader in, PrintWriter out) throws IOException {
        String s = in.next().trim();
        int n = s.length();
        int[] k = new int[n+1];
        for(int i=1; i<=n; i++) {
            k[i] = s.charAt(i-1) - '0';
        }
        int d = in.nextInt();

        int[][][] dp = new int[n+1][d][2];
        dp[0][0][0] = 1;
        for(int i=1; i<=n; i++) {
            for(int j=0; j<d; j++) {
                int x = ((j - k[i]) % d + d) % d;
                dp[i][j][0] = dp[i-1][x][0];

                for(int l=0; l<10; l++) {
                    x = ((j - l) % d + d) % d;
                    dp[i][j][1] += dp[i-1][x][1];
                    if(l<k[i]) {
                        dp[i][j][1] += dp[i-1][x][0];
                    }
                    dp[i][j][1] %= MOD;
                }
            }
        }
        int rs = dp[n][0][0] + dp[n][0][1];
        if(rs>=MOD) rs -= MOD;
        rs -= 1;
        if(rs==-1) rs += MOD;
        out.println(rs);
    }
    

    public static void main(String[] args) throws IOException {
        if(args.length>0 && args[0].equalsIgnoreCase("d")) {
            DEBUG_FLAG = true;
        }
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        long start = System.nanoTime();
        while(t-- >0) {
            new Main().solve(in, out);
        }
        long end = System.nanoTime();
        debug("\nTime: " + (end-start)/1e6 + " \n\n");
        out.close();
    }
    
    static boolean DEBUG_FLAG = false;
    static void debug(String s) {
        if(DEBUG_FLAG) System.out.print(s);
    }
    
    public static void show(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    
    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;
    
        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 58372
#include <stdio.h>
int main() {
  int sx,sy,tx,ty,dx,dy;
  scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
  dx=tx-sx;
  dy=ty-sy;
  for(int i=0;i<dy;i++){
    printf("U");
  }
  for(int i=0;i<dx;i++){
    printf("R");
  }
  for(int i=0;i<dy;i++){
    printf("D");
  }
  for(int i=0;i<=dx;i++){
    printf("L");
  }
  for(int i=0;i<=dy;i++){
    printf("U");
  }
  for(int i=0;i<=dx;i++){
    printf("R");
  }
  printf("D");
  printf("R");
  for(int i=0;i<=dy;i++){
    printf("D");
  }
  for(int i=0;i<=dx;i++){
    printf("L");
  }
  printf("U");
  
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> n(N);
    for(int i=0;i<N;i++) cin >> n[i];
    sort(n.rbegin(),n.rend());
    int sum1 = 0,sum2 = 0;
    for(int i=0;i<N;i++) {
        if(i % 2 == 0) sum1 += n[i];
        else sum2 += n[i];
    }
    if(sum1 >= sum2) cout << sum1 - sum2;
    else cout << sum2 - sum1;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int week = scan.nextInt();
		double debt = 100000;
		
		for(int i = 0; i < week; i++){
			debt = debt * 1.05 / 1000;
			debt = Math.ceil(debt);
			debt = debt * 1000;
		}
		
		int ans = (int)debt;
		System.out.println(ans);

	}

}

Measured memory_bytes: 25768
N,S = map(int,input().split())
A = list(map(int,input().split()))
MOD=998244353

Q = [0 for _ in range(S+1)]
ans = 0
for i in range(N):
  Q[0] += 1
  Q2 = [0 for _ in range(S+1)]
  for j in range(S+1):
    Q2[j] += Q[j]%MOD
    if j+A[i] <= S: #(1+x^A[i])をかけてもx^sを超えないときに限り。
      Q2[j+A[i]] += Q[j]%MOD
  Q = Q2
  ans += Q[S]%MOD
ans = ans %MOD
print(ans)

Measured memory_bytes: 46428