akhauriyash/Code-Regression huggingface dataset:
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const long long MOD = 1000000007;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;


void solve(long long n, long long k){

    auto mpow = [](auto x, i64 y){
     auto z = x;
     decltype(x) val = y & 1 ? x : decltype(x)(1);
     while(z *= z, y >>= 1)
      if(y & 1)
       val *= z;
     return val;
    };

    auto calc_fact = [mpow]{
     constexpr int N = 5e5;
     vector<mint> fact(N + 1, 1);
     vector<mint> inv(N + 1, 1);
     for(int i = 1; i < N; ++i){
      fact[i + 1] = fact[i] * (i + 1);
      inv[i + 1] = mpow(fact[i + 1], MOD - 2);
     }
     return make_pair(fact, inv);
    };
    vector<mint> fact, inv;
    tie(fact, inv) = calc_fact();

    auto ncr = [&fact, &inv](int n, int r){
     if(n < 0 || r < 0 || n < r)
      return mint(0);
     return fact[n] * inv[r] * inv[n - r];
    };

    auto nhr = [ncr](int n, int r){
     return ncr(n + r - 1, r);
    };


    /*
    mint ans = nhr(n, n);
    for(int i = k + 1; i < n; ++i){
        ans -= ncr(n - 1, n - i - 1);
    }
    */

    mint ans = 0;
    for(int i = 0; i <= min(n - 1, k); ++i){
        int m = n - i;
        // cout << n - 1 << " " << m - 1 << ": " << ncr(n - 1, m - 1) << endl;
        ans += ncr(n - 1, m - 1) * ncr(n, m);
    }

    cout << ans << endl;

}


signed main(){
    long long n;
    scanf("%lld",&n);
    long long k;
    scanf("%lld",&k);
    solve(n, k);
    return 0;
}


Measured memory_bytes: 15872
# ノードの開始が'0'でなく'1'であることに注意!!※※※
# AtCoder Beginner Contest 168
# https://atcoder.jp/contests/abc168/tasks/abc168_d

import sys
input = sys.stdin.readline

n, m =  map(int, input().split()) # nは頂点の数、mは辺の数
pic = [[] for _ in range(n)] # 隣接リスト_初期化

for _ in range(m): # 隣接リスト_取り込み
    a, b = map(int, input().split())
    pic[a-1].append(b-1) # ※※※
    pic[b-1].append(a-1) # ※※※

from collections import deque

def BFS(u): # 'u'を開始位置として各頂点までの距離を探索する関数_dis → 探索元ノードを探索_ans
    queue = deque([u]) # dequeオブジェクトとして初期化、初期値は開始位置の'u'のみ
    dis = [None] * n # uからの距離を全ノード分初期化
    dis[u] = 0 # 自分'u'との距離は0
    ans = [-1] * n # 探索元のノードを格納する
    while queue:
        v = queue.popleft() # v:探索元のノード 
        for i in pic[v]: # pic[v]: 探索元のノードに隣接するノードのリスト
            if ans[i] == -1:
                ans[i] = v
            if dis[i] is None:
                dis[i] = dis[v] + 1
                queue.append(i)
    return ans

tmp = BFS(0) # ここは'1'でなく'0'※※※
print('Yes')
for j in tmp[1:]:
    print(j+1) # ※※※

Measured memory_bytes: 34696
#include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;

string a[200001];
int n,i,dem=1;

int main()
{
   ios::sync_with_stdio(0);
   cin.tie(0);
   getline(cin,a[1]);
   fflush(stdin);
   n=stoi(a[1]);
   for (i=1;i<=n;i++)
   {
       getline(cin,a[i]);
       fflush(stdin);
   }
   sort(a+1,a+1+n);
   for (i=2;i<=n;i++)
       if (a[i] != a[i-1]) dem++;
   cout << dem;
}

Measured memory_bytes: 9852
#include <algorithm>
#include <iostream>

using namespace std;
using ll = long long;

const int NMAX = 1e2 + 11;
const int WMAX = 1e5 + 11;

