akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String probCount = scanner.nextLine();
        String[] timesList = scanner.nextLine().split(" ");
        Integer drinkCount = new Integer(scanner.nextLine());

        IntStream.range(0, drinkCount).forEach(i -> {
            String[] pair = scanner.nextLine().split(" ");
            Integer nProb = new Integer(pair[0]);
            String nTime = pair[1];

            String[] copiedList = new String[timesList.length];
            System.arraycopy(timesList, 0, copiedList, 0, timesList.length);

            copiedList[nProb - 1] = nTime;

            System.out.println(addTimes(copiedList));
        });



    }
    private static Integer addTimes(String[] timesList) {
        Integer sum = 0;
        for (int i = 0; i < timesList.length; i++ ) {
            sum = sum + new Integer(timesList[i]);
        }
        return sum;
    }
}


Measured memory_bytes: 26836
#include<iostream>

int main(){
    int W,H,x,y,r;
    int right,left,top,bottom;

    std::cin>>W>>H>>x>>y>>r;

    right=x+r;
    left=x-r;
    top=y+r;
    bottom=y-r;

    if(left<0||right>W){
        std::cout<<"No"<<std::endl;
    }else if(bottom<0||top>H){
        std::cout<<"No"<<std::endl;
    }else{
        std::cout<<"Yes"<<std::endl;
    }

    return 0;
    
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;



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

    int h,n; cin >> h >> n;
    vll a(n);
    ll sum = 0;
    REP(i,n) {
        cin >> a[i];
        sum += a[i];
    }
    cout << ((accumulate(ALL(a),0) >= h) ? "Yes" : "No" )<< endl;

    return 0;
}



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

