akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

constexpr long long mod{998244353};
long long fact[4096], inv[4096], finv[4096];
void init_combi();
long long combi(int, int);

int main()
{
	// a + b == 2 * k + 2のとき、combi_sum[a] == combi_sum[b]
	// a <= k + 1まで求めればいい
	// x + y == iとなるとき、iに対してx,yは一対一対応(x == yに注意)
	// i.e.ペアとなるx,yについて、どちらか一方のみしか使わなければ条件を満たす
	// i:奇数 なら 1 <= x <= i/2のみについて考えて、xが使われた分だけ2の累乗をかける(∵同じ組み合わせがyについても作れる)
	// 1 <= x <= i/2を満たすxのうちt個だけ全部合わせてs個使うなら(k-i+1)C(s-t) * (i/2)C(t) * 2^t通りの数字の選び方
	// それぞれの数字の選び方に対し、組み合わせは(n-1)C(s-1)
	// これを各s,tについて足す(i <= z <= kだから0 <= s-t <= k - i + 1)
	// i:偶数 なら 1 <= x <= i/2-1で、(k-i+1)C(n-t) * (x)C(t) * 2^t
	// さらにi/2も一度だけなら使ってもいいから、1 <= x <= i/2-1で、 nをn-1に置き換えたものを足す
	int k, n;
	long long combi_sum[2048]{}, two_pow[2048]{1};
	init_combi();
	for (int i = 1; i <= 2000; i++)
		two_pow[i] = 2 * two_pow[i - 1] % mod;
	scanf("%d%d", &k, &n);
	for (int i{2}; i <= k + 1; i++)
	{
		// tを固定すると、n個をk-i+1+t個に分ける分け方を求めればよくなる。ただし、t個については1以上でk-i+1個については0以上
		// ここで、k-i+1個分余計に用意しておけば、すべてのk-i+1+t個全部に対して同様に1以上という条件の下で計算できる
		int t_limit{std::min((i - 1) / 2, n)};
		for (int t{}; t <= t_limit; t++)
		{
			combi_sum[i] += combi((i - 1) / 2, t) * two_pow[t] % mod * combi(n + k - i, k - i + t) % mod;
			combi_sum[i] %= mod;
		}
		if (~i & 1)
		{
			int t_limit{std::min((i - 1) / 2, n - 1)};
			for (int t{}; t <= t_limit; t++)
			{
				combi_sum[i] += combi((i - 1) / 2, t) * two_pow[t] % mod * combi(n - 1 + k - i, k - i + t) % mod;
				combi_sum[i] %= mod;
			}
		}
	}
	for (int i{2}; i <= k + 1; i++)
		printf("%lld\n", combi_sum[i]);
	for (int i{k}; i > 1; i--)
		printf("%lld\n", combi_sum[i]);

	return 0;
}