int  n, c, w[NMAX], v[NMAX];
ll   mem[NMAX][WMAX];
bool vis[NMAX][WMAX];

// i : current pos, cl : capacity left
ll dp(int i, int cl)
{
    ll &ans = mem[i][cl];

    if (i == n)
        return 0;
    if (vis[i][cl])
        return mem[i][cl];

    vis[i][cl] = true;
    ans        = 0;
    if (cl - w[i] >= 0)
        ans = dp(i + 1, cl - w[i]) + v[i];
    return (ans = max(ans, dp(i + 1, cl)));
}

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

    for (int i = 0; i < n; ++i)
        cin >> w[i] >> v[i];

    cout << dp(0, c) << endl;
    return 0;
}


Measured memory_bytes: 88576
use std::io;

fn f(s1: &str, s2: &str) -> String {
    let mut s = String::new();
    let mut it1 = s1.chars();
    for c2 in s2.chars() {
        let c1 = it1.next().unwrap();
        s.push(c1);
        s.push(c2);
    }
    if let Some(c) = it1.next() {
        s.push(c);
    }
    s
}

fn main() {
    let mut s1 = String::new();
    let mut s2 = String::new();
    io::stdin().read_line(&mut s1).unwrap();
    io::stdin().read_line(&mut s2).unwrap();

    println!("{}", f(s1.trim(), s2.trim()));
}

#[test]
fn test() {
    assert_eq!(f("xyz", "abc"), "xaybzc".to_string());
    assert_eq!(f("atcoderbeginnercontest", "atcoderregularcontest"), "aattccooddeerrbreeggiunlnaerrccoonntteesstt".to_string());
}


Measured memory_bytes: 4352
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int r;
	cin>>r;
	cout<<r*r<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}






Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;


int main(){
string s;cin>>s;
string str="ATCG";
int ans=0,max=0;
for(int i=0;i<s.length();i++){
    if(str.find(s[i])!=-1)ans++;
    else ans=0;
    if(ans>max)max=ans;
}
cout<<max;
}

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

