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

typedef long long ll;

bool dp[1<<18];

int main() {
    int x;
    cin >> x;
    dp[0] = 1;
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < 6; j++) {
            dp[i + 100 + j] |= dp[i];
        }
    }
    cout << dp[x] << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    char c; cin >>c;

    if (c == 'a' || c == 'i' ||c == 'u' ||c == 'e' ||c == 'o' ) {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    } 
    return 0;
}




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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);

        long base = (long) 1e9 + 7;

        long ans = 1;

        if (Math.abs(n - m) == 0) {
            ans *= 2;
            ans %= base;
        } else if (Math.abs(n - m) > 1) {
            System.out.println(0);
            System.exit(0);
        }

        for (int i = 1; i <= n; i++) {
            ans *= i;
            ans %= base;
        }

        for (int i = 1; i <= m; i++) {
            ans *= i;
            ans %= base;
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 21716
import math
K = int(input())
A = list(map(int, input().split()))
mincnt = 2
for a in reversed(A):
    if a < mincnt:
        a = math.ceil(mincnt/a) * a
    mincnt = max(mincnt, a)

#print(mincnt)

maxcnt = 2
nowgropu = 1
for a in reversed(A):
    nowgropu = maxcnt // a
    maxcnt = a * (nowgropu + 1) - 1

#print(maxcnt)

def check(init, A):
    cnt = init
    for a in A:
        group = cnt // a
        cnt = group * a
    return cnt == 2

#print(check(mincnt, A))
if check(mincnt, A) and check(maxcnt, A):
    print(mincnt, maxcnt)
else:
    print(-1)



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

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

    ll n;
    cin >> n;
    vector<ll> p(n);
    for (ll i = 0;i < n;i++){
        cin >> p[i];
        p[i]--;
    }

    ll ans = 0;
    for (ll i = 0; i < n; i++){
        if (p[i] == i){
           ans++; 
           i++;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 3960
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
ll calc(ll n) {

	ll ret = 0;

	if (n % 2) {
		ret = ((n + 1) / 2) % 2;
	}
	else {
		ret = (n / 2) % 2;
		ret ^= n;
	}

	return ret;

}

void solve() {

	ll A, B;
	cin >> A >> B;

	cout << (calc(B) ^ calc(A - 1)) << endl;

	return;

}

int main() {

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

	solve();

	return 0;

}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

int main() {
    LL N, M;
    cin >> N >> M;
    LL s = 0;
    REP(i, M) {
        LL a;
        cin >> a;
        s += a;
    }
    if(N < s) {
        cout << -1 << endl;
    }else{
        cout << N - s << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (1LL<<60);

ll N,K;
ll x[100005];
vector<ll> A,B;

ll solve(){
  A.clear();
  B.clear();
  for(int i=0;i<N;i++){
    if(x[i]>0)A.push_back(x[i]);
    else B.push_back(x[i]);
  }
  ll ans=INF;
  if( (ll)A.size() >= K )ans=A[K-1];
  for(int i=0;i<(int)B.size();i++){
    ll v= K - (B.size()-i);

    ll tmp= abs(B[i]) * 2LL;
    if( v > A.size() )continue;
    if( v > 0 ) tmp += A[v-1];
    ans=min(ans, tmp);
  }
  return ans;
}

int main(){
  cin>>N>>K;
  for(int i=0;i<N;i++){
    cin>>x[i];
  }
  ll ans=solve();
  for(int i=0;i<N;i++)x[i]*=-1LL;
  sort(x,x+N);
  ans=min(ans,solve());
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3316
#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>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#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 <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

typedef long long LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = N; i >= 0; i--)

template<typename Container>
bool include(const Container& c, const typename Container::value_type& v) {
  return ( c.end() != std::find(c.begin(),c.end(),v) );
}

template<class T>
vector<T> unique_vec(const vector<T> &v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  rep(i, N)
    cin >> S[i];
  int AC, WA, TLE, RE;
  AC = WA = TLE = RE = 0;
  rep(i, N) {
    if(S[i] == "AC") AC++;
    if(S[i] == "WA") WA++;
    if(S[i] == "TLE") TLE++;
    if(S[i] == "RE") RE++;
  }
  cout << "AC" << " x " << AC << endl;
  cout << "WA" << " x " << WA << endl;
  cout << "TLE" << " x " << TLE << endl;
  cout << "RE" << " x " << RE << endl;

  return 0;
}


Measured memory_bytes: 6380
/*
 _ _ _   _    _   _    _   _ _ _   _    _   _ __ _   __       __
|  _ _| | |  | | | |  | | |  _  | | |  | | |  __  | |   \   /   |
| |_ _  | |__| | | |  | | | |_| | | |__| | | |__| | | |\ \_/ /| |
|_ _  | |  __  | | |  | | |  _ <  |  __  | |  __  | | | \   / | |
 _ _| | | |  | | | |__| | | |_| | | |  | | | |  | | | |  \_/  | |  _   _   _
|_ _ _| |_|  |_| |_ __ _| |_ _ _| |_|  |_| |_|  |_| |_|       |_| |_| |_| |_|

*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
const int MOD=1e9 + 7;
const int N=1000100;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){  
                                                        for (auto &v : vec) is >> v; return is; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve(){
    long n;
    cin>>n;
    map<string,long> mp;
    long maxx=0;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        mp[s]++;
        maxx=max(maxx,mp[s]);
    }
    for(auto it=mp.begin();it!=mp.end();it++){
        if(mp[it->first]==maxx){
            cout<<it->first<<endl;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t = 1;
    // cin>>t;
    for (long int tt = 1; tt <= t; tt++) {
        solve();
    }
    return 0;
}


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

using namespace std;

char a[51][51];

int check(int x, int y, int &n, int &m){
  int res = 0;
  if(x - 1 >= 0){
    if(a[x - 1][y] == '#'){
      res++;
    }
    if(y - 1 >= 0){
      if(a[x - 1][y - 1] == '#'){
        res++;
      }
    }
    if(y + 1 < m){
      if(a[x - 1][y + 1] == '#'){
        res++;
      }
    }
  }
  if(x + 1 < n){
    if(a[x + 1][y] == '#'){
      res++;
    }
    if(y - 1 >= 0){
      if(a[x + 1][y - 1] == '#'){
        res++;
      }
    }
    if(y + 1 < m){
      if(a[x + 1][y + 1] == '#'){
        res++;
      }
    }
  }
  if(y - 1 >= 0){
    if(a[x][y - 1] == '#'){
      res++;
    }
  }
  if(y + 1 < m){
    if(a[x][y + 1] == '#'){
      res++;
    }
  }
  return res;
}

int main(){
  int n, m;
  scanf("%d %d", &n, &m);
  for(int i = 0; i < n; ++i){
    scanf("%s", a[i]);
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(a[i][j] != '#'){
        printf("%d", check(i, j, n, m));
        continue;
      }
      printf("%c", a[i][j]);
    }
    puts("");
  }
  return 0;
}

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

using namespace std;


bool primary_number_checker(int p){
    bool checker = true;

    for(int i = 2; i < p; i++){
        if(p % i == 0) checker = false;
    }
    return checker;
}

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

    for(int i = 31; i <= 55555; i += 30){
        if(primary_number_checker(i) == true){
            if(i != 31){
                cout << i << " ";
                n--;
            }
        }
        if(n == 0){
            break;
        }
    }

    return 0;

}


Measured memory_bytes: 256
import functools as ft
import heapq
import itertools as it
import logging
import unittest
from collections import (
    OrderedDict,
    defaultdict,
    namedtuple,
    Counter,
)

import numpy as np

_ = [ft, it, np, heapq, namedtuple, Counter, defaultdict, OrderedDict]

debug = logging.getLogger(__name__).debug


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


def _main():
    l, r = input_ints()
    logging.debug([l, r])
    i_close = set()
    j_close = set()
    result = float('inf')
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            result = min(result, (i * j) % 2019)
            j_close.add(j % 2019)
            if len(j_close) == 2019:
                break
        i_close.add(i % 2019)
        if len(i_close) == 2019:
            break
    print(result)


class Test(unittest.TestCase):
    def setUp(self):
        import run
        self._test = run

    def test_main(self):
        self._test.test_files(self, _main)


if __name__ == '__main__':
    _main()


Measured memory_bytes: 12476
#APC001_B
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

plus, minus = 0, 0
for i in range(n):
    if a[i] < b[i]:
        plus += (b[i] - a[i]) // 2
    if a[i] > b[i]:
        minus += (a[i] - b[i])
        
print('Yes' if minus <= plus else 'No')

Measured memory_bytes: 4724
/*-----lusar98-----*/
#include<bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define mod 1000000007
#define eps 1e-9
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
using namespace std;
deque<ll> arr;
ll n;
ll memo[3000+10][3000+10][2];
ll solve(ll i, ll j, ll p)
{
	if(i==j )
	{
		return ( p ? 0 : arr[i] );
	}
	if(memo[i][j][p]!=-1)
		return memo[i][j][p];
	ll ans;
	if(p == 0)
	{
		ans = max(solve(i,j-1,1) + arr[j] , solve( i +1 , j , 1 ) +arr[i] );	
	}
	else
	{
		ans = min(solve(i, j-1 , 0) , solve(i+1 , j ,0) );
	}
	return memo[i][j][p] =ans;
}
int main()
{
    //fast();
	cin>>n;
	memset(memo,-1,sizeof memo);
	ll sum=0;
	for(ll i=0;i<n;i++)
	{
		ll x;
		cin>>x;
		sum+=x;
		arr.pb(x);
	}
	cout<<(2*solve(0,n-1,0) - sum)<<endl;
}


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

ll dp[3001][3001];

ll score(vector<ll>& v,int i,int j,bool turn){
    if(i>j){
        return 0;
    }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    if(turn==1){
        return dp[i][j] = max(v[i] + score(v,i+1,j,0),v[j] + score(v,i,j-1,0));
    }
    else{
        return dp[i][j] = min(score(v,i+1,j,1),score(v,i,j-1,1));
    }
}

int main(){
    int n;
    cin>>n;
    vector<ll> v(n);
    ll sum = 0;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++){
        cin>>v[i];
        sum += v[i];
    }
    ll scoreX = score(v,0,n-1,1);
    ll scoreY = sum - scoreX;
    cout<<scoreX - scoreY;
    return 0;
}

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

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

    map<string,int> dic;
    string str;

    rep(i,N){
        cin >> str;
        dic[str]++;
    }

    map<string,int>::iterator it;
    int max = 0;
    for(it=dic.begin();it!=dic.end();it++){
        if(max < it->second) max = it->second;
    }

    for(it=dic.begin();it!=dic.end();it++){
        if(it->second == max) cout << it->first << endl;
    }

    return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;

#define test(t)		int t; cin>>t; while(t--)
#define all(a)		a.begin(), a.end()
#define f(i, a, b)	for(int i = a; i < b; ++i)
#define endl 		"\n"
#define deb(x)		cout << #x << "--" << x << "--" << endl;
#define deb2(x,y)	cout << #x << "--" << x << "--" << endl <<  #y << "--" << y << "--" << endl;
#define fast 		ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define mx9		1000000007
#define mx7		10000007
#define mx6		1000006
#define mx5		200005
#define inf		1<<30                                 
#define eps		1e-9
#define mod		1000000007

void solve()
{
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
    if(a >= k) 
      cout << k << endl;
	else if(a + b >= k) 
      cout << a << endl;
	else 
      cout << a - (k - a - b) << endl;
}


int main()
{
     fast;
     //test(t)
          solve();
     return 0;
}


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

int main() {
  string s;
  cin >> s;
  if (s.at(s.size()-1) == 's') {
    cout << s << "es" << endl;
  } else {
    cout << s << "s" << endl;
  }
}


Measured memory_bytes: 3592
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <time.h>
#define _USE_MATH_DEFINES
#define LL long long
#define UN unsigned
using namespace std;
const double PI = acos(-1.0);

int max_num(int ary[], int length) {
	int max = ary[0];
	for (int i = 1; i < length; i++)
		if (max < ary[i]) max = ary[i];
	return max;
}

int max_ord(int ary[], int length) {
	int max;
	max = max_num(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == max) return i;
	}
	return -1;
}

int min_num(int ary[], int length) {
	int min = ary[0];
	for (int i = 1; i < length; i++)
		if (min > ary[i]) min = ary[i];
	return min;
}

int min_ord(int ary[], int length) {
	int min;
	min = min_num(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == min) return i;
	}
	return -1;
}

void dfs(int rest, string s) {
	if (rest == 0)
		cout << s << endl;
	else
		for (char c = 'a'; c <= 'c'; c++)
			dfs(rest - 1, s + c);
}

int main() {
	LL n, a[100000], cnt4 = 0, cnt0 = 0, cnt2 = 0;
	bool ans = true;
	cin >> n;
	for (LL i = 0; i < n; i++) cin >> a[i];

	for (LL i = 0; i < n; i++) {
		if (a[i] % 4 == 0)
			cnt4++;
		else if (a[i] % 2 != 0)
			cnt0++;
		else
			cnt2++;
	}
	cnt2 %= 2;
	if (cnt4 + 1 < cnt0 + cnt2) {
		ans = false;
	}
	cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N, M; cin >> N >> M;
    if (N != M) cout << "No\n";
    else cout << "Yes\n";
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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

A, B, C, K = map(int, input().split())

total = 0

if (A <= K):
    total += A
    K -= A
    if (B <= K):
        K -= B
        if (K > 0):
            total -= K
else:
    total += K

print("{}".format(total))

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

using namespace std;

typedef pair<int, int> P;

int n;
vector<vector<P>> g;
int ans[101010];

int dfs(int v, int pv, int d) {
  for (auto nv : g[v]) {
    if (nv.first == pv) continue;
    int e = d + nv.second;
    if (e % 2 == 0) {
      dfs(nv.first, v, e);
    } else {
      ans[nv.first] = 1;
      dfs(nv.first, v, e);
    }
  }
}

int main() {
  cin >> n;
  g.assign(n, vector<P>());
  for (int i = 0; i + 1 < n; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    g[u].emplace_back(v, w);
    g[v].emplace_back(u, w);
  }

  dfs(0, -1, 0);
  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 8192
import collections
import sys
sys.setrecursionlimit(2000000)
# import math
# import itertools
# import statistics
# import numpy as np
n = int(input())
a = list(map(int, input().split()))
a_count = collections.Counter(a)
a_list = list(a_count.items())
a_sorted = sorted(a_list, key=lambda x: x[0], reverse=True)
# print(a_sorted)

ans = []
kouho = []
for i in range(len(a_sorted)):
    if a_sorted[i][1] >= 4:
        b = a_sorted[i][0]
        kouho.append(b)
        ans.append(b*b)
    if a_sorted[i][1] >= 2:
        kouho.append(a_sorted[i][0])


if len(ans) == 0 and len(kouho) < 2:
    print(0)
else:
    if len(ans) == 0:
        print(kouho[0]*kouho[1])
    else:
        print(max(max(ans), kouho[0]*kouho[1]))


Measured memory_bytes: 23204
/* C - Skill Up */

#include <stdio.h>
// #define INF (int)1e9
const int INF = 1e9;

int main(void){
  int N, M, X, ans = INF;
  scanf("%d %d %d", &N, &M, &X);
  int C[N], A[N][M];
  for(int i = 0; i < N; i++){
    scanf("%d", &C[i]);
    for(int j = 0; j < M; j++){
      scanf("%d", &A[i][j]);
    }
  }
  /* bit全探索 */
  for(int bit = 0; bit < (1 << N); bit++){
    int money = 0, totalA[M]; // 可変長配列は = {} で初期化できない
    // 以下のように配列を初期化
    for(int j = 0; j < M; j++){
      totalA[j] = 0;
    }
    for(int i = 0; i < N; i++){
      if(bit & (1 << i)){
        money += C[i];
        for(int j = 0; j < M; j++){
          totalA[j] += A[i][j];
        }
      }
    }
    int judge = 1;
    for(int j = 0; j < M; j++){
      if(totalA[j] < X){
        judge = 0;
        break;
      }
    }
    if(judge && money < ans){
      ans = money;
    }
  }
  if(ans == INF){
    puts("-1");
  }else{
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    ll a, b;
    cin >> a >> b;

    if (a > b) swap(a, b);

    for (ll i=a; i<=b; i++) 
    {
        if (abs(a - i) == abs(b - i))
        {
            cout << i << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,x=0;
	scanf("%d",&k);
	for(int i=1;i<=k;i++)
	{
		x=(x*10+7)%k;
		if(!x)
		{	printf("%d",i); return 0; }
	}
	printf("-1");
}

Measured memory_bytes: 3788
/**************
*Author:MySakure
*Time:2019-05-26
*Source:
*Theory:
*State:
***************/
#include<bits/stdc++.h>
using namespace std;

const int maxn=110;
struct Node{
	string name;
	int score;
	int id;
}v[maxn];
int n;
bool cmp(const Node&a,const Node&b){
	return a.name!=b.name?a.name<b.name:a.score>b.score;
}
int main() {
	ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>v[i].name;
		cin>>v[i].score;
		v[i].id=i;
	}
sort(v+1,v+1+n,cmp);
for(int i=1;i<=n;++i)cout<<v[i].id<<endl;
	return 0;
}


Measured memory_bytes: 256
// 1_2_A
#include <stdio.h>

int BubbleSort(int [], int);

int main(){
    int length, i;
    int numbers[100] = {};

    scanf("%d", &length);
    for(i = 0; i < length; i++){
        scanf("%d", &numbers[i]);
    }

    BubbleSort(numbers, length);

    return 0;
}

int BubbleSort(int numbers[], int length){
    int flag = 1, cnt = 0, i = -1, j, tmp;

    while(flag){
        flag = 0;
        for(j = length - 1; j > i + 1; j--){
            if(numbers[j] < numbers[j - 1]){
                tmp = numbers[j - 1];
                numbers[j - 1] = numbers[j];
                numbers[j] = tmp;

                cnt++;
                flag = 1;
            }
        }
        i++;
    }

    for(i = 0; i < length - 1; i++){
        printf("%d ", numbers[i]);
    }
    printf("%d\n", numbers[length - 1]);
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 600
import java.util.*;
public class Main {
    public static void main(String[]_) throws Exception {
        Scanner s=new Scanner(System.in);
        // 階乗
        long a=1;
        long N=s.nextLong();
        for(int i=2;i<=N;i++){ // 1はいらない
            a*=i;
            a%=1e9+7; // 1e9 = 1 x 10^9
        }
        System.out.println(a);
    }
}


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

#define mx 100005

using namespace std;

int n, m, a, b, root, pa[mx];
vector<int> ch[mx];
bool nt[mx], active[mx];

 void search(int node){
	 active[node] = true;
	 for(int i : ch[node]){
		 if(!pa[i]){
			 pa[i] = node;
			 search(i);
		 }else if(active[pa[i]]) pa[i] = node;
	 }
	 active[node] = false;
 }

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n + m - 1; i++){
		scanf("%d%d", &a, &b);
		ch[a].push_back(b);
		nt[b] = true;
	}
	for(root = 1; nt[root]; root++);
	search(root);
	for(int i = 1; i <= n; i++){
		printf("%d\n", pa[i]);
	}
}


Measured memory_bytes: 11520
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

vector<int> T = {2, 5, 5, 4, 5, 6, 3, 7, 6};

int f(int x){
    return T[x-1];
}

string solve(string a, string b){
    if(a.size() > b.size()) return a;
    if(b.size() > a.size()) return b;
    return max(a, b);
}

int main(){
    int N, M; cin >> N >> M;
    vector<int> A(M);
    for(int &a:A)
        cin >> a;

    vector<string> dp(N+1);
    for(int i=1; i<=N; i++){
        for(int j=0; j<M; j++){
            if(i-f(A[j])==0 || ((i-f(A[j])>0) && dp[i-f(A[j])]!="")){
                dp[i] = solve(dp[i], dp[i-f(A[j])]+char('0'+A[j]));
            }
        }
    }
    
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 41600
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

int main(void){
  ll a, b, x;
  cin >> a >> b >> x;
  
  if (a > 0)
    cout << b / x - (a-1) / x << endl;
  else
    cout << b / x + 1 << endl;

  return 0;
}


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

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

const int MAXN = 2e5+10;
long long sz[MAXN];

int main() {
    int n;
    cin >> n;
    for(int i=0;i<n;i++) {
        cin >> sz[i];
    }
    long long s = 0;
    for(int i=1;i<n;i++) {
        if(sz[i]<sz[i-1]) {
            s += sz[i-1]-sz[i];
            sz[i] = sz[i-1];
        }
    }
    cout << s << endl;
    return 0;
}

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

int main(){
	
	
	int n,k,x,y;
	int i;
	
	while(cin>>n>>k>>x>>y){
		
		if(k<=n){
			
			cout<<x*k+y*(n-k)<<endl;
		}else{
			cout<<x*n<<endl;
		}
		
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/*
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i,n) for(int (i)=0, i##_len = (n);(i)<i##_len;(i)++)
#define reps(i,x) for(int (i)=1;(i)<=(int)(x);(i)++)
#define rrep(i,x) for(int (i)=((int)(x)-1);(i)>=0;(i)--)
#define rreps(i,x) for(int (i)=((int)(x));(i)>0;(i)--)
#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1)<<(n))
#define all(x) (x).begin(),(x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl 
#define nint int
using namespace std;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
typedef pair<int,int> pii;
typedef pair<double,double> dop;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;



signed main()
{
int k,a,b;
std::cin >> k >> a >> b;
int sum = 0;
if(a + 2>= b || a > k){
    std::cout << k + 1 << std::endl;
} else {
    int time = k - (a - 1);
    sum += a;
    int inc = b - a;
    int n = time / 2;
    int plus = time % 2;
    int get = (b - a) * n;
    sum += (get + plus);
    std::cout << sum << std::endl;
}

return 0;
}

Measured memory_bytes: 256
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void YES()
{
	OUT("YES");
}
void NO()
{
	OUT("NO");
}
void YESNO(const bool cond)
{
	OUT(cond ? "YES" : "NO");
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}
void YesNo(const bool cond)
{
	OUT(cond ? "Yes" : "No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

// 階乗を計算 O(N) (N=10^7 で O(10^7))
ll factorial(ll n)
{
	for (ll i = n - 1; i > 1; --i)
		n *= i;
	return n;
}

// nCrを計算 O(N) (N=10^7 で O(10^7))
ll ncr(const ll n, ll r)
{
	if (r * 2 > n) r = n - r;

	ll dividend = 1, divisor = 1;

	for (ll i = 1; i <= r; ++i) {
		dividend *= n - i + 1;
		divisor *= i;
	}

	return dividend / divisor;
}

// 素数判定 O(sqrt(N)) (N=10^7 で O(10^3))
bool isprime(const ll num)
{
    if (num < 2) return false;
    if (num == 2) return true;
    if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0) return false;
    }

    return true;
}

// 各桁の和を計算 O(logN) (N=10^7 で O(7))
ll digsum(ll n)
{
	ll sum = 0;
	while(n != 0){
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	inll x1, y1, x2, y2;

	ll dx = x2 - x1, dy = y2 - y1;
	
	return OUT(x2-dy,y2+dx,x1-dy,y1+dx);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define rep(i, n) for(int i=0;i<n;i++)

  
int main(){
  int s;
  cin >> s ;
  vector<int> a(1000000);
  a.at(0)=s;
  for(int i=0;i<999999;i++){
    if(a.at(i)%2 ==0){
      a.at(i+1)=a.at(i)/2;
    }
    if(a.at(i)%2==1){
      a.at(i+1)=a.at(i)*3+1;
    }
  }
  bool fine=false;
  rep(i,1000000){
    rep(j,i){
      if(a.at(i)==a.at(j)){
        cout << i+1 << endl;
        fine =true;
        break;
      }
    }
    if(fine) break;
  }
    
  
}

Measured memory_bytes: 4096
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  string s;
  cin >> s;

  if(s[0] != 'A'){
    cout << "WA\n";
    return 0;
  }
  int cnt = 0;
  REP(i,(int)s.length()){
    if(s[i] == 'C' && i < (int)s.length() - 1 && i > 1){
      cnt++;
    }
    if(s[i] != 'A' && s[i] != 'C' && (s[i] < 'a' || s[i] > 'z')){
      cout << "WA\n";
      return 0;
    }
  }

  if(cnt != 1){
    cout << "WA\n";
    return 0;
  }

  cout << "AC\n";
  return 0;
}



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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i32 n, x,y;
    vi a(3); cin >> n >> a[0] >> a[1] >> a[2];
    char ch1, ch2;
    vec<PII> s;
    rep(i,n) {
        cin >> ch1 >> ch2;
        i32 f = (i32)(ch1-'A'), g = (i32)(ch2-'A');
        s.emplace_back(max(f,g), min(f, g));
    }
    queue<char> que;
    char out = 'A';
    rep(i, n) {
        x = s[i].first, y = s[i].second;
        if(a[x] == 0 && a[y] == 0) {
            cout << "No" << '\n';
            return 0;
        }
        else if(a[x] == 0) {
            a[x] += 1;
            a[y] -= 1;
            que.push(char(out+x));
        }
        else if(a[y] == 0) {
            a[x] -= 1;
            a[y] += 1;
            que.push(char(out+y));
        }
        else {
            if((a[x] == 1 || a[y] == 1) && a[(~(x^y))] == 0 && s[i] != s[i+1] && i != n-1) {
                if(x == s[i+1].first || x == s[i+1].second) {
                    a[x] += 1;
                    a[y] -= 1;
                    que.push(char(out+x));
                }
                else {
                    a[x] -= 1;
                    a[y] += 1;
                    que.push(char(out+y));
                }
            }
            else {
                a[min(x, y)] += 1;
                a[max(x, y)] -= 1;
                que.push(char(out+min(x, y)));
            }
        }
    }

    cout << "Yes" << '\n';
    while(que.size()) {
        cout << que.front() << '\n';
        que.pop();
    }

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 5392
#include <iostream>
using namespace std;
int main(void){
    int n,i,a;
    cin >> n;
    int ans = 0;
    for(i=0; i<n; i++){
        cin >> a;
        while(a%2 == 0){
            a /= 2;
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

    int B1, B2;
    int sum = 0;
    cin >> B1;
    sum += B2 = B1;
    for (int i = 1; i < N-1; i++) {
        cin >> B2;
        sum += min(B1, B2);
        B1 = B2;
    }
    sum += B2;

    cout << sum << endl;
}

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

int top,S[1000];


void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}


int main(){
  int a,b;
  top = 0;
  char s[100];

  while(scanf("%s",s) != EOF){
    if (s[0] == '+'){
      a = pop();
      b = pop();
      push(a+b);
    }
    else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
    }
    else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a*b);
    }
    else{
      push(atoi(s));
    }
  }
  
  printf("%d\n",pop());

  return 0;
}



Measured memory_bytes: 2088
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
#define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;


//0-index

ll n,vs[2*100010],depth[2*100010],id[100010],root,q;
vll G[100010];

struct SegmentTree{
    static const int MAX_N = 1<<18;
    int n;
    pii dat[2 * MAX_N -1];
    SegmentTree(int n_){
        n=1;
        while(n<n_) n*= 2;
        for(int i=0;i<2*n-1;i++) dat[i] = pii(INT_MAX,0);
    }
    void update(int k,int a){
        ll i=k;
        k += n-1;
        dat[k].first=a;
        dat[k].second=i;
        while(k>0){
            k=(k-1)/2;
            dat[k]=min(dat[k*2+1],dat[k*2+2]);
        }
    }
    pii query(int a,int b,int k,int l,int r){
        if(r<=a || b<=l) return pii(INT_MAX,INT_MAX);
        if(a<=l && r<=b) return dat[k];
        else{
            pii vl = query(a,b,k*2+1,l,(l+r)/2);
            pii vr = query(a,b,k*2+2,(l+r)/2,r);
            return min(vr,vl);
        }
    }
    int query(int a,int b){
        return query(a,b,0,0,n).second;
    }
};


void dfs(ll v,ll p,ll d,ll &k){
    id[v]=k;
    vs[k]=v;
    depth[k++]=d;
    rep(i,(ll)G[v].size()){
        if(G[v][i]!=p){
            dfs(G[v][i],v,d+1,k);
            vs[k]=v;
            depth[k++]=d;
        }
    }
}

void init(){
    ll k=0;
    dfs(root,-1,0,k);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cin>>n;
    root=0;
    rep(i,n){
        ll k;
        cin>>k;
        rep(j,k){
            ll a;
            cin>>a;
            G[i].pb(a);
            G[a].pb(i);
        }
    }
    init();
    SegmentTree sg(n*2-1);
    rep(i,2*n-1){
        sg.update(i,depth[i]);
    }
    cin>>q;
    rep(i,q){
        ll a,b;
        cin>>a>>b;
        ll s=vs[sg.query(min(id[a],id[b]),max(id[a],id[b])+1)];
        cout<<s<<endl;
    }
    return 0;
}



Measured memory_bytes: 28568
program Project1;
{$APPTYPE CONSOLE}
uses
  SysUtils,math;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,d,p:Integer;
  l:array[0..40] of Integer=(1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169,196,
   216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961,1000);
  s,s123,s1,s2,s3:string;
  al:string = 'abcdefghijklmnopqrstuvwxyz';
  tf,tfl,tfr:Boolean;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    Readln(x);
    y:=0;

    while True do begin
      if l[y]>x then begin
        Writeln(l[y-1]);
        Readln;
        exit;
      end;
      inc(y);
    end;
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 128
n, m = map(int, input().split())
h = list(map(int, input().strip().split()))

f = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] == h[b-1]:
        f[a-1] = 1
        f[b-1] = 1
    elif h[a-1] > h[b-1]:
        f[b-1] = 1
    elif h[a-1] < h[b-1]:
        f[a-1] = 1

#print(h0)
#print(h)


ans = 0
for i in range(n):
    if f[i] <= 0:
        #print(i)
        ans += 1

print(ans)

Measured memory_bytes: 20128
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

struct tree{
    ll self;
    vector<ll> child;
    ll counter = 0;
};
tree t[200010];
bool visited[200010];
void score(ll c){
    visited[c] = true;
    rep(i, t[c].child.size()){
        ll leaf = t[c].child[i];
        if(visited[leaf])continue;
        t[leaf].counter += t[c].counter;
        score(leaf);
    }
}
int main(){
    ll n, q;
    cin >> n >> q;
    for(int i = 1; i < n; ++i){
        ll a, b;
        cin >> a >> b;
        t[a].child.push_back(b);
        t[b].child.push_back(a);
    }
    rep(i, q){
        ll p, x;
        cin >> p >> x;
        t[p].counter += x;
    }
    rep(i, 200010)visited[i] = false;

    score(1);
    for(int i = 1; i <= n; ++i)cout << t[i].counter << " ";
}

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

int main() {
	int N; cin >> N;
	string S; cin >> S;
	int P=0;
	for(int i=1; i<S.size(); ++i) if(S[i]=='E') ++P;
	int Q=P;
	for(int i=1; i<S.size(); ++i){
	    if(S[i-1]=='W') ++Q;
	    if(S[i]=='E') --Q;
	    if(Q<P) P=Q;
	}
	cout << P << endl;
	return 0;
}


Measured memory_bytes: 900
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	string s; cin >> s;
	s[5] = ' ';
	s[13] = ' ';
	cout << s << endl;
}

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

using ll= long long;
#define double long double
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _set(x) __builtin_popcount(x)
#define PI  3.14159265358979323846264338327950L
#define mod 1000000007
#define dpv(...) cerr<< "["#__VA_ARGS__ " : ";for(int i: (__VA_ARGS__)){cerr<<i<<" ";}cerr<<"]\n"

void solve(){
    int a,b;
    int k;
    cin>>k;
    cin>>a>>b;
    if(a%k==0 ||b%k==0 || ((a+k-1)/k)*k <=b)
    cout<<"OK\n";
    else
    cout<<"NG\n";
}
int32_t main(){
	IOS
	// freopen("input.txt","r",stdin);
	int _;
	// cin>>_;
	_=1;
	while(_--){
        solve();
    }
	return 0;
}

/*
   check for overflows int long long
   correct size of array
*/

Measured memory_bytes: 3644
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll m;cin>>m;
    ll d[m],c[m];
    rep(i,0,m)cin>>d[i]>>c[i];
    deque<ll> v;
    ll ans=0;
    rep(i,0,m){
        c[i]--;
        ll u=c[i]/9;
        ans+=u*(d[i]+9);
        ll t=c[i]%9;
        ll now=d[i];
        deque<ll> dq;
        rep(j,0,t+1)dq.push_back(d[i]);
        for(;;){
            if(dq.size()==1)break;
            ll f=dq.front();dq.pop_front();
            ll g=dq.front();dq.pop_front();
            ans++;
            f+=g;
            if(f<=9)dq.push_front(f);
            else{
                dq.push_front(f%10);
                dq.push_front(f/10);
            }
        }
        v.push_back(dq.front());
    }
    //rep(i,0,v.size())cout<<v[i]<<" ";
    for(;;){
    if(v.size()==1)break;
    ll f=v.front();v.pop_front();
    ll g=v.front();v.pop_front();
    ans++;
    f+=g;
    if(f<=9)v.push_front(f);
    else{
        v.push_front(f%10);
        v.push_front(f/10);
    }
    }
        cout<<ans<<endl;
}


Measured memory_bytes: 4992
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    n, m = map(int, input().split())
    uf = UnionFind(n)
    la = [None]*m
    for i in range(n):
        a = list(map(int, input().split()))
        for v in a[1:]:
            if la[v-1] is None:
                la[v-1] = i
            else:
                uf.union(i, la[v-1])
    if uf.group_count() == 1:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()


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

int flg_kawaisou(int a, int b, int c){
    if(a == b && b != c){
        return 1;
    }
    else if(a == c && c != b){
        return 1;
    }
    else if(b == c && c != a){
        return 1;
    }
    else{
        return 0;
    }
}

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(flg_kawaisou(a, b, c)==1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int con = 1;


		for (int i = 0; i < N; i++) {
			int target = sc.nextInt();
			if (target % 2 == 0) {
				con *= 2;
			}else {
				con *= 1;
			}
		}

		System.out.println((int)Math.pow(3, N) - con);
	}
}


Measured memory_bytes: 35552