akhauriyash/Code-Regression huggingface dataset:
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 100005, mod = 1e9 + 7;

int f[N][2];
vector<int> g[N];


int go(int x, bool y, int p = 0) {
    int& res = f[x][y];
    if(res == -1) {
        res = 1;
        for(auto && c : g[x]) {
            if(c == p) {
                continue;
            }
            res = int((res * (ll)go(c, 0, x)) % mod);
        }
        if(y == 0) {
            int cur = 1;
            for(auto && c : g[x]) {
                if(c == p) {
                    continue;
                }
                cur = int((cur * (ll)go(c, 1, x)) % mod);
            }
            res += cur;
            if(res >= mod) {
                res -= mod;
            }
        }
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    rep(i, 0, n - 1) {
        int x, y;
        cin >> x >> y;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    memset(f, -1, sizeof(f));
    cout << go(1, 0) << endl;
}

Measured memory_bytes: 14848
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int a, b, c;
  while(cin>>a>>b>>c) {
    if(a == 0) return 0;
    int ans = 0;
    FOR(x,1,c) {
      FOR(y,1,c) {
        int en = (100+a)*x/100+(100+a)*y/100;
        if(en == c) {
          ans = max(ans, (100+b)*x/100+(100+b)*y/100);
          break;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
 int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(k-a-b<0){
    if(k<a){
    cout << k <<endl;
  }
    else{
      cout << a <<endl;
    }
  }
  else{
    cout << a-(k-a-b)<<endl;
  }
}

Measured memory_bytes: 3604
//C - Flip,Flip, and Flip......

using System;
using System.Linq;
using System.Collections.Generic;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split().Select(long.Parse).ToArray();

            var ans = 0L;


            if (nm[0] > 1 && nm[1] > 1)
            {
                ans = (nm[0] - 2) * (nm[1] - 2);
            }
            else if(nm[0]==1 && nm[1]==1)
            {
                ans = 1;
            }
            else
            {
                ans = Math.Max(nm[0],nm[1])-2;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
def is_good_num(x):
    i = 1
    while i ** 2 <= x:
        if i ** 2 == x:
            return True
        i += 1
    return False

def main():
    n, d = map(int, input().split())
    x = [[int(x) for x in input().split()] for i in range(n)]
    ans = 0
    for i in range(n):
        for j in range(i + 1, n):
            s = 0
            for k in range(d):
                s += (x[i][k] - x[j][k]) ** 2   
            if is_good_num(s):
                ans += 1
    print(ans)
    
main()

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

// 文字列s内に文字列tがいくつ含まれるか
int count(string s, string t) {
  int size_s = s.size();
  int size_t = t.size();
  if (size_s < size_t) return 0;
  int ret = 0;
  for (int i = 0; i < size_s - size_t + 1; i++) {
    if (s.substr(i, size_t) == t) ret++;
  }
  return ret;
}

void solve() {
  string s; cin >> s;
  outl(count(s, "1"));
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

/**
 * @author Tran Anh Tai
 * @template for CP codes
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
    // main solver
    static class Task{
        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int cnt[] = new int[1000001];
            boolean mark[] = new boolean[1000001];
            for (int i = 0; i < n; i++){
                cnt[in.nextInt()]++;
            }
            int  result = 0;
            for (int i = 1; i <= 1000000; i++){
                if (!mark[i] && cnt[i] >= 1){
                    if (cnt[i] == 1)result++;
                    for (int j = 2 * i; j <= 1000000; j += i){
                        mark[j] = true;
                    }
                }
            }
            out.println(result);
        }
    }
    // fast input reader class;
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (line == null) {
                    return null;
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        public long nextLong(){
            return Long.parseLong(nextToken());
        }
    }
}

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

int main() {
    int A,B;
    cin >> A >> B;

    for(int i = 0; i < 1000000000; i++) {
        if(abs(A - i) == abs(B - i)) { cout << i; return 0; }
    }

    cout << "IMPOSSIBLE";

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (long int)n; i++)
using namespace std;

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  cout << min(a*n,b);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main(void){
long int N,i;
scanf("%ld",&N);
long int A[N];
for(i=0;i<N;i++){
	scanf("%ld",&A[i]);
}
long int k=1;
for(i=0;i<N;i++){
	if(A[i]==k){
		k++;
	}
}
if(k==1){
	printf("-1");
}
else {
printf("%ld",N-k+1);
}
}

Measured memory_bytes: 1664
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007


constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 

 
int main() {
    ll X,Y,ans;
    cin >>X>>Y;
    ans=0;

    ll temp=Y/X;

    while(temp>0){
        ans++;
        temp=temp/2;
    }

    cout<<ans<<endl;
  return 0;
}


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

const long long int DENOMI = 1000000007;

int main()
{
	string s;
	cin >> s;
	long long int ans = 1, b = 2;
	for(auto c : s){
		ans = ans * 3 % DENOMI;
		if(c == '0'){
			ans = (ans - b + DENOMI) % DENOMI;
		}else{
			b = b * 2 % DENOMI;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  st s;
  	ci(s);
  SORT(s);
  if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3]) co("Yes")
    else co("No")
    }

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

ll x[1000];
ll mod=1e9+7;

void pf(ll n){
	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			x[i]++;
			n/=i;
		}
	}

	if(n!=1) x[n]++;

}

int main(void){
	          ll i;

	          ll N;
	          cin >> N;
	          for(i=1;i<=N;i++){
	        	  pf(i);
	          }

	          ll ans=1;
	          for(i=1;i<=N;i++){
	        	  ans=ans*(x[i]+1)%mod;
	          }

	          cout << ans%mod << endl;

	          return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <math.h>
#include <deque>
#include <stack>
#include <queue>

#define PI 3.14159265358979323846

using namespace std;

typedef long long ll;
typedef long double ld;


int solve() {
    ll a1,a2,a3;
    cin >> a1 >> a2 >> a3;
    if(a1 + a2 + a3 >= 22){
        cout << "bust" << endl;
    }else {
        cout << "win" << endl;
    }
    return 0;
}


int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  int time = 0;
  REP(i,4) time += getInt();
  printf("%d\n%d\n", time / 60, time % 60);
  return 0;
}

Measured memory_bytes: 0
# 簡単なアルゴリズムなのだが、下の # で躓きその違いは？

n = int(input())
l = [input() for _ in [0]*n]
if len(set(l)) != n:
    print('No')
else:
    for i in range(n-1):
        if l[i][-1] != l[i+1][0]: # if list(l[i])[-1] != list(l[i+1][0]): との違いが？
            print('No')
            break
        else:
            continue
    else:
        print('Yes')


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

int main() {
	int n, ans=0, len, glen; bool f;
	string s, gs; set<int> fidx, sidx;
	cin >> n >> s;
	len = (signed)s.length();
	for(int i=0; i<n; ++i) {
		cin >> gs;
		glen = (signed)gs.length();
		if(glen==1) {
			if(gs.find(s[0], 0)!=string::npos) ans++;
		}else {
			f = false;
			fidx.clear(); sidx.clear();

			// find first character or second character of s in gs
			for(int j=0; j<glen; ++j) {
				if(gs[j]==s[0]) fidx.insert(j);
				else if(gs[j]==s[1]) sidx.insert(j);
			}

			for(set<int>::iterator f_it=fidx.begin(); f_it!=fidx.end()&&!f; ++f_it) {
				for(set<int>::iterator s_it=sidx.lower_bound(*f_it); s_it!=sidx.end()&&!f; ++s_it) {
					int k = (*s_it)-(*f_it);
					if((*f_it)+k*(len-1)+1>glen) break;
					for(int l=2; l<len; ++l) {
						if(s[l]!=gs[(*f_it)+k*l]) break;
						if(l==len-1) {
							ans++; f=true;
							break;
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
	int n; cin >> n;
	vector<long long> a(n), cnt(n);
	for (auto& e : a) {
		cin >> e;
		--e;
		++cnt[e];
	}
	long long ans = 0;
	for (int i = 0; i < n; ++i) ans += cnt[i] * (cnt[i] - 1) / 2;
	for (int i = 0; i < n; ++i)
		cout << ans - cnt[a[i]] * (cnt[a[i]] - 1) / 2 + (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2 << endl;

	return 0;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// AtCoder_B
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		Long D = sc.nextLong();

		Long X = (long) 0;
		Long Y = (long) 0;

		int ans = 0;

		for(int i=0; i<N; i++) {
			X = sc.nextLong();
			Y = sc.nextLong();

			if(Math.sqrt((X * X) + (Y * Y)) <= D) {
				ans++;
			}
		}

		// 出力
		System.out.println(ans);
	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}
}


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

signed main() {
    int N;
    cin >> N;

    vector<int> h(N);
    for (int& x : h) cin >> x;

    int ans = 0;
    for (;;) {
        bool f = false;

        bool pre, now;
        pre = now = false;

        for (int i = 0; i < N; i++) {
            now = (h[i] > 0);
            ans += (now && now != pre);
            pre = now;
            f += now;
            h[i]--;
        }


        if (!f) break;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#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 <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
// #include <boost/foreach.hpp>
// #include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
//#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};
typedef pair<int,int> P;

const long long MOD=1000000007LL;
bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)||islower(c));}
template<typename T> 
void print(vector<T> v){
    for(int i=0;i<v.size();i++){
        if(i)cout<<" ";
        cout<<v[i];
    }
    cout<<endl;
}
int INF=1e18;

template<typename T>
void printendl(vector<T> v){
    for(auto date:v)cout<<date<<endl;
}

template<typename T>
void printvv(vector<vector<T>> v){
    for(int i=0;i<v.size();i++){
        for(int j=0;j<v[i].size();j++){
            if(j)cout<<" ";
            cout<<v[i][j];
        }
        cout<<endl;
    }
}
int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    else return gcd(b,a%b);
}

struct Edge{
    int to,cost;
};

signed main (){
    int n,d;
    cin>>n>>d;
    d*=2;
    d++;
    cout<<(n+d-1)/d<<endl;

}







    


/*
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
template <class T>
using Grid = vector<vector<T>>;

int main() {
    int N;
    cin >> N;
    vector<int> v(N + 1);
    for (ll x = 1; x * x < N; x++) {
        for (ll y = 1; y * y < N; y++) {
            for (ll z = 1; z * z < N; z++) {
                ll ans = x * x + y * y + z * z + x * y + y * z + z * x;
                if (ans <= N)
                    v[ans]++;
            }
        }
    }
    rep2(i, N) {
        printf("%d\n", v[i]);
    }
}

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


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    { 
        
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int x = s[0];
            int y = s[1];

            if (x % y == 0)
            {
                WriteLine(-1);
            }
            else
            {
                WriteLine(x);
            }
        }
    }
}


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

int main() {
  int N,K;
  cin >> N >> K;
  set <int>S;
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int A;
      cin >> A;
      S.insert(A);
    }
  }
  int count = 0;
  for (int i = 1; i <= N; i++) {
    if (!S.count(i)) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
//#define int long long

int n, m;
vector<int> g[200200];
string s;

void solve() {
	cin >> n >> m >> s;
	vector<int> dega(n, 0), degb(n, 0);
    rep(i, m) {
        int a, b; cin >> a >> b; --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
		if(s[a] == 'A') {
			dega[b] ++;
		} else {
			degb[b] ++;
		}
		if(s[b] == 'A') {
			dega[a] ++;
		} else {
			degb[a] ++;
		}
    }
	queue<int> que;
	vector<bool> ispushed(n, 0);
	rep(i, n) {
		if(dega[i] == 0 || degb[i] == 0) {
			que.push(i);
			ispushed[i] = 1;
		}
	}
	while(!que.empty()) {
		int v = que.front(); que.pop();
		for(auto& nv: g[v]) {
			if(ispushed[nv]) continue;
			if(s[v] == 'A') {
				dega[nv] --;
			} else {
				degb[nv] --;
			}

			if(dega[nv] == 0 || degb[nv] == 0) {
				que.push(nv);
				ispushed[nv] = 1;
			}
		}
	}
	bool ok = false;
	rep(i, n) {
		if(!ispushed[i]) ok = true;
	}
	if(ok) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}  

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

int main(){
  int x,y;
  cin >> x >> y;
  
  if (y%2!=0)
    cout << "No" << endl;
  else if (2*x-y/2>=0 && -x+y/2>=0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int compute(int y, int m, int d){
  int sum = 1;
  for ( int i = y+1; i < 1000; i++ ) sum += (i%3==0)?(10*20):(5*19+5*20);
  for ( int i = m+1; i <= 10; i++ ) {
    if ( y%3 == 0 ) sum += 20;
    else  sum += (i%2)?20:19;
  }
  if ( y%3 == 0 ) sum += 20-d;
  else sum += (m%2)?(20-d):(19-d);
  return sum;
}

main(){
  int n, y, m, d; cin >> n;
  for ( int i = 0; i < n; i++ ){
    cin >> y >> m >> d;
    cout << compute(y, m, d) << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
 
int main() {
	int n,part,story,num,resi;
	cin >> n;
	int info[5][4][11];
 
	//?????????
	for(int s = 1; s <= 4; s++){
		for(int k = 1; k <= 3; k++){
			for(int t = 1; t <= 10; t++){
				info[s][k][t] = 0;
			}
		}
	}
 
	//?????????????????????????´?
	for(int i = 0; i < n; i++){
	cin >> part >> story >> num >> resi;
	info[part][story][num] += resi;
	}
 
 
	//??????????????????
	for(int a = 1; a <= 4; a++){
		for(int b = 1; b <= 3; b++){
			for(int c = 1; c <= 10; c++){
				cout << " " << info[a][b][c];
			}
			cout << endl;
		}
		if(a != 4)cout << "####################" << endl;
	}
	return 0;
}

Measured memory_bytes: 3044
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    int overlap = 0;
    for(int i = 1; i <= n; i++) {
        if (s.substr(n-i, i) == t.substr(0, i)) {
            overlap = i;
        }
            
    }
    cout << n*2 - overlap << endl;
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define module 1000000007
#define pb push_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
 
#define vi vector<int>
#define vll vector<long long>

int main()
{
	ll n,i,x,counter=0,max1;
	cin>>n;
	ll a[n+2]; ll b[n+2];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	counter=0;
	b[n-1]=0;
	for(i=n-2;i>=0;i--)
	{
		if(a[i]>a[i+1])
			b[i]=b[i+1]+1;
		else if( a[i] == a[i+1] )	
			b[i]=b[i+1] + 1;
		else
			b[i]=0;	
	}
	max1=INT_MIN;
	for(i=0;i<n;i++)
	{
		if(b[i] > max1)
		{
		//	cout<<"yes\n";
				max1=b[i];	
		}
		
	}
	cout<<max1<<endl;
	
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
int N,st;
double xt,yt,vt,xs,ys,vs;
vector<P> vc;
D inf=1e50,eps=1e-10,tt[1001];
P t,s;
bool eq(D a, D b) { return abs(a-b)<eps;}
bool eq(P a, P b) { return abs(a-b)<eps;}
int sig(D a) { return eq(a,0) ? 0 : (a>0 ? 1 : -1);}
inline D cro(P a, P b) { return imag(conj(a)*b);};
inline int ccw (P a, P b, P c){
//	cout << cro(b-a,c-a) << endl;
	if(sig(cro(b-a,c-a))==1) return 1;
	if(sig(cro(b-a,c-a))==-1) return -1;
	if(eq(abs(a-c)+abs(c-b),abs(a-b))) return 0;
	if(eq(abs(a-b)+abs(b-c),abs(a-c))) return -2;
	if(eq(abs(c-a)+abs(a-b),abs(c-b))) return 2;
}
P t0(D x){
	for(int i=st;i>=0;i--){
		if(tt[i]>x){
			D left=x-tt[i+1];
			P ret=vc[i+1];
			ret+=(vc[i]-vc[i+1])/abs(vc[i]-vc[i+1])*left*vt;
			return ret;
		}
	}
	return vc[0];
}
P t1(D x){
	for(int i=st;i<N;i++){
		if(tt[i]>x){
			D left=x-tt[i-1];
			P ret=vc[i-1];
			ret+=(vc[i]-vc[i-1])/abs(vc[i]-vc[i-1])*left*vt;
			return ret;
		}
	}
	return vc[N-1];
}
int main(){
	cin>>N;
	rep(i,N){
		int x,y;
		cin>>x>>y;
		vc.pb(P(x,y));
	}
	cin>>xt>>yt>>vt>>xs>>ys>>vs;
	t=P(xt,yt);
	s=P(xs,ys);
	rep(i,N-1){
		if(ccw(vc[i],vc[i+1],t)==0){
			if(vc[i]==t){
				st=i;
				break;
			}
			if(vc[i+1]==t){
				st=i+1;
				break;
			}
			vc.insert(vc.begin()+i+1,t);
			st=i+1;
			break;
		}
	}
	N=vc.size();
	D now=0;
	for(int i=st;i>=0;i--){
		tt[i]=now;
		if(i==0) break;
		now+=abs(vc[i]-vc[i-1])/vt;
	}
	now=0;
	for(int i=st;i<N;i++){
		tt[i]=now;
		if(i==N-1) break;
		now+=abs(vc[i]-vc[i+1])/vt;
	}
	D ans=max(tt[0],tt[N-1]);
	//first 0
	D ub=tt[0],lb=0;
	rep(i,200){
		D m=(ub+lb)/2;
		if(abs(t0(m)-s)<m*vs) ub=m;
		else lb=m;
	}
	ans=min(ans,max(tt[N-1],ub));
	D nowt=ub;
	if(!eq(nowt,tt[0])){
		//show(nowt);
		P nows=t0(nowt);
		//show(nows);
		ub=1e10,lb=0;
		rep(i,200){
			D m=(ub+lb)/2;
			if(abs(t1(m+nowt)-nows)<m*vs) ub=m;
			else lb=m;
		}
		ans=min(ans,nowt+ub);
	}
	//first 1
	ub=tt[N-1],lb=0;
	rep(i,200){
		D m=(ub+lb)/2;
		if(abs(t1(m)-s)<m*vs) ub=m;
		else lb=m;
	}
	ans=min(ans,max(tt[0],ub));
	nowt=ub;
	if(!eq(nowt,tt[N-1])){
		P nows=t1(nowt);
		ub=1e10,lb=0;
		rep(i,200){
			D m=(ub+lb)/2;
			if(abs(t0(m+nowt)-nows)<m*vs) ub=m;
			else lb=m;
		}
		ans=min(ans,nowt+ub);
	}
	printf("%.12f\n",ans);
}

Measured memory_bytes: 1304
N, K, Q = map(int, input().split())
Qlist = list(int(input()) for n in range(Q))

score = []

for i in range(0, N) :
  score.append(int(0))
  
for j in Qlist :
  score[ j - 1 ] += 1

minScore = Q - K
 
len(score)
  
for l in score :
  if l > minScore :
    print("Yes")
  else :
    print("No")

Measured memory_bytes: 8640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[]{sc.nextInt(), sc.nextInt()};
        System.out.println(greatestCommonDivisor(a[0], a[1]));
    }

    private static int greatestCommonDivisor(int a, int b) {
        int big, small;
        if (a == b) {
            return a;
        } else if (a > b) {
            big = a;
            small = b;
        } else {
            big = b;
            small = a;
        }

        while (true) {
            int x = big % small;
            if (x == 0) {
                return small;
            } else {
                big = small;
                small = x;
            }
        }
    }
}

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int a, b;
    cin >> a >> b;
    cout << (a*b)/__gcd(a, b) << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9+7;

// 各桁の和
template<typename T>
T digit(T num){
  T sum = 0;
  while(num){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

template<typename T>T gcd(T a,T b){
  if(b == 0)
    return a;
  return gcd(b,a%b);
}
template<typename T>T lcm(T a, T b){
  T g = gcd(a,b);
  return a/g*b; 
}
template<typename T>T power(T a,T b){
  T tmp = 1;
  rep(i,b){
    tmp *= a;
  }
  return tmp;
}
int main(){
  int n,m;cin>>n>>m;
  vector<int> a(n,0);
  
  rep(i,m){
    int t1,t2;
    cin>>t1>>t2;
    a[t1-1]++;
    a[t2-1]++;
  }
  rep(i,n){
    print(a[i])
  }
  return 0;
}


Measured memory_bytes: 256
N, K = gets.chomp.split(" ").map(&:to_i)
P = gets.chomp.split(" ").map(&:to_i)

idx = 0
sum = P[0, K].inject(&:+)
smax = sum
(1...(N-K)).each{|i|
  sum = sum - P[i] + P[i + K]
  (idx = i+1; smax = sum) if smax < sum
}

puts P[idx, K].inject(0){|r, x| r + (x + 1) / 2.0}


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

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

using namespace std;

int main(){
    int x, n;
    cin >> x >> n;
    int p[102] = {0};
    int tmp;
    rep(i, n){
        cin >> tmp;
        ++p[tmp];
    }

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

    int ans;
    int left = 0, right = 101;
    int dif_left, dif_right;
    for(int i = x; i >= 0; --i){
        if(p[i] == 0){
            left = i;
            dif_left = abs(x-i);
            break;
        }
    }
    for(int i = x; i <= 101; ++i){
        if(p[i] == 0){
            right = i;
            dif_right = abs(x-i);
            break;
        }
    }
    if(dif_left <= dif_right) ans = left;
    else ans = right;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3564
n, k = map(int, input().split())
a = sorted(map(int, input().split()), reverse=True)
s = 0 #sum a which may not be necessary
need = 0
for i in range(n):
    if s + a[i] < k:
        s += a[i]
    else:
        need = i+1
print(n - need)

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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

#define MAX 100000 //最大ノード数

struct node {
  ll v, d;
  node(ll v, ll d):v(v),d(d){}
  bool operator<(const node &n) const { return d > n.d; }
};
struct edge {
  ll to, d;
  edge(ll to, ll d):to(to),d(d){}
};
ll V;
vector<edge> G[MAX];
ll dist[MAX]; // dijkstraの結果の最短経路
int previous[MAX];

void dijkstra(int s) { // sからの最短経路
  rep(i,MAX) dist[i] = 1ll << 59;
  memset(previous, -1, sizeof(previous));
  priority_queue<node> que;
  que.push(node(s, 0));
  dist[s] = 0;
  while(!que.empty()){
    ll v = que.top().v, d = que.top().d;
    que.pop();
    rep(i,sz(G[v])){
      ll tmp = d + G[v][i].d;
      if(dist[G[v][i].to] > tmp){
	dist[G[v][i].to] = tmp;
	previous[G[v][i].to] = v;
	que.push(node(G[v][i].to, tmp));
      }
    }
  }
}

vi getpath(int t){ // tへの最短経路を返す
  vi path;
  while(t != -1){
    path.pb(t);
    t = previous[t];
  }
  reverse(all(path));
  return path;
}  

main()
{
  int n; cin >> n;
  vi p(n); rep(i,n) cin >> p[i];

  rep(i,n){
    // サイコロで進むpath
    if(p[i] == 0)
      FOR(j,1,7)
	if(i + j < n)
	  G[i].pb(edge(i + j, 1));
    
    // マスの効果で進むpath
    G[i].pb(edge(i + p[i], 0));
  }

  dijkstra(0);

  //rep(i,n) cout << dist[i] << " "; cout << endl;

  cout << dist[n-1] << endl;
}


Measured memory_bytes: 14340
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
fn main() {
    input! {
        n:i64,
        an:[i64;n],
    }
    let mut map = HashMap::new();
    for &a in &an{
        *map.entry(a).or_insert(0) += 1;
    }
    let ans = map.into_iter()
        .map(|(_,v)| v)
        .filter(|v| v % 2 != 0)
        .count();
    println!("{}",ans);
}


Measured memory_bytes: 12540
$line = <STDIN>;
chomp $line;
($a , $b ) = split / /, $line;

$a1=$a+$b;
$a2=$a-$b;
$a3=$a*$b;

$a1=$a2 if ( $a2>$a1 );
$a1=$a3 if ( $a3>$a1 );

print "$a1\n";


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define ROOP(i,n) for(i=0;i<n;i++)

//prototype declaration
int getint();
long long getllint();
double getdint();
char getch();
void setstring(char *s);
void showint(int i);
void showllint(long long i);
void showdouble(double i);
void showchar(char c);
void showstring(char *s);

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int min(int a, int b) {
	return a < b ? a : b;
}

int main(void) {
	int n, i, j;
	n = getint();
	int w[n];
	ROOP(i, n) {
		scanf("%d", &w[i]);
	}
	if (n == 2) {
		if (w[0] < w[1]) {
			printf("%d\n", 2);
		} else {
			printf("%d\n", 1);
		}
		return 0;
	}
	int sum1 = 0, sum2 = 0;
	int k;
	int min = 100000;
	ROOP(i, n) {
		for (j = 0; j <= i; j++) {
			sum1 += w[j];
		}
		for (k = j; k < n; k++) {
			sum2 += w[k];
		}
		if (min > abs(sum1 - sum2)) {
			min = abs(sum1 - sum2);
		}
		sum1 = 0;
		sum2 = 0;
	}
	printf("%d\n", min);
	return 0;
}

int getint() {
	int i;
	scanf("%d", &i);
	return i;
}

long long getllint() {
	long long i;
	scanf("%lld", &i);
	return i;
}

double getdint() {
	double i;
	scanf("%lf", &i);
	return i;
}

char getch() {
	char c;
	scanf("%c", &c);
	return c;
}

void setstring(char *s) {
	scanf("%s", s);
}

void showint(int i) {
	printf("%d\n", i);
}

void showllint(long long i) {
	printf("%lld\n", i);
}

void showdouble(double i) {
	printf("%lf\n", i);
}

void showchar(char c) {
	printf("%c\n", c);
}

void showstring(char *s) {
	printf("%s\n", s);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
    //#define int long long
    typedef long long ll;
    #define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
    #define forn(i, n) fore(i, 0, n)
    #define fori(i, l, r) fore(i, l, (r) + 1)
    #define sz(v) int((v).size())
    #define all(v) (v).begin(), (v).end()
    #define pb push_back
    #define mp make_pair
    #define ff first
    #define ss second
    using namespace std; 
     
    const double PI = atan(1)*4;

    int dx[8]={1,0,-1,0,1,-1,-1,1};
    int dy[8]={0,1,0,-1,1,1,-1,-1};
     
     
    bool isprime(int n)
    {
        for(int i=2;i*i<=n;i++)
            if(n%i==0)
                return false;
        return true;
    }
     
    bool comp(pair<int,int> a, pair<int,int> b)
    {
        return b.ff < a.ff ;
    }
     
    int modpow(int b,int p,int m)
    {
        if(p==0) return 1%m;
        if(p%2) return (b*modpow(b,p-1,m))%m;
        int u=modpow(b,p/2,m);
        return (u*u)%m;
    }
     
    int fn(int x,int y,int z)
    {
        int ans=((x-y)*(x-y) + (y-z)*(y-z) + (z-x)*(z-x) );
        //cout<<x<<" "<<y<<" "<<z<<"\n";
        return ans; 
    }
     
    /*void bsearch(int max,int min)   //  for function 
    //void bsearch(int a,int n, int x)     // for array
    {
        int k=min;
     
        //  for array
     
    /*    for(int b=n/2; b>=1; b/=2)
        {
            while(k+b<n && arr[k+b]<=x) k+=b; 
        }
     
        if(arr[k]==x)
            cout<<"found at "<<k+1;
        else
            cout<<"not found";
    */
     
        //  for function 
     
    /*    for(int b=max; b>=1; b/=2)
        {
            while( !fn(b+k) ) k+=b;
        }
        cout<<k+1;
     
    }*/
     
    int vis[200005];
     
    int main()
    {
     
        #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
     
        int t=1;
        //cin>>t;
     
        while(t--)
        {
            int n;
            ll k;
            cin>>n>>k;
            int a[n];
            forn(i,n)
            cin>>a[i];

            ll cnt=0;
            map<int , int> m;
            int i=1;
            while(vis[i]==0)
            {
                cnt++;
                vis[i]=cnt;
                m[cnt]=a[i-1];
                i=a[i-1];

                if(cnt>=k)
                    break;
            }

            if(k<=cnt)
            {
                cout<<m[k];
                return 0;
            }

            if( ((ll)k-vis[i]+1)%(cnt-vis[i]+1) + vis[i]-1 == 0)
            {
                cout<<m[cnt];
                return 0;
            }
            cout<<m[((ll)k-vis[i]+1)%(cnt-vis[i]+1) + vis[i]-1];
        /*    fori(i,1,n) cout<<vis[i]<<" ";
            cout<<"\n";
            for(auto x=m.begin();x!=m.end();x++)
                cout<<x->ff<<" "<<x->ss<<"\n";*/
        }
        return 0;
    }

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

int main(void){
  int N; cin >> N;
  double avg = 0;
  vector<int> a(N);
  for(int i = 0; i < N; i++) cin >> a[i];
  for(int i = 0; i < N; i++) avg += a[i];
  avg /= (double)N;
  double minv = 1000000;

  double res = -1;
  for(int i = 0; i < N; i++) {
    double diff = abs(a[i] - avg);
    if(minv > diff){
      minv = diff;
      res = i;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int i = 1; i < n; i++) {
    vector<int> list(26);
    vector<bool> list2(26);
    for (int j = 0; j < n; j++) {
      if (j < i) {
        list[s[j] - 'a']++;
      } else {
        if (list[s[j] - 'a'] >= 1) list2[s[j] - 'a'] = true;
      }
    }
    ans = max(ans, (int)count(all(list2), true));
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
const int N = 2e5 + 5;

int n;

int NumOfDigit(int n){
    if(n==0)return 0;
    return NumOfDigit(n/10)+1;
}

int main() {
    scanf("%d",&n);
    int ans = 0;
    for(int i=1;i<=n;++i){
        if(NumOfDigit(i)%2)ans++;
    }
    printf("%d",ans);
    return 0;
} 

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

int main()
{
  int N;
  std::cin >> N;
  int in[N];

  for(int i=0;i<N;i++) std::cin >> in[i];
  
  int ans = 0;
  int current_min = in[0];
  for(int i=0;i<N;i++){
      if(current_min >= in[i]){
          ans++;
          current_min = in[i];
      }
  }
  
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 1024
<?php
// $n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$n = (int)$input[0];
$k = (int)$input[1];

$input = explode(' ', trim(fgets(STDIN)));

if ($k >= $n) {
	echo 0;
	exit();
}

$h_list =[];
foreach ($input as $v) {
	$h_list[] = (int)$v;
}
sort($h_list);

$monster = $n - $k;
$sum = 0;
for ($i=0; $i < $monster; $i++) { 
	$sum += $h_list[$i];
}
echo $sum;

Measured memory_bytes: 31344
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int N,M;


int main()
{
  cin >> N >> M;
  priority_queue<ll,vector<ll>, greater<ll> > A;
  REP(i, 0, N)
  {
    ll a;
    cin >> a;
    A.push(a);
  }

  vector<pair<ll, int> > p;

  REP(i, 0, M)
  {
    int b;
    ll c;
    cin >> b >> c;
    p.push_back(make_pair(c, b));
  }

  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  ll sum = 0;
  REP(i, 0, M)
  {
    ll c = p[i].first;
    int b = p[i].second;
    bool flag = false;
  

    while(!A.empty()&&b>0){

      ll a = A.top();
      if(a<c){
        sum += c;
        A.pop();
        b--;
      }else{
        flag = true;
        break;
      }
      
    }
    if(A.empty()||flag){
      break;
    }
  }

  while(!A.empty()){

    sum += A.top();
    A.pop();
  }

  cout <<sum << endl;

  return 0;
}

Measured memory_bytes: 3188
s = sorted(input())
t = sorted(input(), reverse=True)

for i in range(min(len(s), len(t))):
    if ord(s[i]) < ord(t[i]):
        print('Yes')
        exit()
    elif ord(s[i]) > ord(t[i]):
        print('No')
        exit()
if len(s) < len(t):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060