void init_combi()
{
	fact[0] = fact[1] = inv[0] = inv[1] = finv[0] = finv[1] = 1;
	for (int i{2}; i <= 4000; i++)
	{
		fact[i] = i * fact[i - 1] % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

long long combi(int n, int r)
{
	if (n < 0 || r < 0 || n < r) return 0;
	return fact[n] * finv[r] % mod * finv[n - r] % mod;
}

Measured memory_bytes: 384
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000007
#define int long long
#define inf (1LL << 30)
const int maxnodes=1005;
#define LL long long
#define N 1001
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int32_t main()
{
    IOS;
    
    int deg[4];
    memset(deg,0,sizeof(deg));
    bool ch = 1;
    for(int i = 0;i < 3;i++)
    {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        deg[a]++;
        deg[b]++;
        if(deg[a] > 2 or deg[b] > 2)
            ch = 0;
    }
    if(ch)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> weights(N);
  vector<int> sums(N+1);
  for (int n = 0; n < N; ++n) {
    cin >> weights[n];
    sums[n+1] = sums[n] + weights[n];
  }
  int res = sums.back();
  for (int n = 1; n < N; ++n) {
    int l = sums[n];
    int r = sums.back() - l;
    res = min(res, abs(r - l));
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 3620
// vim: set fdm=marker:
// {{{
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <utility>

using namespace std ;

typedef long long ll ;

// }}}

int a1[111];
int a2[111];
int pos[111], pre[111];

int main()
{
    int N;
    cin >> N;
    for(int i = 1 ; i <= N ; i++)
      scanf("%d", &a1[i]);
    for(int i = 1 ; i <= N ; i++)
      scanf("%d", &a2[i]);
    for(int i = 1 ; i <= N ; i++)
      pre[i] = pre[i-1] + a1[i];
    for(int i = N ; i >= 0 ; i--)
      pos[i] = pos[i+1] + a2[i];
    int ans = 0;
    for(int i = 1 ; i <= N ; i++)
      ans = max(ans, pre[i]+pos[i]);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		while(true){
			int n = si();
			if(n==0) break;
			Playerr[] ppl = new Playerr[n];
			for (int i = 0; i < n; i++) {
				ppl[i] = new Playerr(si(),si()*60+si()+si()*60+si()+si()*60+si()+si()*60+si());
			}
			Arrays.sort(ppl);
			out.println(ppl[0].id);
			out.println(ppl[1].id);
			out.println(ppl[n-2].id);
		}
		out.flush();
	}

	static int si() {
		return Integer.parseInt(scan.next());
	}
}

class Playerr implements Comparable<Object> {
	int id,rec;
	Playerr(int p,int q){
		id=p;rec=q;
	}
	@Override
	public int compareTo(Object o) {
		return this.rec-((Playerr)o).rec;
	}

}

Measured memory_bytes: 72696
//
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<cassert>
#include<algorithm>
#include<cmath>

#include<cstring>
#include<string>
#include<cctype>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<list>

typedef long long ll;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
typedef std::vector<int> vi;

const int OO=(int)2e9;
const ll INF=(ll)4e18;
const double EPS=(double)1e-12;

#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front

#define INL(i,a,b) ((a<=i)&&(i<=b))
#define EXL(i,a,b) ((a< i)&&(i< b))
#define REPP(i,a,b,c) for(int i=a;i<=b;i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a;i>=b;i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
using namespace std;

int n,l;
int dat[55][55];
char s[55];

int main(){
	REP(i,0,53) REP(j,0,53)dat[i][j]=0;
	scanf("%d",&n);
	REP(i,1,n){
		scanf("%s",s);
		l=strlen(s);
		REP(j,1,l)dat[i][s[j-1]-'a']++;
	}
	REP(j,0,25){
		dat[52][j]=OO;
		REP(i,1,n)dat[52][j]=min(dat[52][j],dat[i][j]);
	}
	REP(j,0,25) while(dat[52][j]--)printf("%c",j+'a');
	puts("");
	return 0;
}

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

public class Main {
    private static IO io = new IO();
    public static void main(String[] args) {

        while (io.hasNext()) {
            int n = io.nextInt();
            int prime[] = new int[n];    // i??????????´???°???????´?
            boolean isprime[] = new boolean[n+1];    // i???true??????i????´???°
            Arrays.fill(isprime, true);

            int ans = 0;
            for (int i = 2; i <= n; i++) {
                if (isprime[i]) {
                    prime[ans++] = i;
                    for (int j = 2 * i; j <= n; j += i) isprime[j] = false;
                }
            }

            System.out.println(ans);
        }
        
    }

    static class IO extends PrintWriter {
        private final InputStream in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        IO() {
            this(System.in);
        }

        IO(InputStream source) {
            super(System.out);
            this.in = source;
        }

        boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }
        int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }
        boolean isPrintableChar(int c) {return 33<=c &&c <=126;}
        void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;}
        boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }

        int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public void close() {
            super.close();
            try {
                in.close();
            } catch (IOException ignored) {
            }
        }
    }
}

Measured memory_bytes: 55820
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    h,w = map(int,input().strip().split())
    ll=["#" * (w+2)]
    
    for _ in range(h):
        ll.append("#"+input().strip()+"#")
    ll.append("#" * (w+2))
    for s in ll:
        print(s)


if __name__ == '__main__':
    main()