int main(){
  string S; cin >> S;
  for(int i=0;i<3;i++){
    if(S[i]=='7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}
  

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

typedef long long ll;

pair<ll, ll> func(ll x) {
    if (x < 10) {
        return pair<ll, ll>(x, x);
    }

    ll a = x%10, b;
    while (x >= 10)
        x /= 10;
    
    b = x;
    return pair<ll, ll>(b,a);
}

int main() {
    int n;  cin >> n;
    vector<vector<ll> > v(10, vector<ll>(10, 0));
    for (ll i = 1; i <= n; i++) {
        pair<ll, ll> p = func(i);
        v[p.first][p.second]++;
    }

    ll ans = 0;
    for (ll i = 0; i <= 9; i++) {
        for (ll j = 0; j <= 9; j++) 
            ans += v[i][j] * v[j][i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		String s2 = sc.next();
		String s3 = sc.next();
		boolean f1 = false;
		boolean f2 = false;
		if(s1.charAt(s1.length()-1)==s2.charAt(0)){
			f1=true;
		}
		if(s2.charAt(s2.length()-1)==s3.charAt(0)){
			f2=true;
		}
		if(f1==true && f2==true){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 22740
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007



signed main(){
    int N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
    

    return 0;
}
/*



*/

Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]); var wmax = int.Parse(line[1]);
        var vaL = new int[n+1]; var w = new int[n+1];
        var dp = new int[n +1 , wmax + 1];
        DpSet(dp, vaL, w);
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= wmax; j++)
                if (w[i] <= j)
                    dp[i, j] = Math.Max(dp[i - 1, j], dp[i - 1, j - w[i]] + vaL[i]);
                else dp[i, j] = dp[i - 1, j];
        Console.WriteLine(dp[n , wmax]);
    }
    public static void DpSet(int[,] dp, int[] p, int[] w)
    {
        for (int i = 1; i < dp.GetLength(0); i++)
            for (int j = 1; j < dp.GetLength(1); j++) dp[i, j] = -1;
        for (int i = 1; i < p.Length; i++)
        {
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            p[i] = int.Parse(line2[0]);
            w[i] = int.Parse(line2[1]);
        }
    }
}

Measured memory_bytes: 13124
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.18 17:43:20
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int m;cin >> m;
    ll total = 0;
    ll ans = 0;
    for (int i = 0; i < m; i++) {
        ll d,c;cin >> d >> c;
        ans += c;
        total += (d * c - 1) % 9 + 1;
        ans += (d * c - 1) / 9;
    }
    ans += (total - 1) / 9;
    cout << ans - 1 << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string S;
  cin >> S;
  long ans = 0;
  for (char c: S) if (c == '+') ans++; else ans--;
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


n = load()

ps = []
for i in range(1, int(math.sqrt(n))+1):
    if n % i ==0:
        ps.append((i, int(n/i)))
if not ps:
    print(n-1)
    exit()
mn = min(ps, key=lambda p: p[0] + p[1])
print(mn[0]-1 + mn[1]-1)

Measured memory_bytes: 3828
package main
 
import (
  "fmt"
)
 
func main() {
 
  var n int
  c := 0
  fmt.Scan(&n) 
  
  for i := 1; i <= n; i++ {
    if (i < 10) || (99 < i && i < 1000) || ( 9999 < i && i < 100000) {
      c++
    } 
  }
 
  fmt.Println(c)
}

Measured memory_bytes: 512
K,N = map(int,input().split())
list_A = list(map(int,input().split()))

list_A.sort()

list_dis = list(range(N))
min = 1000
dis = 0


for i in range(N):
    if i == N-1:
         list_dis[i] = K - list_A[i] + list_A[0]
    else:
         list_dis[i] = list_A[i+1] - list_A[i]


list_dis.sort()
del list_dis[N-1]
print(sum(list_dis))
 

Measured memory_bytes: 26444
from collections import deque


def solve(width, height):
    ver_walls = []
    hor_walls = []

    x_dir = [0, 1, 0, -1]
    y_dir = [-1, 0, 1, 0]

    for i in xrange(2 * height - 1):
        if i % 2 == 0:
            ver_walls.append(map(int, raw_input().split()))
        else:
            hor_walls.append(map(int, raw_input().split()))

    maze = [[True for j in xrange(2 * width + 1)] for i in xrange(2 * height + 1)]

    for i in xrange(len(ver_walls)):
        for j in xrange(len(ver_walls[i])):
            if not ver_walls[i][j]:#no wall
                maze[i * 2 + 1][(j  + 1) * 2] = False

    for i in xrange(len(hor_walls)):
        for j in xrange(len(hor_walls[i])):
            if not hor_walls[i][j]:#no wall
                maze[(i + 1) * 2][j * 2 + 1] = False

    queue = deque([])

    queue.append((1, 1, 1))

    goal = (2 * width - 1, 2 * height - 1)
    path_goal = 0

    while len(queue) != 0:
        now_x, now_y, path_now = queue.popleft()

        if (now_x, now_y) == goal:
            path_goal = path_now
            break

        for i in xrange(4):
            next_y = now_y + y_dir[i]
            next_x = now_x + x_dir[i]
            if not maze[next_y][next_x]:#no wall
                maze[next_y][next_x] = True
                next_y += y_dir[i]
                next_x += x_dir[i]
                maze[next_y][next_x] = True
                queue.append((next_x, next_y, path_now + 1))

    print path_goal


def main():
    while True:
        temp = map(int, raw_input().split())
        width = temp[0]
        height = temp[1]

        if width == 0 and height == 0:
            break

        solve(width, height)

if __name__ == '__main__':
    main()

Measured memory_bytes: 6724
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;

typedef long long ll;
ll n, m, l, r = 1e18, md, s, mn = 1e18, a[N];

ll f(ll p) {
    ll i, j, re = 0;
    for (i = 0, j = n - 1; i < n; i++) {
        for (; j >= 0 && a[i] + a[j] >= p; j--);
        re += n - j - 1;
    }
    return re;
}

int main()
{
    int i, j;
    cin >> n >> m;
    for (i = 0; i < n; i++) scanf("%lld", &a[i]);
    sort(a, a + n);
    while (l < r) {
        md = (l + r + 1) / 2;
        if (f(md) >= m) l = md;
        else r = md - 1;
    }
    for (i = 0, j = n - 1; i < n; i++) {
        for (; j >= 0 && a[i] + a[j] >= l; j--);
        if (j < n - 1) mn = min(mn, a[i] + a[j + 1]);
        s += a[i] * (n - j - 1) * 2;
    }
    cout << s - (f(l) - m) * mn << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, a, n) for(int i=a;i < n;i++)
#define all(e) e.begin(), e.end()
#define INF (1 << 30)
#define INFL (1LL << 55)

using namespace std;

class Solver {
public:
    Solver(int size) {
        this->H = size;
    }

    void solve() {
        input();
        rep(z, 0, 20) {
            //加点・消去パート
            rep(h, 0, H) {
                int prev = V[0][h];
                int cont = 1;
                rep(w, 1, 5) {
                    if (V[w][h] == prev) {
                        cont++;
                    } else {
                        if (cont >= 3) {
                            ans += cont * prev;
                            rep(i, w - cont, w) {
                                V[i][h] = 0;
                            }
                        }
                        prev = V[w][h];
                        cont = 1;
                    }

                }
                if (cont >= 3) {
                    ans += cont * prev;
                    rep(i, 5 - cont, 5) {
                        V[i][h] = 0;
                    }
                }
            }

            //再配置パート
            rep(w, 0, 5) {
                rep(h, 0, H) {
                    if (V[w][h] != 0) {
                        int tmp = h - 1;
                        while (tmp >= 0) {
                            if (V[w][tmp] != 0) break;
                            tmp--;
                        }
                        swap(V[w][h], V[w][tmp + 1]);
                    }
                }
            }
            /*
            cerr<<"turn"<<z<<", "<<ans<<endl;
            for (int h = H - 1; h >= 0; h--) {
                rep(w, 0, 5) {
                    cerr << V[w][h] << " ";
                }
                cerr << endl;
            }*/
        }


        cout << ans << endl;
    }

private:
    int H;
    vector<vector<int>> V; // フィールド
    long long ans = 0;

    void input() {
        V.resize(5, vector<int>(H));
        for(int h=H-1;h>=0;h--) {
            rep(w, 0, 5) {
                cin >> V[w][h];
            }
        }
    }
};

int main() {

    int N;
    while (cin >> N, N) {
        Solver(N).solve();
    }


    return 0;
}


Measured memory_bytes: 3116
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):  # リストに重複した要素があるか判定（要素にリストがある場合）
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


a, b, c, d = map(int, input().split())
x = c-a
y = d-b
print(c+(-y), d+x, a+(-y), b+x)


Measured memory_bytes: 3832
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fbo find_by_order
#define ook order_of_key
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define MOD 1000000007
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 200003
#define pc(x) putchar_unlocked(x);
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;
struct aa{
	long long x,y,z;
};
vector<aa>dp[mx];
long long level[mx],p[mx],n,pake[mx],idx,depth[mx];
vector<int>ve,g[mx];
void dfs(int now,int lev){
	level[now]=depth[now]=lev;
	//debug(now);
	ve.pb(now);
	int cnt=0;
	for(int i:g[now]){
		dfs(i,lev+1);
		depth[now]=max(depth[now],depth[i]);
		cnt=1;
	}
	if(cnt==0){
		pake[now]=++idx;
	}
}

bool cmp(int x,int y){
	return level[x]>level[y];
}

bool cmp2(int x,int y){
	return depth[x]<depth[y];
}

const long long ini=500000004;

int main(){
	cin>>n;
	long long pang=1;
	for(int i=0;i<=n;i++)pang=(pang*2)%MOD;
//	debug(pang);
	for(int i=1;i<=n;i++){
		cin>>p[i];
		g[p[i]].pb(i);
	}
	long long jaw=0;
	dfs(0,1);
	for(int i=0;i<=n;i++)sort(ALL(g[i]),cmp2);
	sort(ALL(ve),cmp);
	for(int i:ve){
		if(pake[i]){
			dp[pake[i]].pb({ini,ini,0});
			continue;
		}
		int cnt=0;
		for(int j:g[i]){
			if(cnt==0){
				pake[i]=pake[j];
				if(g[i].size()>1){
					for(auto &k:dp[pake[i]]){
						k.x=(k.x+k.z)%MOD;
						k.z=0;
					}
				}
				cnt++;
				continue;
			}
			//debug(cnt);
			int x=dp[pake[i]].size()-1,y=dp[pake[j]].size()-1;
			assert(x<=y);
			for(;x>=0 && y>=0;x--,y--){
				auto tmp=dp[pake[j]][y];
				auto &now=dp[pake[j]][y];
				auto sem=dp[pake[i]][x];
				//0 -> 0 dan 0
				now.x=(sem.x*((tmp.x+tmp.z)%MOD))%MOD;
				//1 -> 0 dan 1, 1 dan 0
				now.y=(sem.x*tmp.y)%MOD;
				now.y=(now.y+(sem.y*((tmp.x+tmp.z)%MOD))%MOD)%MOD;
				//2 ->1 dan 1, 2 dan 0, 2 dan 1
				now.z=(sem.y*tmp.y)%MOD;
				now.z=(now.z+(sem.z*((tmp.x+tmp.z)%MOD))%MOD)%MOD;
				now.z=(now.z+(sem.z*tmp.y)%MOD)%MOD;
			}
			if(cnt==g[i].size()-1){
				pake[i]=pake[j];
				break;
			}
			for(;y>=0;y--){
				auto &now=dp[pake[j]][y];
				now.x=(now.x+now.z)%MOD;
				now.z=0;
			}
			if(i==0){
				//debug(j);
				//ebug(depth[j]);
			}
			pake[i]=pake[j];
			cnt++;
		}
	//	debug(i);
		dp[pake[i]].pb({ini,ini,0});
	}
	for(auto i:dp[pake[0]]){
		long long sem=(i.y*pang)%MOD;
		jaw=(jaw+sem)%MOD;
	}
	cout<<jaw<<endl;
}




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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	template<typename T> inline int ts(T *s)
	{
		int a=0,c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)s[a++]=c,c=fetch();
		return a;
	}
}
using ae86::ty;
using ae86::ts;

