akhauriyash/Code-Regression huggingface dataset:
MOD = 1000000007

n = int(input())
a = map(int, input().split())

res = 1
values = [0, 0, 0]
last = 0

for e in a:
    yo = 0
    for (i, v) in enumerate(values):
        if v == e:
            yo += 1
            last = i

    if yo == 0:
        res = 0
        break


    res = (res * yo) % MOD

    values[last] += 1

print(res)


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


int main(){
    int a[5],k,tmp;
    for (int i=0;i<5;++i) cin >> a[i];
    cin >> k;

    if(a[4]-a[0]<=k){
        cout << "Yay!" << endl;
    }
    else cout << ":(" << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){

	double x, h;

	while(cin>>x>>h, x+h){
		double c = sqrt( ( (x/2)*(x/2) ) + (h*h) );
		printf("%.6f\n", ( x*x + 2*c*x ) );
	}
	return 0;
}

Measured memory_bytes: 1236
n = int(input())
a = list(map(int, input().split()))

hantei = True

for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 != 0:
            if a[i] % 5 != 0:
                hantei = False

if hantei == True:
    print('APPROVED')
else:
    print('DENIED') 

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

int main(){
  int n, t, e;

  while(cin >> n >> t >> e){
    int ans = -1;

    for(int i = 0; i < n; i++){
      int x;
      cin >> x;

      for(int j = t - e; j <= t + e; j++){
        if(j % x == 0){
          ans = i + 1;
          break;
        }
      }
    }

    cout << ans << endl;
  }
}

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

int main(){
	int n;	cin >> n;
  	vector<int> a(n-1);
  	for(int i = 0; i < n - 1; i++){cin >> a.at(i);}
  
  	vector<int> count(n,0);
  	for(int i = 0; i < n - 1; i++){
    	count.at(a.at(i)-1)++;
    }
  	for(int i = 0; i < n; i++){
    	cout << count.at(i) << endl;
    }
}

Measured memory_bytes: 4856
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int64 S;
  cin >> S;
  if (S <= (int64)1e9) {
    cout << 0 << ' ' << 0 << ' ' << 1 << ' ' << 0 << ' ' << 1 << ' ' << S
         << endl;
    return 0;
  }
  if (S == (int64)1e18) {
    cout << 0 << ' ' << 0 << ' ' << (int64)1e9 << ' ' << 0 << ' ' << 0 << ' '
         << (int64)1e9 << endl;
    return 0;
  }
  int64 syou = S / (int64)1e9;
  int64 amari = S % (int64)1e9;
  debug(syou, amari);
  cout << 0 << ' ' << 0 << ' ' << 1 << ' ' << 1000000000 << ' ' << syou + 1
       << ' ' << (int64)1e9 - amari << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cmath>
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long int ll;
const ll maxn=(3*1e3)+5;
const int N = 1e5;
int main()
{
    ll n;
    cin>>n;
    ll a[n][2],i;
    for(i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1];
    }
    int f=0;
    for(i=0;i<n-2;i++)
    {
        if(a[i][0]==a[i][1] && a[i+1][0]==a[i+1][1] && a[i+2][0]==a[i+2][1])
            f=1;
    }
    if(f)
        cout<<"Yes"<<"\n";
    else
        cout<<"No"<<"\n";
    cerr<<"\nTime elapsed:"<< 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

#define N 8

