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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

constexpr ll BIG = 1000000000000L;

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

    int N, K;
    cin >> N >> K;

    vll H(N+2, 0);
    for(int i=1;i<=N;i++) cin >> H[i];

    vll dprow(K+1, BIG);
    vvll dp(N+2, dprow);

    dp[0][0] = 0;

    for (int n=0;n<=N;n++){
        for (int k=0;k<=K;k++) {
            for (int d=0;n+d<=N && k+d <= K; d++) {
                dp[n+d+1][k+d] = min(dp[n+d+1][k+d], dp[n][k] + abs(H[n+d+1] - H[n]));
            }
        }
    }

    ll ans = BIG;
    for (int k=0;k<=K;k++) ans = min(ans, dp[N+1][k]);
    
    cout << ans/2 << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

vector<vector<bool> > A(51,vector<bool>(51));
vector<vector<bool> > B(51,vector<bool>(51));
vector<vector<bool> > C(51,vector<bool>(51));
vector<vector<bool> > Y(51,vector<bool>(51));
vector<vector<bool> > mp(51,vector<bool>(51));

int main()
{
	int n,m,a,b,c;
	cin >> n >> m>> a >> b >> c;
	
	REP(i,m)
	{
		int u,v;
		cin >> u >> v;
		u--;v--;
		mp[u][v] = true;
	}
	
	Y = mp;
	REP(i,max(a,max(b,c)))
	{
		vector<vector<bool> > Z(51,vector<bool>(51));

		if(i+1 == a)A = Y;
		if(i+1 == b)B = Y;
		if(i+1 == c)C = Y;


		REP(i,n)REP(j,n)REP(k,n)
		{
			Z[i][j] = Z[i][j] | ( Y[i][k] & mp[k][j]);
		}
		Y = Z;
	}
	
	set<int> goal;
	goal.insert(n-1);
	
	for(int ans = 1;;ans++)
	{
		set<int> nw;
		REP(i,n)
		{
			if(!goal.count(i))
			{
				bool aa = false;
				bool bb = false;
				bool cc = false;
				REP(j,n)
				{
					if(goal.count(j))
					{
						if(A[i][j])aa = true;
						if(B[i][j])bb = true;
						if(C[i][j])cc = true;
					}
				}
				if(aa&&bb&&cc)nw.insert(i);
			}
		}
		if(nw.empty())
		{
			cout << "IMPOSSIBLE" << endl;
			return 0;
		}	
		goal.insert(ALL(nw));
		if(goal.count(0))
		{
			cout << ans << endl;
			return 0;
		}
	}
	return 0;
}

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

int N, M, X[100000], L[100000];
int pL = 0;

bool cmp(int a, int b) {
    return a > b;
}

int main() {
    cin >> N >> M;
    for(int i=0; i<M; i++)
        cin >> X[i];

    if(N >= M) {
        cout << "0" << endl;
        return 0;
    }

    sort(X, X+M);
    
    for(int i=1; i<M; i++)
        L[pL++] = X[i] - X[i-1];
    sort(L, L+pL, cmp);

    int ans = X[M-1] - X[0];
    for(int i=0; i<N-1; i++)
        ans -= L[i];
    cout << ans << endl;
}

Measured memory_bytes: 1024
#![allow(unused_imports)]

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};

fn main() {
    proconio::input!{
        n: usize,
        mut ab: [(i64, i64); n],
    }
    ab.sort_by_key(|p| p.1);
    let ts: Vec<_> = ab.iter().copied().scan(0, |state, p| {
        *state += p.0;
        Some(*state)
    }).collect();
    if ab.iter().copied().enumerate().all(|(i, p)| ts[i] <= p.1) { println!("Yes"); }
    else { println!("No"); }
}


Measured memory_bytes: 10364
import sys
def fast_input():
    return sys.stdin.readline()[:-1]

def solve(a, b):
    product = a * b
    if product % 2 == 0:
        return "Even"
    else:
        return "Odd"


def main():
    a, b = map(int, fast_input().split())
    result = solve(a, b)
    print(result)

main()



Measured memory_bytes: 9140
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> V;
  vector<int> C;
  for (int i=0; i<N; i++){
    int tmp;
    cin >> tmp;
    V.push_back(tmp);
  }
  for (int i=0; i<N; i++){
    int tmp;
    cin >> tmp;
    C.push_back(tmp);
  }
  int res = 0;
  for (int i=0; i<N; i++){
    int gain = V[i] - C[i];
    if (gain > 0) res += gain;
  }
  cout << res << endl;
}
  

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