Measured memory_bytes: 60012
#include<bits/stdc++.h>
using namespace std;
int num[101];
int n;
long long int dp[1001][1001];
long long int searcher(int place,int total);
int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> num[i];
  }
  cout << searcher(1,num[0]) << endl;
}
long long int searcher(int place,int total){
  if(dp[place][total]!=0){
    return dp[place][total];
  }
  else if(place == n-1){
    if(total == num[n-1]){
      return 1;
    }
    else{
      return 0;
    }
  }
  else if(total < 0 || total > 20){
    //cout << total << " ";
    return 0;
  }
  else{
    return dp[place][total] = searcher(place+1,total-num[place]) + searcher(place+1,total+num[place]);
  }
}

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

int main(){
    
    int S, h, m, s;
    cin >> S;
    
    h = S /3600;
    m = (S - 3600*h) / 60;
    s = S % 60;
    
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
    
}


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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::string o, e;
  std::cin >> o >> e;

  for (int i = 0; i < o.size(); i++) {
    std::cout << o[i];
    if (i < e.size()) {
      std::cout << e[i];
    }
  }
  std::cout << std::endl;
  return 0;
}


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const ll MOD = 1000000007;

#define MAX 10000007

ll fat[MAX];
	
ll binPow(ll a, ll p){
	ll ans = 1;
	while(p){
		if(p&1)
			ans=(ans*a)%MOD;
		a = (a*a)%MOD;
		p>>=1;
	}
	return ans;
}

ll calculateBIN(int m, int k){
	//if(m < m) return 0;
	ll ans = fat[m-k] * fat[k] % MOD;
	ans = fat[m] * binPow(ans, MOD-2) % MOD;
	return ans;
}

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

	fat[0] = 1;
	for(int i = 1; i < MAX; i++)
		fat[i] = fat[i-1] * i % MOD;

	int n, k; cin >> n >> k;
	vi v(n);
	for(auto& p: v) cin >> p;

	sort(all(v));
	
	ll ans = 0;
	for(int i = k-1; i < n; i++){
		ll add = calculateBIN(i, k-1) * v[i];
		ans = (ans + add) % MOD;
	}	

	for(int i = n-k; i >= 0; i--){
		ll add = calculateBIN(n-i-1, k-1) * v[i];
		ans = (ans - add + MOD) % MOD;
	}

	cout << ans << '\n';

	return 0;
}


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

#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>

const int N = 3002;
int dp[2][N][2];
int a[N];
int n;