const int alp = 26 , _ = 500007;

int n,s[_],las[alp],f[_],wha[_],nex[_];

int main()
{
	n=ts(s);
	for(int i=0;i<n;i++)s[i]-='a';
	for(int i=0;i<alp;i++)las[i]=n;

	memset(f,63,sizeof(f)),memset(nex,63,sizeof(nex));
	f[n+1]=0;
	for(int i=n-1;i>=0;i--)
	{
		las[s[i]]=i;
		for(int j=0;j<alp;j++)
			if(f[i]>f[las[j]+1]+1)
				f[i]=f[las[j]+1]+1,wha[i]=j,nex[i]=las[j]+1;
	}

	int now=0;
	while(now<n)putchar('a'+wha[now]),now=nex[now];
	puts("");

	return 0;
}


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


int main() {
	int n; cin >> n;
	n %= 10;
	if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
		cout << "hon" << endl;
	}
	else if (n == 0 || n == 1 || n == 6 || n == 8) {
		cout << "pon" << endl;
	}
	else {
		cout << "bon" << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace ABC176
{
    class Program
    {
        static void Main(string[] args)
        {
            //var NXT = Console.ReadLine().Split().Select(double.Parse).ToArray();
            var N = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            // var CA = Enumerable.Repeat(0, (int)N).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            //var L = Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();
            var sum = 0L;
            var max = A[0];
            for (int i = 0; i < N; i++)
            {
                if (A[i] < max) { sum += max - A[i]; A[i] += max - A[i]; }
                if (max < A[i]) max = A[i];
            }

            Console.WriteLine(sum);

        }
    }
}


Measured memory_bytes: 47464
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B,K;
    cin >> A >> B >> K;
    rep(i,0,K){
        if(i % 2 == 0){
            if(A % 2 == 1) A--;
            A /= 2;
            B += A;
        }else{
            if(B % 2 == 1) B--;
            B /= 2;
            A += B;
        }
    }
    print2(A,B);
}

