akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX_N 100000
#define MAX_M 100000
const int MAX = 100100;
const int MOD = 1000000007;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecbvecb vector<vector<bool>>
#define vecst vector<string>
#define vecch vector<char>
#define vecf vector<float>
#define vecvec vector<vector<int>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
const long long INF = 1LL<<60;
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

int main() {
  int n;
  ll w;
  cin>>n>>w;
  ll we[110],va[110];
  for(int i=0;i<n;i++){
    cin>>we[i]>>va[i];
  }
  ll dp[110][MAX];
  for (int i = 0; i < 110; ++i) for (int j = 0; j < MAX; ++j) dp[i][j] = INF;
  dp[0][0]=0;
  for(int i=0;i<n;i++){
    for(ll j=0;j<MAX;j++){
      if(j>=va[i]){
        dp[i+1][j]=min(dp[i+1][j],dp[i][j-va[i]]+we[i]);
      }
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
    }
  }
  ll ans=0;
  for(ll i=0;i<MAX;++i){
    if(dp[n][i]<=w) ans=i;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 86272
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

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

    vector<pair<pair<string, int64_t>, int64_t>> s(n);
    for (auto i : irange(0L, n)) {
        cin >> s[i].first.first >> s[i].first.second;
        s[i].first.second *= -1;
        s[i].second = i + 1;
    }

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

    for (const auto& ss : s) {
        cout << ss.second << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=1;i<=100000;i++)
	{
		if(a*i%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<map>
#include<queue>

using namespace std;

#define INF 2000000000;

int main(void){

    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = INF;

    for(int i = 0;i <= max(x, y);i++){
        ans = min(ans, i * 2 * c + max(0, x - i) * a + max(0, y - i) * b);
    }

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

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
 
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
 
#define len(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
 
#ifdef LOCAL
	#define dbg(x) cout << #x << " = " << x << endl;
#else 
	#define dbg(x)
#endif 
 
using namespace std;
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("file1.txt", "r", stdin);                                       
    freopen("file2.txt", "w", stderr);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(15);
    solve();  	
}
 
const int MAXN = 1e5 + 10, MOD = 1e9 + 7, INF = 1e18;
 
vector<int> z_fun(string &s) {
    int l = 0, r = 0, n = len(s);
    vector<int> z(n);
    for (int i = 1; i < n; ++i) {
     	if (i > r) {
     		int j = 0;
     		for (j = 0; i + j < n && s[j] == s[i + j]; ++j);
     		z[i] = j; l = i; r = i + j - 1;
     	}
     	else if (z[i - l] < r - i + 1) z[i] = z[i - l];
     	else {
     	 	int j = 1;
     	 	for (j = 1; r + j < n && s[r + j] == s[r - i + j]; ++j);
     	 	z[i] = r - i + j; l = i; r = r + j - 1;
     	}
    }
    
    return z;
}	

void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;                             	
  
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		vector<int> z = z_fun(s);
		for (int j = 0; j < len(z); ++j) {
		    ans = max(ans, min(z[j], j));
		}	
		s.erase(0, 1);
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;



int main() {
	
	int n;
	
	cin >> n;
	
	vector <pair<string,int>> rest(n);
	vector <pair<string,int>> org_rest(n);
	
	for (int i = 0;i < n; i++) {
		cin >> rest.at(i).first >> rest.at(i).second;
		org_rest.at(i).first =rest.at(i).first;
		org_rest.at(i).second =rest.at(i).second;
	}
	
	int res = 0;
	pair<string,int> tmp = make_pair("a",0);
	
	while(rest.size() > 0){
		
		//変数初期化
		res = 0;
		tmp = make_pair("zzzzzzzzzz", 0);
		
		
		for (int i = 0; i < rest.size(); i++){
			
	//		cout << "dbg r.f " << rest.at(i).first << ", r.s " << rest.at(i).second << endl;
			
			if (tmp.first.compare(rest.at(i).first) > 0) {
				//町が若ければ置き換える
				
	//			cout << "mw" << endl;
				
				tmp.first = rest.at(i).first;
				tmp.second = rest.at(i).second;
				res = i;
			} else if (tmp.first.compare(rest.at(i).first) == 0){
				//町の名前一致
				
	//			cout << "me" << endl;
				if (tmp.second < rest.at(i).second) {
					
	//				cout << "sb" << endl;
					
					tmp.second = rest.at(i).second;
					res = i;
				}
			} else {
				//どこにも入らない(ソート外)
				
	//			cout << "others" << endl;
			}
				
				
		}//for i 終わり
		
	//	cout << "loop" << org_rest.size()-rest.size() + 1 << " end, res is " << res << endl;
		
		//cout << res+1 << endl;
		//cout << "ANSWER " << res+1 + (org_rest.size()-rest.size()) << endl;
		int ans = 0;
		for (int i = 0; i < org_rest.size(); i++) {
			if (org_rest.at(i).first == tmp.first && org_rest.at(i).second == tmp.second) {
				cout << i + 1 << endl;
				break;
			}
		}

		rest.erase(rest.begin()+res);
		
	
	}//while終わり(先に書いた)
	
	return 0;
}


Measured memory_bytes: 256
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n: usize = s.trim().parse().unwrap();
    let mut dp = vec![false; std::cmp::max(n + 1, 106)];
    dp[0] = true;
    for i in 100..106 { dp[i] = true; }
    for i in 200..n + 1 {
        for j in 100..106 {
            dp[i] |= dp[i - j];
        }
    }
    println!("{}", if dp[n] { 1 } else { 0 });
}

Measured memory_bytes: 4352
import java.util.ArrayList;                                                      
import java.util.Collections;                                                    
import java.util.List;                                                           
import java.util.Scanner;                                                        
                                                                                 
class Main {                                                                     
	public static void main(String[] args) {                                     
		Scanner sc = new Scanner(System.in);                                     
		int N = Integer.parseInt(sc.next());                                     
		int T = Integer.parseInt(sc.next());                                     
                                                                                 
		List<Integer> list = new ArrayList();                                    
		for(int i=0; i<N; i++){                                                  
			int a=Integer.parseInt(sc.next());                                   
			int b=Integer.parseInt(sc.next());                                   
			if(b <= T){                                                          
				list.add(a);                                                     
			}                                                                    
		}                                                                        
		if(list.size() == 0){                                                    
			System.out.println("TLE");                                           
		} else {                                                                 
			Collections.sort(list);                                              
			System.out.println(list.get(0));                                     
		}                                                                        
	}                                                                            
}                                                                                
                                                                                 

Measured memory_bytes: 26984
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(c) (c).begin(), (c).end()
#define P pair<int, int>
#define chmin(x, y) x = min(x, y)

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

int main()
{
  int n, k;
  cin >> n >> k;
  vector<ll> l(k), r(k);
  for (int i = 0; i < k; i++)
  {
    cin >> l[i] >> r[i];
  }

  vector<mint> dp(n, 0);
  dp[0] = 1;
  vector<mint> cum(n, 0);
  cum[0] = 1;

  for (int i = 1; i < n; i++)
  {
    for (int j = 0; j < k; j++)
    {
      mint cum_l = 0;
      mint cum_r = 0;
      if (i - l[j] >= 0)
        cum_l = cum[i - l[j]];
      if (i - r[j] - 1 >= 0)
        cum_r = cum[i - r[j] - 1];
      dp[i] += cum_l - cum_r;
    }
    cum[i] = cum[i - 1] + dp[i];
  }

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


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

int main(){
  int k,a,b;
  cin >> k >> a >> b;
  if(b/k - (a-1)/k){
    cout << "OK";
  }else{
    cout << "NG";
  }
}

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

int main () {
  int W, H, N;
  cin >> W >> H >> N;
  
  int x, y, a, a1=0, a2=W, a3=0, a4=H;
  for (int i = 0; i < N; i++) {
    cin >> x >> y >> a;
    if (a == 1) {
      a1 = max(a1,x);
    }
    if (a == 2) {
      a2 = min(a2,x);
    }
    if (a == 3) {
      a3 = max(a3,y);
    }
    if (a == 4) {
      a4 = min(a4,y);
    }
  }
  if (a1<a2 && a3<a4) {
    cout << (a2-a1)*(a4-a3) << endl;
  }
  else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
import itertools

N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]

def min_cost(target, l_list):
  return 10*(len(l_list) - 1) + abs(target - sum(l_list))


ans = 1000 * 3
combs = list(itertools.product([0, 1, 2, 3], repeat=N))
for comb in combs:
  labcn = [[], [], [], []]
  for i, idx in enumerate(comb):
    labcn[idx].append(L[i])
  
  la, lb, lc, ln = labcn
  if len(la)*len(lb)*len(lc):
    ans = min(ans, min_cost(A, la)+min_cost(B, lb)+min_cost(C, lc))

print(ans)

Measured memory_bytes: 10996
// VC, WIP

#include <bits/stdc++.h>
using namespace std;

// Utility
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, X, Y) for (int I = (X); I < (Y); I++)
using ll = int64_t;
using ull = uint64_t;
namespace std {
template<class ...Ts>        istream& operator>>(istream& i, tuple<Ts...>& x) { apply([&](auto&&... ys){ ((i >> ys), ...); }, x); return i; }
template<class T1, class T2> istream& operator>>(istream& i, pair<T1, T2>& x) { i >> x.first >> x.second; return i; }
template<class T>            istream& operator>>(istream& i, vector<T>& x)    { for (auto& y : x) { i >> y; } return i; }
}

// Debugging
#define DD(X) std::cout << #X ": " << (X) << std::endl << std::flush
namespace std {
template<class ...Ts>        ostream& operator<<(ostream& o, const tuple<Ts...>& x) { o << "("; apply([&](auto&& y, auto&&... ys){ o << y; ((o << ", " << ys), ...); }, x); o << ")"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const pair<T1, T2>& x) { o << tie(x.first, x.second); return o; }
template<class T>            ostream& operator<<(ostream& o, const vector<T>& x)    { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const set<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
}

// Main
void mainCase() {
  ll n, m, x;
  cin >> n >> m >> x;

  vector<ll> c(n, 0);
  vector<vector<ll>> a(n, vector<ll>(m, 0));
  FOR(i, 0, n) {
    cin >> c[i];
    FOR(j, 0, m) {
      cin >> a[i][j];
    }
  }

  // Brute force 2^n
  ll res = -1;
  FOR(b, 0, 1 << n) {
    ll cost = 0;
    FOR(i, 0, n) {
      cost += c[i] * ((b >> i) & 1);
    }

    vector<ll> zs(m, 0);
    FOR(j, 0, m) {
      FOR(i, 0, n) {
        zs[j] += ((b >> i) & 1) * a[i][j];
      }
    }
    // DD(tie(cost, zs));

    if (*min_element(ALL(zs)) >= x) {
      if (res == -1 || cost < res) {
        res = cost;
      }
    }
  }

  cout << res << endl;
}

int main() {
  mainCase();
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
using namespace std;
const long INF = 1e9;
const long MOD = 1e9 + 7;
#define repi(i, n, init) for (int i = init; i < int(n); i++)

int selectionSort(vector<int> &A)
{
    int m, cnt = 0;
    repi(i, A.size(), 0)
    {
        m = i;
        repi(j, A.size(), i + 1)
        {
            if (A[j] < A[m])
            {
                m = j;
            }
        }
        if (A[i] != A[m])
        {
            cnt++;
            swap(A[i], A[m]);
        }
    }
    return cnt;
}
int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    repi(i, n, 0)
    {
        cin >> A[i];
    }
    int cnt = selectionSort(A);
    repi(i, n, 0)
    {
        cout << A[i] << ((i + 1) % n ? " " : "");
    }
    cout << endl
         << cnt << endl;

    return 0;
}


Measured memory_bytes: 3104
s = input()
odd = {'R', 'U','D'}
even = {'L', 'U', 'D'}

for si in range(len(s)): 
    if (si+1) % 2 == 0 and s[si]=='R' or (si+1)%2==1 and s[si]=='L':
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 3060
import java.util.LinkedHashSet;
import java.util.Scanner;

public class Main {
	static double ans = 0;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		sc.close();

		permutation(x, y, new LinkedHashSet<>());
		for (int i = 2; i <= n; i++) {
			ans /= i;
		}
		System.out.println(ans);
	}

	static void permutation(int[] x, int[] y, LinkedHashSet<Integer> set) {
		if (set.size() == x.length) {
			Integer[] arr = set.toArray(new Integer[0]);
			for (int i = 1; i < arr.length; i++) {
				ans += Math.hypot(x[arr[i]] - x[arr[i - 1]], y[arr[i]] - y[arr[i - 1]]);
			}
			return;
		}

		for (int i = 0; i < x.length; i++) {
			if (!set.contains(i)) {
				set.add(i);
				permutation(x, y, set);
				set.remove(i);
			}
		}
	}
}


Measured memory_bytes: 35716
/* AOJ 0021 Parallelism */

#include <iostream>
#include <cmath>

using namespace std;

const double EPS = 1e-10;

int
main()
{
    int n;
    double x1, y1, x2, y2, x3, y3, x4, y4;

    cin >> n;

    while (n--) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

        if (fabs((x2 - x1) * (y4 - y3) - (x4 - x3) * (y2 - y1)) < EPS)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }

    return 0;
}

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

struct UnionFind
{
    vector<int> p;

    UnionFind(int n)
    {
        p = vector<int>(n, -1);
    }

    int root(int c)
    {
        if (p.at(c) < 0)
            return c;
        else
            return p.at(c) = root(p.at(c));
    }

    void unite(int a, int b)
    {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb)
            return;
        if (p.at(ra) > p.at(rb))
            swap(p.at(ra), p.at(rb));
        p.at(ra) += p.at(rb);
        p.at(rb) = ra;
    }

    int size(int c)
    {
        return -p.at(root(c));
    }
};

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

    UnionFind fuf(n);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        fuf.unite(a - 1, b - 1);
    }

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans = max(ans, fuf.size(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4460
n = int(input())


if n % 2 == 0:
    ans = int(n/2)
    n -= 1
    while n > 0:
        ans += int(n/2)
        n -= 1
else :
    ans = 0
    while n > 0:
        ans += int(n/2)
        n -= 1

print(ans)

Measured memory_bytes: 3060
##C
X = int(input())
##素数かどうか判定
from math import sqrt
def is_prime(n):
    for i in range(2, int(sqrt(n))):
        if n % i == 0:
            return False
    else:
        return True

while (not is_prime(X)):
    X += 1

print(X)


Measured memory_bytes: 2940
from statistics import mean 
import math
n=int(input())
arr=[int(x) for x in input().split()]
a=math.ceil(mean(arr))
b=math.floor(mean(arr))
s1=0
s2=0
for x in arr:
    s1=s1+((x-a)**2)
    s2=s2+((x-b)**2)
print(min(s1,s2))


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N,M,L;
const int MAX_N = 100,MAX_L = 1000;
int dist [MAX_N] [MAX_N];
int P [MAX_L],T [MAX_L];
bool edge [MAX_L] [MAX_L];
int matching [MAX_L];
bool vis [MAX_L];
const int INF = 1e9;

bool dfs(int curr)
{
	vis [curr] = true;
	FOR(i,0,L) if(edge [curr] [i]){
		int nxt = matching [i];
		if(nxt == -1 || (vis [nxt] == false && dfs(nxt))){
			matching [i] = curr;
			return true;
		}
	}
	return false;
}

int main()
{
	while(scanf("%d%d%d",&N,&M,&L),N + M + L){
		fill(dist [0],dist [MAX_N],INF);
		memset(edge,0,sizeof(edge));
		FOR(i,0,M){
			int u,v,c;
			scanf("%d%d%d",&u,&v,&c);
			chmin(dist [u] [v],c);
			chmin(dist [v] [u],c);
		}
		FOR(i,0,L){
			scanf("%d%d",&P [i],&T [i]);
		}
		FOR(i,0,N) dist [i] [i] = 0;
		FOR(k,0,N) FOR(i,0,N) FOR(j,0,N) chmin(dist [i] [j],dist [i] [k] + dist [k] [j]);

		FOR(i,0,L) FOR(j,0,L) if(j != i && T [i] <= T [j] && dist [P [i]] [P [j]] <= T [j] - T [i]){
			edge [i] [j] = true;
		}

		int ans = L;
		memset(matching,-1,sizeof(matching));
		FOR(i,0,L){
			memset(vis,0,sizeof(vis));
			ans -= dfs(i);
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 4256
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
#define INF 1000000009
int matrix[MAX][3];
int n;
int main()
{
    cin >> n;
    vector<int> dp(3);
    // dp[i] - total cost that we did ith activity in the day we are considering
    for(int day = 0;day<n;++day)
    {   vector<int> new_dp(3,0);
        vector<int> c(3);
        for(int i=0;i<3;i++)
        cin >> c[i];

        for(int i=0;i<3;i++)
        {
            for(int j=0;j<3;j++)
            {
                if(i!=j)
                new_dp[j] = max(new_dp[j],dp[i]+c[j]);
            }
            
        }
        dp = new_dp;
    } 

    cout << max(dp[0],max(dp[1],dp[2]));   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   cin>>n;
   int arr[n];
   for(int i=0;i<n;i++) cin>>arr[i];
   int dp[n+1];
   fill(dp,dp+n,0);
   dp[2]=abs(arr[1]-arr[0]);
   for(int i=3;i<=n;i++)
   {
      dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i-2]),dp[i-2]+abs(arr[i-1]-arr[i-3]));
   }
   cout<<dp[n]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
#define ll  long long 
  vector<ll>to[1000005];
int main(){
  ll a;cin>>a;
  vector<ll>b(a);
  vector<ll>c(a);
  rep(i,a)cin>>b[i];
  c=b;
  sort(b.begin(),b.end());
  rep(i,a){
    if(c[i]==b[a-1])cout<<b[a-2]<<endl;
    else cout<<b[a-1]<<endl;
  }
}


Measured memory_bytes: 28160
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    if(a <= b){
        for(int i = 0; i < b; i++){
            cout << a;
        }
    } else {
        for(int i = 0; i < a; i++){
            cout << b;
        }
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
num = list(map(int,input().split()))
s = input()
cnt=0
for i in range(len(s)):
	if(s[i] == "-"):
		cnt+=1
if(cnt > 1):
	print("No")
	exit()
if((len(s) == num[0]+num[1]+1) and (s[num[0]] == "-")):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int MOD = 1e9+7;
const int N = 5*1e5;



int main(){
    AC
    string s;
    cin>>s;
    if(s=="ABC")
        cout<<"ARC"<<endl;
    else
        cout<<"ABC"<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

string s[50];
int t[50];

int main() {
  int n;
  while(cin>>n) {
    REP(i,n) {
      cin >> s[i] >> t[i];
    }
    string x;
    cin >> x;
    int f = 0;
    int ans = 0;
    REP(i,n) {
      if (f) ans += t[i];
      if (s[i] == x) f = 1;
    }
    cout << ans << endl;
  }
}


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


def main():
    import sys
    input = sys.stdin.readline

    x = int(input())

    if x >= 1800:
        print('1')
    elif x >= 1600:
        print('2')
    elif x >= 1400:
        print('3')
    elif x >= 1200:
        print('4')
    elif x >= 1000:
        print('5')
    elif x >= 800:
        print('6')
    elif x >= 600:
        print('7')
    elif x >= 400:
        print('8')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
#include <cstdio>
#include <algorithm>
using namespace std;
 
int A, B, X;
 
int main()
{
	scanf("%d%d%d", &A, &B, &X);
 
	bool isok = X >= A && X <= A + B;
 
	if (isok) {
		puts("YES");
	} else {
		puts("NO");
	}
	return 0;
}

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

int main(){
  int x1, x2, x3, x4;
  int y1, y2, y3, y4;
  cin >> x1 >> y1 >> x2 >> y2;
  int x = x2-x1;
  int y = y2-y1;
  x3 = x2-y;
  y3 = y2+x;
  x4 = x1-y;
  y4 = y1+x;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   string s,t;
   cin>>s>>t;
   ll ans=t.length();
   ll temp=0;
   ll count=0;
   for(int i=0;i<=s.length()-t.length();i++)
   {
       for(int j=0;j<t.length();j++)
       {
           if(s[i+temp]!=t[j])
           count++;
           temp++;
       }
       ans=min(ans,count);
       count=0;
       temp=0;
       
   }
   cout<<ans<<"\n";
    
    
    
    return 0;
}

Measured memory_bytes: 3616
from bisect import*
n,d,a,*t=map(int,open(0).read().split())
c=[0]*-~n
z=sorted(zip(*[iter(t)]*2))
s=0
for i,(x,h)in enumerate(z):
    c[i]+=c[i-1]
    h-=c[i]
    t=0--max(0,h)//a
    c[i]+=t*a
    c[bisect(z,(x+d+d,10e9))]-=t*a
    s+=t
print(s)

Measured memory_bytes: 49236
n, m = map(int, input().split())

A = []
for i in range(n):
    A.append(list(map(int, input().split())))
b = []
for i in range(m):
    b.append(int(input()))

for i in range(n):
    sum = 0
    for j in range(m):
        sum += A[i][j] * b[j]
    print(sum)



Measured memory_bytes: 6016
#include<stdio.h>
int n,i,j;
long r=0,g=0,b=0,q;
char s[4001];
int main(){
    scanf("%d%s",&n,s);
    for(i=0;i<n;i++)s[i]=='R'?r++:s[i]=='G'?g++:b++;
    q=r*g*b;
    for(i=0;i<n;i++){
        for(j=1;i+2*j<n;j++){
            if(s[i]!=s[i+j]&&s[i]!=s[i+2*j]&&s[i+2*j]!=s[i+j])q--;
        }
    }
    printf("%ld",q);
    return 0;
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

struct Combination{
  const int MOD = 1e9+7;

  vector<int> fact; //　fact[i] = iの階乗
  void init(int n){
    fact.resize(n+1);
    fact[0] = fact[1] = 1;
    for(int i = 2; i <= n; i++){
      fact[i] = i * fact[i-1] % MOD;
    }
  }

  int nCr(int n, int r){ // nCr = n!/r!(n-r)!
    if(n < r) return 0;
    return fact[n] * mod_pow(fact[r]*fact[n-r]%MOD, MOD-2) % MOD;
  }

  int mod_pow(int n, int p){ // a/n ≡ a*n^(p-2) nとpは互いに素
    int r = 1;
    for(; p > 0; p >>= 1){
      if(p & 1LL) r = (r * n) % MOD;
      n = (n * n) % MOD;
    }
    return r; // r = n^p % MOD
  }

}comb;

signed main(){

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

  comb.init(200001);
  vector<int> cnt(200001, 0);
  for(int i = 0; i < n; i++){
    cnt[a[i]]++;
  }
  int sum = 0;
  for(int p : cnt){
    //sum += comb.nCr(p, 2);
    sum += p * (p-1) / 2;
  }

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

  return 0;
}


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

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

    int count = 0;
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    for (int i = 0; i < n; i++) if(v[i] >= k) count++;

    cout << count << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

int main(void){
    int n,m,t;
    cin>>n>>m>>t;
    vi d(t,1);
    rep(i,n){
        int p;cin>>p;
        fill(d.begin()+(int)max(p-m,0),d.begin()+(int)min(p+m,t),0);
    }
    cout<<accumulate(all(d),0)<<endl;
}

Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e17;
const int BIG = 1000000007;




int main() {

	int N;
	cin >> N;
	int A[300000];
	int B[300000];
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		B[i] = A[i];
	}
	sort(B + 1, B + N + 1);

	for (int i = 1; i <= N; i++) {
		if (B[N] == A[i]) { cout << B[N - 1]<<endl; }
		else { cout << B[N] << endl; }
	}

	system("PAUSE");

}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(ll (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(ll (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
const ll maxn=5e5+5;
ll n,l,t;
ll x[maxn],cnt[maxn][2],w[maxn],ans[maxn];
ll calc(ll L,ll c){
	ll res=(L/l)*cnt[n][c];
	L%=l;
	ll i=lower_bound(x+1,x+n+1,L)-x;
	if(x[i]>L)i--;
	return (res+cnt[i][c])%n;
}
int main(){
	read(n);read(l);read(t);
	rep(i,1,n){
		read(x[i]);
		read(w[i]);
		w[i]--;
		cnt[i][w[i]]=cnt[i-1][w[i]]+1;
		cnt[i][!w[i]]=cnt[i-1][!w[i]];
	}
	x[n+1]=1e9+19;
	rep(i,1,n)if(!w[i]){
		ll cnt=calc(x[i]+2*t,1)-calc(x[i],1);
		ans[(i+cnt-1)%n+1]=(x[i]+t)%l;
	}
	rep(i,1,n)if(w[i]){
		ll ub=(2*t+l-1)/l*l;
		ll dlt=ub-2*t;
		ub--;
		ll cnt=calc(ub,0)-(calc(x[i]+dlt-1,0)-calc(x[i],0));
		ans[(i-cnt+n-1)%n+1]=((x[i]-t)%l+l)%l;
	}
	rep(i,1,n)printf("%lld\n",ans[i]);
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	rep(i, n) {
		s[i] = 'x';
	}
	rep(i, n) {
		cout << s[i];
	}

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  if (n % 10 == 3) cout << "bon" << endl;
  else if (n % 10 == 0) cout << "pon" << endl;
  else if (n % 10 == 1) cout << "pon" << endl;
  else if (n % 10 == 6) cout << "pon" << endl;
  else if (n % 10 == 8) cout << "pon" << endl;
  else cout << "hon" << endl;
}

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

using namespace std;

void func_A(){
    
    int x;
    for (int i = 1; i <= 5; ++i) {
        cin >> x;
        if (x == 0) {
            cout << i;
            return;
        }
    }

}

void func_B() {

    int x, y, turu, kame;
    cin >> x >> y;

    turu = (4 * x - y);
    if (turu % 2 == 1 || turu < 0) {
        cout << "No";
        return;
    }

    kame = (y - 2 * x);
    if (kame % 2 == 1 || kame < 0) {
        cout << "No";
        return;
    }
    cout << "Yes";
}

void func_C() {

    int x, n;
    cin >> x >> n;
    if (n == 0) {
        cout << x;
        return;;
    }
    vector<int> p(n);

    for (int i = 0; i < n; ++i) {
        int temp;
        cin >> temp;
        p[i] = temp - x;
        //cout << p[i] << " ";
    }

    for (int i = 0; i <= 99; ++i) {
        int judge = 0;
        int temp = -1 * i;
       
        for (int j = 0; j < n; ++j) {
            if (p[j] == temp) judge = 1;
        }
        if (judge == 0) {
            cout << x + temp;
            return;
        }

        judge = 0;
        temp *= -1;

        for (int j = 0; j < n; ++j) {
            if (p[j] == temp) judge = 1;
        }
        if (judge == 0) {
            cout << x + temp;
            return;
        }


    }

}

int main()
{

    //func_A();
    //func_B();
    func_C();

    return 0;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
  public static void main(String... args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();

    int[] A = new int[N+1];
    for(int i=1; i<=N; i++) {
      A[scan.nextInt()] = i;
    }
    
    for(int i=1; i<=N; i++) {
      System.out.print(A[i]+" ");
    }
  }
}


Measured memory_bytes: 65680
import sys
from collections import Counter

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit("i8(i8[:],i8[:])")
def solve(keys, values):
    MAX_A = 10 ** 6
    divisible = [False] * (MAX_A + 1)
    ans = 0
    for k, v in zip(keys, values):
        if v == 1 and not divisible[k]:
            ans += 1
        for i in range(k, MAX_A + 1, k):
            divisible[i] = True
    return ans


def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    c = Counter(A)
    keys = np.array(tuple(c.keys()), dtype=np.int64)
    values = np.array(tuple(c.values()), dtype=np.int64)

    ans = solve(keys, values)
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

int n, q;
vector<int> A(n);

bool solve( const int p, int t )
{
	if( 0 == t ) { return true; }
	if( p < n ) {
		return solve( p+1, t - A.at( p ) ) | solve( p+1, t );
	} else {
		return false;
	}
}

int main()
{
	ios::sync_with_stdio( false );
	cin>>n;
	int num;
	for( int i=0; i<n; i++ ) {
		cin>>num;
		A.push_back( num );
	}
	cin>>q;
	for( int i=0; i<q; i++ ) {
		cin>>num;
		if( solve( 0, num ) ) {
			cout<<"yes"<<'\n';			
		} else {
			cout<<"no"<<'\n';
		}
	}
	
    return 0;
}	
	

Measured memory_bytes: 1200
<?php
 	fscanf(STDIN, "%s", $S);
 	fscanf(STDIN, "%s", $T);

	$pred = str_split($S);
	$act = str_split($T);

	$count = 0;
	for ($i = 0; $i < 3; $i++) {
      
      if ($pred[$i] === $act[$i]) {
        $count++;
      }
    }
	echo ($count);
?>

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

int main(){
	int n;
	cin>>n;
	int a[n];
	rep(i,n) cin>>a[i];
	
	int cnt=0;
	bool flag=true;
	while(flag){
		rep(i,n){
			if(a[i]%2==0) a[i]/=2; 
			else flag=false;
		}
		if(flag==false) break;
		cnt++;
	}
	cout << cnt << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, L;
    cin >> N >> L;
    vector<string> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    for(int i = 0; i < N; i++){
        cout << A.at(i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i < (int)n; i++)
#define Loopr(i, n) for(int i= (int)n - 1; i >= 0; i--)
using namespace std;
typedef long long int ll;


struct node {
	int key;
	node *left, *right;
};

node* NIL = (node*)malloc(sizeof(node));
node* root;
int k;

void insert(node** focus) {
	if (*focus == NIL) {
		node* buf = (node*)malloc(sizeof(node));
		buf->key = k;
		buf->left = NIL;
		buf->right = NIL;
		*focus = buf;
	}
	else if (k < (*focus)->key) insert(&((*focus)->left));
	else insert(&((*focus)->right));
}
void print_in(node* focus) {
	if (focus == NIL) return;
	print_in(focus->left);
	printf(" %d", focus->key);
	print_in(focus->right);
}

void print_pre(node* focus) {
	if (focus == NIL) return;
	printf(" %d", focus->key);
	print_pre(focus->left);
	print_pre(focus->right);
}

void print() {
	print_in(root);
	printf("\n");
	print_pre(root);
	printf("\n");
}

int main() {
	int m;
	root = NIL;
	cin >> m;
	char query[10];
	Loop(i, m) {
		scanf("%s", query);
		if (query[0] == 'i') {
			scanf("%d", &k);
			insert(&root);
		}
		else print();
	}
	return 0;
}

Measured memory_bytes: 18836
S = input()
n = len(S)
char = ['A','C','G','T']

mx = 0
for i in range(n):
	for j in range(i,n):
		part = S[i:j+1]
		if all(c in char for c in part) and mx<len(part):
			mx = len(part)

print(mx)

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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

    if(s == "AAA"){
    cout << "No" << endl;
    }

    else if(s == "BBB"){
    cout << "No" << endl;
    }

    else{
        cout << "Yes" << endl;
    }


}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

LL dist = 0;

vector<LL> f(vector<vector<LL>>& graph,vector<bool>& toutatu,LL idx){
  toutatu[idx] = false;
  vector<LL> res;
  res.push_back(0);
  REP(i, graph[idx].size())
  {
    if(toutatu[graph[idx][i]]){
      vector<LL> a = f(graph, toutatu, graph[idx][i]);
      LL max = 0;
      REP(j, a.size())
      {
        if(a[j]>max){
          max = a[j];
        }
      }
      res.push_back(max+1);
    }
  }
  if(res.size()>=3){
    BACKSORT(res);
    LL a = res[0] + res[1] + 1;
    if(a>dist){
      dist = a;
    }
  }
  return res;
}

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

  LL N;
  cin >> N;

  vector<vector<LL>> graph(N, vector<LL>(0));

  REP(i,N-1){
    LL a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  if(N==1||N==3){
    cout << "First" << endl;
  }else
  if(N==2){
    cout << "Second" << endl;
  }else{
    LL idx = 0;
    if(graph[idx].size()==1){
      idx = graph[idx][0];
    }

    vector<bool> toutatu(N, true);
    vector<LL> a = f(graph, toutatu, idx);
    BACKSORT(a);
    if(dist%3==2){
      cout << "Second" << endl;
    }else{
      cout << "First" << endl;
    }
  }
}


Measured memory_bytes: 35200
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = [[0]*10 for _ in range(10)]

for i in range(1, N+1):
    s = str(i)
    first = int(s[0])
    end = int(s[-1])
    As[first][end] += 1

ans = 0
for i in range(10):
    for j in range(10):
        a = As[i][j]
        b = As[j][i]
        ans += a*b

print(ans)

Measured memory_bytes: 67940
/************************************/
//
//???????????´??° x ?????????????????§???x ?????????????¨????????????????????????????????????°??????
//
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_B&lang=jp
/************************************/

#include<stdio.h>

#define MIN 1
#define MAX 100

int main()
{
	int x=0;
	
	scanf("%d", &x);
	
	/* ??¶?´? */
	if(x>=MIN && x<=MAX)
	{
		printf("%d\n", x*x*x);
	}
	else
	{
		/* ERROR */
		return -1;
	}
	
	return 0;
}

Measured memory_bytes: 1800
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if((a*100+b*10+c)%4)
		cout<<"NO"<<endl;
	else
		cout<<"YES"<<endl;
}

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

int cmp(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a > b ? -1 : a < b;
}

int N, M, C;
int l[114514];

int ballNums[114514];
int* balls[114514];

int asumisu;
int mizuhasu[114514];

int main(void) {
	int i;
	int answer = 0;
	if (scanf("%d%d%d", &N, &M, &C) != 3) return 1;
	for (i = 1; i <= C; i++) {
		if (scanf("%d" ,&l[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		int c, w;
		int* newBalls;
		if (scanf("%d%d", &c, &w) != 2) return 1;
		newBalls = realloc(balls[c], sizeof(*balls[c]) * (ballNums[c] + 1));
		if (newBalls == NULL) return 2;
		newBalls[ballNums[c]++] = w;
		balls[c] = newBalls;
	}
	for (i = 1; i <= C; i++) {
		if (ballNums[i] > 0) {
			int j;
			qsort(balls[i], ballNums[i], sizeof(*balls[i]), cmp);
			for (j = 0; j < ballNums[i] && j < l[i]; j++) {
				mizuhasu[asumisu++] = balls[i][j];
			}
		}
	}
	qsort(mizuhasu, asumisu, sizeof(*mizuhasu), cmp);
	for (i = 0; i < M && i < asumisu; i++) {
		answer += mizuhasu[i];
	}
	printf("%d\n", answer);
	return 0;
}



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

void print_vec(vector<int> vec) {
    cout << "{";
    for(auto s: vec) cout << s << " ";
    cout << "}" << endl;
}

int main() {
    int N;cin >> N;
    vector<ll> H(N);
    vector<int> K;
    int kaisu = 0;
    rep(i,N) cin >> H.at(i);
    rep(i,N-1) {
        if(H.at(i) >= H.at(i+1))
            kaisu++;
        else {
            K.push_back(kaisu);
            kaisu = 0;
        }
    }
    K.push_back(kaisu);
    //print_vec(K);
    int ans = K.at(0);
    for(auto k: K)
        if(k > ans) ans = k;

    cout << ans << endl;
}

Measured memory_bytes: 1660
#include<iostream>
    using namespace std;
    int main(){
        int len;
        string s;
        cin>>len>>s;
        long long s1=0,s2=0,s3=0,sum=0;
        for(int i=0;i<len;i++){
            if(s[i]=='R') s1++;
            if(s[i]=='G') s2++;
            if(s[i]=='B') s3++;
        }
        sum=s1*s2*s3;
        for(int i=0;i<len;i++){
            for(int j=i;j<len;j+=2){
                if(s[i]!=s[j] && s[i]!=s[(i+j)/2] && s[j]!=s[(i+j)/2]) sum--;
            }
        }
        cout<<sum;
        return 0;
    }

Measured memory_bytes: 3636
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		byte[] aa = sc.next().getBytes();
		byte[] bb = sc.next().getBytes();
		int n = aa.length;
		int m = bb.length;
		int[] pp = new int[n + 1];
		int[] qq = new int[m + 1];
		for (int i = 0; i < n; i++)
			pp[i + 1] = pp[i] + aa[i] - 'A' + 1;
		for (int j = 0; j < m; j++)
			qq[j + 1] = qq[j] + bb[j] - 'A' + 1;
		int q = sc.nextInt();
		while (q-- > 0) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();
			println(((pp[b] - pp[a - 1]) - (qq[d] - qq[c - 1])) % 3 == 0 ? "YES" : "NO");
		}
	}
}


Measured memory_bytes: 71144
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

struct modint{
	int v = 0;
	int operator=(const int& rhs){
		v = rhs;
		return v;
	}
	bool operator==(const modint& rhs){
		return (v == rhs.v);
	}
	modint operator+(const modint &rhs){
		modint ret;
		ret.v = v + rhs.v;
		ret.v = (ret.v<MOD)?ret.v:(ret.v-MOD);
		return ret;
	}
	void operator+=(const modint &rhs){
		v += rhs.v;
		v = (v<MOD)?v:(v-MOD);
	}
	modint operator-(const modint &rhs){
		modint ret;
		ret.v = v - rhs.v;
		ret.v = (ret.v<0)?(ret.v+MOD):ret.v;
		ret.v = (ret.v<MOD)?ret.v:(ret.v-MOD);
		return ret;
	}
	void operator-=(const int &rhs){
		v -= rhs;
		v = (v<0)?v+MOD:v;
		v = (v<MOD)?v:(v-MOD);
	}
	void operator-=(const modint &rhs){
		v -= rhs.v;
		v = (v<0)?v+MOD:v;
		v = (v<MOD)?v:(v-MOD);
	}
	modint operator*(const modint &rhs){
		ll tmp = 1ll;
		modint ret;
		tmp *= v;
		tmp *= rhs.v;
		tmp %= MOD;
		ret.v = tmp;
		return ret;
	}
	void operator*=(const modint &rhs){
		ll tmp = 1ll;
		tmp *= v;
		tmp *= rhs.v;
		tmp %= MOD;
		v = tmp;
	}
	modint operator/(const modint &rhs){
		modint ret;
		ll t=1ll,a,p = MOD-2;
		a = rhs.v;
		while(p){
			if(p%2){
				t *= a;
				t %= MOD;
			}
			a *= a;
			a %= MOD;
			p /= 2;
		}
		t *= v;
		t %= MOD;
		ret.v = t;
		return ret;
	}
	void operator/=(const modint &rhs){
		ll t=1ll,a,p = MOD-2;
		a = rhs.v;
		while(p){
			if(p%2){
				t *= a;
				t %= MOD;
			}
			a *= a;
			a %= MOD;
			p /= 2;
		}
		t *= v;
		t %= MOD;
		v = t;
	}
	bool operator<(const modint &rhs){
		return (v<rhs.v);
	}
	bool operator<=(const modint &rhs){
		return (v<=rhs.v);
	}
	void operator ++() {
		v += 1;
		v = (v<MOD)?v:(v-MOD);
	}
};

ostream& operator <<(ostream& o, const modint &rhs){
	o << rhs.v;
	return o;
}

istream& operator >>(istream& o, modint& rhs){
	o >> rhs.v;
	return o;
}

int main(void){
	modint i,n,m,k,ans,t;
	cin >> n.v >> m.v >> k.v;
	t = n*m;
	for(i=1; i<n; ++i){
		ans += (i)*(n-i)*m*m;
	}
	for(i=1; i<m; ++i){
		ans += (i)*(m-i)*n*n;
	}
	k -= 2; t -= 1;
	for(i=1; i<=k; ++i){
		ans *= (t-i);
		ans /= i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        
        int wari = N % K;
        
        if(wari == 0){
            System.out.println(0); 
        }else {
            System.out.println(1);
        }
    }
}

Measured memory_bytes: 21332