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

using namespace std;

#define int long long int
#define cont continue;
#define ff first
#define ss second
#define pb push_back
#define ins insert
#define mp make_pair
#define endl '\n'


typedef vector<int> vi;
typedef set<int> si;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef map<int, int> mi;

//const
#define EPS 1e-9
#define INF LLONG_MAX
const int mod = 1000 * 1000 * 1000 + 7; //1e9+7
const double PI = 3.14159265358979323846264;
const pi steps[] = {{1, 0}, {0, 1}, { -1, 0}, {0, -1}, {1, -1}, {1, 1}, { -1, -1}, { -1, 1}}; //for (auto [dx,dy] : steps)
//const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};

// inputs & output & debug
#define w(t) int t; cin>> t; while(t--)

#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

//useful functions
//#define deb(x) cout<<#x<<": "<<x<<endl;
#define isPowOfTwo(x) return (x && (!(x&(x-1))));
#define sz(a) (int)((a).size())
#define present(c,x) ((c).find(x) != (c).end())
#define ip_arr(a,n)   for(int i=0;i<n;i++) cin>>a[i];
#define op_arr(arr,n) for(int i=0;i<n;i++) cout<<arr[i]<<"\n"; cout<<endl;
#define fill_arr(arr,n,i) fill(arr,arr+n,i)
#define fill_vec(v,n,i) fill(v.begin(),v.begin()+n,i);
#define sortv(a) sort(a.begin(),a.end())

void fio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
void setUpLocal()
{
#ifndef ONLINE_JUDGE
	freopen("/Users/asuryana/Documents/CP/input.txt", "r", stdin);
	freopen("/Users/asuryana/Documents/CP/output.txt", "w", stdout);
#else
#define cerr if(0) cerr
#endif
}

const int maxN = 1e7;
// vi gp[gp_size];
// int vis[gp_size];
// int cnt[gp_size];

void solve()
{

	int n, m;
	cin >> n >> m;

	char tab[n][m];
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> tab[i][j];
		}
	}

	int dp[n][m];
	memset(dp, 0, sizeof(dp));

	//init row
	for (int i = 0; i < m; i++)
	{
		if (tab[0][i] == '.')
		{
			dp[0][i] = 1;
		}
		else
			break;
	}


	// init col
	for (int i = 0; i < n; i++)
	{
		if (tab[i][0] == '.')
		{
			dp[i][0] = 1;
		}
		else
			break;
	}


	for (int i = 1; i < n; i++)
	{
		for (int j = 1; j < m; j++)
		{
			if (tab[i][j] == '.')
			{
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
			}
		}
	}


	cout << dp[n - 1][m - 1] << endl;



}

int32_t main()
{
	fio();
	//setUpLocal();
	return solve(), 0;
}


Measured memory_bytes: 12336
#include <stdio.h>

int main(void)
{
	int N;
	scanf("%d",&N);
	if(65<=N && 90>=N){
		printf("1\n");
	}
	else if(97<=N && 122>=N){
		printf("2\n");
	}
	else{
		printf("0\n");
	}
	return 0;
}



Measured memory_bytes: 2112
# -*- coding: utf-8 -*-

N = int(input())
aN = list(map(int, input().split()))

mx = 0
mn = 0
cnt = 0
if len([i for i in aN if 1 <= i < 400]) > 0:
    cnt += 1
if len([i for i in aN if 400 <= i < 800]) > 0:
    cnt += 1
if len([i for i in aN if 800 <= i < 1200]) > 0:
    cnt += 1
if len([i for i in aN if 1200 <= i < 1600]) > 0:
    cnt += 1
if len([i for i in aN if 1600 <= i < 2000]) > 0:
    cnt += 1
if len([i for i in aN if 2000 <= i < 2400]) > 0:
    cnt += 1
if len([i for i in aN if 2400 <= i < 2800]) > 0:
    cnt += 1
if len([i for i in aN if 2800 <= i < 3200]) > 0:
    cnt += 1

# 神がいる場合は話が変わってくる
kami = len([i for i in aN if 3200 <= i])
if kami == 0:
    print(str(cnt) + " " + str(cnt)) 