void solve()
{
   cin >> n;
    
   f(i,n) cin >> a[i];
    
   for(int i=1;i<=n;i++)
     for(int j=0;j<n-i+1;j++)
        for(int k=0;k<=1;k++)
          dp[i%2][j][k] = max(-dp[(i-1)%2][j][k^1]+a[j+i-1],-dp[(i-1)%2][j+1][k^1]+a[j]);  
       
   cout << dp[n%2][0][0] << '\n'; 
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 384
using System;
using System.Linq;

namespace _0102
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) break;
                int[,] a = new int[n + 1, n + 1];
                for (int i = 0; i < n; i++)
                {
                    int[] now = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    for (int j = 0; j < n; j++)
                    {
                        a[i, j] = now[j];
                    }
                    a[i, n] = now.Sum();
                    for (int k = 0; k < 5 - a[i, 0].ToString().Length; k++) Console.Write(" ");
                    Console.Write(a[i, 0]);
                    for (int j = 1; j <= n; j++)
                    {
                        for (int k = 0; k < 5 - a[i, j].ToString().Length; k++) Console.Write(" ");
                        Console.Write(a[i, j]);
                    }
                    Console.WriteLine();
                }
                int sum = 0;
                for (int i = 0; i < n; i++)
                {
                    sum += a[i, 0];
                }
                for (int i = 0; i < 5 - sum.ToString().Length; i++) Console.Write(" ");
                Console.Write(sum);
                for (int j = 1; j <= n; j++)
                {
                    sum = 0;
                    for (int i = 0; i < n; i++)
                    {
                        sum += a[i, j];
                    }
                    for (int i = 0; i < 5 - sum.ToString().Length; i++) Console.Write(" ");
                    Console.Write(sum);
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <map>

#define ull unsigned long long
#define ll long long

using namespace std;

int x[200010];

int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    int x,y;
    if(c%b==0){
        x=c/b;
    }
    else{
        x=c/b+1;
    }
    if(a%d==0){
        y=a/d;
    }
    else{
        y=a/d+1;
    }
    if(x<=y){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORX(i, a, b, x) for (int i = (a); i <= (b); i+=x)
#define debug(x) cerr << #x << " is= " << x << endl; //use for debugging
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 5] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
 
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define mp(a,b) make_pair(a,b)
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vov        vector<vector<int>> 
#define pr         pair<ll,ll>
#define vpll       vector<pair<ll,ll>>
#define all(v)     v.begin(),v.end()
#define rall(v)    v.rbegin(),v.rend()  //reverse of above;
#define sz(container) int((container).size())
#define cut(x) {cout<<x<<"\n"; return;}
#define setprec(x) cout << fixed << showpoint << setprecision(8)<<x<<endl;
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define time cout << clock() / double(CLOCKS_PER_SEC) << endl;
#define endl "\n"
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
//*s.find_by_order() ->returns an iterator to the k-th largest element (counting from zero);
//s.order_of_key() ->number of elements strictly smaller then our item;
//st.rbegin()->second; last element in set
//st.erase(prev(st.end())); delete last element in set;
//sort(a+1,a+n+1,[](ll x,ll y){return abs(x)>abs(y);});
//sort(v.begin(), v.end(), greater<int>()); 
const int N=2e5+5;
int n,m;
string s;
void solve()
{
 int ans=0;
 s='#'+s;
 FOR(i,1,n/2) if(s[i]!=s[n-i+1]) ans++;
 cout<<ans;
}
int main()
{
  fast_io;
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  cin>>s;
  n=sz(s);
  solve();
}

Measured memory_bytes: 3628
def main():
    n, q = map(int, input().split())
    At = list()
    for i in range(n):
        At.append(list())

    for _ in range(q):
        param = [int(a) for a in input().split()]

        if   param[0] == 0:
            At[param[1]].append(param[2])

        elif param[0] == 1:
            if len(At[param[1]]) == 0:
                print()
            else:
                print(*At[param[1]])

        elif param[0] == 2:
            if len(At[param[1]]) == 0:
                continue
            else:
                At[param[1]].clear()
main()



Measured memory_bytes: 29656
def main():
    a, b = map(int, input().split())
    s, k = '.#'
    ans = [[k] * 100 for _ in range(50)] + [[s] * 100 for _ in range(50)]
    col = 0
    row = 0
    for _ in range(a - 1):
        ans[row][col] = s
        col += 2
        if col == 100:
            col = 0
            row += 2
    col = 0
    row = 99
    for _ in range(b - 1):
        ans[row][col] = k
        col += 2
        if col == 100:
            col = 0
            row -= 2
    print(100, 100)
    for row in ans:
        print(''.join(row))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi LUCA;
  LUCA.pb(2);
  LUCA.pb(1);
  FOR(i,2,n+1){
    LUCA.pb(LUCA[i-1]+LUCA[i-2]);
  }
  OUT(LUCA[LUCA.size()-1]);
}

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

using namespace std;


void solve() {
    int n,m;
    cin >> n >> m;
    string s,t;
    cin >> s >> t;
    int g = __gcd(n,m);
    int a = n/g, b = m/g;
    for (int i=0,j=0; i<n && j<m; i+=a, j+=b) {
        if (s[i] != t[j]) {
            cout << -1; return;
        }
    }
    long long res = 1ll*n*m/g;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 640
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using static System.Math;
using static System.Console;

class E { static void Main() => new J(); }
class J
{
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var n = F();
		var mc = new int[26];
		for (var i = 0; i < 26; i++) mc[i] = 100;
		for (var i = 0; i < n; i++)
		{
			var c = new int[26];
			var s = ReadLine();
			foreach (var ch in s) c[ch - 'a']++;
			for (var j = 0; j < 26; j++) mc[j] = Min(mc[j], c[j]);
		}
		for (var i = 0; i < 26; i++) for (var j = 0; j < mc[i]; j++) Write((char)('a' + i));
		WriteLine();
	}
}

Measured memory_bytes: 11092
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
#include<vector>
using namespace std;
long long  mod = 1000000007;

struct edge {
	int to, cost;
};
vector<edge> G[100010];

