akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.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++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;

int main()
{
    int R, C, K;
    cin >> R >> C >> K;
    vector<vector<ll>> item(R + 5, vector<ll>(C + 5, 0));
    rep(i, K)
    {
        int r, c;
        ll v;
        cin >> r >> c >> v;
        r--, c--;
        item[r][c] = v;
    }

    vector<vector<vector<ll>>> dp(R + 5, vector<vector<ll>>(C + 5, vector<ll>(4, 0)));
    dp[0][0][1] = item[0][0];

    for (int row = 0; row < R; row++) {
        for (int col = 0; col < C; col++) {
            for (int num = 0; num < 4; num++) {
                dp[row][col + 1][num] = max(dp[row][col + 1][num], dp[row][col][num]);
                if (num < 3) {
                    dp[row][col + 1][num + 1] = max(dp[row][col + 1][num + 1], dp[row][col][num] + item[row][col + 1]);
                }
            }
            for (int num = 0; num < 4; num++) {
                dp[row + 1][col][0] = max(dp[row + 1][col][0], dp[row][col][num]);
                dp[row + 1][col][1] = max(dp[row + 1][col][1], dp[row][col][num] + item[row + 1][col]);
            }
        }
    }
    ll ans = 0;
    for (int num = 0; num < 4; num++) {
        ans = max(ans, dp[R - 1][C - 1][num]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 709044
S = input()
count = 0
mcount = 0
for i in range (len(S)):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        count = count +1
        mcount = max(mcount,count)
    else:
        count = 0
print(mcount)

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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << min(a, k) - max(0, k-a-b);
    return 0;
}


Measured memory_bytes: 3652
//Krunal_Mathukiya
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define li long int
#define pb push_back
#define mkp make_pair
#define nikalL return
#define umap unordered_map
#define fr(i,s,n) for(int i=s;i<=n;++i)
#define frr(i,s,n) for(int i=s;i>=n;--i)
#define jaldiKarNe ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
int arr[100007];
int dp[100007];
int vis[100007];
int n,k;
lli fn(int i) {
	if (i >= n) return 0;
	if(vis[i]) return dp[i];
	vis[i]=1;
	lli ans=10000000000;
	fr(j,i+1,min(n,i+k)) {
		lli tmp=abs(arr[i]-arr[j])+fn(j);
		ans=min(ans,tmp);
	}
	return dp[i]=ans;
}
void TestingChaluKarEyy() {
	cin >> n>>k;
	fr(i, 1, n) cin >> arr[i],vis[i]=0;
	cout << fn(1);
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	jaldiKarNe;
	int TestingKaravvuChhe = 1;
	// cin >> TestingKaravvuChhe;
	while (TestingKaravvuChhe--) {
		TestingChaluKarEyy();
	}
}


Measured memory_bytes: 10992
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]

sort_s = []
for s in S:
    sort_s.append(''.join(sorted(s)))

count = dict(Counter(sort_s))

ans = 0
for i in count.values():
    ans += i*(i-1)/2

print(int(ans))


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

int main() {
    int n, m; cin >> n >> m;
    int r = n;
    int l = 0;
    for(int i = 0; i < m; i ++) {
        int x,y; cin >> x >> y;
        l = max(l,x);
        r = min(r,y);
    }
    cout << (r-l>=0 ? r-l+1 : 0) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main() {
  long long n;
  int x;
  scanf("%lld",&n);
  x=log10(n);
  if (n==(long long)(n/pow(10,x)+1)*pow(10,x)-1) {
    printf("%lld\n",(long long)(n/pow(10,x))+9*x);
  } else {
    printf("%lld\n",(long long)(n/pow(10,x))+9*x-1);
  }
  return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (s.length() <= k) {
        cout << s << endl;
    } else {
        cout << s.substr(0, k) + "..." << endl;
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebug(multimap<T1, T2> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mdebugr(map<T1, T2, greater<T1>> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebugr(multimap<T1, T2, greater<T1>> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll n, m, a[100010], asum[100010];
    cin >> n >> m;
    rep(i, n){
        cin >> a[i];
    }

    asum[0] = 0;
    reps(i, 0, n-1){
        asum[i+1] = asum[i] + a[i];
    }

    map<ll, ll> restmap;
    reps(i, 0, n){
        ll rest = asum[i]%m;
        restmap[rest]++;
    }

    //adebug(asum, n);
    //mdebug(restmap);

    ll res = 0;
    for(auto const& r : restmap){
        ll num = r.second;
        res += num*(num-1)/2;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <type_traits>
//#include <bits/stdc++.h>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// print(x, y, z);
// printVec(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << std::distance(begin, it) << "] " << *it << " ";
    if (std::distance(begin, it) % 20 == 19) { std::cout << std::endl; }
  }
  std::cout << std::endl;
}

template<typename T> T bitnum(T x)
{
  T cnt = 1;
  T ret = 0;
  while (x > 0) {
    ret += (x % 2) * cnt;
    x /= 2;
    cnt *= 10;
  }
  return ret;
}

template<typename T> T lminimum(const std::vector< T >& v) {return *std::min_element(v.begin(), v.end());}
template<typename T> T lmaximum(const std::vector< T >& v) {return *std::max_element(v.begin(), v.end());}
template<typename T> void lunique(std::vector< T >& v) {v.erase(std::unique(v.begin(), v.end()), v.end());}
template<typename T> void lsort(std::vector< T >& v) {std::sort(v.begin(), v.end());}
template<typename T> void lgreatersort(std::vector< T >& v) {std::sort(v.begin(), v.end(), std::greater<>());}
template<typename T> bool lnext_permutation(std::vector< T >& v) {return std::next_permutation(v.begin(), v.end());}

ll dp[101][76];

int main(int argc, char* argv[])
{
  ll N;
  std::cin >> N;

  std::vector< ll > ve(N+1, 0LL);

  for (ll i = 2; i <= N; i++) {
    ll cur = i;
    for (ll j = 2; j <= i; j++) {
      while (cur % j == 0) {
	cur /= j;
	ve[j]++;
      }
    }
  }

  //printVec(ve.begin(), ve.end());

  // dp[i][j] iまで調べた時の 約数の個数が j である組み合わせ
  std::fill(dp[1], dp[1] + 76, 0LL);
  dp[1][1] = 1;
  for (ll i = 2; i <= N; i++) {
    for (ll j = 1; j <= 75; j++) {
      for (ll k = 0; k <= ve[i]; k++) {
	if (j * (k+1) <= 75) {
	  dp[i][j * (k+1)] += dp[i-1][j];
	}
      }
    }
  }

  print(dp[N][75]);
  return 0;
}


Measured memory_bytes: 256
import math
def Is_Prime(N):
    if N==1:
        return False
    for K in range(2,int(math.sqrt(N))+1):
        if N%K==0:
            return False
    return True

X = int(input())
Flag = True
while Flag:
    if Is_Prime(X):
        Flag = False
    else:
        X += 1
print(X)

Measured memory_bytes: 9180
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pr;

int main()
{
	int N,sum =0,mx = 0;
	vector<int> s;
	cin >> N;
	s.resize(N);

	for (int i = 0; i < N; i++) {
		cin >> s[i];
		sum += s[i];
	}

	sort(s.begin(),s.end());
	if (sum % 10 != 0) {
		mx = sum;
	}
	else {
		for (int i = 0; i < N; i++) {
			if ((sum - s[i]) % 10 != 0) {
				mx = sum - s[i];
				break;
			}
		}
	}
	cout << mx << endl;
return	0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <climits>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
#define FOR(var,start,end) for(int var=start; var<end; var++)
#define REP(var,cnt) FOR(var,0,cnt)

pair<int, int> pd[10010];

int main(void) {
	while(true) {
		int N, M;
		cin >> N >> M;
		if ( N==0 ) { break; }
		
		
		REP(i, N) {
			int D, P;
			cin >> D >> P;
			pd[i] = make_pair(P,D);
		}
		sort(pd, pd+N);
		reverse(pd, pd+N);
		
		int ret = 0;
		REP(i, N) {
			if ( M > 0 ) {
				M -= pd[i].second;
				if ( M < 0 ) {
					ret += -M * pd[i].first;
				}
			} else {
				ret += pd[i].first*pd[i].second;
			}
		}
		
		cout << ret <<endl;
	}
}

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  s << p.first << " " << p.second << "\n"; return s;
}

// cout vector<pair>
template<typename T1, typename T2> ostream& operator<<(ostream& s, const vector<pair<T1, T2> >& vp) {
  int len = vp.size(); s << "\n";
  for (int i = 0; i < len; ++i) { s << vp[i]; }
    s << "\n"; return s;
}

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  int h, w;
  scanf("%d %d", &h, &w);
  vector<vector<char> > a(h, vector<char>(w));
  vi cnt(26, 0);
  rep (i, h) {
    char c;
    rep (j, w) {
      scanf(" %c", &c);
      cnt[c - 'a'] += 1;
    }
  }
  int num1, num2, num4;
  num1 = num2 = num4 = 0;
  rep (i, 26) {
    int atmp = cnt[i];
    num4 += (atmp / 4);
    atmp %= 4;
    num2 += (atmp / 2);
    atmp %= 2;
    num1 += atmp;
  }
  int need4 = (h / 2) * (w / 2);
  int need2 = 0;
  if (h % 2 == 1) {
    need2 += (w / 2);
  }
  if (w % 2 == 1) {
    need2 += (h / 2);
  }
  if (num4 < need4) {
    printf("No\n");
    return 0;
  }
  num4 -= need4;
  num2 += (num4 * 2);
  if (num2 < need2) {
    printf("No\n");
    return 0;
  }
  printf("Yes\n");

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++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 iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

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

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

int sx,sy,tx,ty;

int main(){
	FAST;
	cin >> sx >> sy >> tx >> ty;

	const int dx=tx-sx;
	const int dy=ty-sy;

	cout << string(dy,'U') << string(dx,'R');

	cout << string(dy,'D') << string(dx,'L');

	cout << 'L' << string(dy+1, 'U') << string(dx+1, 'R') <<'D';

	cout << 'R' << string(dy+1,'D') << string(dx+1,'L') << 'U';

	cout << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		//Scanner????????????????????????
		Scanner scan = new Scanner(System.in);
		//??\??????????????????int??????
		int n = scan.nextInt();
		int[] ary = new int[n];

		//????????????????????????????´?
		for(int i = 0; i < n; i++){
			ary[i] = scan.nextInt();
			//System.out.println(i);
		}
		//??????(??????????????????????????????????????§??°?????????)
		for(int j = n-1; 0 <= j; j-- ){
			System.out.print(ary[j]);
			if(j != 0){
				System.out.print(" ");
			}else{
				System.out.println();
			}
		}
	}
}

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

int main() {
  long long x; cin >> x;
  long long cho = 100;
  for(long long i = 1; i < 3000000000; i++){
    cho = cho + (cho / 100);
   // cout << cho << endl;
    if(cho >= x){
      cout << i;
      return 0;
    }
  }
  cout << cho;
}

Measured memory_bytes: 3624
N, M = list(map(int, input().split(' ')))
MOD = int(1e9 + 7)
primes = []
if M % 2 == 0:
  primes.append(2)

seeds = []
p = 2
while M > 1:
  if p*p > M:
    seeds.append(M)
    M = 1
  while M % p == 0:
    seeds.append(p)
    M = M // p
  p += 1

def comb(n, k):
  ans = 1
  for i in range(1, k + 1):
    ans = (ans * (n + 1 - i) // i)
  return ans

ans = 1
hogehoge = set(seeds)
for i in hogehoge:
  a_ct = seeds.count(i)
  ans = (ans * comb(a_ct + N-1, min(a_ct, N-1))) % MOD
print(ans)



Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)


int main(){
    int n;
    while(cin>>n){
        int ans = 0;
        if(n%2==0){
            ans = 2;
            for(int i=1;i<n/2;i++)ans+=6*pow(3,(i-1));
        }
        else{
            ans = 1;
            for(int i=1;i<n/2+1;i++)ans+=4*pow(3,(i-1));
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3268
#include<stdio.h>
int main(void)
{
    long int n,i,sum = 0;
    scanf("%ld",&n);
    for(i = 1 ; i <= n ; i++)
    {
        if(i % 3 != 0 && i % 5 != 0)
        {
            sum += i;
        }
    }
    printf("%ld\n",sum);
    return 0 ;
}

Measured memory_bytes: 1712
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 line = "";

        while ((line = br.readLine()) != null && !line.isEmpty()) {
            char[] str = line.toCharArray();
            int u;
            char c;
            for (int i = 0; i < str.length / 2; i++) {
                u = str.length - 1 - i;
                c = str[i];
                str[i] = str[u];
                str[u] = c;
            }
            System.out.println(str);
        }
    }
}

Measured memory_bytes: 15024
#include<cstdio>

int main() {
	int a;
	scanf("%d", &a);
	printf("%d\n", a*a*a);
	/*
	#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

string c[1002];
int ruisekiwa[1000][1000];
int main() {
	int a, b;
	cin >> a >> b;
	for (int d = 0; d<a; d++) {
		cin >> c[d];
	}
	string f[2];
	cin >> f[0] >> f[1];
	int sum = 0;
	for (int g = 0; g<a - 1; g++) {
		for (int h = 0; h<b - 1; h++) {
			bool s[2][2]{}; int l = 0;
			for (int i = 0; i<2; i++) {
				for (int j = 0; j<2; j++) {
					if (c[g + i][h + j] == f[i][j]) { l++; s[i][j] = true; }
				}
			}
			if (l == 4) {
				sum++;
				for (int x = 0; x<2; x++) {
					for (int y = 0; y<2; y++) {
						ruisekiwa[g + x][h + y]--;
					}
				}
			}
			else if (l == 3) {
				for (int x = 0; x<2; x++) {
					for (int y = 0; y<2; y++) {
						if (!s[x][y])ruisekiwa[g + x][h + y]++;
					}
				}
			}
		}
	}
	int MAX = 0;
	for (int i = 0; i<a; i++) {
		for (int p = 0; p<b; p++) {
			MAX = max(MAX, ruisekiwa[i][p]);
		}
	}
	cout << sum + MAX << endl;
}

	*/
}

Measured memory_bytes: 2708
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string
#include <vector> // vector
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <cstdint> // int64_t, int_fast64_t

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

typedef std::int_fast64_t ll; // at least int64 > 9*10^18
typedef std::uint_fast64_t ull; // at least uint64

#define int ll

#define INF 10101010

struct FastIO
{
  FastIO() {
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(0); 
  }
}fastio;

signed main() {
  int n,m,q;
  std::cin >> n >> m >> q;
  std::vector<std::vector<int> > trains(n,std::vector<int>(n,0));
  rep(i,m) {
    int l,r;
    std::cin >> l >> r;
    l--;r--;
    trains[l][r]++;
  }
  rep(i,q) {
    int l,r;
    std::cin >> l >> r;
    if(l==1&&r==n) {
      std::cout << m << ENDL;
      continue;
    }
    l--;r--;
    int count = 0;
    for(int x=l;x<=r;x++) {
      for(int y=r;y>=x;y--) {
        count += trains[x][y];
      }
    }
    std::cout << count << ENDL;
  }
  return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>

int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a < b) {
		if (b < c) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 580
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int N;
int col[9] = { 0 };

signed main()
{
	cin >> N;
	REP(i, N)
	{
		int r;
		cin >> r;
		int c = r / 400;
		if (c >= 8) c = 8;
		col[c]++;
	}

	int cnt = 0;
	REP(i, 8)
	{
		if (col[i] > 0)
		{
			cnt++;
		}
	}

	if (cnt == 0 && col[8] > 0)
	{
		cout << "1 " << (cnt + col[8]) << endl;
	}
	else
	{
		cout << cnt << " " << (cnt + col[8]) << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n1 = sc.nextInt();
		int n2 = sc.nextInt();
		int n3 = sc.nextInt();
		int count =0;

		if(n1 == n2){
			count++;
		}
		if(n1 == n3){
			count++;
		}
		if(n2 == n3){
			count++;
		}
		if(count == 1){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

		}
}

Measured memory_bytes: 22228
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

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

	string s;
	cin>>s;
	set<char> ss;
	for(ll i=0;i<3;++i)
    {
        ss.insert(s[i]);
    }
    if(ss.size()==2){cout<<"Yes";}
    else{cout<<"No";}

	return(0);
}


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

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    int sum = r*100 + g*10 + b;
    if (sum % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
(defun solver ()
  (let ((a (read)) (b (read))
        (s (read-line)))
    (if (and (parse-integer s :start 0 :end a :junk-allowed t)
             (char= (char s a) #\-)
             (parse-integer s :start (+ a 1) :end (+ a b 1) :junk-allowed t))
        (format t "Yes~%")
        (format t "No~%"))))

(solver)

Measured memory_bytes: 12648
'use strict'
function main(input) {
  input = input.trim().split('\n')
  
  input = input
    .map((val, index) => {
      let fp = Number(val.slice(-1)) || 10
      return {
        index: index,
        val: Number(val),
        sort: fp,
        time: 10 - fp + Number(val)
      }
    })
    .sort((a, b) => a.sort < b.sort)
    .reduce((prev, current, index) => {
      let time = index !== input.length - 1 ? current.time : current.val
      return prev + time
    }, 0)
    
  console.log(input)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <stdio.h>

int main()
{

    int n, i, j, num[100], cnt = 0, tmp, min;
    int minj;

    scanf("%d", &n);

    for (i = 0; i < n; i++)
        scanf("%d", &num[i]);

    for (i = 0; i < n; i++)
    {
        minj = i;
        for (j = i; j < n; j++)
        {

            if (num[minj] > num[j])
            {
                minj = j;
            }
        }
        if (minj != i)
        {
            tmp = num[i];
            num[i] = num[minj];
            num[minj] = tmp;
            cnt++;
        }
    }

    for (i = 0; i < n; i++)
    {
        printf("%d", num[i]);
        if (i != n - 1)
            printf(" ");
    }
    printf("\n%d\n", cnt);

    return 0;
}



Measured memory_bytes: 2112
#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> E;
typedef long long LL;
int a[100000];
double dp[20][200001];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> a[i];
	for (int i = 0; i < N; i++) for (int j = 0; j <= 2 * a[i]; j++) dp[i][j] = 1e9;
	for (int i = 1; i <= 2 * a[0]; i++) {
		dp[0][i] = (double)abs(i - a[0]) / a[0];
	}
	for (int i = 0; i + 1 < N; i++) {
		for (int j = 1; j <= 2 * a[i]; j++) {
			for (int k = j; k <= 2 * a[i + 1]; k+=j) {
				dp[i + 1][k] = min(dp[i + 1][k], max(dp[i][j], (double)abs(k - a[i + 1]) / a[i + 1]));
			}
		}
	}
	double ans = 1e9;
	for (int i = 1; i <= 2 * a[N - 1]; i++) ans = min(ans, dp[N - 1][i]);
	printf("%.15lf\n", ans);
}


Measured memory_bytes: 17756
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc169_b
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();
            var s = 1L;
            for (int i = 0; i < N; i++)
            {
                if (A[i] == 0)
                {
                    s = 0;
                    break;
                }
                if (A[i] <= 1000000000000000000 / s) s *= A[i];
                else
                {
                    s = -1;
                    break;
                }
            }
            
            Console.WriteLine(s);
            Console.Read();
        }
    }
}


Measured memory_bytes: 43188
// https://atcoder.jp/contests/dp/tasks/dp_a

#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;


/* range: ± 3.27 * 10^4 */
using i16 = short int;
/* range: 0 to 65535 */
using u16 = short unsigned int;
/* range: ± 2.14 * 10^9 */
using i32 = int;
/* range: 0 to 4.29 * 10^9 */
using u32 = unsigned int;
/* range: ± 9.22 * 10^18 */
using i64 = long long int;
/* range: 0 to 1.84 * 10^19 */
using u64 = long long unsigned int;


int main() {
    i32 n = 0, k;
    cin >> n >> k;

    vector<i64> heights(n);
    for (auto& ht : heights) {
        cin >> ht;
    }

    vector<i64> dp(n, numeric_limits<i64>::max());
    dp[n - 1] = 0;
    for (auto i = n - 1; i > 0; i--) {
        for (i32 j = 1; j <= k && i - j >= 0; j++) {
            dp[i - j] =
                min(dp[i - j], dp[i] + abs(heights[i] - heights[i - j]));
        }
    }

    cout << dp[0] << '\n';
}

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

int main() {
	int N,x,d1=-1,d2=-1;
	ll K;
	set<int> s;
	s.insert(0);

	cin >> N >> K;
	vector<int> A(N),t(N,0);
	rep(i,N)
		cin >> A.at(i);

	rep(i,N-1) {
		t.at(i+1) = A.at(t.at(i))-1;
		if(s.count(t.at(i+1))) {
			x = t.at(i+1);
			break;
		}
		s.insert(t.at(i+1));
	}

	rep(i,N)
		if(t.at(i)==x)
			if(d1 == -1) {
				d1 = i;
			} else {
				d2 = i;
				break;
			}

	if(K <= d1)
		cout << t.at(K)+1 << endl;
	else
		cout << t.at(((K-d1)%(d2-d1))+d1)+1 << endl;
}

Measured memory_bytes: 14044
import math
# import numpy as np
# import queue
# import heapq


def main():
    print(solve())


def solve():
    A, B, N = map(int, input().split())

    x = min((B-1), N)
    v = math.floor(A * x / B)

    return v


if __name__ == "__main__":
    main()


Measured memory_bytes: 9160
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
const ll INF = 999999999999999;
const ll MOD = 998244353;
const ll MAX_N = 500010;
ll A, B, C, D, E, F, G, H, X, Y, Z, P, Q, M, N, T, R, K, W, L, ANS;
string S, S1, S2;
#include <cstdint>
template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

  public:
    u64 a;
    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept { return modint(*this) += rhs; }
    constexpr modint operator-(const modint rhs) const noexcept { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint rhs) const noexcept { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint rhs) const noexcept { return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if(a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if(a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while(exp) {
            if(exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};
using mint = modint<MOD>;
template <typename T> mint modpow(T x, ll n) {
    mint res = 1;
    mint a = x;
    while(n > 0) {
        if(n & 1)
            res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> K;
    vector<mint> KAIJO;
    KAIJO.pb(1);
    rep(i, 500000) { KAIJO.push_back(KAIJO.back() * (i + 1)); }
    mint AANS = 0;
    rep(i, K + 1) { AANS += modpow(M - 1, N - i - 1) * M * KAIJO[N - 1] / KAIJO[N - 1 - i] / KAIJO[i]; }

    cout << AANS.a << endl;
}

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

typedef struct{
    long long price;
    long long num;
} store;

int sort(const void *a, const void *b)
{
    store *A = (store *)a;
    store *B = (store *)b;
    return A->price - B->price;
}

int main(void)
{
    long long i, n, m, sum = 0;
    scanf("%lld%lld", &n, &m);
    store AB[n];

    for ( i = 0; i < n; i++)
        scanf("%lld%lld", &AB[i].price, &AB[i].num);

    qsort(AB, n, sizeof(AB[0]), sort);

    i = 0;
    while(m > 0){
        if(m <= AB[i].num){
            sum += m * AB[i].price;
            break;
        }else{
            m -= AB[i].num;
            sum += AB[i].price * AB[i].num;
        }
        i++;
    }
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 3324
import fractions
from functools import reduce

def gcd(*num):
    return reduce(fractions.gcd, num)

N, X = [int(x) for x in input().split()]
x_list = input().split()
x_list = list(map(int, x_list))
x_list = list(map(lambda x: abs(X - x), x_list))
print(gcd(*x_list))

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mods[] = {998244353, 1000000007, 1000000009};
const ll bases[] = {997, 1009, 1013};
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;


ll n,k;
vl p;
set<ll> s;
ll ans;
vl idx;

class union_find {
private:
  vl *par;
  vl *rnk;
  vl *siz;
public:
  union_find (ll n){
    par = new vl(n);
    iota(par->begin(),par->end(),0);
    rnk = new vl(n,0);
    siz = new vl(n,1);
  }
  ll find(ll x){
    if(par->at(x) == x) return x;
    else return par->at(x) = find(par->at(x));
  }
  ll size(ll x){
    return siz->at(find(x));
  }
  void unite(ll x,ll y){
    x = find(x);y = find(y);
    if(x == y)return;
    if(rnk->at(x) < rnk->at(y)){
      par->at(x) = y;
      siz->at(y) += siz->at(x);
    }
    else {
      par->at(y) = x;
      siz->at(x) += siz->at(y);
      if(rnk->at(x) == rnk->at(y)) rnk->at(x)++;
    }
  }
  bool same(ll x,ll y){
    return find(x) == find(y);
  }
};

union_find uf(0);
set<ll> m;

int main(){
  cin >> n >> k;
  p = vl(n);
  for(ll i = 0;i < n;i++) cin >> p[i];
  for(ll i = 0;i < k;i++) s.insert(p[i]);
  ans = 1;
  for(ll i = k;i < n;i++){
    if(p[i] > *(s.rbegin()) && p[i-k] == *(s.begin())){

    }else{
      ans++;
    }
    s.erase(p[i-k]);
    s.insert(p[i]);
  }
  uf = union_find(n);
  for(ll i = 1;i < n;i++){
    if(p[i] > p[i-1]) uf.unite(i-1,i);
  }
  for(ll i = 0;i < n;i++){
    if(uf.size(i) >= k) m.insert(uf.find(i));
  }
  if(m.size() > 1){
    ans -= m.size()-1;
  }
  cout << ans << endl;


}


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

using namespace std;

typedef long long ll;

#ifdef RED
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const int N = (int)1e6 + 5;
const int inf = (int)1e9 + 7;

int n, k;
int a[N];
int dp[N];

int main() {
#ifdef RED
  freopen("a.in", "r", stdin);
#endif
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    dp[i] = inf;
  }
  dp[1] = 0;
  for (int i = 2; i <= n; ++i) {
    for (int j = 1; j <= k; ++j) {
      dp[i] = min(dp[i], dp[max(1, i - j)] + abs(a[i] - a[max(1, i - j)]));
    }
  }
  cout << dp[n] << "\n";
  return 0;
}


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

void quicksort(int,int);
void partitition(int,int);
typedef struct{

  int num;
  char m[2];
  int check;
  
} data;

data A[100000];

int main(){

  int n,i,r,a,c=0;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d",A[i].m,&A[i].num);
    A[i].check=i;
  }
   quicksort(0,n-1);

   for(i=0;i<n-1;i++){
     if(A[i].num==A[i+1].num && A[i].check>A[i+1].check) c++;
   }

   if(c>0) printf("Not stable\n");
   else printf("Stable\n");
   
  for(i=0;i<n;i++){
    printf("%c %d\n",A[i].m[0],A[i].num);

    }
  return 0; 
}

int partition(int p,int r){
  int x,j,i;
  data a,b;
  x=A[r].num;
  i=p-1;
  for(j=p;j<r;j++){
  
    if(A[j].num<=x){
      i=i+1;
      a=A[i];
      A[i]=A[j];
      A[j]=a;
    }
  }
  b=A[i+1];
  A[i+1]=A[r];
  A[r]=b;
  
  return i+1;
}

void quicksort(p,r){
  int q;
  if(p<r){
    q=partition(p,r);
    quicksort(p,q-1);
    quicksort(q+1,r);
  }

}

Measured memory_bytes: 1780
#include <iostream>

using namespace std;

int main() {
    long long int A, B, C;
    cin >> A >> B >> C;
    
    if(C>B+1) {
        if(C>A+B+1) {
            cout << B+(A+B+1) << endl;
        } else {
            cout << B+C << endl;
        }
    } else {
        cout << B+C << endl;
    }


    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
/*#include <sstream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include<climits>
#include <bitset>
#include <ctime>
#include <cassert>
#include <functional>
#include <iomanip>
#include <vector>
#include <stack>
#include <fstream>*/
// priority_queue<int,vector<int>,greater<int> >vec;
//long long fix(int n){return ((n%mod)+mod)%mod;}
#define mod 1000000007
//std::ifstream cin("input.txt");
//std::ofstream cout("output.txt");
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//cout<<fixed<<setprecision(*)<<***<<endl;
//a=97  A=65 z=122 Z=90
/*scanf("%d",&..);
printf("%d",..);*/

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie();
	int n,k; cin>>n>>k;
	if(n%2==0)n=n/2;
	else n=n/2+1;
	if(k<=n)return cout<<"YES"<<endl,0;
	else cout<<"NO"<<endl,0;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main
{
	public static void main(String args[]) throws java.lang.Exception
	{
		BufferedReader inp = new BufferedReader (new InputStreamReader(System.in));
			String h[]=inp.readLine().split(" ");

			int n=Integer.parseInt(h[0]);
			int k=Integer.parseInt(h[1]);
			String aa[]=inp.readLine().split(" ");
			long arr[]=new long[n];

			for(int i=0;i<arr.length;i++)
			{
				arr[i]=Long.parseLong(aa[i]);
			}
			// PriorityQueue<Pair>pr=new PriorityQueue<>((a,b)->(int)(a.b-b.a));
			// boolean visited[]=new boolean[n];
			// visited[0]=true;
			// pr.offer(new Pair(0,(long)0));
			long cost[]=new long[n];
			cost[1]=Math.abs(arr[1]-arr[0]);
			for(int i=2;i<n;i++)
			{
				long min=Integer.MAX_VALUE;
				for(int j=1;j<=k && i>=j;j++){
				min=Math.min(cost[i-j]+Math.abs(arr[i]-arr[i-j]),min);}
				cost[i]=min;
			}
			System.out.println(cost[n-1]);
		
	}
	
}
class Pair
{
	int a;
	long b;
	
	Pair(int e, long f)
	{
		a=e;
		b=f;
		
	}
}

Measured memory_bytes: 37976
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int a,b,c,d; cin>>a>>b>>c>>d;
    cout<<(a-c)*(b-d)<<endl;
}


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


int main(){
    int n,k,ans=1,i;
    cin>>n>>k;
    int a[n];
    for(i=0;i<n;i++)
    cin>>a[i]; 
    int cnt=0;
    for(i=k;i<n;i++){
        if(cnt<k)
        cnt++;
        if(cnt==k){
        	cnt=1;
        	ans++;
        }
        
    }
    if(cnt>0)
    ans++;
   
    cout<<ans;
return 0;
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            String str1 = in.nextLine();
            String[] ar = str1.split(" ");
            String A = ar[0];
            String B = ar[1];
            String C = ar[2];

            if (A.charAt(A.length() - 1) == B.charAt(0) &&
                    B.charAt(B.length() - 1) == C.charAt(0)) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }
    }
}



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

#ifdef DEBUG
#include "../include/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    int X, A;
    cin >> X >> A;

    if (X < A) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }

    return 0;
}

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

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

    vector<int> A(n - 1);
    REP(i, n - 1) A[i] = i + 1;

    bool G[n][n] = {};
    REP(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a][b] = true;
        G[b][a] = true;
    }

    int cnt = 0;
    do{
        int s = 0, e;
        bool f = true;
        REP(i, A.size()){
            e = A[i];
            if(G[s][e]);
            else{
                f = false; break;
            }
            s = A[i];
        }
        if(f) cnt++;
    }while(next_permutation(A.begin(), A.end()));

    cout << cnt << endl;

    return 0;
}

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

int N;
int A[2010];
int memo[2100000];
int sum[2010];
int res;

void solve()
{
	int i, j, k, l;
	sort(A, A+N);
	sum[N] = 0;
	for(i=N-1; i>=0; i--){
		sum[i] = sum[i+1] + A[i];
	}
	memo[0] = 1;
	k = 0;
	for(i=0; i<N; i++){
		l = sum[0]/2+1-sum[i];
		if(l<0)
			l = 0;
		for(j=k; j>=l; j--){
			if(memo[j]==1){
				memo[j+A[i]] = 1;
				if(j+A[i]<=sum[0]/2+1)
					k = j+A[i];
				break;
			}
		}
		for(; j>=l; j--){
			if(memo[j]==1){
				memo[j+A[i]] = 1;
			}
		}
	}
	if(sum[0]%2==1)
		l = sum[0]/2+1;
	else
		l = sum[0]/2;
	for(i=l; i<=sum[0]; i++){
		if(memo[i]==1){
			res = i;
			break;
		}
	}
	printf("%d\n", res);
}

void test1()
{
	int i;
	N = 2000;
	for(i=0; i<N; i++)
		A[i] = rand() % 2000 + 1;
	solve();
}

void test()
{
	int i;
	for(i=0; i<20; i++)
		test1();
}

int main()
{
	//test();
	int i;
	scanf("%d", &N);
	for(i=0; i<N; i++)
		scanf("%d", &A[i]);
	solve();
	return 0;
}

Measured memory_bytes: 8448
const lines: string[] = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line: string) {
  lines.push(line);
});

reader.on("close", function () {
  const rule = lines.shift().split(" ").map(Number);
  const num = rule[0];
  const yen = rule[1];
  let count = 0;

  for (let i = 0; i <= num; i++) {
    for (let j = 0; j <= num; j++) {
      if (i + j > num) break;
      const k = num - i - j;

      const sum = i * 10000 + j * 5000 + k * 1000;

      if (sum === yen) {
        console.log(i, j, k);
        return;
      }
    }
  }

  console.log(-1, -1, -1);
});


Measured memory_bytes: 7628
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    chars = "abcdefghijklmnopqrstuvwxyz"
    res = ""

    for i in range(1, 100):
        x = n % 26
        if x == 0:
            x = 26
        res += chars[x - 1]
        n -= x
        n //= 26
        if n == 0:
            break

    print(res[::-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 61880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans[3000] = {};
ll mo;
ll mypow(ll a, ll b){
  ll res = 1;
  a %= mo;
  while (b)
  {
    if (b & 1)
      res = res * a % mo;
    a = a * a % mo;
    b >>= 1;
  }
  return res;
}
const int MAX = 5100;
int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k){
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
ll p ;
cin >> p ;
mo=p;
MOD=p;
vector<ll> a(p);
rep(i, p){
  cin >> a[i];
}
auto mod = [](ll modx){modx%=mo;modx+=mo;modx%=mo;return modx;};
COMinit();
rep(i,p){
  if(a[i]==1){
    ans[0]+=1;
    ll te=1;
    rep(j,p){
      ans[p-j-1]-=COM(p-1,j)*te*(j%2?-1:1);
      te=te*i%mo;
    }
  }
}
rep(i,p)
cout <<  mod(ans[i]) << " ";
cout << endl;
return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<double,double>;

int main(){
  int n; cin>>n;
  vector<P> num(n);
  for(int i=0;i<n;i++){
    double a,b; cin>>a>>b;
    num[i]=P(a,b);
  }double sum=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i==j) continue;
      sum+=sqrt((num[i].first-num[j].first)*(num[i].first-num[j].first)+(num[i].second-num[j].second)*(num[i].second-num[j].second));
    }
  }double m=1;
  for(int i=1;i<=n;i++){
    m*=i;
  }
  cout<<setprecision(15)<<sum/n<<endl;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

string judge(int n){
    string s;
    cout << n << endl;
    cin >> s;
    return s;
}

int main(void){
    int N; cin >> N;
    string sl, sr;
    
    sl = judge(0);
    if(sl=="Vacant") return 0;

    int l = 0, r = N, n = (l+r)/2;
    if((n-l)%2==0) n++;

    while(r-l>2){
        sr = judge(n);
        if(sr=="Vacant") return 0;

        if(sl == sr) r = n;
        else{
            l = n;
            sl = sr;
        }
        n = (l+r)/2;
        if((n-l)%2==0) n++;
    }

    sl = judge(l+1);
    if(sl=="Vacant") return 0;
    sl = judge(l+2);
    if(sl=="Vacant") return 0;
    return 0;
}

Measured memory_bytes: 852
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int dp[105][100005];

int main(){
  int N,W,v[105],w[105];
  cin>>N>>W;
  rep(i,N)cin>>v[i]>>w[i];
  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){
      if(w[i]<=j)dp[i+1][j]=max(dp[i][j],max(dp[i][j-w[i]]+v[i],dp[i+1][j-w[i]]+v[i]));
      else dp[i+1][j]=dp[i][j];
    }
  }
  cout<<dp[N][W]<<endl;
  return 0;
}



Measured memory_bytes: 7424