else:
    if cnt == 0:
        mn = 1
        mx = kami
    else:
        mn = cnt
        mx = cnt + kami
    print(str(mn) + " " + str(mx))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<string> s(n);
  for (auto &x: s) cin >> x;

  int ans = 0;
  for (auto &x: s) {
    if (x == "E869120") ans++;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3320
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
void insert(int);
void inorder(Node);
void preorder(Node);

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if (strcmp(com,"insert")==0){
      scanf("%d", &x);
      insert(x);
    }
    else if (strcmp(com,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void insert(int k){
  Node y=NIL;
  Node x=root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key=k;
  z->right=NIL;
  z->left=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else if(z->key < y->key){
    y->left=z;
  }
  else{
    y->right=z;
  }

}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
  
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

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

enum class Color {
    None,
    Black,
    White,
};

void solve(long long N, std::vector<long long> a, std::vector<long long> b)
{
    EDGE edges(N + 1);
    for (ll i = 0; i < N - 1; i++) {
        edges[a[i]].push_back(b[i]);
        edges[b[i]].push_back(a[i]);
    }

    vector<Color> colors(N + 1, Color::None);
    queue<pair<ll, Color>> que;

    auto mov = [&que, &colors](ll v, Color c) {
        que.emplace(v, c);
        colors[v] = c;
    };

    mov(1, Color::Black);
    mov(N, Color::White);

    while (!que.empty()) {
        auto a = que.front();
        que.pop();
        auto v = a.first;
        auto c = a.second;
        for (auto&& e : edges[v]) {
            if (colors[e] == Color::None) {
                mov(e, c);
            }
        }
    }

    auto black = count(begin(colors), end(colors), Color::Black);
    auto white = count(begin(colors), end(colors), Color::White);
    if (black > white) {
        cout << "Fennec\n";
    } else {
        cout << "Snuke\n";
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
#pragma GCC diagnostic ignored "-Wunused-result"
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N-1);
    std::vector<long long> b(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    solve(N, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 8448
#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 = 1e9+7;

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

vector<int> solve(int x){
    vector<int> res;

    int bi = 2;
    rep(i, 60){
        res.push_back(x / bi * (bi / 2));
        if(x % bi > bi / 2){
            res.back() += x % bi - bi / 2;
        }

        bi *= 2;
    }
    return res;
}

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

    int a, b;
    cin >> a >> b;
    auto va = solve(a);
    auto vb = solve(b + 1);

    int ans = 0;
    rep(i, SZ(vb)){
        if((vb[i] - va[i]) % 2){
            ans ^= 1LL << i;
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
    int n;
    std::cin >> n;
    std::unordered_set<std::string> set;
    std::string S;
    std::cin >> S;
    set.insert(S);
    bool flag = false;
    for(int i = 0; i < n - 1; i++){
        std::string T;
        std::cin >> T;
        if(S[S.size() - 1] != T[0]) flag = true;
        if(set.find(T) != set.end()) flag = true;
        if(flag){
            std::cout << "No" << std::endl;
            return 0;
        }else{
            set.insert(T);
            S = T;
        }
    }

    std::cout << "Yes" << std::endl;

    return 0;
}


Measured memory_bytes: 256
fn main(){
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let n :f32 = buf.trim().parse::<f32>().unwrap();
    println!("{}", ceil(n / 2.0) / n);
}

fn ceil(n :f32) -> f32{
    let m = n as i32 as f32;
    if n - m != 0.0 {
        m + 1.0
    }else{
        m
    }
}

Measured memory_bytes: 4352
n = int(input())
al = list(map(int, input().split()))
al.sort(reverse=True)


def ceil(a, b):
    return -(-a // b)


if n % 2 == 0:
    ans = sum(al[:n//2-1])
    top = al[:n//2]
    ans += top[-1]
    ans += sum(top[1:])
    print(ans)
else:
    ans = sum(al[:(n+1)//2-1])
    ans += sum(al[1:1+n//2])
    print(ans)


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

namespace AtCorder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var A = new Dictionary<int, int>();
            for(int i = 1; i <= N; i++)
            {
                var a = cin.ReadInt;
                A.Add(i, a);
            }
            A = A.OrderBy(v => v.Value).ToDictionary(v => v.Key, v => v.Value);
            foreach(var v in A)
            {
                Write(v.Key + " ");
            }
            WriteLine();
        }
        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}

Measured memory_bytes: 28640
N=int(input())

max7=N//7
max4=N//4
bool_N=False

for i in range(max7+1):
    for j in range(max4+1):
        if 7*i+4*j==N:
            bool_N=True

if bool_N:
    print('Yes')
else:
    print('No')

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

int main(){
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int count = 0;
  for(int i = 0; i < N; i++){
    x -= a.at(i);
    if(x < 0){
      cout << count << endl;
      return 0;
    }
    count++;
    if(x == 0){
      cout << count << endl;
      return 0;
    }
  }
  cout << count - 1 << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() {
  int x, y, z;
  cin>>S;
  ;
}
bool check(string s){
  debug(s);
  if (s.size() % 2 == 1)return false;

  int n = s.size();
  debug(n);
  rep(i,0,n/2-1){
    cerr<<s[i]<<","<<s[n-i-1]<<endl;
    if (s[i] != s[n/2 + i]){return false;}
  }
  return true;
}
void solve() {
  rrep(i,S.size()-1, 0){
    if (check(S.substr(0,i))){
      cout<<i<<endl;return;
    }
  }
  
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

int main() {
  int a , b , c , d ;
  cin >> a >> b >> c >> d ;

  if ((a + b) > (c + d)) {
    cout << "Left" << endl;
  }
  if ((a + b) < (c + d)) {
    cout << "Right" << endl;
  }
  if ((a + b) == (c + d))  {
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int target;
	int num,i;
	int start,end;
	while(1) {
		scanf("%d",&target);
		if(target==0)break;
		scanf("%d",&num);
		for(i=0;i<num;i++) {
			scanf("%d%d",&start,&end);
			target-=end-start;
		}
		if(target<=0)puts("OK"); else printf("%d\n",target);
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void){
    char s[4];
    int ans =1;
    int i;
    for(i=0;i<4;i++){
        scanf("%c",&s[i]);
    }
    for(i=0;i<4;i++){
        if(s[i]==s[i+1]){
            ans =0;
        }
    }
    if(ans==1){
        printf("Good");
    }else{
        printf("Bad");
    }

    return 0;
}

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

int main() {
	long long n,k = 26;
	char ans[10000];
	cin >> n;

	int i;
	for (i = 0; n > 26;i++) {
		long long m = (n-1) % 26;
		n = (n-1) / 26;
		ans[i] = 'a' + m;
	}
	ans[i] = 'a' - 1 + n;

	for (int j = i; j >= 0; j--) cout << ans[j];
	cout << endl;
}

Measured memory_bytes: 3644
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


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


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
5
1 3 5 4 2
'''


def MAIN():
  # T_IN()
  A()


def A():
  s = IN_I()
  l = IN_L_I()

  r = [0] * s

  p = l[0]
  pc = 0
  m = l[0]
  mc = 0

  for num in l[1:]:
    if num < p:
      pc += 1
    else:
      r[pc] += 1
      pc = 0

    if num > m:
      mc += 1
    else:
      r[mc] += 1
      mc = 0

    p = num
    m = num

  r[pc] += 1
  r[mc] += 1

  ret = 0
  for i, count in enumerate(r[2:]):
    ret += (i + 1) * count

  print(ret)

def B():
  return None


def C():
  return None


MAIN()


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

int a[1000000];
int n;

int binaryS(int key){
    int left = 0, right = n;
    int mid;
    while(left < right){
        mid = (left + right) / 2;
        if(a[mid] == key){
            return 1;
        }else if(key < a[mid]){
            right = mid;
        }else if(key > a[mid]){
            left = mid + 1;
        }
    }
    
    return 0;
}

int main(){
    int q;
    int cnt = 0;

    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    cin >> q;
    int b[q];
    for(int i = 0; i < q; i++){
       cin >> b[i];
    }
    
    for(int i = 0; i < q; i++){
        if(binaryS(b[i]))
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;
typedef long long ll;
const double PI = acos(-1);
const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    double a,b,x;
    cin>>a>>b>>x;
    if(x<=a*b*a/2){
        double radian = atan2(b, 2*x/(a*b));
        //cout<< radian <<endl;
        cout<< radian* 180 / PI<<endl;
    }
    else{
        double radian = atan(2*(a*a*b-x)/(a*a*a));
        cout<<radian*180/PI<<endl;
    }
}

Measured memory_bytes: 256
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

####
MOD = 10**9 + 7
YES, NO, IMP = "YES", "NO", "IMPOSSIBLE"
from collections import defaultdict as ddic

N=rri()
A = rrmm(N)
X = []
Y = []
for x, y in A:
    X.append(x-y)
    Y.append(x+y)
#print X
#print Y

xlo, xhi = min(X), max(X)
ylo, yhi = min(Y), max(Y)

print(max(yhi-ylo, xhi-xlo))


Measured memory_bytes: 118304
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x); cout<<#x<<"="<<x<<endl;
#define debug2(x,y); cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define int long long
using namespace std;
const long long mod=1e9+7;


long long inverseMod(long long x,long long mod);
long long nCr(long long n,long long r,long long mod){
    //when r is lesser and is greater
    long long res=1;
    if(r>n-r)r=n-r;
    long long div=1;
    for(long long  i=0;i<r;i++){
        res=(res*(n-i))%mod;
    }

    for(long long i=1;i<=r;i++){
        div=(div*i)%mod;
    }
    return (res*inverseMod(div,mod))%mod;
}


long long power(long long x,long long n,long long mod){
//(x^n)%mod
long long result=1;

    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}

long long inverseMod(long long x,long long mod){

return power(x,mod-2,mod);
}

int n,k;
vector<int>adj[200005];
vector<char> color;
vector<int> parent;
int cycle_start, cycle_end;

bool dfs(int v) {
    color[v] = 1;
    for (int u : adj[v]) {
        if (color[u] == 0) {
            parent[u] = v;
            if (dfs(u))
                return true;
        } else if (color[u] == 1) {
            cycle_end = v;
            cycle_start = u;
            return true;
        }
    }
    color[v] = 2;
    return false;
}
vector<int>arr;
void find_cycle() {
    color.assign(n+1, 0);
    parent.assign(n+1, -1);
    cycle_start = -1;

    for (int v = 0; v < n; v++) {
        if (color[v] == 0 && dfs(v))
            break;
    }

    if (cycle_start == -1) {
        cout << "Acyclic" << endl;
    } else {
        vector<int> cycle;
        //cycle.push_back(cycle_start);
        for (int v = cycle_end; v != cycle_start; v = parent[v])
            cycle.push_back(v);
        cycle.push_back(cycle_start);

        reverse(cycle.begin(), cycle.end());
        int cnt=0;
        int i=1;
        int start=cycle[0];
        vector<int>path;
        while(i!=start){
            i=arr[i];
            path.push_back(i);
            cnt++;
        }
        if(k<=cnt){
            cout<<path[k-1];
        }
        else{
            k-=cnt;
            int cyclesize=cycle.size();
            //watch(cyclesize);
            //cout<<k<<endl;
            k=(k%cyclesize);
            //cout<<k<<endl;
            cout<<cycle[k];
        }
    }
}

int32_t main(){

    fast
    //int n,k;
    cin>>n>>k;
    arr.resize(n+1);
  

    for(int i=1;i<=n;i++){
        cin>>arr[i];
        adj[i].push_back(arr[i]);
    }
    find_cycle();

    return 0;
}



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

using namespace std;

void solve() {
  ll N;
  cin >> N;
  vector<ll> H(N);
  vector<ll> A(N);
  rep (i, N) cin >> H[i];
  rep (i, N) cin >> A[i];

  map<ll, ll> result;
  rep (i, N) {
    auto it = result.lower_bound(H[i]);
    if (it == result.begin()) {
      result[H[i]] = A[i];
    } else {
      it--;
      result[H[i]] = it->second + A[i];
    }
    it = result.upper_bound(H[i]);
    ll tmp = result[H[i]];
    unordered_set<ll> to_erase;
    for(;it != result.end(); it++) if (it->second <= tmp) to_erase.insert(it->first); else break;
    for (auto it: to_erase) result.erase(it);
  }
  auto it = result.end();
  it--;
  cout << it->second << endl;
}

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


Measured memory_bytes: 15872
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

const int MINP = 100;
const int MAXP = 105;

int judge(int money, int up) 
{
    if (money % up == 0) {
        return 1;
    }

    if (up == MINP) {
        return 0;
    }

    for (int i = 0; i*up <= money; ++i) {
        if (judge(money - i * up, up-1)) {
            return 1;
        }
    }
    return 0;
}

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

    int X;
    cin >> X;

    LL ans = judge(X, MAXP);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n);
#define DEBUG printf("%s\n","debug")
using namespace std;
typedef pair<int,int> P;
//////////////////////////////////////////////////////
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_C&lang=jp


const long long INF = 9223372036854775000;
const int VMAX = 102;
const int EMAX = 10000;

struct Edge{
	int from;
	int to;
	int cost;
};


int main() {
	int V,E; SCD2(V,E);
	struct Edge e[EMAX];
	long long d[VMAX][VMAX];
	bool negcycle = false;
	
	REP(i,E){
		int s,t,c;
		SCD3(s,t,c);
		e[i].from = s;
		e[i].to = t;
		e[i].cost = c;
	}
	
	REP(s,V){ //s -> [0..V-1]
		
		REP(i,VMAX){
			d[s][i] = INF;
		}
	
		d[s][s] = 0;
	
		REP(i,V){ // loop V times --> NEGCYCLE

			bool update = false;
			REP(j,E){
				int u = e[j].from;
				int v = e[j].to;
				int c = e[j].cost;
				
				if ((d[s][u] + c < d[s][v]) and (d[s][u] != INF)) {
					d[s][v] = d[s][u] + c;
					update = true;
				}
			}
		
			if ((update) and (i == V-1)){ // NEGCYCLE
				negcycle = true;
			}
			
		}
		
	}
	
	if (negcycle) {
		printf("NEGATIVE CYCLE\n");
		return 0;
	}
	
	REP(s,V){
		REP(i,V-1){
			if (d[s][i] != INF){
				printf("%lld ",d[s][i]);
			}else{
				printf("INF ");
			}
		}
			
		if (d[s][V-1] != INF){
			printf("%lld\n",d[s][V-1]);
		}else{
			printf("INF\n");
		}
		
	}
	
	
	return 0;
}











Measured memory_bytes: 3340
import java.util.Scanner;
class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			String[] a = scan.nextLine().split(" ");
			String[] b = scan.nextLine().split(" ");
			int sumA = 0;
			int sumB = 0;
			for(int i=0;i<4;i++){
				sumA += Integer.parseInt(a[i]);
				sumB += Integer.parseInt(b[i]);
			}
			System.out.println(Math.max(sumA,sumB));
		}
	}
}

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

struct Order {
  int index;
  int number;

  Order(int i, int n) : index(i), number(n) {}

  bool operator<(const Order& other) const {
    return number < other.number;
  }
};

int main() {
  int n, a;
  vector<Order> ary;

  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    ary.emplace_back(i + 1, a);
  }

  sort(ary.begin(), ary.end());
  

  for (auto it = ary.begin(); it != ary.end(); ++it) {
    if (it != ary.begin()) cout << " ";
    cout << (*it).index;
  }
  cout << endl;  
  
  return 0;
}


Measured memory_bytes: 1780
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    int x = Integer.parseInt(br.readLine());
    
    int result = 0;
    while (x >= 500){
      x -= 500;
      result += 1000;
    }
    while (x>= 5){
      x -= 5;
      result += 5;
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 22996
h,w=map(int,input().split())
a=[list(map(int,input().split())) for i in range(h)]
ans=[]
for i in range(h):
    for j in range(w-1):
        if a[i][j]%2==1:
            a[i][j+1]+=1
            a[i][j]-=1
            ans.append([i+1,j+1,i+1,j+2])
for i in range(h):
    if a[i][w-1]%2==1:
        if i!=h-1:
            a[i+1][w-1]+=1
            a[i][w-1]-=1
            ans.append([i+1,w,i+2,w])
l=len(ans)
print(l)
for i in range(l):
    print(" ".join(map(str,ans[i])))

Measured memory_bytes: 29876
N, K = map(int, input().split())
a = list(map(int, input().split()))

ans = pow(10, 18)

for i in range(2 ** N):
    cost = 0
    cnt = 0
    highest = 0
    for j in range(N):
        if (i >> j) & 1:
            cnt += 1
            if highest >= a[j]:
                cost += highest - a[j] + 1
                highest += 1

        highest = max(highest, a[j])
    if cnt >= K:
        ans = min(cost, ans)

print(ans)

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

using namespace std;

int a;
string s, ans;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> a >> s;
    
    if (a >= 3200) {
        ans = s;
    } else {
        ans = "red";
    }
    
    cout << ans << endl;
    
    return 0;
}



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

U=[['#' for j in range(100)] for i in range(50)]
for w in range(A-1):
    s=w//50;t=w%50
    U[s*2][t*2]='.'

D=[['.' for j in range(100)] for i in range(50)]
for b in range(B-1):
    u=b//50;v=b%50
    D[u*2+1][v*2]='#'

print(100,100)
for Ui in U:
    print(''.join(Ui))
for Di in D:
    print(''.join(Di))

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);
    vi p(N);
    Rep(i,N) Scd(p[i]);

    int ma = INF;
    int ans = 0;
    Rep(i,N){
        if( p[i] < ma ) ans++, ma = p[i];
    }

    printf ("%d\n", ans );

    return 0;
}



Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<iostream>
#include<string>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define REP(i,x) for (int i=0;i<x;i++)
#define REPP(i,x,y) for (int i=x;i<=y;i++)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define MX3(x,y,z) max({x,y,z})
#define MX4(x,y,z,p) max({x,y,z,p})
#define MX5(x,y,z,p,q) max({x,y,z,p,q})
#define MN3(x,y,z) min({x,y,z})
#define MN4(x,y,z,p) min({x,y,z,p})
#define MN5(x,y,z,p,q) min({x,y,z,p,q})
#define amax(x,y) x=max(x,y)
#define amin(x,y) x=min(x,y)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef tuple<int,int,int> ti;
typedef tuple<ll,ll,ll> tl;
// #####################################################################

const int MAX = 100000 +10;
char arr[MAX];
int dp[MAX];
int from[MAX];

void solve() {

    int n, m;
    SI(n); SI(m);
    scanf("%s", arr);

    set<pair<int,int>> st;
    st.insert(make_pair(0, 0));
    dp[0] = 0;
    for(int i = 1 ; i <= n ; i++){
        if(arr[i] == '1') {
            dp[i] = -1;
        } else {
            if(st.size() == 0) dp[i] = -1;
            else {
                dp[i] = (*st.begin()).first + 1;
                from[i] = (*st.begin()).second;
                st.insert(make_pair(dp[i], i));
            }
        }
        if(i >= m && dp[i-m] != -1) {
            st.erase(st.find(make_pair(dp[i-m], i-m)));
        }
    }
    if(dp[n] == -1) puts("-1");
    else {
        int tmp = n;
        stack<int> st;
        while(tmp > 0){
            st.push(tmp);
            tmp = from[tmp];
        }
        int last = 0;
        while(!st.empty()) {
            printf("%d ", st.top() - last);
            last = st.top();
            st.pop();
        }
    }
}

void init() {
    


}

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


Measured memory_bytes: 3712
N, M = map(int,input().split())

S = [list(map(int,input().split())) for i in range(M)]

cnt = [0]*N
ans = 0

for i in range(M):
        if S[i][0]==1 and S[i][1]==0 and N!=1:
                print('-1')
                exit()
        if cnt[S[i][0]-1]!=0 and cnt[S[i][0]-1]!=S[i][1]:
                print('-1')
                exit()
        if N==1 and cnt[S[i][0]-1]!=S[i][1] and i > 0:
                print('-1')
                exit()
        else:
                cnt[S[i][0]-1] = S[i][1]

if N==1:
        print(cnt[0])
        exit()
if cnt[0]!=0:
        for i in range(N):
                ans += cnt[i] * (10**(N-1-i))
else:
        ans += 1 * (10**(N-1))
        for i in range(1, N):
                ans += cnt[i] * (10**(N-1-i))

print(ans)

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

int main()
{
    int n, a, b, c, d, x, y;
    cin >> n;
    a = n%10;
    b = (n/10)%10;
    c = ((n/10)/10)%10;
    d = (((n/10)/10)/10)%10;
    x = (d*10)+c;
    y = (b*10)+a;

    if((y>0 && y<13) && (x>0 && x<13))
    {
        cout << "AMBIGUOUS\n";
    }
    else if(x>0 && x<13)
    {
        cout << "MMYY\n";
    }
    else if(y>0 && y<13)
    {
        cout << "YYMM\n";
    }
    else
    {
        cout << "NA\n";
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
xl = []
for i in range(n):
    x,l = map(int,input().split())
    xl.append([x-l,x+l])
xl.sort(key = lambda x: x[1])
ans = 0
arm = -10**18
for i in range(n):
    if arm<=xl[i][0]:
        ans += 1
        arm = xl[i][1]
print(ans)

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

int main(void){

  double r;

  scanf("%lf", &r);

  printf("%f %f\n", (double)r * r * M_PI, (double)2 * r * M_PI);
  
  return 0;
}


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

int main() {
  string s, t;
  cin >> t;
  for (auto e : t) {
    if (e == 'A' || e == 'B') {
      s.push_back(e);
    } else if (e == 'C') {
      if (!s.empty() && s.back() == 'B') {
        *rbegin(s) = 'C';
      } else {
        s.push_back('.');
      }
    } else {
      s.push_back('.');
    }
  }
  ll r = 0, a = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') {
      a++;
    } else if (s[i] == 'C') {
      r += a;
    } else {
      a = 0;
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>


#define fs first
#define sc second

using namespace std;

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


vector<int> edge[210];

int bfs(int s){
    queue<int> q;
    q.push(s);
    int state[210];
    fill(state, state+210, -1);
    state[s] = 0;
    int next = 0;

    while(!q.empty()){
        int v = q.front();
        q.pop();
        if(state[v] == next){
            next++;
        }
        for(auto u: edge[v]){
            if(state[u] == -1){
                state[u] = next;
                q.push(u);
            }
            else{
                if(state[u] - state[v] == -1 || state[u] - state[v] == 1){
                    continue;
                }
                else{
                    return -1;
                }
            }
        }

    }
//    cout << s << endl;
//    for(int i = 0; i < 6; i++){
//        cout << state[i] << " ";
//    }
//    cout << endl << endl;
    return next;
}

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        string s;
        cin >> s;
        for(int j = 0; j < N; j++){
            if(s[j] == '1'){
                edge[i].push_back(j);
            }
        }
    }

    int resK = -1;
    for(int i = 0; i < N; i++){
        resK = max(resK, bfs(i));
    }

    cout << resK << endl;

    return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
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;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    ll N; cin >> N;
    vector<ll> A(N);
    REP(i,N){
        cin >> A[i];
    }

    ll nvalue = 1000;

    REP(i,N){
        ll buy = A[i];
        ll sell = buy;
        int sellindex = -1;
        for (size_t j = i + 1; j < N; j++) {
            if (A[j] < A[j-1]) break;
            if (A[j] > A[j-1]){
                chmax(sell,A[j]);
                sellindex = j;
            }
        }
        if (buy == sell) continue;
        i = sellindex;
        ll buycount = nvalue / buy;
        nvalue -= buy * buycount;
        nvalue += sell * buycount;
    }
    cout << nvalue << endl;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
   int l,r,d,ans=0;
   cin>>l>>r>>d;
   for(int i=l;i<=r;i++)
   {
       if(i%d==0)
        ans++;
   }
   cout<<ans;
    return 0;
}


Measured memory_bytes: 3644
N = int(input())
l = list(map(int,input().split(' ')))
mid = N // 2
MAP = [0]*N
ans_l = []
for i in range(N-1,mid-1,-1):
    k = l[i]
    MAP[i] = k
    if k==1:
        ans_l.append(str(i+1))
flag = False
for i in range(mid,0,-1):
    s = N // i + 1
    t = 0
    for j in range(2,s):
        t += MAP[i*j-1]
    if t%2==0:
        if l[i-1]%2==1:
            ans_l.append(str(i))
            MAP[i-1] += 1
    else:
        if l[i-1]%2==0:
            ans_l.append(str(i))
            MAP[i-1] += 1
 
leng = len(ans_l)
print(leng)
print(" ".join(ans_l))

Measured memory_bytes: 17208
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 10001;

int n;
int a[8];

int main(void) {
//	in = fopen("C.in", "rt");
	
	int ans = 0;
	fscanf(in, "%d", &n);
	for (int i = 0; i < n; i++) {
	    char buff[128];
	    fscanf(in, "%s", buff);
	    int len = (int)strlen(buff);
	    for (int i = 1; i < len; i++) {
	        if (buff[i - 1] == 'A' && buff[i] == 'B')
	           ans++;
        }

        // Doesn't start with A or B
        if (buff[0] != 'A' && buff[0] != 'B') {
            if (buff[len - 1] == 'A') a[0]++;
            if (buff[len - 1] == 'B') a[1]++;
        }
        // Doesn't end with A or B
        else if (buff[len - 1] != 'A' && buff[len - 1] != 'B') {
            if (buff[0] == 'A') a[2]++;
            if (buff[0] == 'B') a[3]++;
        }
        // Start and end with A or B
        else {
            if (buff[0] == 'A' && buff[len - 1] == 'A') a[4]++;
            if (buff[0] == 'A' && buff[len - 1] == 'B') a[5]++;
            if (buff[0] == 'B' && buff[len - 1] == 'A') a[6]++;
            if (buff[0] == 'B' && buff[len - 1] == 'B') a[7]++;
        }
    }
    
    int endA = a[0] + a[4];
    int startB = a[3] + a[7];
    
    if (a[6] > 0) {
        ans += a[6] - 1;
        if (endA > 0) {
            ans++;
            endA--;
        }
        if (startB > 0) {
            ans++;
            startB--;
        }
    }
    ans += min(endA, startB);
    fprintf(out, "%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: h,w,i,j
    character(1),allocatable:: a(:,:),ans(:,:)

    read*, h,w
    allocate(a(w,h),ans(w,h))
    a(:,:) = ' '
    ans(:,:) = ' '

    block
        character(w):: inpt_a
        integer(int32):: diff=0
        do i=1,h
            read*, inpt_a
            if (all_dot(inpt_a)) then
                diff=diff+1
                cycle
            end if
            do j=1,w
                a(j,i-diff) = inpt_a(j:j)
            end do
        end do
    end block

    block
        character(h):: ah
        integer(int32):: diff

        do j=1,w
            diff=0
            do i=1,h
                ah(i:i) = a(j,i)
            end do
            if(all_dot(ah))then
                diff=diff+1
                cycle
            end if
            ans(j,:) = a(j+diff,:)
        end do
    end block
    
    block
        character(w):: ansc
        integer(int32):: d
        do i=1,h
            d=0
            ansc = repeat(' ',w)
            do j=1,w
                if (ans(j,i) == ' ') then
                    d=d+1
                    cycle
                end if
                ansc(j-d:j-d) = ans(j,i)
            end do
            ! if (len_trim(ansc) == 0) cycle
            print'(a)', trim(ansc)
            ! print*, ans(:,i)
        end do
    end block

contains
        function all_dot(s) result(ret)
            character(*):: s
            logical:: ret
            integer(int32):: l,i

            l = len(s)
            ret = .true.
            do i=1,l
                if (s(i:i) == '#') ret=.false.
            end do
        end function
end program name

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

typedef long long ll;
const int MAXN=1e5+5;

int n;
ll a[MAXN];
vector<int> E[MAXN];

inline void err(){puts("NO"); exit(0);}

void dfs(int u,int fa=0){
    if(E[u].size()==1) return;
    ll sum=0,mx=0;
    for(int i=0;i<(int)E[u].size();i++){
        int v=E[u][i];
        if(v==fa) continue;
        dfs(v,u);
        sum+=a[v];
        mx=max(mx,a[v]);
    }
    if(sum<a[u]||sum>2*a[u]) err();
    if(mx>a[u]) err();
    a[u]=2*a[u]-sum;
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    if(n==2){
        if(a[1]!=a[2]) err();
        puts("YES");
        exit(0);
    }
    for(int i=1;i<n;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        E[u].push_back(v);
        E[v].push_back(u);
    }
    int st=1;
    for(;E[st].size()==1;st++);
    dfs(st);
    if(!a[st]) puts("YES");
    else puts("NO");
}


Measured memory_bytes: 13184
(let* ((n (read))
       (m (read))
       (edges (make-array (1+ n) :initial-element 0)))
  (dotimes (i m t)
    (incf (elt edges (read)))
    (incf (elt edges (read))))
  (format t "~:[NO~;YES~]" (every #'evenp edges)))

Measured memory_bytes: 68836
#include <bits/stdc++.h>
//#define rep(i,a,b) for(int i=a;i<b;i++)
//#define T int t ;cin >> t;while(t--)
using namespace std ;
typedef long long ll;
//typedef unsigned long long ull;
int main()
{
    ll a;
    scanf("%lld",&a);
    if(a>=30)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


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

using namespace std;

#define sc(a) scanf("%d", &a);

typedef long long ll;

int A, B;

int main(){
    sc(A);
    sc(B);
    if(A + B > 16 || A > 8 || B > 8){
        cout << ":(\n";
    } else{
        cout << "Yay!\n";
    }
}

Measured memory_bytes: 256
using System;

namespace ITP1_11_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] number = Console.ReadLine().Split(' ');
            int q = int.Parse(Console.ReadLine());
            Search searchclass = new Search(number);

            for (int i = 0; i < q; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                string a = str[0];
                string b = str[1];

                string right = searchclass.Rolling(a, b);
                Console.WriteLine(right);
            }
        }
    }

    class Search
    {
        public string[] D;

        public Search(string[] data)  //data=number
        {
            D = data;
        }

        public string Rolling(string x, string y)  //x=上、y=前
        {
            string D0 = D[0]; //1
            string D1 = D[1]; //2
            string D2 = D[2]; //3
            string D3 = D[3]; //4
            string D4 = D[4]; //5
            string D5 = D[5]; //6
            string result = null;

            if (x==D0) //上が1
            {
                if (y == D1) result = D2;
                if (y == D2) result = D4;
                if (y == D3) result = D1;
                if (y == D4) result = D3;
            }
            if (x == D1) //上が2
            {
                if (y == D2) result = D0;
                if (y == D5) result = D2;
                if (y == D0) result = D3;
                if (y == D3) result = D5;
            }
            if (x == D2) //上が3
            {
                if (y == D4) result = D0;
                if (y == D0) result = D1;
                if (y == D5) result = D4;
                if (y == D1) result = D5;
            }
            if (x == D3) //上が4
            {
                if (y == D1) result = D0;
                if (y == D5) result = D1;
                if (y == D0) result = D4;
                if (y == D4) result = D5;
            }
            if (x == D4) //上が5
            {
                if (y == D3) result = D0;
                if (y == D0) result = D2;
                if (y == D5) result = D3;
                if (y == D2) result = D5;
            }
            if (x == D5) //上が6
            {
                if (y == D2) result = D1;
                if (y == D4) result = D2;
                if (y == D1) result = D3;
                if (y == D3) result = D4;
            }
            return result;
        }
    }
}



Measured memory_bytes: 7848
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
const int MAXN = 1010;
int x, y, z, k;
ll a[MAXN], b[MAXN], c[MAXN];

void solve() {
  vector<ll> ab;
  for (int i=0;i<x;i++) {
    for (int j=0;j<y;j++) {
      ab.push_back(a[i] + b[j]);
    }
  }
  sort(ab.begin(), ab.end(), greater<ll>());
  sort(c, c + z, greater<ll>());

  vector<ll> ans;
  for (int i=0;i<min(k, x * y);i++) {
    for (int j=0;j<min(k, z);j++) {
      ans.push_back(ab[i] + c[j]);
    }
  }
  sort(ans.begin(), ans.end(), greater<ll>());
  for (int i=0;i<k;i++) {
    cout << ans[i] << endl;
  }
}

int main() {
  cin >> x >> y >> z >> k;
  for (int i=0;i<x;i++) {
    cin >> a[i];
  }
  for (int i=0;i<y;i++) {
    cin >> b[i];
  }
  for (int i=0;i<z;i++) {
    cin >> c[i];
  }
  solve();
}


Measured memory_bytes: 43108
#include<stdio.h>
int yaku(int,int);
int main(void){
int A,B;
  scanf("%d %d",&A,&B);
  int kouyaku=yaku(A,B);
  int a=A/kouyaku;
  int b=B/kouyaku;
  long ans=(long)a*(long)b*(long)kouyaku;
  printf("%ld",ans);
  
  return 0;
}
int yaku(int A,int B){
  if(B>A){
int w=A;
    A=B;
    B=w;
  }
  
  int c=A%B;
  if(c==0){return B;}
  else return yaku(B,c);
}



Measured memory_bytes: 128