int main()
{
  int vehicle[N]={4,1,4,1,2,1,2,1},passenger[N];
  int i,j,wait,min,place;
  while(cin>>passenger[0]){
    for(i=1;i<N;i++)cin>>passenger[i];

    min=INT_MAX;place=0;
    for(i=0;i<N;i++){
      wait=0;
      for(j=0;j<N;j++){
	if(passenger[j]-vehicle[(j+i)%N]>0)wait+=passenger[j]-vehicle[(j+i)%N];
      }
      if(min>wait){min=wait;place=i;}
      else if(min==wait){
	int t=0,d=1;
	for(j=N-1;j>=0;j--){
	  t+=vehicle[(j+i)%N]*d-vehicle[(j+place)%N]*d;
	  d*=10;
	}
	if(t<0)place=i;
      }
    }

    for(i=0;i<N;i++){
      if(i!=0)cout<<' ';
      cout<<vehicle[(i+place)%N];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 0
import heapq
x,y,z,k = map(int,input().split())
ax = [int(_) for _ in input().split()]
ay = [int(_) for _ in input().split()]
az = [int(_) for _ in input().split()]
ax.sort(reverse=True)
ay.sort(reverse=True)
az.sort(reverse=True)
INF = - 3 *10 ** 10
ax.extend([INF])
ay.extend([INF])
az.extend([INF])
l = [(-(ax[0]+ay[0]+az[0]),0,0,0)]
checked = {(-(ax[0]+ay[0]+az[0]),0,0,0)}
for i in range(k):
    t = heapq.heappop(l)
    print(-t[0])
    if (-(ax[t[1]+1]+ay[t[2]]+az[t[3]]),t[1]+1,t[2],t[3]) not in checked:
        heapq.heappush(l,(-(ax[t[1]+1]+ay[t[2]]+az[t[3]]),t[1]+1,t[2],t[3])) 
        checked.add((-(ax[t[1]+1]+ay[t[2]]+az[t[3]]),t[1]+1,t[2],t[3]))
    if (-(ax[t[1]]+ay[t[2]+1]+az[t[3]]),t[1],t[2]+1,t[3]) not in checked:
        heapq.heappush(l,(-(ax[t[1]]+ay[t[2]+1]+az[t[3]]),t[1],t[2]+1,t[3]))
        checked.add((-(ax[t[1]]+ay[t[2]+1]+az[t[3]]),t[1],t[2]+1,t[3]))
    if (-(ax[t[1]]+ay[t[2]]+az[t[3]+1]),t[1],t[2],t[3]+1) not in checked:
        heapq.heappush(l,(-(ax[t[1]]+ay[t[2]]+az[t[3]+1]),t[1],t[2],t[3]+1))
        checked.add((-(ax[t[1]]+ay[t[2]]+az[t[3]+1]),t[1],t[2],t[3]+1))

Measured memory_bytes: 5228
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    intl cnt = 1;
    intl len = s.length();
    while(true){
        if((len - cnt) & 1){
            cnt++;
            continue;
        }
        string t = "";
        string u = "";
        rep(i,(len - cnt)/2)t += s[i];
        repi(i,(len - cnt)/2,len - cnt)u += s[i];
        //debug(t);
        //debug(u);
        if(t == u)break;
        cnt++;
    }
    cout << len - cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 100

int min( int a , int b ){
	
	if( a < b ){
		return a;
	}else{
		return b;
	}
}

int main( void ){
	
	int n , p[N+1] , m[N+1][N+1];
	
	scanf( "%d" , &n );
	
	for( int i = 1; i <= n; i++ ){
		scanf( "%d" , &p[i-1] );
		scanf( "%d" , &p[i] );
	}
	
	for( int i = 1; i <= n; i++ ){
		m[i][i] = 0;
	}
	for( int l = 2; l <= n; l++ ){
		for( int i = 1; i <= n-l+1; i++ ){
			int j = i+l-1;
			m[i][j] = (1<<21);
			for( int k = i; k <= j-1; k++ ){
				m[i][j] = min( m[i][j] , m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
			}
		}
	}
	
	printf( "%d\n" , m[1][n] );
	
	return 0;
}
	


Measured memory_bytes: 2108
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var N = consoleReader.Int();
            var lines = consoleReader
                .RepeatSplit(N)
                .Select((l, i) => new Restaurant { id = i + 1, name = l[0], point = int.Parse(l[1]) })
                .OrderBy(r => r.name)
                .ThenByDescending(r => r.point)
                .Select(r => r.id);
            return MultiLine(lines);
        }

        class Restaurant
        {
            public int id;
            public string name;
            public int point;
        }

        public const int mod = 1000000007;
        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc()); static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

    public class ConsoleReader { public virtual string String() => Console.ReadLine(); public int Int() => int.Parse(String()); public long Long() => long.Parse(String()); public ulong ULong() => ulong.Parse(String()); public double Double() => double.Parse(String()); public string[] Split() => String().Split().ToArray(); public int[] SplitInt() => String().Split().Select(int.Parse).ToArray(); public long[] SplitLong() => String().Split().Select(long.Parse).ToArray(); public ulong[] SplitULong() => String().Split().Select(ulong.Parse).ToArray(); public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray(); public IEnumerable<string> Repeat(int count) { for (int i = 0; i < count; i++) yield return String(); } public IEnumerable<int> RepeatInt(int count) { for (int i = 0; i < count; i++) yield return Int(); } public IEnumerable<long> RepeatLong(int count) { for (int i = 0; i < count; i++) yield return Long(); } public IEnumerable<string[]> RepeatSplit(int count) { for (int i = 0; i < count; i++) yield return Split(); } public IEnumerable<int[]> RepeatSplitInt(int count) { for (int i = 0; i < count; i++) yield return SplitInt(); } }
}

Measured memory_bytes: 13788
#include <stdio.h>

int main(void)
{
	int N, K;
	scanf("%d %d", &N, &K);

	int max_c = N >= K ? N / K : 1;
	int min_c = N >= K ? N / K : 0;

	if (N > K && N % K)
		max_c++;

	int res = max_c - min_c;

	printf("%d\n", res);
	return 0;
}


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n;
  cin >> n;
  
  ll k = 2;
  bool flag = false;
  while( k*(k-1)<=2*n){
    if(k*(k-1) == 2*n){
      flag = true;
      break;
    }else{
      k++;
    }
  }
  if(!flag){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
    int val = 1;
    vector<vector<int>> set(k,vector<int>(0));
    REP(i,k){
      FOR(j,i+1,k){
        set[i].push_back(val);
        set[j].push_back(val);      
        val++;
      }
    }
    cout << k << endl;
    REP(i,k){
      int size = (int)set[i].size();
      cout << size << " ";
      for(auto s : set[i]){
        cout << s << " ";
      }
      cout << '\n';
    }
    
  }
  return 0;
}