/*int gcd(int a, int b) {
	if (a < b) return gcd(b, a);
	else if (b == 0) return a;
	else return gcd(b, a % b);
}*/
int d[100010];
void dfs(int v, int parent) {
	for (int i = 0; i < G[v].size(); i++) {
		if (G[v][i].to == parent)
			continue;
		d[G[v][i].to] = (d[v] + G[v][i].cost) % 2;
		dfs(G[v][i].to, v);
	}
}

int main()
{

	int N, u, v, w;

	scanf("%d", &N);
	for (int i = 0; i < N - 1; i++) {
		scanf("%d%d%d", &u, &v, &w);
		G[u].push_back({ v,w });
		G[v].push_back({ u,w });
	}
	int V;
	/*scanf("%d", &V);
	for (int i = 0; i < G[V].size(); i++) {
		printf("%d %d\n", G[V][i].to, G[V][i].cost);
	}*/
	dfs(1, -1);
	for (int i = 1; i <= N; i++) {
		printf("%d\n", d[i] % 2);
	}
	return 0;
}

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

int N,dp[5010][2];
int main(){
    scanf("%d",&N);
    fill_n(*dp,5010*2,1e9);
    dp[0][1]=dp[1][0]=0;

    for(int i=0;i<N-1;i++){
        int c;scanf("%d",&c);
        for(int j=N/2;j>=0;j--){
            dp[j+1][0]=min(dp[j][0],dp[j][1]+c);
            dp[j][1]=min(dp[j][1],dp[j][0]+c);
        }
    }
    printf("%d\n",min(dp[N/2][0],dp[N/2][1]));
    return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <tuple>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <time.h>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n)