int main() {
  int H, W;
  cin >> H >> W;

  char a[H+2][W+2];
  
  for(int i=0; i<H+2; i++){
    for(int j=0; j<W+2; j++){
      a[i][j] = '#';
    }
  }

  for(int i=1; i<H+1; i++){
    for(int j=1; j<W+1; j++){
      cin >> a[i][j];
    }
  }

  for(int i=0; i<H+2; i++){
    for(int j=0; j<W+2; j++){
      cout << a[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
int main() {
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			cout << i << 'x' << j << '=' << i*j << endl;
		}
	}
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    bool ok = false;
    for (auto &x: s) ok |= x == '7';
    if (ok) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(void) {
	int i,j;
	char s[16];
	while(scanf("%s",s) != EOF){
		for(i = 0;i < 9;i++){
			for(j = 0;j < 9-i;j++){
				s[j] = (((s[j]-48)+(s[j+1]-48))%10)+48;
			}
		}
		printf("%c\n",s[0]);
	}
	return 0;
}

Measured memory_bytes: 540
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int a = Integer.parseInt(strArr[0]);
		int b = Integer.parseInt(strArr[1]);
		int ans = a + b;
		if (ans < (a - b))
			ans = (a - b);
		if (ans < (a * b))
			ans = (a * b);
		System.out.println(ans);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int a,b,c,d;
  a = N/1000;
  b = N%1000 /100;
  c = N%100 / 10;
  d = N%10;
  
  if(a == b && b == c || b == c && c == d){
  	cout << "Yes" << endl; 
  }else{
  	cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var a = ReadStringNext();
            var b = ReadStringNext();
            var c = ReadStringNext();
            var ans = a[a.Length - 1] == b[0] && b[b.Length - 1] == c[0] ? "YES" : "NO";
            Console.WriteLine($"{ans}");
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);

        public static string[] Buffer = new string[] { };
        public static int Index;
        public static string ReadStringNext()
        {
            if (Buffer.Length == 0 || Buffer.Length <= Index - 1)
            {
                Buffer = ReadStringArray();
                Index = 0;
            }
            return Buffer[Index++];
        }

        public static int ReadNextInt()
        {
            return int.Parse(ReadStringNext());
        }
    }
}


Measured memory_bytes: 13140
package main
import (
	"bufio"
	"fmt"
	"os"
)
var r = bufio.NewReader(os.Stdin)

func main(){
    var a, b int
    fmt.Fscan(r, &a, &b)
    if a < b {
       fmt.Printf("%v\n" ,"a < b")
    }else if a > b {
        fmt.Printf("%v\n" ,"a > b")
    }else {
        fmt.Printf("%v\n" ,"a == b")
    }
}



Measured memory_bytes: 1148
#include <stdio.h>

int dif(int a,int b){

	return a > b ? a-b : b-a;
}

int main(void){
	int a, b, c, d, di;

	scanf("%d %d %d %d", &a,&b,&c,&d);

	di = dif(a,c);

    if(di <= d) printf("Yes");
	else if(di > d && di <=2*d){
		dif(a,b)<=d && dif(b,c)<=d ? printf("Yes") : printf("No");
	}
	else printf("No");


	return 0;
}



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

int main(){
  long long int X,Y,A,ans;
  cin >>X>>Y;
  int flag=0;
  A=X;ans=1;
  while(true){
    A*=2;
    if(A>Y){break;}
    else{
    ans++;
    }
  }  
  cout<<ans;
}



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

int main()
{
    string word;
    cin>>word;
    string a = "dreamer";
    string b = "dream";
    string c = "eraser";
    string d = "erase";
    int flag = 1;
    while(flag)
    {
        flag = 0;
        int len = word.length();
        if(len < 5)break;

        if((word.compare(len-5,len,b)==0) || (word.compare(len-5,len,d)==0))
        {
            word.erase(len-5,len);
            flag = 1;
            continue;
        }
        if((word.compare(len-6,len,c)==0))
        {
            word.erase(len-6,len);
            flag = 1;
            continue;
        }
        if((word.compare(len-7,len,a)==0))
        {
            word.erase(len-7,len);
            flag = 1;
            continue;
        }
    }
    if(word.length() == 0)printf("YES\n");
    else printf("NO\n");
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  string N;
  cin >> N;
  if(N.at(0) == N.at(1) && N.at(1) == N.at(2))	cout << "Yes" << endl;
  else if(N.at(1) == N.at(2) && N.at(2) == N.at(3))	cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int x, a;
  cin >> x >> a;
  if (x < a) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,K;
    cin>>N>>K;
    if(K==1) cout <<0<<"\n";
    else cout <<N-K<<"\n";
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstdio>
#include<cmath>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 200000
#define LL long long
#define INF 0x3f3f3f3f
int read(){
	int f=1,x=0;
	char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();}
	return f*x;
}
struct node{
	int v;LL w;
};
vector<node> G[MAXN+5];
inline void Addedge(int u,int v,LL w){
	G[u].push_back((node){v,w});
	G[v].push_back((node){u,w});
	return ;
}
int n,m;
LL Min=1,Max=INF;
int vis[MAXN+5],dis[MAXN+5];
void DFS(int u,int f,LL x,int fa){
	if(x<=0){
		if(!f) Min=max(Min,-x+2);
		else printf("0\n"),exit(0);
	}
	if(f) Max=min(Max,x);
	vis[u]=f+1,dis[u]=x;
	int siz=G[u].size();
	for(int i=0;i<siz;i++){
		int v=G[u][i].v,w=G[u][i].w;
		if(v==fa) continue;
		if(vis[v]){
			if(vis[u]==vis[v]){
				if(((dis[u]+dis[v])%2+2)%2!=w%2)
					printf("0\n"),exit(0);
				if(vis[v]==1)
					Min=max(Min,(1+(w-(dis[u]+dis[v]))/2)*1ll),
					Max=min(Max,(1+(w-(dis[u]+dis[v]))/2)*1ll);
				else 
					Min=max(Min,(1+((dis[u]+dis[v])-w)/2)*1ll),
					Max=min(Max,(1+((dis[u]+dis[v])-w)/2)*1ll);
			}
			else if(dis[u]+dis[v]!=w)
				printf("0\n"),exit(0);
			continue;
		}
		DFS(v,(f+1)%2,w-x,u);
	}
	return ;
}
int main(){
	//freopen("graph.in","r",stdin);
	//freopen("graph.out","w",stdout);
	n=read(),m=read();
	for(int i=1;i<=m;i++){
		int u=read(),v=read();LL w=read();
		Addedge(u,v,w);
	}
	dis[1]=1;
	DFS(1,0,1,0);
	printf("%lld\n",max(0ll,Max-Min+1));
	return 0;
}

Measured memory_bytes: 18816
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 998244353;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

int powM(int x, int n){
    if(n == 0){
        return 1;
    }
    if(n % 2 == 0){
        return powM(x * x % MOD, n / 2);
    }
    return powM(x, n-1) * x % MOD;
}

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

    string s;
    cin >> s;

    bool isSame = false;
    bool isAllSame = true;
    int sum = 0;
    rep(i, SZ(s)){
        if(s[0] != s[i]){
            isAllSame = false;
        }
        if(i < SZ(s) - 1 && s[i] == s[i+1]){
            isSame = true;
        }
        sum += s[i] - 'a';
        sum %= 3;
    }

    if(isAllSame){
        cout << 1 << endl;
        return 0;
    }

    if(SZ(s) == 2){
        cout << 2 << endl;
        return 0;
    }

    if(SZ(s) == 3){
        if(isSame){
            cout << 6 << endl;
        }else if(sum == 0){
            cout << 3 << endl;
        }else{
            cout << 7 << endl;
        }
        return 0;
    }

    vector3<int> dp1 = initVec3<int>(SZ(s), 3, 3, 0);
    dp1[0][0][0] = dp1[0][1][1] = dp1[0][2][2] = 1;
    rep(i, SZ(s) - 1){
        rep(j, 3){
            rep(k, 3){
                rep(l, 3){
                    if(k == l){
                        continue;
                    }
                    dp1[i+1][(j+l)%3][l] += dp1[i][j][k];
                    dp1[i+1][(j+l)%3][l] %= MOD;
                }
            }
        }
    }
    vector2<int> dp2 = initVec2<int>(SZ(s) + 1, 3, 0);
    dp2[0][0]  = 1;
    rep(i, SZ(s)){
        rep(j, 3){
            rep(k, 3){
                dp2[i+1][(j+k)%3] += dp2[i][j];
                dp2[i+1][(j+k)%3] %= MOD;
            }
        }
    }
    int ans = dp2[SZ(s)][sum];
    rep(i, 3){
        ans = ans + MOD - dp1[SZ(s)-1][sum][i];
        ans %= MOD;
    }

    if(not isSame){
        ans++;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 50428
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <climits>
#define SIZE 262144

struct info {
	int val, index;
};
std::pair<long long, int> lazy[SIZE * 2 + 1], tree[SIZE * 2 + 1], a[SIZE];
info input[SIZE];
std::vector<int> X;

void init(int node, int start, int end) {
	lazy[node] = std::make_pair(0, 0);
	if (start == end)
		tree[node] = a[start];
	else {
		init(node << 1, start, (start + end) >> 1);
		init((node << 1) | 1, ((start + end) >> 1) + 1, end);
		tree[node] = std::min(tree[node * 2], tree[node * 2 + 1]);
	}
}

void lazy_propagation(int node, int start, int end) {
	if (lazy[node].first != 0) {
		tree[node].first += lazy[node].first;
		if (start != end) {
			lazy[node << 1].first += lazy[node].first;
			lazy[(node << 1) | 1].first += lazy[node].first;
		}
		lazy[node] = std::make_pair(0, 0);
	}
}

void update(int node, int start, int end, int i, int j, long long val) {
	lazy_propagation(node, start, end);
	if (i > end || j < start)
		return;
	if (i <= start && end <= j) {
		tree[node].first += val;
		if (start != end) {
			lazy[node << 1].first += val;
			lazy[(node << 1) | 1].first += val;
		}
		return;
	}
	else {
		update(node << 1, start, (start + end) / 2, i, j, val);
		update((node << 1) | 1, (start + end) / 2 + 1, end, i, j, val);
		tree[node] = std::min(tree[node << 1], tree[(node << 1) | 1]);
	}
}

std::pair<long long, int> query(int node, int start, int end, int i, int j) {
	lazy_propagation(node, start, end);
	if (i > end || j < start)
		return std::make_pair(LLONG_MAX / 2, 0);
	if (i <= start && end <= j)
		return tree[node];
	return std::min(query(node * 2, start, (start + end) / 2, i, j), query(node * 2 + 1, (start + end) / 2 + 1, end, i, j));
}

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

	for (int i = 1; i <= n; i++) {
		scanf("%d", &input[i].val);
		X.push_back(input[i].val);
	}

	std::sort(X.begin(), X.end());
	X.erase(std::unique(X.begin(), X.end()), X.end());

	for (int i = 1; i <= n; i++) {
		input[i].index = std::lower_bound(X.begin(), X.end(), input[i].val) - X.begin() + 1;
	}

	int lastNode = X.size();

	for (int i = 1; i <= lastNode; i++)
		a[i] = std::make_pair(X[i - 1], i);

	init(1, 1, lastNode);
	long long r = 0;
	for (int i = 1; i <= n; i++) {
		std::pair<long long, int> q = query(1, 1, lastNode, input[i].index, lastNode);
		r = r + q.first - input[i].val;

		update(1, 1, lastNode, 1, q.second - 1, 1);
	}

	printf("%lld\n", r);
}

Measured memory_bytes: 23156
#include<bits/stdc++.h>
using namespace std;
int dp[2][100001];
bool util(int arr[], int n, int k, int p){
    if(dp[p][k] != -1) return dp[p][k];
    bool flag = false;
    for(int i=0;i<n;i++){
        if(k - arr[i] >= 0){
            bool next = util(arr, n, k - arr[i], 1 - p);
            if(next == false){
                flag = true;
                break;
            }
        }
    }
    dp[p][k] = flag;
    return flag;
}
int main(){
    int n, k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    memset(dp, -1, sizeof(dp));
    bool res = util(arr, n, k, 0);
    if(res){
        cout<<"First";
    }else cout<<"Second";
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
string s[100005];
long long n,ans,t=1;
int main(){
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
        
    }
    sort(s,s+n);
    for(int i=0;i<n-1;i++)
    {
        if(s[i]==s[i+1])t++;
        else ans+=t*(t-1)/2,t=1;
    }
    ans+=t*(t-1)/2;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 7296
/*
解説AC
https://atcoder.jp/contests/sumitrust2019/submissions/8683667
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)

int main(){
    ll n,ans=1;
    cin>>n;
    vi a(n),c(3,0);
    rep(i,n)cin>>a[i];
    rep(i,n){
        //idでどのcounterを進めるかを決めている
        //配列cを使って赤、青、緑の人が何人かを管理している。
        //a[i]に合致するものを探すのに合わせて計算して問題ない
        //わざわざ配列を使ってシミュレートするより楽
        //思いつかなかった......
        ll cnt=0,id=-1;
        if(a[i]==c[0]){cnt++;id=0;}
        if(a[i]==c[1]){cnt++;id=1;}
        if(a[i]==c[2]){cnt++;id=2;}
        if(id==-1){cout<<0<<endl;return 0;}
        ans*=cnt;
        c[id]++;
        ans%=INF;
    }
    cout<<ans<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 3788
#include<stdio.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int n;
    scanf("%d",&n);
    int keep[200000]={};
    int a,b;
    int time=0;
    scanf("%d",&a);
    time=a%86400;
    keep[time]++;keep[time+86400]++;
    REP(i,n-1){
        scanf("%d%d",&b,&a);
        time+=b+a;
        time%=86400;
        keep[time]++;
        keep[time+86400]++;
    }
    ll sha=0;
    REP(i,10801)sha+=keep[i];
    ll max=sha;
    REP(i,86400){
        sha=sha+keep[i+10801]-keep[i];
        if(sha>max)max=sha;
    }
    printf("%lld\n",max);
    return 0;
}

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

int main()
{
  int N;

  cin >> N;

  vector<long long>A(N);
  long long ans=1;


  for(int i=0;i<N;i++){
    cin >> A.at(i);

    if(A.at(i)==0){
      cout << 0 << endl;
      return 0;
    }
  }

 long long MAX=1000000000000000000LL;

  for(int i=0;i<N;i++){

    if(MAX / ans < A[i]){
      cout << -1 << endl;
      return 0;
    }
      ans*=A.at(i);
  }

  cout << ans << endl;

return 0;
}


Measured memory_bytes: 4048
#include <iostream>
#include <set>
#include <vector>
#include <cstdlib>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    while(true) {
        int N, K;
        cin >> N >> K;
        if(!N && !K) break;

        vector<string> cards(N);
        for(int i = 0; i < N; ++i) {
            cin >> cards[i];
        }
        int pos[] = {0,1,2,3};
        set<int> made;
        while(true) {
            vector<int> arr(&pos[0], &pos[K]);
            do {
                string str;
                for(int i = 0; i < K; ++i) {
                    str += cards[arr[i]];
                }
                int n = atoi(str.c_str());
                made.insert(n);
            } while(next_permutation(arr.begin(), arr.end()));

            ++pos[K-1];
            for(int i = K-1; i >= 0; --i) {
                if(pos[i] >= N-(K-i-1)) {
                    if(i > 0) ++pos[i-1];
                    pos[i] = -1;
                }
                else break;
            }
            /*
            cout << "pos[0]: " << pos[0] << endl;
            cout << "pos[1]: " << pos[1] << endl;
            cout << "pos[2]: " << pos[2] << endl;
            */
            if(pos[0] == -1) break;
            for(int i = 1; i < K; ++i) {
                if(pos[i] != -1) continue;
                pos[i] = pos[i-1]+1;
            }
        }
        cout << made.size() << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
using lint=long long;
using namespace std;

int main()
{
	lint K,A,B;
	lint ans=1;
	
	cin >> K >> A >> B;
	
	if(B-A>2)
	{
		ans+=A-1;
		if((K-(A-1))%2==1)
		{
			ans++;
			K--;
		}
		ans+=((B-A))*((K-(A-1))/2);
		
	}else{
		ans+=K;
	}
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, c, k;
  cin >> n >> c >> k;
  int T[n];
  for(int i=0; i<n; ++i) cin >> T[i];
  sort(T, T+n);
  int ans = 0;
  for(int i=0; i<n;){
    ++ans;
    int st = i;
    while(i < n && T[i]-T[st] <= k && i-st < c) ++i;
  }
  cout << ans << endl;
}

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

static const int INF = 2000;

int N,T,c,t;

int main(int argc, char const *argv[])
{
    cin>>N>>T;
    int ans = INF;  // a certain large number
    for(int i=0; i<N;i++) {
        cin>>c>>t;
        if(t <= T) ans = min(c, ans);
    }
    if(ans != INF)
        cout<<ans<<endl;
    else
        cout << "TLE" << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, m = ns()

    # 分割数：N個の数をK個に分ける方法
    # 分けたものは区別できないので、3を[1,2],[2,1]のように分けるのは合わせて1カウント
    # dp[i][j] = dp[i][j-i] + dp[i-1][j] jをi個に分割する数
    # 蟻本P66

    dp = [[0 for _ in range(n + 1)] for __ in range(m + 1)]
    dp[0][0] = 1

    for i in range(1, m + 1):
        for j in range(n + 1):
            if j - i >= 0:
                dp[i][j] = dp[i - 1][j] + dp[i][j - i]
            else:
                dp[i][j] = dp[i - 1][j]
            dp[i][j] %= MOD
    print(dp[m][n])


if __name__ == '__main__':
    main()



Measured memory_bytes: 47352
#include<iostream>
#include<vector>
#include<algorithm>
 
using namespace std;
int main()
{
	int N,a[110],sum_a=0,sum_b=0;
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> a[i];
	}
	sort(a,a+N);
	for(int i=N-1; i>=0; i--){
		if((N - 1 -i) % 2) sum_b += a[i];
		else sum_a += a[i];
	}
	cout << sum_a - sum_b << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;

int main(void) {
  for (lld i = 1; i <= 5; i++) {
    lld x;
    cin >> x;
    if (x == 0) {
      cout << i << "\n";
      return 0;
    }
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int n;
int a[300000];

bool C(int t){
	map<int,int>mp;
	for(int i=1;i<n;i++){
		if(a[i]>a[i-1])continue;
		int d=a[i];
		while(mp[d]==t){
			if(d==1){
				return false;
			}
			d--;
		}
		mp[d]++;
		auto it=mp.lower_bound(d+1);
		while(it!=mp.end()){
			it=mp.erase(it);
		}
	}
	return true;
}
int main(){
	scanf("%d",&n);
	bool flag=false;
	rep(i,n){
		scanf("%d",&a[i]);
		if(i&&a[i-1]>=a[i])flag=true;
	}
	if(!flag){
		puts("1");return 0;
	}
	int ok=n*2,ng=0;
	while(ok-ng>1){
		int t=(ok+ng)/2;
		if(C(t))ok=t;
		else ng=t;
	}
	cout<<ok+1<<endl;
}


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

using namespace std;

int main() {
  int n, x;
  cin >> n >> x;
  
  vector<int> vm(n);
  int min_m = 2000;
  for (int i = 0; i < n; i++) {
    cin >> vm[i];
    x -= vm[i];
    min_m = min(min_m, vm[i]);
  }
  
  cout << n + (x / min_m) << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	bool ok = true;
	for (int i = 0; i < n; ++i) {
		if (a[i] % 2 == 0) {
			if (a[i] % 3 != 0 && a[i] % 5 != 0)
				ok = false;
		}
	}
	cout << (ok ? "APPROVED" : "DENIED") << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 1000000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    /*ll n;cin>>n;
    V<ll>use;
    map<ll,ll>m;ll ans=0;
    for(ll i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0)ans+=i;
    }
    cout<<ans<<endl;*/

    int k;cin>>k;
    int ans=0;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                ans+=GCD(a,GCD(b,c));
            }
        }
    }
    cout<<ans<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------




































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

using namespace std;

int main()
{
    int x, a=0, b=0, res;
    cin>>x;
    a=x/500;
    b=(x%500)/5;
    res = (a*1000) + (b*5);
  	cout<<res;
    return 0;
}

Measured memory_bytes: 256
import sys

N,Y = map(int,input().split())

for i in range(N+1):
    for j in range(N+1):
        k = N - i - j

        if k >= 0 and Y == i * 10000 + j * 5000 + k * 1000:
            print(i,j,k)
            sys.exit()
print("-1 -1 -1")


Measured memory_bytes: 2940
import java.io.*
import java.util.*

var pw = PrintWriter(System.out)
fun solve(N: Int, C: IntArray, S: IntArray, F: IntArray) {
    for (i in 0 until N - 1) {
    var time = S[i] + C[i]
        for (j in i + 1 until N - 1) {
            time = when {
                time <= S[j] -> S[j]
                else -> S[j] + floorDiv(time - S[j], F[j]) * F[j]
            }
            time += C[j]
        }
        pw.println(time)
    }
    pw.println(0)
    pw.flush()
    return
}

fun floorDiv(a: Int, b: Int): Int = a / b + if (a % b == 0) 0 else 1

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val C = IntArray(N - 1)
    val S = IntArray(N - 1)
    val F = IntArray(N - 1)
    for (i in 0 until N - 1) {
        C[i] = sc.next().toInt()
        S[i] = sc.next().toInt()
        F[i] = sc.next().toInt()
    }
    solve(N, C, S, F)
}


Measured memory_bytes: 31364
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n int
	fmt.Sscan(getNextLine(scanner), &n)
	aaa := getIntList(scanner)
	for i := 0; i < n; i++ {
		aaa[i] -= i + 1
	}
	sort.Sort(sort.IntSlice(aaa))
	ans := 0
	for i := 0; i < n; i++ {
		if i < n/2 {
			ans += aaa[n/2] - aaa[i]
			continue
		}
		ans += aaa[i] - aaa[n/2]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 33536
#include <iostream>

using namespace std;

int main(){

    long long A, B, C;
    cin >> A >> B >> C;

    long long ans;
    if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0){
        ans = 0;
    }else{
        long long M = A + B + C - min(A, min(B, C)) - max(A, max(B, C));
        ans = min(A, min(B, C)) * M;
    }
    
    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
int main()
{
	int n; cin>>n;
	n%=10;
	if(n==3) cout<<"bon"<<endl;
	else if(n==0 || n==1 || n==6 || n==8) cout<<"pon"<<endl;
	else cout<<"hon"<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007

int main(){
	int n,m;
	while(1){
		map<int,int>mp;
		cin >> n >> m;
		if(n==0)break;
		vector<int>h(n),w(m);
		for(int i=0;i<n;i++){
			cin >> h[i];
		}
		for(int i=0;i<m;i++){
			cin >> w[i];
		}
		for(int i=0;i<n;i++){
			int tmp = 0;
			for(int j=i;j<n;j++){
				tmp += h[j];
				mp[tmp]++;
			}
		}
		ll ans = 0;
		for(int i=0;i<m;i++){
			int tmp = 0;
			for(int j=i;j<m;j++){
				tmp += w[j];
				ans += mp[tmp];
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  int N,M;
  string s,t;
  cin>>N>>M;
  
  vector<char> vec(100);
  s="";
  t="";
  
  for(int i=0;i<M+2;i++)
    s+="#";
    
  cout<<s<<endl;
  
  for(int i=0;i<N;i++){
    
    for(int j=0;j<M;j++){
    cin>>vec.at(j);
    t+=vec.at(j);
    }
    
    cout<<"#"<<t<<"#"<<endl;
    t="";
  }
  
  cout<<s<<endl;
    
}
    

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

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

    if (__builtin_popcount(n) == 1) {
        std::cout << "No" << std::endl;
        return 0;
    }

    int r = n % 4;
    std::deque<std::pair<int, int>> q;
    auto add_edge = [&](int i, int j) {
        q.emplace_back(i, j);
    };

    if (r == 1 || r == 3) {
        add_edge(1, 2);
        add_edge(2, 3);
        add_edge(3, 1 + n);
        add_edge(1 + n, 2 + n);
        add_edge(2 + n, 3 + n);

        for (int i = 1; i * 4 + 1 <= n; i++) {
            add_edge(i * 4, i * 4 + 1);
            add_edge(i * 4 + 1, 1);
            add_edge(1, i * 4 + n);
            add_edge(i * 4 + n, i * 4 + 1 + n);
        }

        for (int i = 1; i * 4 + 3 <= n; i++) {
            add_edge(i * 4 + 2, i * 4 + 3);
            add_edge(i * 4 + 3, 1);
            add_edge(1, i * 4 + 2 + n);
            add_edge(i * 4 + 2 + n, i * 4 + 3 + n);
        }
    } else if (r == 0) {
        int s = 1 << __builtin_ctz(n),
            t = n ^ s;
        std::vector<int> a { s, t };
        for (int i = 1; i < n; i++) {
            if (i != s && i != t) a.push_back(i);
        }
        for (int i = 1; i < n - 1; i++) {
            add_edge(a[i - 1], a[i]);
            add_edge(a[i - 1] + n, a[i] + n);
        }
        add_edge(a.back(), a.front() + n);
        add_edge(n, s);
        add_edge(t, n + n);
    } else {
        add_edge(1, 2);
        add_edge(2, 3);
        add_edge(3, 1 + n);
        add_edge(1 + n, 2 + n);
        add_edge(2 + n, 3 + n);

        for (int i = 1; i * 4 + 1 < n - 2; i++) {
            add_edge(i * 4, i * 4 + 1);
            add_edge(i * 4 + 1, 1);
            add_edge(1, i * 4 + n);
            add_edge(i * 4 + n, i * 4 + 1 + n);
        }

        for (int i = 1; i * 4 + 3 < n - 2; i++) {
            add_edge(i * 4 + 2, i * 4 + 3);
            add_edge(i * 4 + 3, 1);
            add_edge(1, i * 4 + 2 + n);
            add_edge(i * 4 + 2 + n, i * 4 + 3 + n);
        }

        add_edge(n, n - 1);
        add_edge(n - 1, 3);
        add_edge(3, n + n);
        add_edge(n + n, n - 1 + n);

        add_edge(n - 2, n - 1);
        add_edge(2, n - 2 + n);
    }

    std::cout << "Yes\n";
    for (const auto &e : q) std::cout << e.first << " " << e.second << std::endl;

    return 0;
}


Measured memory_bytes: 4464
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			//var a = Console.ReadLine ().Split().Select(x=>int.Parse(x)).ToArray();
			string N = Console.ReadLine ();
			int chartoint = 0;
			int[] result = new int[N.Length];
			for (int i = 0; i < N.Length; i++) {
				chartoint = N [i] - 'a';
				result [i] = chartoint;
			}
			int a = 0;
			bool flag = true;
			for (int i = 0; i < 26; i++) {
				a = 0;
				for (int j = 0; j < N.Length; j++) {
					{
						if (result[j] == i)
							a++;
					}
				}
				if (a % 2 != 0) {
					Console.WriteLine ("No");
					flag = false;
					break;
				}	
			}

			if (flag)
				Console.WriteLine ("Yes");
		}
	}
}


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

int main(){
    ll n,k,p;
    cin>>n>>k;
    map<ll,ll> m;
    for(ll i=1;i<=n;i++){
        cin>>p;
        m[i]=p;
    }
    map<ll,vector<ll> > m1;
    ll st=1;
    ll count=1;
    while(count<k){
        if(m1.find(st)==m1.end()){
            m1[st].push_back(count);
        }
        else break;
        count++;
        st=m[st];
    }
    if(count==k) cout<<m[st]<<endl;
    else{
        //cout<<st<<endl;
        m1[st].push_back(count);
        vector<ll> v=m1[st];
        ll ss=v[1]-v[0];
        // for(auto x:v) cout<<x<<" ";
        // cout<<endl;
        ll aa=v[0];
        k-=(aa-1);
        ll z=k%ss;
        //z=z-1;
        //cout<<z<<endl;
        while(z--){
            st=m[st];
        }
        cout<<st<<endl;
    }

}

Measured memory_bytes: 33620
#include<bits/stdc++.h>
using namespace std;
void solveA()
{
  long long a,b,tem;
  cin>>a>>b;
  tem=(a+b);
  if(tem%2==0)
  {
    cout<<tem/2<<endl;
  }
  else
  {
    cout<<"IMPOSSIBLE"<<endl;
  }
}
void solveB()
{
  int n,i,j,count;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  j=1;
  count=0;
  for(i=0;i<n;i++)
  {
    if(ar[i]!=j)
    {
      count++;
    }
    if(count>2)
    {
      cout<<"NO"<<endl;
      return;
    }
    j++;
  }
  cout<<"YES"<<endl;
}
void solveC()
{
  int a,b,x,y;
  cin>>a>>b;
  x=max(a,b);
  y=min(a,b);
  if((x-y)>=2)
  {
    cout<<2*x-1<<endl;
  }
  else
  {
    cout<<x+y<<endl;
  }
}
void solveD()
{
  int n,i,j;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  int count=n;
  for(i=n-1;i>=0;i--)
  {
    for(j=i-1;j>=0;j--)
    {
      if(ar[i]<ar[j])
      {
        count--;
        break;
      }
    }
  }
  cout<<count<<endl;
}
void solveE()
{
  int h,w,x,y,H,W;
  cin>>H>>W;
  cin>>h>>w;
  x=h*W;
  y=(H-h)*w;
  cout<<(H*W)-(x+y)<<endl;
}
void solveF()
{
  int n,m,c,i,j;
  cin>>n>>m>>c;
  int b[m];
  int ar[n][m];
  for(i=0;i<m;i++)
  {
    cin>>b[i];
  }
  for(i=0;i<n;i++)
  {
    for(j=0;j<m;j++)
    {
      cin>>ar[i][j];
    }
  }
  int count=0;
  int sum;
  for(i=0;i<n;i++)
  {
    sum=0;
    for(j=0;j<m;j++)
    {
      sum=sum+ar[i][j]*b[j];
    }
    if((sum+c)>0)
    {
      count++;
    }
  }
  cout<<count<<endl;
}
void solveG()
{
  
}
int main()
{
  // solveA();
  //solveB();
  // solveC();
 solveD();
 //solveE();
// solveF();
  return 0;
}

Measured memory_bytes: 3556
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

void prime_number_factor(int n, map<int, int> &ps) {
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ps[i]++;
            n /= i;
        }
    }
    if (n != 1) ps[n]++;
}