Measured memory_bytes: 256
import sys
x, y = map(int, input().split())

if (x >= 0 and y <= 0) or (x < 0 and y > 0):
    print(abs(abs(x) - abs(y)) + 1)
    sys.exit()

if x > y:
    print(x - y + 2)
    sys.exit()
elif x < y:
    print(y - x)
    sys.exit()

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

const int MOD = 1000000007;

using namespace std;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (auto&& i : v) {
    cin >> i;
  }
  int ans = 0;
  for (int i = 0; i < v.size(); i++) {
    k - v.at(i) > v.at(i) ? ans += v.at(i) * 2 : ans += (k - v.at(i)) * 2;
  }
  cout << ans << endl;

}



Measured memory_bytes: 256
import java.io.*;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
    //Solution by Sathvik Kuthuru
    public static void main(String[] args) {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        int t = 1;
        for(int tt = 1; tt <= t; tt++) solver.solve(tt, scan, out);
        out.close();
    }

    static class Task {

        public void solve(int testNumber, FastReader scan, PrintWriter out) {
            int n = scan.nextInt(), m = scan.nextInt(), a = 0;
            for(int i = 0; i < m; i++) a += scan.nextInt();
            out.println(Math.max(-1, n - a));
        }
    }

    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

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

const int maxn=1<<18;