int main() {
  int N, A;
  int c;
  
  cin >> N >> A;
  
  c = N % 500;
  
  if(c <= A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (int) (1e9+7)
#define INF (int) 2e9

vector<int> edge[100005];
int memo[100005];

int dfs(int s){
    if(edge[s].size()==0){
        memo[s] = 0;
        return 0;
    }
    if(memo[s]!=-1) return memo[s];

    int MAX = 0;

    for (auto v : edge[s]){
        MAX = max(MAX, dfs(v)+1);
    }

    memo[s] = MAX;
    return MAX;
}

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, n) memo[i+1] = -1;
    rep(i, m){
        int x, y;
        cin >> x >> y;
        edge[x].emplace_back(y);
    }
    int ans = 0;
    rep(i, n) ans = max(ans, dfs(i+1));
    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    vector<pair<string, int>> v(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i].F >> v[i].S;
    }

    string s;
    cin >> s;
    int res = 0;
    for(int i = N - 1; i >= 0; --i) {
        if(v[i].F == s) break;
        res += v[i].S;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'

//DP法
template <class T>
inline bool chmin(T &a, T b) //change minimum
{
        if (a > b)
        {
                a = b;
                return true;
        }
        return false;
}
template <class T>
inline bool chmax(T &a, T b) //change max
{
        if (a < b)
        {
                a = b;
                return true;
        }
        return false;
}

typedef long long ll; //64bit型

using namespace std;

// const long long INF = 1LL << 60; //無限大の値
int INF = 1000000;

int main()
{
        int N;
        cin >> N;
        vector<pair<int, int>> task(N);
        REP(i, N)
        {
                cin >> task[i].second >> task[i].first;
        }

        sort(task.begin(), task.end());
        ll ans = 0;

        REP(i, N)
        {
                ans += task[i].second;
                if (ans > task[i].first)
                {
                        puts("No");
                        return 0;
                }
        }

        puts("Yes");
        return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[200010];
ll kai[200010];
ll m;
ll beki(ll n,ll k){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=m;
    }
    now*=now;
    now%=m;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n){
  return beki(n,mod-2);
}
void nckinit(ll n){
  kai[0]=1;
  kai[1]=1;
  for(int i=2;i<=n;i++){
    kai[i]=kai[i-1]*i;
    kai[i]%=mod;
  }
  gya[n]=gyaku(kai[n]);
  for(int i=n-1;i>=1;i--){
    gya[i]=gya[i+1]*(i+1);
    gya[i]%=mod;
  }
  gya[0]=1;
}    
ll nck(ll n,ll k){
  if(k<0)return 0;
  if(k==0||n==k)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=mod;
  ret*=gya[k];
  ret%=mod;
  return ret;
}
ll npk(ll n,ll k){
  if(k<0)return 0;
  if(k==0)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=mod;
  return ret;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  ll a[n+1][n];
  rep(i,1,n+1){
    rep(j,1,n)cin>>a[i][j];
  }
  ll now[n+1];
  fill(now,now+n+1,1);
  queue<pll> q;
  rep(i,1,n+1){
    ll y=a[i][now[i]];
    if(i>y)continue;
    ll r=a[y][now[y]];
    if(r==i)q.push({i,y});
  }
  ll ans=0;
  ll d=0;
  ll cnt=0;
  bool used[n+1];
  fill(used,used+n+1,true);
  while(q.size()>0){
    pll p=q.front();q.pop();
    ll f=p.first,g=p.second;
    cnt++;
   // cout<<f<<" "<<g<<endl;
    if(used[f]==false&&used[g]==false){
      used[f]=true;
      used[g]=true;
    }
    else{
      d++;
      fill(used,used+n+1,false);
      used[f]=true;
      used[g]=true;
    }
    now[f]++;
    if(now[f]<n){
      ll t=a[f][now[f]];
      ll tt=a[t][now[t]];
      if(tt==f){
        q.push({f,t});
      }
    }
    now[g]++;
    if(now[g]<n){
      ll t=a[g][now[g]];
      ll tt=a[t][now[t]];
      if(tt==g){
        q.push({g,t});
      }
    }
  }
  if(cnt<((n-1)*n)/2){
    cout<<-1<<endl;
  }
  else cout<<d<<endl;
}
  

Measured memory_bytes: 8064
#include <stdio.h>
#include <math.h>

int main(void) {

  long n;
  scanf("%ld", &n);
  long ans = 0;
  if (n == 3) {
    ans = pow(4,3)-3;
    printf("%ld\n", ans);
    return 0;
  }
  long mod = pow(10,9)+7;
  long dp[n+1][4][4][4][4];
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        for (int l = 0; l < 4; l++) {
          dp[4][i][j][k][l] = 1;
          if (i == 0 && k == 2 && l == 1) {
            dp[4][i][j][k][l] = 0;
          }
          if (i == 0 && j == 2 && l == 1) {
            dp[4][i][j][k][l] = 0;
          }
          if (i == 0 && j == 2 && k == 1) {
            dp[4][i][j][k][l] = 0;
          }
          if (j == 0 && k == 2 && l == 1) {
            dp[4][i][j][k][l] = 0;
          }
          if (i == 2 && j == 0 && k == 1) {
            dp[4][i][j][k][l] = 0;
          }
          if (j == 2 && k == 0 && l == 1) {
            dp[4][i][j][k][l] = 0;
          }
          if (i == 0 && j == 1 && k == 2) {
            dp[4][i][j][k][l] = 0;
          }
          if (j == 0 && k == 1 && l == 2) {
            dp[4][i][j][k][l] = 0;
          }
        }
      }
    }
  }
  for (int length = 5; length <= n; length++) {
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        for (int k = 0; k < 4; k++) {
          for (int l = 0; l < 4; l++) {
            dp[length][i][j][k][l] = 0;
            if (i == 0 && k == 2 && l == 1) {
              continue;
            }
            if (i == 0 && j == 2 && l == 1) {
              continue;
            }
            if (i == 0 && j == 2 && k == 1) {
              continue;
            }
            if (j == 0 && k == 2 && l == 1) {
              continue;
            }
            if (i == 2 && j == 0 && k == 1) {
              continue;
            }
            if (j == 2 && k == 0 && l == 1) {
              continue;
            }
            if (i == 0 && j == 1 && k == 2) {
              continue;
            }
            if (j == 0 && k == 1 && l == 2) {
              continue;
            }
            for (int m = 0; m < 4; m++) {
              dp[length][i][j][k][l] += dp[length-1][m][i][j][k];
              dp[length][i][j][k][l] %= mod;
            }
          }
        }
      }
    }
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        for (int l = 0; l < 4; l++) {
          ans += dp[n][i][j][k][l];
          ans %= mod;
        }
      }
    }
  }
  printf("%ld\n", ans);

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
//-0.4620981203755741
int main(){
    int a,b,c;
    std::cin >> a>>b>>c;
    itn ans=b+min(c,a+b+1);
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    int sum = 0;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    int dif = INF;
    int res = N - 1;
    for(int i = N - 1; i >= 0; i--) {
        if(abs(A[i] * N - sum) <= dif) {
            dif = abs(A[i] * N - sum);
            res = i;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import math

s=int(input())
if s<3:
    print(0)
else:
    k=math.factorial(s-3)
    l=k
    m=1
    num=0
    for i in range(1,s//3+1):
        num+=l//(k*m)
        num%=10**9+7
   
        if i!=s//3:
            l//=(s-2*i-1)*(s-2*i-2)
            k//=(s-3*i)*(s-3*i-1)*(s-3*i-2)
            m*=i
    print(num%(10**9+7))

Measured memory_bytes: 66776
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n = I()
s = sum(int(x) for x in (str(n)))
if n % s == 0:
    print("Yes")
else:
    print("No")


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

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

    vector<int64_t> ans;
    while (n != 0) {
        if (n % 2 != 0) {
            ans.push_back(1);
            --n;
        } else {
            ans.push_back(0);
        }
        n /= -2;
    }

    for (auto a : ans | reversed) {
        cout << a;
    }
    cout << endl;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if ((a + b) > (c + d)) {
    cout << "Left" << endl;
  }
  if ((a + b) == (c + d)) {
    cout << "Balanced" << endl;
  }
  if ((a + b) < (c + d)) {
    cout << "Right" << endl;
  }
    
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define fi first
#define se second
#define all(a) a.begin(),a.end()
int ans;
map<int,int>m;
signed main(){
	int n;
	cin>>n;
	int a[n],b[n];
	r(i,n)cin>>a[i],b[i]=a[i];
	r(i,n-1)b[i+1]+=b[i];
	r(i,n)m[b[i]]++;
	int sum=0;
	r(i,n){
		ans+=m[sum];
		m[b[i]]--;
		sum+=a[i];
		//ans+=m[-a[i]];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 15872
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

printList [a] = print a
printList (a:as) = putStr ( show a ) >> putChar ' ' >> printList as

main = getLine >> readIntegers >>= print . solve 0

solve _ [] = 0
solve s (a:as) = s *% a +% solve ( s +% a ) as

a +% b = ( a + b ) `mod` 1000000007
a *% b = a * b `mod` 1000000007

Measured memory_bytes: 44676
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7

N,M,P = map(int,(input().split()))
line = []
for i in range(M):
    a,b,c = map(int,(input().split()))
    line.append([a-1,b-1,-c+P])
line.sort()

min_distance = [float("inf")]*N # min_distance[i] は始点から街iまでの最短距離
min_distance[0] = 0 # 始点から始点への最短距離は0とする

update = False
for _ in range(N):
    for s,g,d in line: # [s,g,d] = [道路の始点,道路の終点,道路の長さ] について、すべての道路を見る
        if min_distance[s] != float("inf") and min_distance[s] + d < min_distance[g]: # 最短経路が確立されている街から伸びる道路を通ることで、距離を短くできるならば、
            min_distance[g] = min_distance[s] + d # 最短距離を上書きする
            update = True
    if not update:
        break
else:
    for _ in range(N):
        for s,g,d in line: # [s,g,d] = [道路の始点,道路の終点,道路の長さ] について、すべての道路を見る
            if min_distance[s] != float("inf") and min_distance[s] + d < min_distance[g]: # 最短経路が確立されている街から伸びる道路を通ることで、距離を短くできるならば、
                min_distance[g] = -float("inf")
                if g == N-1:
                    print(-1)
                    exit()

print(max(-min_distance[N-1],0))

#print(min_distance)

Measured memory_bytes: 75952
#include <bits/stdc++.h>
using namespace std;
int x,n,maxv=1000,a,ans,dif;
int main() {
  cin >> x >> n;
  bool s[110];
  for(int i = 0;i<110;i++){
    s[i] = false;
  }
  for(int i = 0;i<n;i++){
    cin >> a;
    s[a] = true;
  }
  
  for(int i = 0;i<110;i++){
    if(s[i]){
      continue;
    }
    dif = abs(x - i);
    if(maxv == dif){
      cout << ans << endl;
      return 0;
    }
    if(maxv > dif){
      maxv = dif;
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3476
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::vec::Vec;
use std::{vec, cmp, num};


struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

// create Vec<char> from String
#[allow(dead_code)]
fn to_chars(s: String) -> vec::Vec<char> {
    let mut cs = s.chars();
    let mut res = vec::Vec::new();
    while let Some(c) = cs.next() {
        res.push(c);
    }
    res
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n: i32 = sc.read();
    println!("ABC{}", n);
}

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

#define ll long long int
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'



#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef tuple<ll,ll,ll>tpl;

int main()
{
    _fastio
    ll n,a;
    cin>>n;
    vector<ll>v,v1;
    for1(i,n)
    {
    	cin>>a;
    	pb(v,a);
    }
    srt(v);
    rv(v);
    ll cmf=0;
    for(int i=0;i<(n/2)+1;i++)
    {
    	pb(v1,v[i]);
    }
    for(ll i=0;i<v1.size()-1;i++)
    	cmf+=v1[i];

    if(n%2==0)
    {
    	for(ll i=0;i<v1.size()-2;i++)
    	{
    		cmf+=min(v1[i],v1[i+1]);
    	}
    }
    else
    {
    	for(ll i=0;i<v1.size()-1;i++)
    	{
    		cmf+=min(v1[i],v1[i+1]);
    	}
    }
    cout<<cmf<<en;
}


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

typedef unsigned long long uLL;
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <int,pii> piii;
typedef pair <long long,long long> pll;
typedef pair <long long,pll> plll;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int MOD = 1000000007;

int n;
LL a[ N ][ 5 ];
LL dp[ N ][ 5 ];

LL solve( int idx , int prev ) {
        if( idx > n ) return 0;
        if( dp[idx][prev] != -1 ) return dp[idx][prev];
        LL ret = 0;
        for( int i = 1; i <= 3; i++ ) {
                if( i != prev ) {
                        ret = max( ret , solve( idx + 1 , i ) + a[idx][i] );
                }
        }
        return dp[idx][prev] = ret;
}
int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( NULL );
        cin >> n;
        for( int i = 1; i <= n; i++ ) {
                for( int j = 1; j <= 3; j++ ) {
                        cin >> a[i][j];
                }
        }
        memset( dp , -1 , sizeof( dp ) );
        cout << max( solve( 2 , 1 ) + a[1][1] , max( solve( 2 , 2 ) + a[1][2] , solve( 2 , 3 ) + a[1][3] ) ) << endl;
        return 0;
}













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

int main(){
  int k;
  string s;
  cin >> k >> s;
  if(s.size()<=k) cout << s << endl;
  else{
    for(int t=0; t<k; t++){
      cout << s.at(t);
    }
    cout << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include<cstdio>

int main(){

  int n; scanf("%d", &n); // cin >> n;
  long  A[n]; for(int i=0; i<n; i++) scanf("%ld", &A[i]); //cin >> A[i];

  long  min = A[0];
  long cnt = 0;

  for(int i=0; i<n; i++){
    if(min <= A[i]) min = A[i];
    else cnt += min - A[i];
  }
//  cout << cnt << endl;
  printf("%ld\n", cnt);
  return 0;
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const ld pi = 3.14159265358;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; 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;
    }
}

// 二項係数計算
ll 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;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll Q;
    cin >> Q;
    rep(i,Q){
        string S,T;
        cin >> S >> T;
        ll s = S.size(),t = T.size();
        vector<vector<ll>> memo(s + 1,vector<ll>(t + 1));
        rep(i,s){
            rep(j,t){
               if(S[i] == T[j]){
                   memo[i + 1][j + 1] = max(max(memo[i][j + 1],memo[i + 1][j]),memo[i][j] + 1);
                }
                else{
                    memo[i + 1][j + 1] = max(memo[i + 1][j],memo[i][j + 1]);
                }
            }
        }
        cout << memo[s][t] << endl;
    }
}


Measured memory_bytes: 10888
using System;

class Range{
      static void Main(string[] args){
      	string[] str = Console.ReadLine().Split(' ');
	int a = int.Parse(str[0]);
	int b = int.Parse(str[1]);
	int c = int.Parse(str[2]);
	if(a < b && b < c) Console.WriteLine("Yes");
	else Console.WriteLine("No");
      }
}

Measured memory_bytes: 8876
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	int N;
	string S;
	cin >> N >> S;
	int i,ans=0;
	for(i=0;i<N-2;i++){
		if(S[i]=='A'&& S[i+1]=='B'&& S[i+2]=='C')ans++;
	}
	cout << ans;
    return 0;
}


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

int main()
{
  string s, t;
  cin >> s >> t;
  int length = s.length();
  if (s.length() == t.length() || s.length() + 1 < t.length())
  {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i < length; i++)
  {
    if (s[i] != t[i])
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    ll ma=-1e12,mi=1e12;
    REP(i,n){
        ll r;
        cin>>r;
        if(i==0) mi=r;
        else{
            ma = max(ma,r-mi);
            mi = min(mi,r);
        }
    }

    cout<<ma<<endl;
}


Measured memory_bytes: 3212
#include "stdio.h"

int num;
int get;
int own[100000] = {};
int box[100000] = {};
int block[100000] = {};
int cal=0;
int ans = 0;

void MergeSort(int x[], int left, int right) {
	if (left == right)return;
	int mid = (left + right) / 2;
	MergeSort(x, left, mid);
	MergeSort(x, mid + 1, right);
	for (int i = left; i <= mid; i++)box[i] = x[i];
	for (int i = mid + 1, j = right; i <= right; i++, j--)box[i] = x[j];
	int a = left, b = right;
	for (int i = left; i <= right; i++) {
		if (box[a] < box[b])x[i] = box[a++];
		else x[i] = box[b--];
	}
}

int main() {
	scanf("%d %d", &num, &get);
	while (num != 0) {
		cal = 0;
		ans = 0;
		for (int i = 0; i < get; i++) {
			scanf("%d", &own[i]);
		}
		MergeSort(own, 0, get - 1);
		block[cal++] = -1;
		for (int i = 1; i < own[1]; i++) {
			block[cal++] = i;
		}
		for (int i = 1; i < get; i++) {
			for (int j = own[i] + 1; j < own[i + 1]; j++) {
				block[cal++] = j;
			}
		}
		for (int i = own[get - 1]+1; i <= num; i++) {
			block[cal++] = i;
		}
		block[cal++] = num + 1;
		if (own[0] == 0) {
			for (int i = 1; i < cal - 1; i++) {
				if (ans < block[i + 1] - block[i - 1] - 1)ans = block[i + 1] - block[i - 1] - 1;
			}
		}
		else {
			for (int i = 0; i < cal -1; i++) {
				if (ans < block[i + 1] - block[i] - 1)ans = block[i + 1] - block[i] - 1;
			}
		}
		printf("%d\n", ans);
		scanf("%d %d", &num, &get);
	}
	return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  vector<char> str(26);
  str = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
         'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
  
  for (int i = 0; i < S.size(); i++) {
    char s = S[i];
    for (int j = 0; j < 26; j++) {
      if (s == str[j]) {
        int k = j + N;
        if (k > 25) {
          k -= 26;
        }
        cout << str[k];
        break;
      }
    }
  }
  cout << endl;
}

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

bool isequal_array(int *Array1, int *Array2, int N);

int main(){
    int N;
    cin >> N;
    int P[N];
    int Q[N];

    for(int i=0; i<N; i++){
        cin >> P[i];
    }

    for(int i=0; i<N; i++){
        cin >> Q[i];
    }

    int default_perm[N];
    for(int i=0; i<N; i++){
        default_perm[i] = i+1;
    }

    int counter=0;
    int counter_P = 0;
    int counter_Q = 0;
    
    do{
        bool is_equal_P = isequal_array(P, default_perm, N);
        bool is_equal_Q = isequal_array(Q, default_perm, N);
        if(is_equal_P){counter_P = counter;}
        if(is_equal_Q){counter_Q = counter;}
        
        counter += 1;
    }while(next_permutation(default_perm, default_perm+N));

    cout << abs(counter_P - counter_Q) << endl;
    return 0;

}

bool isequal_array(int *Array1, int *Array2, int N){
    for(int i=0; i<N; i++){
        if(Array1[i] != Array2[i]){
            return false;
        } 
    }
    return true;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define endl '\n'
#define int long long


int32_t  main()
{
    IOS;  
    int n,k;
    cin>>n>>k;
    set<int> ans;;
    for(int i=1;i<=k;i++)
    {
        int d;
        cin>>d;
        for(int j=0;j<d;j++)
        {
            int x;
            cin>>x;
            ans.insert(x);
        }
    }
    cout<<n-ans.size();
}	

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

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,K;
  	string S;
  	cin >> N;
    cin >> S;
    cin >> K;
  	string o;
    for(int i = 0; i < N; i++)
    {
      if(S[K-1] != S[i])
      {
        o += '*';
      }
      else
      {
        o += S[i];
      }
    }
  	cout << o << endl;
	
  return 0;
}

Measured memory_bytes: 256
(defparameter *a* #())
(defparameter *ans* 0)

(defun solve ()
  (loop :for i :across *a*
        :do (setf *ans* (+ *ans* (abs i))))

  (if (oddp (loop :for i :across *a* :count (<= i 0)))
      (let ((minimum 1000000000000))
        (loop :for i :across *a* :do (setf minimum (min minimum (abs i))))
        (setf *ans* (- *ans* (* (abs minimum) 2)))))
  *ans*)

(defun main ()
  (let* ((n (read))
         (a (loop :repeat n :collect (read))))
    (setf *a* (make-array (length a) :initial-contents a))
    (format t "~A~%" (solve))))

(main)


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

ll W, N;
ll x[50000];
ll xsum[50010];
int dp[50010];

// [l, r]
ll minw(int l, int r){
	ll sum = xsum[r + 1] - xsum[l] + (r - l);
	if(sum > W) return -1;
	ll rem = W - (xsum[r + 1] - xsum[l]);
	return (rem + (r - l - 1)) / (r - l);
}

bool check(int w){
	memset(dp, 0, sizeof dp);
	dp[0] = 1;
	int cnt = 0;
	int L = 0, R = 0;
	for(int i = 1; i < N; i++){
		while(L < i && minw(L, i) == -1){
			if(dp[L]) cnt--;
			L++;
		}
		while(R < i && minw(R, i) <= w){
			if(dp[R]) cnt++;
			R++;
		}
		//assert(minw(L, i) <= w && minw(R, i) <= w);
		if(cnt){
			dp[i + 1] = 1;
			// ???????????????????????????????????°ok
			ll sum = xsum[N] - xsum[i + 1] + max(0LL, N - i - 2);
			if(i == N - 1 || sum <= W) return true;
		}
		else{
			dp[i + 1] = 0;
		}
	}
	return false;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	while(cin >> W >> N, W + N){
		for(int i = 0; i < N; i++){
			cin >> x[i];
			xsum[i + 1] = xsum[i] + x[i];
		}

		ll sum = xsum[N] + N - 1;
		if(sum <= W){
			cout << 1 << endl;
			continue;
		}

		int ng = 0, ok = W;
		while(abs(ng - ok) > 1){
			int mid = (ng + ok) / 2;
			if(check(mid)) ok = mid;
			else ng = mid;
		}
		cout << ok << endl;
	}
}

Measured memory_bytes: 4128
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    
    // std::string S;
    // std::cin >> S;

    if (N % 2 == 0) {
        std::cout << N  << std::endl;
    }
    else {
        std::cout << N * 2 << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

struct edge{ ll from,to,cost; };
const ll INF=1e18;

void solve(int N,int M,vector<edge>& es)
{
    vector<ll> dist(N,INF);
    dist[0]=0;

    for(int i=0;i<N;i++){
    	for(auto e:es){
    	    if(dist[e.from]==INF) continue;
    	    if(dist[e.to]>dist[e.from]+e.cost){
    		dist[e.to]=dist[e.from]+e.cost;
    	    }
    	}
    }
    bool flag = false;
    for(int i=0;i<N;i++){
    	for(auto e:es){
    	    if(dist[e.from]==INF) continue;
    	    if(dist[e.to]>dist[e.from]+e.cost){
        		dist[e.to]=dist[e.from]+e.cost;
                if(e.to == N-1){
                    flag = true;
                }
    	    }
    	}
        if(flag) break;
    }

    if(flag)
    	cout<<"inf"<<endl;
    else    
	    cout<<-dist[N-1]<<endl;
}

signed main()
{
    ll N,M; cin>>N>>M;
    vector<edge> es(M);
    for(int i=0;i<M;i++){
    	ll a,b,c; cin>>a>>b>>c; a--,b--;
    	es[i]=(edge){a,b,-c};
    }
    solve(N,M,es);
    return 0;
}


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

int main()
{
    int n;
    int p[21];
    cin >> n;
    int i, tmp;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int count = 0;
    for (int i = 1; i < n-1; i++) {
        if (p[i-1] < p[i] and p[i] < p[i+1]) {
            count++;
        }else if(p[i-1] > p[i] and p[i] > p[i+1]) {
            count++;
        }
    }
    cout << count << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int a, b, c, d;
    int n, k;
    
    cin >> n;
    out("ABC" << n);
}



Measured memory_bytes: 256
import sys
from collections import defaultdict as dd
from collections import deque
from functools import *
from fractions import Fraction as f
from copy import *
from bisect import *	
from heapq import *
from math import *
from itertools import permutations ,product
 
def eprint(*args):
    print(*args, file=sys.stderr)
zz=1
 
#sys.setrecursionlimit(10**6)
if zz:
	input=sys.stdin.readline
else:	
	sys.stdin=open('input.txt', 'r')
	sys.stdout=open('all.txt','w')
def inc(d,c):
	d[c]=d[c]+1 if c in d else 1
def bo(i):
	return ord(i)-ord('A')	
def li():
	return [int(xx) for xx in input().split()]
def fli():
	return [float(x) for x in input().split()]	
def comp(a,b):
	if(a>b):
		return 2
	return 2 if a==b else 0		
def gi():	
	return [xx for xx in input().split()]
def fi():
	return int(input())
def pro(a): 
	return reduce(lambda a,b:a*b,a)		
def swap(a,i,j): 
	a[i],a[j]=a[j],a[i]	
def si():
	return list(input().rstrip())	
def mi():
	return 	map(int,input().split())			
def gh():
	sys.stdout.flush()
def isvalid(i,j):
	return 0<=i<n and 0<=j<n	
def bo(i):
	return ord(i)-ord('a')	
def graph(n,m):
	for i in range(m):
		x,y=mi()
		a[x].append(y)
		a[y].append(x)


t=1

while t>0:
	t-=1
	d,tt,s=mi()
	print(["Yes","No"][int(d/s<=tt)^1])

	



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


void solve(long long x){
    ll n = x/11;
    n *= 2;
    x = x % 11;
    if(x > 0) {
        x -= 6;
        n++;
    }
    if(x > 0) n++;

    cout << n << endl;
}

int main(){
    long long x;
    scanf("%lld",&x);
    solve(x);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; i--)
#define REP(i, k, n) for(int i=(int)(k); i<(int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const int INF = INT_MAX;
const ll inf = 1e18;
const ll mod = 998244353;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x, ll y){ if(x>y) swap(x, y);while(x!=0){ y%=x; swap(x, y); }return y; }
ll mpow(ll x, ll r){if(r==0) return 1;if(r%2==1){ return x*mpow(x, r-1)%mod; }else{ ll aa = mpow(x, r/2); return aa*aa%mod; }}

int main(){
	ll x; cin >> x;
	for(ll a=1000; a>=0; a--){
		for(ll b = 1000; b>=0; b--){
			ll s = a*a*a*a*a, t = b*b*b*b*b;
			if(s-t==x){
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}
	for(ll a=1000; a>=0; a--){
		for(ll b = 1000; b>=0; b--){
			ll s = a*a*a*a*a, t = b*b*b*b*b;
			if(s+t==x){
				cout << a << " " << -b << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3596
n = int(input())

A = [int(input()) for i in range(n)]

A = [0] + A
count = 0
light = 1
if 2 not in A:
  print("-1")
  exit()
else:
  while light != 2 and count <= n:
    count += 1
    light = A[light] #A = [0] + Aとしているので，これでよい．light-1としなくてよい．

if count <= n:
  print(count)
else:
  print("-1")

Measured memory_bytes: 7852
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=100005;
int n;
ll s,t,d;
int a[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){scanf("%d",&a[i]);s+=a[i];}
	t=(n*(n+1ll))>>1;
	if(s%t!=0ll){printf("NO");return 0;}
	s/=t;t=0ll;a[n+1]=a[1];
	for(int i=1;i<=n;i++){
		d=s-(a[i+1]-a[i]);
		if(d%n!=0ll||d<0ll){printf("NO");return 0;}
		t+=d;
	}
	if(t==n*s)printf("YES");else printf("NO");
	return 0;
}

Measured memory_bytes: 640
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N,M,X = map(int,input().split())
    CA = [list(map(int,input().split())) for i in range(N)]

    res = 10 ** 9
    isFound = False

    for i in range(2**N):
        now = [0 for _ in range(M+1)]
        for j in range(N):
            if (i & (1<<j)):
                for k in range(M+1):
                    now[k] += CA[j][k]
        isOK = True
        for k in range(M):
            if now[k+1] < X:
                isOK = False
                break
        if isOK:
            res = min(res,now[0])
            isFound = True

    if not isFound:
        res = -1

    print(res)



main()


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

bool ss(string s){
    if (s.size() % 2 == 1){
        return false;
    }
    else{
        if (s.substr(0, s.size() / 2) == s.substr(s.size() / 2)){
            return true;
        }
        else{
            return false;
        }
    }
}

int main(){
    string s;
    cin >> s;
    int s_size = s.size();
    for (int i = 0; i < s_size; i++){
        s.pop_back();
        if (ss(s)){
            cout << s.size() << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;
const int M = 1e9+7;

string s;
int mem[N][20];

void add_itself(int & a , int b){
    a %= M;
    b %= M;
    a += b;
    a %= M;
}

int go(int idx , int mod){
    if(idx == s.size()){
        return mod == 5;
    }
    if(~mem[idx][mod])
        return mem[idx][mod];
    int ways = 0;
    if(s[idx] == '?'){
        for(int i = 0; i < 10; i++){
            add_itself(ways , go(idx + 1 , (mod*10 + i)%13 ));
        }
    } else {
        ways = go(idx + 1 , (mod*10 + int(s[idx]-'0')) % 13);
    }
    return mem[idx][mod] = ways;
}

int main(){
    cin >> s;
    memset(mem , -1 , sizeof mem);
    cout << go(0 , 0) << endl;
}
// number % 13 == 5
/*109%13==5
1%13 = 1
10 % 13 = 10
109 % 13 = 5


2865 % 13 = 5
2*10 - 13 = 7
*/


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

int main(){
    double w,h,x,y;
    cin >> w >> h >> x >> y;
    cout << fixed << setprecision(10);
    cout << w*h/2 << endl;
    if (x == w/2 && y == h/2){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }

}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
auto &errStream = cerr;
#ifdef LOCAL
#define cerr (cerr << "-- line " << __LINE__ << " -- ")
#else
class CerrDummy {
} cerrDummy;
template <class T> CerrDummy &operator<<(CerrDummy &cd, const T &) {
  return cd;
}
using charTDummy = char;
using traitsDummy = char_traits<charTDummy>;
CerrDummy &operator<<(CerrDummy &cd,
                      basic_ostream<charTDummy, traitsDummy> &(
                          basic_ostream<charTDummy, traitsDummy> &)) {
  return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr << "reached" << endl
#define DMP(x) cerr << #x << ":" << x << endl
#define ZERO(x) memset(x, 0, sizeof(x))
#define ONE(x) memset(x, -1, sizeof(x))

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

#define CAPITAL
void Yes(bool ex = true) {
#ifdef CAPITAL
  cout << "YES" << endl;
#else
  cout << "Yes" << endl;
#endif
  if (ex)
    exit(0);
}
void No(bool ex = true) {
#ifdef CAPITAL
  cout << "NO" << endl;
#else
  cout << "No" << endl;
#endif
  if (ex)
    exit(0);
}

const ll infLL = LLONG_MAX / 3;

#ifdef int
const int inf = infLL;
#else
const int inf = INT_MAX / 2 - 100;
#endif

signed main() {
  int N = read();

  int sum = 0, max = -1, l;
  REP(i, N) {
    l = read();
    if (max < l)
      max = l;
    sum += l;
  }

  sum -= max;
  if (sum > max)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
S = list(input())
lenS = len(S)

patternA = []
patternB = []
countA = 0
countB = 0

for x in range(lenS):
    if x % 2 == 0:
        if S[x] == "0":
            countA += 1
        else:
            countB += 1
    else:
        if S[x] == "1":
            countA += 1
        else:
            countB += 1

if countA < countB:
    print(countA)
else:
    print(countB)
    

Measured memory_bytes: 3956
#include <stdio.h>
int n, x, y, ans;
char s[300001];
int a[10];
int main() {
	scanf("%d", &n);
	scanf("%s", &s);
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			x = n;
			for (int k = 0; k < n; k++) {
				if (s[k] == '0' + i) {
					x = k;
					break;
				}
			}
			y = -1;
			for (int k = n - 1; k >= 0; k--) {
				if (s[k] == '0' + j) {
					y = k;
					break;
				}
			}
			for (int k = 0; k < 10; k++)a[k] = 0;
			for (int k = x + 1; k < y; k++) {
				a[s[k] - '0']++;
			}
			for (int k = 0; k < 10; k++) {
				if (a[k])ans++;
			}
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256