Measured memory_bytes: 4216
#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin >> n >> m;
	vector <int> votes(n);
	int sum=0;
	for(int &x:votes)
	{
		cin >> x;
		sum+=x;
	}
	// dbg2(sum,4*m);
	double threshold = ((double)sum)/(4*m);
	// dbg1(threshold);
	int ans=0;
	for(auto x:votes)
	{
		if(x>=threshold)
			ans++;
	}
	if(ans>=m)
		cout << "Yes\n";
	else
		cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;


const int mod = 1e9+7;
int dp[200][200];
signed main(){
  int h, w, K;
  scanf("%lld%lld%lld", &h, &w, &K);
  dp[0][0] = 1;
  rrep(i,h)rep(j,w){
    rep(bit,1<<(w-1)){
      bool ok = true;
      rep(k,w-2){
        if((bit>>k) & 1 and (bit>>(k+1)) & 1)ok = false;
      }
      if(!ok)continue;
      if(0 < j and (bit>>(j-1)) & 1){
        ADD(dp[i][j], dp[i-1][j-1]);
      }else if(j < w-1 and (bit>>j) & 1){
        ADD(dp[i][j], dp[i-1][j+1]);
      }else{
        ADD(dp[i][j], dp[i-1][j]);
      }
    }
  }
  // PRINTF(dp, 2, 3);
  printf("%lld\n", dp[h][K-1]);
  return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include<string>
#include <bitset>

#define SIZE 100001
typedef long long ll;
using namespace std;

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

    if(K % 2 == 0 || K % 5 == 0){
        cout  << "-1" << endl;
    }else{
        int L;
        if(K % 7 == 0){
            L = 9 * K / 7;
        }else{
            L = 9 * K;
        }
        ll surplus = 10 % L;
        if(surplus == 1){
            cout << "1" << endl;
        }else{
            int i;
            for(i = 2 ; i <= L ; i++){
                surplus = (surplus * 10) % L;
                if(surplus == 1){
                    break;
                }
            }
            if(surplus == 1){
                cout << i << endl;
            }else{
                cout << "-1"  << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<string,int,int>;

int main(){
  int n,d; cin >> n >> d;
  int k = 1 + d + d;
  int ans = (n+k-1) / k;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
int h,w,b[6]={0,1,0,-1,-1,-1},c[6]={-1,0,1,1,0,-1},d[6]={1,1,1,0,-1,0},e[6]={-1,0,1,1,0,-1},a[102][102];
struct Q {int x,y;};
int main() {
	while (cin >> w >> h) {
		for (int i = 0; i <= h + 1; i++) {
			for (int j = 0; j <= w + 1; j++)
				a[i][j] = 0;
		}
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++)
				cin >> a[i][j];
		}
		queue<Q>q;
		q.push(Q{ 0,0 });
		int ans = 0;
		while (!q.empty()) {
			Q t = q.front(); q.pop();
			for (int i = 0; i < 6; i++) {
				int x2, y2;
				if (t.y % 2 == 0) {
					y2 = t.y + c[i];
					x2 = t.x + b[i];
				}
				else {
					y2 = t.y + e[i];
					x2 = t.x + d[i];
				}
				if (y2<0 || y2>h + 1 || x2<0 || x2>w + 1) continue;
				if (a[y2][x2] == 0) {
					q.push(Q{ x2,y2 });
					a[y2][x2] = 2;
				}
				else if (a[y2][x2] == 1) ans++;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3184
import sys

input = sys.stdin.readline
n, q = map(int, input().split())

nm2 = n - 2
ans = (nm2) ** 2
a = [-1] * (nm2)
b = [-1] * (nm2)
waku_h = nm2
waku_w = nm2

for _ in range(q):
    t, x = map(int, input().split())
    x -= 2
    if t == 1:
        if x < waku_w:
            ans -= waku_h
            for i in range(x + 1, waku_w):
                b[i] = waku_h
            waku_w = x
        else:
            ans -= b[x]
    else:
        if x < waku_h:
            ans -= waku_w
            for i in range(x + 1, waku_h):
                a[i] = waku_w
            waku_h = x
        else:
            ans -= a[x]

print(ans)


Measured memory_bytes: 71528
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    ll x;
    cin>>x;
    ll ans=0;
    ll cnt=100;
    while(cnt<x){
        cnt=cnt+cnt/100;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int a[5];
int main()
{
	int n; cin >> n;
	string s; cin >> s; int c = 0,mx=0;
	for (int i = 0; i < s.size(); ++i)
	{
		if (s[i] == 'I')
			c++;
		else if (s[i] == 'D')
			c--;
		mx= max(c, mx);

	}
	cout << mx;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int mod =1000000007;
const double PI = acos(-1);

int main(){
    ll n;cin>>n;
    vector<P> res;
    rep(i,n){
        int x,l;cin>>x>>l;
        res.push_back({x+l,x-l});
    }
    sort(been(res));
    int ans =0;
    int now =-INF;
    rep(i,n){
        if(now<=res[i].second){
            ans++;
            now=res[i].first;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4272
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;

//#define fi1 ifstream cin("input.txt")
//#define of1 ofstream cout("output.txt")
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll l,r;
    cin>>l>>r;
    ll val1=(l/2019);
    ll val2=(r/2019);
    if(val1!=val2)
    {
        cout<<0;
    }
    else
    {
        ll ans=INT_MAX;
         for(ll i=l;i<r;i++)
         {
             for(ll j=i+1;j<=r;j++)
             {
                 ans=min(ans,(i*j)%2019);
             }
         }
         cout<<ans;
    }
}

Measured memory_bytes: 256
//https://arc087.contest.atcoder.jp/tasks/arc087_d

#include<bits/stdc++.h>
const int N = 5005;
const int mod = 1e9 + 7;
using namespace std;

vector <int> adj[N];
vector <int> mv;
int n, C[N][N], f[N], a[N], d[N], cnt, cen;
int dp[N][N], ans;

void add(int&a, int b){
    a += b; if (a >= mod) a -= mod; if (a < 0) a += mod;
}

void dfs(int u, int p){
    d[u] = 1; int ck = 0;
    for (auto v : adj[u]){
        if (v == p) continue;
        dfs(v, u);
        d[u] += d[v];
        if (d[v] > n/2) ck = true;
    }
    if (n-d[u] > n/2) ck = true;
    if (!ck) mv.push_back(u);
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    for (int i = 0; i < N; i++) f[i] = ((i) ? 1LL * f[i-1] * i % mod : 1);
    for (int i = 0; i < N; i++) for (int j = 0; j <= i; j++){
        C[i][j] = ((j == 0) ? 1 : (C[i-1][j] + C[i-1][j-1]) % mod);
    }
    cin >> n;
    for (int i = 2; i <= n; i++) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(1, 1);
    if (mv.size() == 2){
        a[++cnt] = n/2; a[++cnt] = n/2;
    }
    else{
        cen = mv[0];
        dfs(cen, cen);
        for (auto v : adj[cen]) a[++cnt] = d[v];
    }
    dp[0][0] = 1;
    for (int i = 1; i <= cnt; i++){
        for (int sum = 0; sum <= n; sum++){
            for (int k = 0; k <= a[i]; k++){
                if (sum >= k) add(dp[i][sum], 1LL * dp[i-1][sum-k] * C[a[i]][k] % mod * C[a[i]][k] % mod * f[k] % mod);
            }
        }
    }
    for (int i = 0; i <= n; i++){
        if (i&1) add(ans, -1LL * dp[cnt][i] * f[n-i] % mod);
        else add(ans, 1LL * dp[cnt][i] * f[n-i] % mod);
    }
    cout << ans;
}


Measured memory_bytes: 196352
#include <iostream>
using namespace std;
int main(){
  int n;
  int x,cnt;
  cin>>n;
  for(int i=1;i<=n;i++){
    x=i/10;
    if(x<1){ cnt++;}
    else if(x<10) ;
    else if(x<100){cnt++;}
    else if(x<1000) ;
    else if(x<10000){cnt++;}
    else if(x<100000) ;
    else if(x<1000000){cnt++;}
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
list1 = []
for i in range(N):
  cnt = 0
  if A[i] % 2 ==1:
    continue
  else:
    while A[i] % 2 == 0:
      cnt += 1
      A[i] = A[i]//2
    list1.append(cnt)

if list1 == []:
  print(0)
elif len(list1) == 1:
  print(list1[0])
else:
  print(sum(list1))

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

k=2
while(2*n > k*(k-1)):
    k+=1

if(2*n!=k*(k-1)):
    print("No")
else:
    print("Yes")
    print(k)
    tmp=0
    result=[[0]*(k-1) for i in range(k)]
    for i in range(k):
        for j in range(i):
            result[i][j]=result[j][i-1]
        for l in range(k-i-1):
            tmp+=1
            result[i][i+l]=tmp
        
    for j in range(k):
        print("{} ".format(k-1),end="")
        for i in range(k-2):
            print("{} ".format(result[j][i]),end="")
        print(result[j][k-2])

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

#define REP(i,n) for(long long 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)

using ll = long long;
#define INF 1e9

int main(){
  int P, Q, R;
  cin >> P >> Q >> R;
  cout << min(P+Q, min(Q+R, R+P)) << endl;

}


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

using namespace std;

int main(){
  int n;
  string s, t;
  cin >> n;
  cin.ignore();

  cin >> s >> t;
  cin.ignore();

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int max(int a,int b,int c=0)
{
    if(a<b) a=b;
    if(a<c) a=c;
    return a;
}





int fun(int arr[][3],int n)
{
    int dp[n][3];
    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];


    for(int i=1;i<n;i++)
    {
        dp[i][0]= arr[i][0] + max(dp[i-1][1],dp[i-1][2]  ); 
        dp[i][1]= arr[i][1] + max(dp[i-1][0],dp[i-1][2]  );
        dp[i][2]= arr[i][2] + max(dp[i-1][0],dp[i-1][1]  );

    }


    return max(dp[n-1][0],dp[n-1][1],dp[n-1][2] );

}






int main()
{
    int n;
    cin >> n;
    int arr[n][3];

    for(int i=0;i<n;i++)        cin >> arr[i][0] >> arr[i][1] >> arr[i][2] ;
        
     

    cout<< fun(arr,n);
    
    
    
    return 0;
}

Measured memory_bytes: 2560
N = int(input())
xy = []
for n in range(N):
    x, y = [int(s) for s in input().split(' ')]
    xy.append((x, y))
total = 0
pattern = 1
for n in range(N):
    pattern *= (1 + n)
    for m in range(n + 1, N):
        x0, y0 = xy[n]
        x1, y1 = xy[m]
        total += ((x0 - x1) ** 2 + (y0 - y1) ** 2) ** 0.5
print(total * pattern / N * 2 / pattern)

Measured memory_bytes: 9400
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<set>
using namespace std;
typedef long long LL;
const int N=200005;
int n,x;
int a[N];
set<int> s;
int main()
{
	memset(a,-1,sizeof(a));
	scanf("%d%d",&n,&x);	
	if (x==1||x==2*n-1) {printf("No\n");return 0;}
	for (int u=1;u<=2*n-1;u++) s.insert(u);
	if (x==2)
	{
		a[n]=1;
		a[n+1]=x;
		a[n+2]=2*n-1;
		a[n-1]=3;
		s.erase(x);s.erase(1);s.erase(2*n-1);s.erase(3);
	}
	else
	{
		a[n]=2*n-1;
		a[n+1]=x;
		a[n+2]=1;
		a[n-1]=2;
		s.erase(x);s.erase(1);s.erase(2*n-1);s.erase(2);
	}
	n=n*2-1;
	printf("Yes\n");
	for (int u=1;u<=n;u++)
	{
		if (a[u]==-1)
		{
			int t=(*s.begin());
			printf("%d\n",t);
			s.erase(t);
		}
		else
		{
			printf("%d\n",a[u]);
		}
	}
	return 0;
}

Measured memory_bytes: 11648
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(M);
    vector<ll> S(M, 0);
    auto p = [&](int i, ll num){
        --i;
        if (0 <= i && i < M) S[i] += num;
    };
    scanInt(before);
    ll count = 0;
    loop(i, N){
        scanInt(ai);
        if (before <= ai){
            const int c = ai - before;
            count += c;
            p(before + 2, 1);
            p(ai + 1, -c);
            p(ai + 2, c - 1);
        }else{
            const int c = (M + ai - before);
            count += c;
            p(before + 2, 1);
            p(1, M - before);
            p(2, 1 - (M - before));
            p(ai + 1, -c);
            p(ai + 2, c - 1);
        }
        before = ai;
    }
    vector<ll> temp(M, 0);
    temp[0] = S[0];
    loop(i, M - 1){
        temp[i + 1] = temp[i] + S[i + 1];
    }
    vector<ll> result(M, 0);
    result[0] = temp[0];
    ll result_max = result[0];
    loop(i, M - 1){
        result[i + 1] = result[i] + temp[i + 1];
        result_max = max(result_max, result[i + 1]);
    }
    printf("%lld\n", count - result_max);
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <vector>
#define N 100000
using namespace std;
typedef long long ll;

ll n, x, y, ans, cx, cy, v[200005];
vector<ll> gr[200005];

void dfs(int p) {
	v[p] = 1;
	p<=N ? cx++ : cy++;
	for(int i=0; i<gr[p].size(); i++) {
		if(!v[gr[p][i]]) dfs(gr[p][i]);
	}
}

int main() {
	ll i, x, y;
	cin >> n;
	for(i=0; i<n; i++) {
		scanf("%lld%lld", &x, &y);
		gr[x].push_back(y+N);
		gr[y+N].push_back(x);
	}
	for(i=0; i<=2*N; i++) {
		if(!v[i]) {
			cx = cy = 0;
			dfs(i);
			ans += cx * cy;
		}
	}
	cout << ans - n;
	return 0;
}

Measured memory_bytes: 11520
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    long long a[5];
    long long n,b;
    cin>>n;
    for(int i=0; i<5; i++)
        cin>>a[i];
    sort(a,a+5);
    b=n/a[0];
    b=n%a[0]?b:b-1;
    cout<<b+5<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static int ans(int val){
        int count = 0;
        while(val > 1){
            if(val % 100 == 0){
                count++;
                val /= 100;
            } else {
                break;
            }
        }
        return count;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int n = sc.nextInt();
        int count = 0;
        int i = 1;
        while(count < n){
            if(ans(i) == d){
                count++;
            }
            i++;
        }
        System.out.println(i-1);
    }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
const double PI = 3.14159265359;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define INF 1000000000000
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
ll ans=0;
int n,y,x,c=0;

cin>>n;
x=n;
y=n-2;
int a[n];
FOR (i,n)
{
	cin>>a[i];
}
sort(a,a+n);
while(x>0)
{  
	if(x==n)
	{
		ans+=0;
	}
	else if(x==n-1)
    {
    	ans+=a[n-1];
	}
	else
	{   if(c==0)
	{	ans+=a[y];
	    c++;
	}
	
		else
		{
				ans+=a[y];
				y-=1;
				c=0;
		}
	}
	x--;
}
cout<<ans<<endl;

return  0;
}






Measured memory_bytes: 4424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;
typedef tuple<int,int,int> TP;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    ll A;
    string B;
    cin >> A >> B;
    B.erase(1,1);
    int C = stoi(B);
    ll D = C;
    cout << A * D / 100 << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#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 repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k,x,y;
  cin>>n>>k>>x>>y;
  if(n<=k){
    cout<<n*x<<endl;
  }
  else{
    cout<<n*y+k*(x-y)<<endl;
  }

  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int main()
{
   char s[1000][1000];
   int h,w;
   cin>>h>>w;

   for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      cin>>s[i][j];

   ll dp[h][w];
   memset(dp,-1,sizeof dp);
   dp[0][0]=0;
   int flag=1;
   for(int i=1;i<h;i++)
   {
       if(s[i][0]=='.'&&flag)
           dp[i][0]=1;
       else
       {
           dp[i][0]=0;
           flag=0;
       }
   }
   flag=1;
   for(int j=1;j<w;j++)
   {
       if(s[0][j]=='.'&&flag)
          dp[0][j]=1;
       else
       {
           dp[0][j]=0;
           flag=0;
       }
   }
   for(int i=1;i<h;i++)
   {
       for(int j=1;j<w;j++)
       {
           if(s[i][j]=='#')
            dp[i][j]=0;
           else
           {
            dp[i][j]=dp[i-1][j]+dp[i][j-1];
            dp[i][j]%=mod;
           }
       }
   }

   cout<<dp[h-1][w-1]<<"\n";
   return 0;
}


Measured memory_bytes: 9088
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

struct P{
  int x, y;
}

void main(){
  int n = readNum!int;
  P[] p = new P[](n);

  foreach(i; 0 .. n){
    auto s = readNums!int;
    p[i].x = s[0];
    p[i].y = s[1];
  }

  p.multiSort!("a.x < b.x", "a.y < b.y");

  int ret = n;
  foreach(i; 0 .. n-1){
    foreach(j; i+1 .. n){
      P d = {p[j].x - p[i].x, p[j].y - p[i].y};
      int cnt;

      bool[] f = new bool[](n);
      foreach(k; 0 .. n){
        if(f[k]) continue;
        f[k] = true;
        cnt++;

        for(int l = 1; ; l++){
          bool found;
          foreach(m; k+1 .. n){
            if((p[k].x + d.x * l) == p[m].x && (p[k].y + d.y * l) == p[m].y){
              f[m] = true;
              found = true;
            }
          }
          if(!found) break;
        }
      }

      ret = min(ret, cnt);
    }
  }

  writeln(ret);
}


Measured memory_bytes: 380
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int k = parseInt(sc.next());
		int[] p = new int[n];
		for (i = 0; i < n; i++) {
			p[i] = parseInt(sc.next());
		}
		sc.close();
		Arrays.parallelSort(p);
		int sum=0;
		for (i = 0; i < k; i++) {
			sum+=p[i];
		}
		out.println(sum);
	}
}


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

p=list(map(int,input().split()))

cnt=0
for i in range(1,n-1):
    if p[i-1]<p[i] and p[i]<p[i+1]:
        cnt+=1
    elif p[i-1]>p[i] and p[i]>p[i+1]:
        cnt+=1

print(cnt)

Measured memory_bytes: 9100
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include<iomanip>
#include<tuple>
#include<cmath>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int N;
    int h[100010];
    int dp[100010];
    cin>>N;
    for (int i=0;i<N;i++){
        cin>>h[i];
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int n=2;n<N;n++){
        dp[n]=min((dp[n-1]+abs(h[n]-h[n-1])),dp[n-2]+abs(h[n]-h[n-2]));
        //cout<<"dp["<<n<<"]"<<dp[n]<<endl;
    }
    cout<<dp[N-1]<<endl;

    return 0;
}

Measured memory_bytes: 1024
import sys


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


def input():
    return sys.stdin.readline().strip()


def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    C = [h for h in H]
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        if C[a] <= H[b]:
            C[a] = 0
        if C[b] <= H[a]:
            C[b] = 0

    ans = 0
    for c in C:
        if c > 0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20052
#include <stdio.h>
#include <stdlib.h>
int main(void) {
    int num,day,move,town=1,temp,road[100000]={0},sum=0,i;
    scanf("%d %d",&num,&day);
    sum=0;
    for (i=0; i<num-1; i++) {
        scanf("%d",&temp);
        road[i+1]=road[i]+temp;
    }
    for (i=0; i<day; i++) {
        scanf("%d",&move);
        sum+=abs(road[town+move-1]-road[town-1]);
        sum%=100000;
        town+=move;
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 996
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MX=2e5+9;
int n,x,ans,a[MX];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n+1;i++){
        if(a[i]==i)x++;
        else if(x){ans+=(x+1)/2;x=0;}
    }
    cout<<ans<<endl ;
}


Measured memory_bytes: 640
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete


main = do
    ls <- map (map readInt . wordsBy (==',')) . lines <$> getContents
    forM_ ls $ \line -> do
        let ls = take 10 line
        let [v1,v2] = drop 10 line
        let sl = scanl (+) 0 ls
        let dist = (v1 * last sl) % (v1 + v2)
        print $ fst $ head $ dropWhile ((<dist) . (%1) . snd) $ zip [1..10] $ tail sl
        

Measured memory_bytes: 4120
#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 << "Right" << endl;
  }
  
  if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
        
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    string s;
    cin >> s;
    cout << s.substr(0,4) << " " << s.substr(4,s.length()) << ENDL;
    
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        int ans=0;
        int bool = 1;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        LinkedList<Integer> nums = new LinkedList<>();
        for(int i=0;i<n;i++){
            nums.add(sc.nextInt());
        }
        nums.sort(Collections.reverseOrder());
        for (int num:nums){
            ans += num*bool;
            bool=(-bool);
        }
        System.out.println(ans);
    }
}

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

int main(){
    int n, m; cin >> n >> m;
    vector<string> submit[n];
    rep(i, m){
        int p; string res; cin >> p >> res;
        submit[--p].push_back(res);
    }

    int acnum = 0, wanum = 0;
    rep(i, n){
        bool acflag = false;
        int watmp = 0;
        for(string sub : submit[i]){
            if(sub == "AC") acflag = true;
            if(!acflag && sub == "WA") watmp++;
        }
        if(acflag) acnum++;
        if(acflag) wanum += watmp;
    }
    cout << acnum << ' ' << wanum << endl;
    return 0;
}

Measured memory_bytes: 10368
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s; cin >> s;
    s[5] = ' '; s[13] = ' ';
    cout << s << endl;
    return 0;
}


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

int main(){
    int N, X, sum{1}, t{};
    cin >> N >> X;
    vector<int> L(N);
    for(int i{}; i<N; i++){
        cin >> L.at(i);
        t += L.at(i);
        if(t<=X){
            sum++;
        }
    }
    cout << sum << endl;
}

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int n, a[200010];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	Int ans = 0;
	bool b = 0;
	if(a[0] != 0) cout << -1 << endl;
	else{
		for(int i = n-1; i > 0; i--){
			if(a[i] - a[i-1] > 1) b = 1;
			if(a[i] <= a[i-1]) ans += a[i];
			else
				ans += a[i] - min(a[i-1], max(a[i]-1, 0));
		}
		if(!b) cout << ans << endl;
		else cout << -1 << endl;
	}
	
	return 0;
}

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

using ll = long long;

ll lcm(ll a, ll b) {
	return a * b / __gcd(a, b);
}

int main() {
	ll n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;
	
	bool ok = true;
	for (ll i = 0; i < n; i++) {
		if (i * m % n) {
			continue;
		}
		if (s[i] != t[i * m / n]) {
			ok = false;
		}
	}
	
	if (ok) {
		cout << lcm(m, n) << endl;
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}


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

int main(){
	deque<char> de;
	string s;
	cin >> s;
	for(int i=0;i<s.length();i++){
		de.push_back(s.at(i));
	}
	int q;
	cin >> q;
	int tcnt = 0;
	for(int i=0;i<q;i++){
		int t;
		cin >> t;
		if(t == 1){
			tcnt++;
			continue;
		}
		int f;
		char c;
		cin >> f;
		cin >> c;
		if(tcnt % 2 == 0){
			if(f == 1){
				de.push_front(c);
			}else{
				de.push_back(c);
			}
		}else{
			if(f == 1){
				de.push_back(c);
			}else{
				de.push_front(c);
			}
		}
	}
	if(tcnt % 2 != 0){
		reverse(de.begin(),de.end());
	}
	for(char x: de){
		cout << x;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3308
N=int(input())
A=[int(input()) for i in range(N)]
A.sort()
a=0
t=1
for i in range(1,N):
    if A[i-1]==A[i]:
        t+=1
    else:
        if t%2==1:
            a+=1
        t=1
if t%2==1:
    a+=1
print(a)


Measured memory_bytes: 7388
n = int(input())
s = input()

# E リーダー W
e = 0
w = s[1:].count("W")
ans = e+w
for i in range(1,n):
    if s[i-1] == "E":
        e += 1
    if s[i] == "W":
        w -= 1
    if ans < e + w: ans = e+w
print(n-ans-1)

Measured memory_bytes: 3700