int n,lg[maxn];
int tote,TO[maxn],NEXT[maxn],FIR[maxn];

void addedge(int u,int v)
{
	TO[++tote]=v;
	NEXT[tote]=FIR[u];
	FIR[u]=tote;
}

int dfs(int u,int f)
{
	int bit=0,over=0,pos;
	for (int p=FIR[u];p;p=NEXT[p])
	{
		int v=TO[p];
		if (v==f) continue;
		int tmp=dfs(v,u);
		over|=bit&tmp;
		bit|=tmp;
	}
	for (pos=lg[over]+1;;pos++)
		if (!((bit>>pos)&1)) break;
	bit|=1<<pos;
	bit&=maxn-(1<<pos);
	return bit;
}

int main()
{
#ifdef h10
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	int i,u,v;
	scanf("%d",&n);
	for (i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		addedge(u,v);
		addedge(v,u);
	}
	lg[0]=-1;
	for (i=0;1<<i<maxn;i++) lg[1<<i]=i;
	for (i=1;i<maxn;i++) lg[i]=max(lg[i],lg[i-1]);
	printf("%d\n",lg[dfs(1,0)]);
}


Measured memory_bytes: 6912
import math

a, b, C = [int(i) for i in input().split()]

S = 0.5 * a * b * math.sin(C * math.pi / 180)
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(C * math.pi / 180))
L = a + b + c
h = (2 * S) / a
print(S)
print(L)
print(h)

Measured memory_bytes: 7996
N = int(input())
A = list(map(int, input().split()))
L = [[] for i in range(N)]
for i in range(N):
    L[i] = [A[i], i+1]
L.sort()
ans = [0 for i in range(N)]
for i in range(N):
    ans[i] = L[i][1]
print(*ans)


Measured memory_bytes: 26468
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

ll gcd(ll m, ll n) {
  while( n != 0) {
    ll r = m % n;
    m = n; n = r;
  }
  return m;
}