int main() {
    int n;
    cin >> n;
    map<int, int> ps;
    repr(i, 2, n + 1) prime_number_factor(i, ps);
    vector<int> cnt;
    for (auto p: ps) cnt.push_back(p.second);
    int sz = cnt.size();
    
    vector<int> v = {3, 5, 15, 25, 75};
    vector<int> idx(76);
    rep(i, 5) idx[v[i]] = i;

    vector<vector<int>> dp(sz + 1, vector<int>(5)); 
    for (int i = 0; i < sz; i++) {
        rep(j, 5) {
            dp.at(i + 1).at(j) = dp.at(i).at(j);
            if (v.at(j) <= cnt.at(i) + 1) dp.at(i + 1).at(j)++;
        }

        rep(j, 5) rep(k, j) if (v.at(k) <= cnt.at(i) + 1 && v.at(j) % v.at(k) == 0) 
            dp.at(i + 1).at(j) += dp.at(i).at(idx[v[j] / v[k]]);
    }
    cout << dp.at(sz).at(4) << endl;
}   

Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort()
Q.sort()
R = R + P[a-x:] + Q[b-y:]
R.sort()
print(sum(R[-(x+y):]))

Measured memory_bytes: 23328
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>
int MIN(int a,int b){
    return a<b?a:b;
}

using namespace std;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll xyz[3],K;
    cin >> xyz[0] >> xyz[1] >> xyz[2] >> K;
    vector<ll> A,B,C;
    ll tmp;
    for(int i = 0; i < xyz[0];i++){
        cin >> tmp;
        A.push_back(tmp);
    }
    for(int i = 0; i < xyz[1];i++){
         cin >> tmp;
        B.push_back(tmp);
    }
    for(int i = 0; i < xyz[2];i++){
         cin >> tmp;
        C.push_back(tmp);
    }
    vector<ll> ans,AB;
    ll wa;
    for(int i = 0; i < xyz[0];i++){
        for(int j = 0; j < xyz[1];j++){
            wa = A[i] + B[j];
            AB.push_back(wa);
        }
    }
    VSORT(AB);
    reverse(ALL(AB));
    for(int i = 0; i < MIN(K,xyz[0]*xyz[1]);i++){
        for(int j = 0; j < xyz[2];j++){
            wa = AB[i] + C[j];
            ans.push_back(wa);
        }
    }
    VSORT(ans);
    reverse(ALL(ans));

    for(int i = 0; i < K;i++){
        cout << ans[i] << endl;
    }
    

    return 0;
}

Measured memory_bytes: 43384