#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
string s, t, n;
int main() {
	cin >> s >> t >> n;
	if (s[s.length() - 1] == t[0] && t[t.length() - 1] == n[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int K;
  string S;
  cin >> K >> S;
  if(S.size()<=K) cout << S << endl;
  else {
    rep(i,K) cout << S[i];
    cout << "..." << endl;
  }
}

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

using namespace std;

#define ll long long
#define fi first
#define se second


const ll maxn = 1e5 + 10;
pair<ll, ll> a[maxn];

bool cmp(pair<ll, ll> x, pair<ll, ll> y) {
    return x.fi + x.se > y.fi + y.se;
}


int main(){
    ll n; cin >>n;
    for (int i = 0; i < n; i++) {
        cin >> a[i].fi >> a[i].se;
    }
    sort(a, a+n, cmp);
    ll suma = 0, sumb = 0;
    for (int i = 0; i < n; i++) {
        suma += a[i].fi;
        i++;
        if (i == n)break;
        sumb += a[i].se;
    }
    cout << suma - sumb << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

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

	ll cnt = 0;
	REP(i, n) {
		if (a[i] != b[i]) {
			cnt++;
		} else if (a[i] != c[i]) {
			cnt++;
		} else if (b[i] != c[i]) {
			cnt++;
		}
		if (a[i] != b[i] && b[i] != c[i] && a[i] != c[i]) cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int y = sc.nextInt();
		boolean ans=false;
		int man=0;
		int go=0; 
		int sen = 0;
		int iMax= y/10000;
		a: for(int i=0; i<=iMax; i++) {
			int jMax= (y-i*10000)/5000;
			for(int j=0; j<=jMax; j++) {
					if((y-i*10000-j*5000)/1000 == n-i-j) { ans=true;
					man=i;
					go=j;
					sen=n-i-j;
					break a;}
				}
			}
		if(ans) {
			System.out.println(man +" "+go+" "+sen);
		} else {
			System.out.println(-1+" "+-1+" "+-1);
		}
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <climits>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define ll long long int
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define loop(i, L, R) for (int i = L; i < R; ++i)
#define looprev(i, L, R) for (int i = L; i > R; --i)
#define MAX(x, y) (x > y ? x : y)
#define MIN(x, y) (x < y ? x : y)
#define wh(t) while (t--)
#define pii pair<int, int>
#define ppi pair<int, pii>
#define pll pair<ll, ll>
#define ppl pair<ll, pll>
#define vii vector<int>
#define vvi vector<vii>
#define vl vector<ll>
#define vvl vector<vl>
#define maxHi priority_queue<int>
#define maxHl priority_queue<ll>
#define minHi priority_queue < int, vector<int>, greater<int>>
#define minHl priority_queue < ll, vector<ll>, greater<ll>>
#define mod 1000000007
#define inf 1000000000000000001
#define PI 3.1415926535897932384626
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define mp(x, y) make_pair(x, y)
#define mem(a, val) memset(a, val, sizeof(a))
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false)
#define endl "\n"
using namespace std;

/*  AH SH*T,  HERE WE GO AGAIN.  */


void solve()
{
    ll i, j, n, m;

    string s;

    cin >> s;


    if (s[0] % 65 <= 25)
        cout << "A" << endl;
    else cout << "a" << endl;



}


int32_t main()
{

    IOS;
    cin.tie(NULL);

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

    int T = 1;



    wh(T)
    {

        solve();

    }
}

Measured memory_bytes: 3636
N = int(input())
a = [int(input()) for _ in range(N)]
s = [0] * N
c = 0
OK = False
n = 0
while True:
    c += 1
    n = a[n] - 1
    if n == 1:
        OK = True
        break
    if s[n] == 1:
        break
    s[n] = 1
if OK:
    print(c)
else:
    print(-1)

Measured memory_bytes: 13620
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;cin>>s;
	int n = s.size();
	if(s =="keyence"){
		cout << "YES" << endl;
		return 0;
	}
	for(int i = 0; i <= n; i++) {
		for(int j = i + 1; j < n; j++) {
			string sub1 = s.substr(0,i);
			string sub2 = s.substr(j);
			if(sub1 + sub2 == "keyence"){
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}

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

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

  for (int i = 0; i < n; i++) {
    cout << s.at(i) << t.at(i);
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3556
#include<iostream>

using namespace std ;

int main()
{
	int n ;
	while( cin >> n , n )
	{
		int a ,b ;
		int acnt = 0 , bcnt = 0 ;
		while( n )
		{
			n-- ;
			cin >> a >> b ;
			if( a == b )
			{
				acnt += a ;
				bcnt += b ;
			}
			else
			{
				a > b ? acnt += a + b : bcnt += a + b ;
			}
		}
		cout << acnt << ' ' << bcnt << endl ;
	}
	return 0 ;
}

Measured memory_bytes: 3076
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * B - ROT N
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 文字列の桁数
        int n = sc.nextInt();
        String s = sc.next();
        String result = "";

        List<String> alphabetsList = Arrays.asList( "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.length(); i++ ) {
//            System.out.println("charat : " + s.charAt( i ));
            int key = alphabetsList.indexOf( String.valueOf( s.charAt( i ) ) );
            if( key + n >= 26 ) {
                key -= 26;
            }
//            System.out.println("key : " + key );
            result += alphabetsList.get( key + n );
        }

        System.out.println( result );

        sc.close();
    }
}

Measured memory_bytes: 147540
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	M := nextInt()
	a := make([]int, N-1+M)
	b := make([]int, N-1+M)
	g := make([][]int, N)
	for i := 0; i < N-1+M; i++ {
		a[i] = nextInt() - 1
		b[i] = nextInt() - 1
		g[a[i]] = append(g[a[i]], b[i])
	}
	list := topologicalSort(g)
	rList := make([]int, N)
	for i := 0; i < len(list); i++ {
		rList[list[i]] = i
	}
	ans := make([]int, N)
	fill(&ans, list[0])
	for i := 0; i < N-1+M; i++ {
		if rList[ans[b[i]]] < rList[a[i]] {
			ans[b[i]] = a[i]
		}
	}
	ans[list[0]] = -1
	fmt.Println(ans[0] + 1)
	for i := 1; i < N; i++ {
		fmt.Println(ans[i] + 1)
	}
}

// g 隣接リスト
func topologicalSort(g [][]int) []int {
	V := len(g) // 頂点数
	ans := make([]int, 0)
	used := make([]bool, V)
	var dfs func(int)
	dfs = func(u int) {
		if used[u] {
			return
		}
		used[u] = true
		for _, v := range g[u] {
			dfs(v)
		}
		ans = append(ans, u)
	}
	for i := 0; i < V; i++ {
		dfs(i)
	}
	for i := 0; i < len(ans)/2; i++ {
		ans[i], ans[len(ans)-1-i] = ans[len(ans)-1-i], ans[i]
	}
	return ans
}

var dy = []int{1, 0, -1, 0, 0}
var dx = []int{0, 1, 0, -1, 0}
var intmax = int(1e9)

func fill(a *[]int, n int) {
	for i := 0; i < len(*a); i++ {
		(*a)[i] = n
	}
}

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = newScanner()
	log.SetFlags(log.Lshortfile)
}

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


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

int main(){
    int N, T, A;
    cin >> N >> T >> A;
    int flag;
    double x = pow(10,6);

    for(int i=0; i<N; i++){
        int X;
        cin >> X;
        int dif = abs(1000*A- (1000*T-X*6) );
        if(dif <x){
            x =dif;
            flag = i+1;
        }
    }

    cout << flag << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
vector<int>e[N];
int dep[N]={-1},n,k,sum,b1,b2,ans=2000;
void dfs(int u,int f)
{
	dep[u]=dep[f]+1;
	if(dep[u]>k/2)
		sum++;
	for(int i=0;i<e[u].size();i++)
		if(e[u][i]!=f)
			dfs(e[u][i],u);
}
void dfs2(int u,int f)
{
	dep[u]=dep[f]+1;
	if(dep[u]>k/2)
		sum++;
	for(int i=0;i<e[u].size();i++)
		if(e[u][i]!=f&&e[u][i]!=b1&&e[u][i]!=b2)
			dfs2(e[u][i],u);
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		e[a].push_back(b);
		e[b].push_back(a);
	}
	if(k%2==0)
	{
		for(int i=1;i<=n;i++)
		{
			sum=0;
			dfs(i,0);
			ans=min(ans,sum);
		}
		printf("%d\n",ans);
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=0;j<e[i].size();j++)
			{
				sum=0;
				b1=i;
				b2=e[i][j];
				dfs2(b1,0);
				dfs2(b2,0);
				ans=min(ans,sum);
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;

int main(){
	cin>>n;
	map<int,int> m;
	vi a;
	for(int i=0;i<n;i++){
		int A;
		cin>>A;
		if(m[A]%2==1){
			a.push_back(A);
		}
		m[A]++;
	}
	sort(a.rbegin(),a.rend());
	if(a.size()<2) cout<<0<<endl;
	else cout<<(ll)a[0]*a[1]<<endl;
}

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

using namespace std;

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

	string s;
	cin >> s;
	istringstream f(s);
	while (getline(f, s, ',')) {
		cout << s << ' ';
	}
	cout << '\n';


	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _001_B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            long[] nx = ReadLongs();
            long n = nx[0];
            long x = nx[1];
            Console.WriteLine(Length(n, x));
        }

        static long Length(long n, long x)
        {
            long min = Math.Min(n - x, x);
            long max = n - min;
            long cnt = max / min;

            if (max % min == 0)
            {
                return min * 3 * cnt;
            }
            else
            {
                long margin = max % min;
                return min * 3 * cnt + Length(margin + min, min);
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
#define N_MAX 1000
#define M_MAX 1000

int N[N_MAX],M[M_MAX];
int n,m;

int main(void){
	int i,a;
	while(scanf("%d%d",&n,&m),n != 0 || m != 0){
		for(i=0;i<n;i++)scanf("%d",N+i);
		for(i=0;i<m;i++)scanf("%d",M+i);
		i = a = 0;
		while(i < n-1){
			i += M[a];
			if(i < n-1){
				i += N[i];
			}
			a++;
		}
		printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 608
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()

    t = []
    k = 0
    kf = False
    for c in s:
        if '0' <= c <= '9':
            k *= 10
            k += int(c)
            kf = True
        else:
            if kf:
                t.append(k)
            k = 0
            t.append(c)
            kf = False
    if kf:
        t.append(k)

    def calc(a,b,o):
        if o == '+':
            return a + b
        if o == '-':
            return a - b
        return a * b

    def f(s, ops):
        t = s[:]
        ff = True
        while ff:
            ff = False
            ti = -1
            for i in range(len(t)-1,-1,-1):
                if t[i] == '(':
                    ti = i
                    break
            if ti < 0:
                break
            tj = -1
            for i in range(ti+1,len(t)):
                if t[i] == ')':
                    tj = i + 1
                    break
            t[ti:tj] = [f(t[ti+1:tj-1], ops)]
            ff = True

        for i in range(3):
            nt = []
            for c in t:
                if isinstance(c, int):
                    if len(nt) > 1 and ops[nt[-1]] == i:
                        kt = calc(nt[-2],c,nt[-1])
                        nt[-2] = kt
                        del nt[-1]
                    else:
                        nt.append(c)
                else:
                    nt.append(c)
            t = nt
        return t[0]

    r = -inf
    for a in itertools.product(range(3), repeat=3):
        tr = f(t, {'+': a[0], '-': a[1], '*': a[2]})
        if r < tr:
            r = tr

    return r




print(main())



Measured memory_bytes: 9044
from collections import Counter
from itertools import accumulate

N, K = map(int,input().split())
A = list(map(int,input().split()))

d = Counter()

A = [0] + list(accumulate(A))
A = [a % K for a in A]

ans = 0
for i in range(N+1):
    ans += d[(A[i]-i) % K]
    d[(A[i]-i) % K] += 1
    if i-K+1 >= 0:
        d[(A[i-K+1] - (i-K+1)) % K] -= 1

print(ans)

Measured memory_bytes: 40400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define ll long long
using namespace std;

ll mod = 1e9 + 7;

vector<ll> fact;

void init_fact(int n) {
    fact = vector<ll>(n);
    fact[0] = 1;
    for (int i = 1; i < n; i++) fact[i] = fact[i - 1] * i % mod;
}

ll calc_pow(ll x, ll pow) {
    if (pow == 0) return 1;
    ll a = calc_pow(x, pow / 2);
    a = a * a % mod;
    if (pow % 2 == 1) a *= x;
    return a % mod;
}

ll calc_div(ll a, ll b) {
    return a * calc_pow(b, mod - 2) % mod;
}

ll calc_comb(ll n, ll r) {
    if (n < r)return 0;
    return calc_div(fact[n], fact[r] * fact[n - r] % mod);
}

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

    init_fact(10000);
    for (int i = 1; i <= k; i++) {
        ll place = calc_comb(k - 1, i - 1);
        ll ball = calc_comb(n - k + 1, i);
        cout << place * ball % mod << endl;
    }
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int count = 0;
    for(long long int i = 0; i < N; i++) {
        i = S.find("ABC", i);
        if(i == string::npos) {
            break;
        }
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int N, M, A[10000];
	long int sum=0;
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M;i++) {
		scanf("%d", &A[i]);
		sum += (long int)A[i];
	}
	if (sum > (long int)N)printf("-1");
	else printf("%ld", (long int)N - sum);
	return 0;
}

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

ans = True

for i in range(n) :
    if a[i] % 2 == 1 :
        continue
    if a[i] % 3 == 0 or a[i] % 5 == 0 :
        continue
    ans = False

if ans :
    print('APPROVED')
else :
    print('DENIED')


Measured memory_bytes: 3064
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

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

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  string s;cin>>s;
  if(s[2]==s[3] && s[4]==s[5])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


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

int main(){
  string s;
  cin >> s;
  if(s == "Sunny"){
    cout << "Cloudy" << endl;
  }
  else if(s == "Cloudy"){
    cout << "Rainy" << endl;
  }
  else if(s == "Rainy"){
    cout << "Sunny" << endl;
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
ll n;
ll attack(ll i){
  if(i == 1) return 1;
  else if(i%2 == 0) return 2*attack(i/2) + 1;
  else return 2*attack((i-1)/2) + 1;
}
 
int main() {
  cin >> n;
  ll ans = attack(n);
  cout << ans << endl;
}




Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

d = {}
for a in A:
  if(a in d):
    d[a] += 1
  else:
    d[a] = 1
cnt = 0
for k, v in d.items():
  if(k > v):
    cnt += v
  elif(k < v):
    cnt += v - k
print(cnt)

Measured memory_bytes: 17784