int main() {
  ll A, B; cin>>A>>B;
  ll C = gcd(A, B);
  cout << (A / C * B) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
# define ll long long
# define ld long double
# define pb push_back
#define F first
#define S second
 
// #define loop(i,n) for(int i=0;i<n;i++)
// #define loops(i,s,n) for(int i=s;i<=n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
 
  
    // for(int i=0;i<n;i++){  
        
    //     int x,y;
    //     cin>>x>>y;
        
    //     v.pb({x,y});         //make pair in vector
    // }
 
using namespace std;

#define P 1000000007


int main()
{ fast;
 
 ll a,b;
 cin>>a>>b;
 if(b>=a)
 {cout<<"unsafe";}
 else
 {cout<<"safe";}
}

Measured memory_bytes: 3636
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int C = sc.nextInt();
		int[] s = new int[n];
		int[] t = new int[n];
		int[] c = new int[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.nextInt() * 2;
			t[i] = sc.nextInt() * 2;
			c[i] = sc.nextInt() - 1;
		}
		boolean[][] using = new boolean[C][2000003];
		for (int i = 0; i < n; i++) {
			for (int j = s[i] - 1; j <= t[i]; j++) {
				using[c[i]][j] = true;
			}
		}
		int[] sum = new int[2000003];
		for (int i = 0; i < C; i++) {
			for (int j = 0; j < 2000003; j++) {
				if (using[i][j]) {
					sum[j]++;
				}
			}
		}
		int max = 0;
		for (int i = 0; i < 2000003; i++) {
			max = Math.max(max, sum[i]);
		}
		System.out.println(max);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private 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;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public 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();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol n; cin >> n;
    int a; cin >> a;
    int b; cin >> b;
    vector<int> p(n);
    int a1{0}, a2{0}, a3{0};
    REP(i, n)
    {
        cin >> p[i];
        if(p[i] <= a)
            a1++;
        else if(p[i] <= b)
            a2++;
        else
            a3++;
    }
    //cout << a1 << " " << a2 << " " << a3 << endl;
    chmin(a1, a2);
    chmin(a1, a3);
    result = a1;

    cout << result << endl;
    return 0;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;

    int cx = 0;
    for (char c : s) {
        cx += c == 'x';
    }

    cout << (cx <= 7 ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == (lint)v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (a >= b) {
    print("delicious");
  } else if (x + a >= b) {
    print("safe");
  } else {
    print("dangerous");
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

void solve(int n,int m){
    int x[1010],s[1010],p=0,ans;
    
    for(int i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    for(int i=0;i<m;i++){
        scanf("%d",&s[i]);
    }
    
    for(ans=0;;ans++){
        p+=s[ans];
        if(p>=n-1) break;
        p+=x[p];
        if(p>=n-1) break;
    }
    
    printf("%d\n",ans+1);
    
    return;
}


int main(){
    int n,m;
    
    while(1){
        scanf("%d%d",&n,&m);
        if(n+m==0) break;
        solve(n,m);
    }
    
    return 0;
}

Measured memory_bytes: 1196
#include <cstdio>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int f[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}, w[4] = {1, - 1, 1, - 1}, N = 2e6 + 10, mo = 1e9 + 7 ;
using namespace std ;
int a[6][2], fac[N], inv[N] ;
void upd(int &x, int y) { x = (x + y) % mo ; }
int C(int x, int y) { return (ll) fac[x + y] * inv[x] % mo * inv[y] % mo ; }
int mul(int a, int b) {
	int ans = 1, w = a % mo ;
	for ( ; b; b /= 2) {
		if (b & 1) ans = (ll) ans * w % mo ;
		w = (ll) w * w % mo ;
	}
	return ans ;
}
int calc(int xa, int ya, int xc, int yc) {
	int res = 0 ; 
	rep(i, a[2][0], a[3][0]) 
		upd(res, (ll) C(i - xa, a[2][1] - 1 - ya) * C(xc - i, yc - a[2][1]) % mo * (- i - a[2][1]) % mo) ,
		upd(res, (ll) C(i - xa, a[3][1] - ya) * C(xc - i, yc - a[3][1] - 1) % mo * (i + 1 + a[3][1]) % mo) ;
	rep(i, a[2][1], a[3][1])
		upd(res, (ll) C(a[2][0] - 1 - xa, i - ya) * C(xc - a[2][0], yc - i) % mo * (- i - a[2][0]) % mo) ,
		upd(res, (ll) C(a[3][0] - xa, i - ya) * C(xc - a[3][0] - 1, yc - i) % mo * (i + 1 + a[3][0]) % mo) ;
	return res ;
}
int main() {
	fac[0] = inv[0] = 1 ;
	rep(i, 1, N - 5) fac[i] = (ll) fac[i - 1] * i % mo ;
	inv[N - 5] = mul(fac[N - 5], mo - 2) ;
	for (int i = N - 6 ; i > 0 ; -- i) inv[i] = (ll) inv[i + 1] * (i + 1) % mo ;
	rep(i, 0, 1) rep(j, 0, 5) scanf("%d", &a[j][i]) ;
	rep(i, 0, 1) rep(j, 0, 1) -- a[j][i] ;
	int ans = 0 ;
	rep(i, 0, 3) rep(j, 0, 3) 
		upd(ans, calc(a[f[i][0]][0] + f[i][0], a[f[i][1]][1] + f[i][1], a[4 + f[j][0]][0] + f[j][0], a[4 + f[j][1]][1] + f[j][1]) * w[i] * w[j]) ;
	printf("%d\n", (ans + mo) % mo) ;
	return 0 ;
}

Measured memory_bytes: 15872
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

int main() {
	int D, T, S;
	cin >> D >> T >> S;
	if (D <= T * S) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



	return 0;
}

Measured memory_bytes: 3560
#include<cstdio>
    using namespace std;
     
    int main(){
    	int n,a,b,c,d;
    	scanf("%d",&n);
    	a=n/1000;
    	b=(n-a*1000)/100;
    	c=((n-a*1000)-b*100)/10;
    	d=n%10;
    	if((a==b&&b==c)||(b==c&&c==d)||(a==b&&b==c&&c==d))
    		printf("Yes\n");
    	else printf("No\n");
    	}
     

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

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

  string s,t;
  cin >> s >> t;

  //文字分繰り返す
  string ans = "";
  rep(i,n) {
    //文字列sとtを順に交互に並べて文字列を作成(sが最初)
    ans = ans + s[i];
    ans = ans + t[i];
  }

  cout << ans << endl;
}


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

using namespace std;

int main()
{
	int n;
	while(cin>>n)
	{
		int area=0,ans=0,i=1;
		while(1)
		{
			if(i*n==600-n)
				break;
			if(i*n>600-n)
				break;
			area=(i*n)*(i*n)*n;
			ans += area;
			area=0;
			i++;
		}
		ans += (600-n)*(600-n)*n;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <cstdlib>
#include <set>

using namespace std;

main(){
    string s;
    cin >> s;
    set<char> seto;    
    for(int i=0;i<s.size();++i){
        seto.insert(s[i]);
    }
    if(s.size()==seto.size()) cout << "yes" << endl;
    else cout << "no" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define inf INF
#define out(i) cout<<i<<endl;
#define allSum(a) accumulate(a.begin(),a.end(),0)
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}

signed main(){
  int n;
  cin>>n;
  vint a(n);
  rep(i,n)cin>>a[i];
  int ans=inf;
  for(int i=-101;i<=101;++i){
    int sum=0,y=i;
    rep(j,n){
      sum+=(a[j]-y)*(a[j]-y);
    }
    ans=min(ans,sum);
  }
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    YES(b - a == c - b);

    return 0;
}


Measured memory_bytes: 256
// ABC105_A
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値

int main() {
    // input
    ll N, M;
    cin >> N >> M;
    
    // calculation
    if (N == M) {
        cout << 0 << "\n";
    } else if (N < M) {
        cout << 1 << "\n";
    } else {
        // N > M
        if (N%M == 0) cout << 0 << "\n";
        else cout << 1 << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256