akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

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

    if(k==1){
        cout << 0 << endl;
        return 0;
    }

    int mn = 1;
    int mx = n-(k-1);
    cout << mx-mn << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    
    if(a+b==c || a+c==b || b+c==a){
      System.out.print("Yes");
    }else{
      System.out.print("No");
    }
  }
}

Measured memory_bytes: 35588
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

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

int main()
{
    int N;
    cin >> N;
    int P[N];
    for(int i = 0; i < N; i++) cin >> P[i];
    int Min = 200001;
    int count = 1;
    for(int i = 0; i < N - 1; i++)
    {
        Min = min(Min,P[i]);
        if(P[i+1] <= Min) count++;
    }
    cout << count << endl;
}     

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define M 100010
#define rep(i, x, y) for(int i = (x); i <= (y); i ++)
inline int read() {
	char ch = getchar(); int x = 0, f = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-') f = -1;
		ch = getchar();
	} while('0' <= ch && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	} return x * f;
}
int a[M];
int main() {
	int n = read();
	rep(i, 1, n) {
		a[i] = read();
	} sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1); int ans = 0;
	rep(i, 1, n) if(i + 1 > a[i + 1]){
		for(int j = i + 1; a[j] == i; j ++) ans ^= 1;
		ans |= (a[i] - i) & 1;
		puts(ans?"First":"Second");
		return 0;
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    int K;
    cin >> s >> K;

    vector<char> alphabet;
    for (int i = 0; i < s.size(); ++i) {
        alphabet.push_back(s[i]);
    }
    sort(alphabet.begin(), alphabet.end());

    auto target_itr = alphabet.begin();
    char target_char;
    set<string> C;
    int count = 0;
    while (1) {
        target_char = *target_itr;
        for (int i = 0; i < s.size(); ++i) {
            if (s[i] == target_char) {
                for (int j = 0; j < K && (i + j) < s.size(); ++j) {
                    C.insert(s.substr(i, j + 1));
                    ++count;
                }
            }
        }
        if (C.size() >= K) {
            break;
        } else {
            while (*(++target_itr) == target_char);
        }
    }

    auto ans = C.begin();
    rep(i, K - 1) {
        ++ans;
    }

    cout << *ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
    int count, x[100];
    scanf("%d", &count);
    for(int i=0; i<count; i++){
    	scanf("%d", &x[i]);
    }
    for(int i=1; i<=count; i++){
    	printf("%d", x[count-i]);
    	if(i < count){
    	    putchar(' ');
    	}
    }
    putchar('\n');
    return 0;
}


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

using namespace std;

int main()
{
  #define int long long
  int n;
    cin>>n;
    int arr[n]={0};
    for(int i=0;i<n;i++)cin>>arr[i];
    int dp[n]={0};
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);

    for(int i=2;i<n;i++)
    {
        dp[i] = min(dp[i-2]+ abs(arr[i-2]-arr[i]), dp[i-1]+ abs(arr[i-1]-arr[i]));
    }

    cout<<dp[n-1];

}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main()
{
    int n,m,l,r,x,y;
    cin>>n>>m;
    x=-1,y=100005;
    for(int i=0;i<m;i++)
    {
        cin>>l>>r;
        if(l>x)
            x=l;
        if(r<y)
            y=r;
    }
    if(y>=x)
    cout<<(y-x+1);
    else
        cout<<'0';
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    ll N, X, M;
    cin >> N >> X >> M;
    vector<int> num_appeared(100000,0);
    ll ans = 0;
    ll tmp = X;
    ll count = 0;
    while (count < N) {
        ans += tmp;
        count++;
        num_appeared[tmp] = 1;
        tmp = (tmp * tmp) % M;
        if (num_appeared[tmp] == 1) break;
    }
//    cout << 1 << endl;
    int loop_length = 0;
    ll sum_loop = 0;
    while (count < N) {
        loop_length++;
        ans += tmp;
        count++;
        sum_loop += tmp;
        num_appeared[tmp] = 2;
        tmp = (tmp * tmp) % M;
        if (num_appeared[tmp] == 2) break;        
    }
    ans += (N - count) / max(loop_length,1) * sum_loop;
    count += (N - count) / max(loop_length,1) * loop_length;
    while (count < N) {
        ans += tmp;
        count++;
        tmp = (tmp * tmp) % M;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3788
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 10000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int H, W, h, w; cin >> H >> W >> h >> w;

	if (H%h == 0 && W % w == 0) {
		cout << "No" << endl;
		return 0;
	}
	int sum = 0;
	vector<VI> ans(H, VI(W, -INF));
	if (H%h) {
		int ma = (h - 1)*w*INF / w - 10;
		int cnt = 0;
		REP(i, H) {
			if (i%h)continue;
			REP(j, W) {
				ans[i][j] = ma;
			}
		}
	}
	else {
		int ma = (w - 1)*h*INF / h - 10;
		int cnt = 0;
		REP(i, H) {
			//if (i%h)continue;
			REP(j, W) {
				if (j%w)continue;
				ans[i][j] = ma;
			}
		}
	}
	

	
	//cout << ma << endl;
	cout << "Yes" << endl;
	REP(i, H) {
		REP(j, W) {
			cout << ans[i][j] << " ";
			sum += ans[i][j];
			//printf("%2lld ", ans[i][j]);
		}
		cout << endl;
	}
	//cout << sum << endl;

	return 0;
}



Measured memory_bytes: 3968
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

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

int main()
{
    int n, k;
    cin >> n >> k;
    int num = 1;
    rep(i, n)
    {
        num += min(num, k);
    }
    cout << num << endl;
}

Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

mod = 10**9+7

N = 10**6                   # 出力の制限
g1 = [1]*(N+1)              # 元テーブル
g2 = [1]*(N+1)              # 逆元テーブル
for i in range(2, N + 1 ): # 準備
    g1[i] = ( g1[i-1] * i ) % mod
g2[N] = pow(g1[-1], mod-2, mod)
for i in range(N, 0, -1):
    g2[i-1] = ( g2[i] * i ) % mod

def nCr(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

s = int(input())
ret = 0
for n in range(1,s):
    r = s - n*3
    if r<0:
        break
    ret += nCr(n+r-1,r)  #n+r-1Cr
    ret %= mod
print(ret)


Measured memory_bytes: 87820
#include<stdio.h>

int array[50];
int suretu(int);

int main(){
  int num;
  int i;

  for(i = 0;i < 50;i++){
    array[i] = -1;
  }

  scanf("%d",&num);
  printf("%d\n",suretu(num));

  return 0;
}

int suretu(int n){
  if(n == 0 || n == 1){
    return array[n] = 1;
  }
  if(array[n] != -1){
    return array[n];
  }

return array[n] = suretu(n - 1) + suretu(n - 2);
}



Measured memory_bytes: 2104
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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

ll N;
vector<vector<int>> a;

//dp
vector<vector<ll>> table;

ll dp(ll n,ll S){
  if(n<0) return 1;
  if(table.at(n).at(S)>-1) return table.at(n).at(S);
  
  ll ret=0;
  rep(i,N){
    if(a.at(n).at(i)&&(S&(1<<i))) ret+=dp(n-1,S&~(1<<i));
  }
  
  return table.at(n).at(S)=ret%MOD;
}
int main()
{
  cin>>N;
  a=vector<vector<int>>(N,vector<int>(N)); rep(i,N) rep(j,N) cin>>a.at(i).at(j);
  
  //dp
  table=vector<vector<ll>>(N,vector<ll>((1<<N),-1));
  
  cout<<dp(N-1,(1<<N)-1)<<endl;
  return 0;
}

Measured memory_bytes: 363816
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int mod = (int)1e9 + 7;
int n;
map < int, int > mp;
const int maxN = 1e5 + 10;
int a[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (a[i] % 2 != (n - 1) % 2) {
            cout << 0;
            return 0;
        }
        if (mp[a[i]] > 1 || (mp[a[i]] > 0 && a[i] == 0)) {
            cout << 0;
            return 0;
        }
        mp[a[i]]++;
    }
    int f = 1;
    for (int p = 1; p <= n / 2; p++) {
        f = (f + f) % mod;
    }
    cout << f;
    return 0;
}

Measured memory_bytes: 2944
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int a, b, c; cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
from collections import defaultdict, deque


def main():
    N, M = list(map(int, input().split()))
    adj = defaultdict(list)
    A, B = -1, -1
    for _ in range(M):
        A, B = list(map(lambda x: int(x) - 1, input().split()))
        adj[A].append(B)
        adj[B].append(A)

    visited = [0] * N
    visited[A] = 1
    visited[B] = 1
    from_a = list()
    que = deque([A])
    while len(que) > 0:
        n = que.pop()
        from_a.append(n)
        visited[n] = 1
        all_visited = True
        for next_n in adj[n]:
            if visited[next_n] == 1:
                continue
            que.append(next_n)
            all_visited = False
        if all_visited:
            break
    from_b = list()
    que = deque([B])
    while len(que) > 0:
        n = que.pop()
        from_b.append(n)
        visited[n] = 1
        all_visited = True
        for next_n in adj[n]:
            if visited[next_n] == 1:
                continue
            que.append(next_n)
            all_visited = False
        if all_visited:
            break
    ans = from_a[::-1] + from_b
    ans = [x + 1 for x in ans]
    print(len(ans))
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 42328
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a1[n];
    int a2[n];
    int count = 0;
    for(int i = 0;i<n;i++)
    {
        cin>>a1[i]>>a2[i];
    }
    int flag = 0;
    for(int i = 0;i<n;i++)
    {
        if(a1[i]==a2[i])
        {
            count++;
        }
        else
        {
            count = 0;
        }
        if(count==3)
        {
            flag = 1;
            break;
        }
    }
    if(flag==0)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    return 0;
}

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

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

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var N = cin.ReadInt;
            int  maxdiv2 = 33;
            for (int i=0; i < N; ++i)
            {
                var a = cin.ReadInt;
                var cnt = 0;
                while (a % 2 == 0)
                {
                    a /= 2;
                    cnt += 1;
                }
                maxdiv2 = Min(cnt, maxdiv2);
            }
            WriteLine(maxdiv2);

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


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

// g++ -std=c++11 -O2 -Wall *.cpp -o *
#define eps 1e-9
#define MAX 10000010
#define MOD 1000000007
#define INF 1e9+10
#define PI 3.14159265358979323846
#define Fi first
#define Se second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define maxof(a) *max_element(all(a))
#define minof(a) *min_element(all(a))
typedef long long ll;

int f[15000+10] = {0};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// freopen("input.txt", "r", stdin);
	// freopen("output.out", "w", stdout);

	int n;
	cin >> n;
	int m = min(int(sqrt(n))+1, 100);
	for (int a = 1; a <= m; ++a)
		for (int b = 1; b <= m; ++b)
			for (int c = 1; c <= m; ++c) {
				int k = a*a + b*b + c*c + a*b+b*c+c*a;
				if (k > n) break;
				f[k]++;
			}
	for (int i = 1; i <= n; ++i)
		cout << f[i] << "\n";

	//cout << endl;
	return 0;
}


Measured memory_bytes: 3604
n = gets.chomp.split(" ").map(&:to_i)
 
 n[0] == 1 ? n[0] = 14 : n[0] = n[0]
 n[1] == 1 ? n[1] = 14 : n[1] = n[1]
 
 case n[0] <=> n[1]
  
    when 1 
        puts "Alice"
    when 0 
        puts "Draw"
    when -1
        puts "Bob"
        
 end 

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

int main() {
  ll N;
  cin >> N;
  map<string, ll> poll;
  vector<pair<ll, string>> result;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (poll.count(s)) {
      poll[s]++;
    }
    else {
      poll[s] = 1;
    }
  }
  
  for (auto p : poll) {
    auto key = p.first;
    auto count = p.second;
    result.push_back(make_pair(count, key));
  }
  sort(result.begin(), result.end());
  reverse(result.begin(), result.end());
  priority_queue<string, vector<string>, greater<string>> ans;
  ans.push(result[0].second);
  int i = 1;
  while (result[i].first == result[0].first && i < result.size()) {
    ans.push(result[i].second);
    i++;
  }
  while(!ans.empty()) {
    cout << ans.top() << endl;
    ans.pop();
  }
}

Measured memory_bytes: 32624
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  int N;
  cin >> N;
  cin >> S;
  int cnt=1;
  for(int i=0;i<N; i++){
    if(i==0){
      continue;
    }
    if(S[i-1] != S[i]){
      cnt++;
    }
  }
  cout << cnt;
}

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


int main() {
	int N,D;
  cin >> N>>D;
  vector<vector<int>> X(N,vector<int>(D));
  for(int i=0;i<N;i++){
	for(int j=0;j<D;j++){
    cin >> X[i][j];
    }
    }
  int ans =0;
  for(int i=0;i<N;i++){
  for(int j=0;j<N;j++){
    if(i != j){
   int d = 0;
    for(int k=0;k<D;k++) d += ((X[i][k] - X[j][k]) *( X[i][k]- X[j][k]));
    bool f=false ;
      for(int k=0;k<=d;k++){
	if(k*k == d) f = true;
      }
      if(f) ans++;
  }
  }
  }
  cout << ans/2 <<endl;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(int i=0;i<n;i++)
#define FOR1(i,n) for(int i=1;i<=n;i++)
#define FORl(i,l,n) for(int i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll mod = 1e9 + 7;

ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    mp["AC"] = 0;
    mp["TLE"] = 0;
    mp["RE"] = 0;
    mp["WA"] = 0;
    while(n--){
        string s;
        cin >> s;
        mp[s]++;
    }   
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;

}

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

int main() {
    int m, f, b;
    cin >> m >> f >> b;
    
    if (m >= b) {
        cout << 0 << endl;
    } else {
        if ((m + f) >= b) {
            cout << b - m << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}


Measured memory_bytes: 3100
#include <iostream> // cout, endl, cin
#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 <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

#include <iostream>

int main()
{
	ll A, B;

	cin >> A >> B;

	if ((A + B) % 2 == 0) { cout << (A+B)/2 << endl; }
	else { cout << "IMPOSSIBLE" << endl; }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif

    int n;
    cin >> n;
    // while (cin >> n) {
    bool ok = 0;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == n) {
                ok = 1;
            }
        }
    }
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    //}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

/*

*/

void solve(){
    int n,q;
    cin >> n >> q;

    vector<pair<int, pair<int,int>>> vp;
    set<int> xs;

    rep(i,n){
        int s,t,x;
        cin >> s >> t >> x;
        vp.emplace_back(make_pair(s-x,make_pair(1,x)));
        vp.emplace_back(make_pair(t-x,make_pair(-1,x)));
    }

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

    int pointer=0;
    rep(i,q){
        int d;
        cin >> d;
        while(vp[pointer].first<=d){
            if(pointer>=vp.size()) break;
            int typ = vp[pointer].second.first;
            int xtmp = vp[pointer].second.second;
            if(typ==1) xs.insert(xtmp);
            else xs.erase(xtmp);
            pointer++;
        }
        if(!xs.empty()) cout << *(xs.begin()) << endl;
        else cout << -1 << endl;
        //cout << *(xs.begin()) << endl;
    }

}

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

Measured memory_bytes: 15340
// One Batch Two Batch Penny and Dime

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define hii cout << "hii" << endl
#define int long long
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 5e5 + 5;
const int MAX = 250000 + 5;
const int M = 1e6 + 5;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int INF = 1e18 + 8;
const int LG = 21;

int arr[M];

void solve()
{
	int n;
	cin >> n;
	int cnt = 0;
	for (int i = 0; i < n; ++i)
	{
		int a, b;
		cin >> a >> b;
		if(a == b)
		{
			cnt++;
		}
		else
		{
			cnt = 0;
		}
		if(cnt == 3)
		{
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
}


 
int32_t main() 
{	
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

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

	int n,x;
	cin >> n>> x;
	
	int sum = 0;
	int cnt = n;
	rep(i,n) {
		int l;
		cin >> l;
		sum += l;
		if (sum > x) {
			cnt = i;
			break;
		}
	}
	
	cout << min(n+1, cnt+1) << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
	static final int MAX = 2_147_483_646; // intMax 
	static final int INF = 1_000_000_000; // 10^9  
	public static void main(String[] args) throws Exception{
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int k = saori.saori_hayami();
		int[] p = new int[n];
		for(int i = 0;i < n;i++){
			p[i] = saori.saori_hayami();
		}
		Arrays.sort(p);
		int ans = 0;
		for(int i = 0;i < k;i++){
			ans += p[i];
		}
		System.out.println(ans);
		saori.close();
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}


Measured memory_bytes: 32488
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
typedef pair<int,int> pii;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

int gcd(int a, int b) { 
   if (b == 0) 
      return a; 
   return gcd(b, a % b);  
} 
vector<vector<int>> adj;
int ans[200005];

void dfs(int s, int p, int val){

    ans[s]+=val;

    for(auto i:adj[s]){
        if(i!=p)dfs(i, s, ans[s]);
    }
}

void solve(){

    int n,q;
    cin >> n >> q;
    adj.resize(n+2);

    for(int i = 1;i<n;i++){
        int x,y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);

    }

    for(int i = 1;i<=q;i++){
        int x,y;
        cin >> x >> y;

        ans[x]+=y;
    }

    dfs(1, -1, 0);

    for(int i = 1;i<=n;i++)cout << ans[i] << " ";
        cout << endl;


}

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 24320
fun main(args: Array<String>) {
    val line: String = readLine()!!.trim()
    val n: Long = line.toLong()
    var result: Long = 0

    for (i: Long in (1..n)) {
        if (i % 3L != 0L && i % 5L != 0L) {
            result += i
        }
    }

    println("${result}")
}


Measured memory_bytes: 35792
#ABC141.B
S= input()
count = 0
if len(S)%2 ==0:
    for i in range(len(S)//2):
        if S[i*2]=='L':
            count +=1
    for m in range(len(S)//2):
        if S[m*2+1]=='R':
            count +=1
elif len(S)%2 ==1:
    for i in range(len(S)//2):
        if S[i*2]=='L':
            count +=1
    for m in range(len(S)//2):
        if S[m*2+1]=='R':
            count+=1
    if S[-1]=='L':
        count+=1
if count ==0:
    print('Yes')
else:
    print('No')

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

int main() {
  int N; cin >> N;
  int A[N];
  for (int i = 0; i<N; i++) cin >> A[i];
  int s = 1, cnt = 0, tmp;
  while(s!=2) {
    if(A[s-1]==-1) {cout << -1 << "\n"; return 0;}
    tmp = s-1;
    s = A[s-1];
    A[tmp] = -1;
    cnt++;
  }
  cout << cnt << "\n";
}

Measured memory_bytes: 640
// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }

using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef DEBUG_MODE

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 100005
#define MAX_M 100005
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

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

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
//  WF("output.txt");
	DF("err.txt");

	int x, t;
	scanf("%d %d", &x, &t);
	printf("%d\n", max(x - t, 0));
}

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

int gcd2(int a,int b){
  if (a%b==0){
    return (b);
  }
  else{
    return(gcd2(b,a%b));
  }
}

int main(){
 int K;
 cin >> K;
 int sum=0;
 for (int i=1;i<=K;i++){
   for (int j=1;j<=K;j++){
     for (int k=1;k<=K;k++){
       sum += gcd2(gcd2(i,j),k);
     }
   }
 }
 cout << sum <<endl;
}

Measured memory_bytes: 3492
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

type Log struct {
	length int
	cut    int

	Index int
}

type PriorityQueue []*Log

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	// a.length / a.cut > b.length / b.cut => a is prior
	return pq[i].length*pq[j].cut > pq[j].length*pq[i].cut
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.Index = -1
	*pq = old[0 : n-1]
	return item
}

func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Log)
	item.Index = n
	*pq = append(*pq, item)
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].Index = i
	pq[j].Index = j
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	N, K := nextInt(), nextInt()
	A := make([]int, N)
	S := 0
	for i := 0; i < N; i++ {
		A[i] = nextInt()
		S += A[i]
	}

	pq := make(PriorityQueue, 0)
	m := 0
	heap.Init(&pq)
	for i := 0; i < N; i++ {
		mc := (A[i] * K) / S
		m += mc
		heap.Push(&pq, &Log{A[i], 1 + mc, -1})
	}

	for k := 0; k < K-m; k++ {
		log := heap.Pop(&pq).(*Log)
		log.cut++
		heap.Push(&pq, log)
	}

	longest := heap.Pop(&pq).(*Log)

	fmt.Fprintf(out, "%d\n", (longest.length-1)/longest.cut+1)
}


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



int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<char>> a(H, vector<char> (W));
    for (int i = 0; i < H;i++)
    {
        for (int j = 0; j < W;j++)
        {
            cin >> a[i][j];
        }
    }


    for (int i = 0; i < W + 2;i++)
    {
        cout << "#";
    }
    cout << endl;

    ////
    for (int i = 0; i < H; i++)
    {
        cout << "#";
        for (int j = 0; j < W; j++)
        {
            cout << a[i][j];
        }
        cout << "#" << endl;
    }

////
    for (int i = 0; i < W + 2;i++)
    {
        cout << "#";
    }
    cout << endl;
}


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

int N, A[100009], B[100009], dp[100009], par[100009], L[100009], G[100009], dist1[100009], dist2[100009];
char c[100009]; vector<int>X[100009], Y[100009];

void dfs(int pos) {
	dp[pos] = 1; if (c[pos] == 'B') dp[pos] = 0;
	for (int i = 0; i < X[pos].size(); i++) {
		if (dp[X[pos][i]] >= 0) continue;
		dfs(X[pos][i]);
		dp[pos] += dp[X[pos][i]]; par[X[pos][i]] = pos;
	}
}

void dfs1(int pos, int depth) {
	if (dist1[pos] >= 0) return;
	dist1[pos] = depth;
	for (int i = 0; i < Y[pos].size(); i++) {
		int cost = 0; if (G[Y[pos][i]] == 1) cost = 1;
		dfs1(Y[pos][i], depth + cost);
	}
}
void dfs2(int pos, int depth) {
	if (dist2[pos] >= 0) return;
	dist2[pos] = depth;
	for (int i = 0; i < Y[pos].size(); i++) {
		int cost = 0; if (G[Y[pos][i]] == 1) cost = 1;
		dfs2(Y[pos][i], depth + cost);
	}
}

int main() {
	cin >> N; int D = 0;
	for (int i = 1; i <= N - 1; i++) {
		cin >> A[i] >> B[i];
		X[A[i]].push_back(B[i]);
		X[B[i]].push_back(A[i]);
	}
	for (int i = 1; i <= N; i++) { cin >> c[i]; if (c[i] == 'W') D++; dp[i] = -1; }
	dfs(1);
	int sum = 0, t = 0;
	for (int i = 1; i <= N; i++) {
		int S = D; bool OK = false;
		for (int j = 0; j < X[i].size(); j++) {
			if (par[i] == X[i][j]) continue;
			if (dp[X[i][j]] == D) OK = true;
			S -= dp[X[i][j]];
		}
		if (S == D && c[i] == 'B') OK = true;
		if (OK == false) { L[i] = 1; t = i; }
	}
	if (t == 0) { cout << "0" << endl; return 0; }
	for (int i = 1; i <= N - 1; i++) {
		if (L[A[i]] == 1 && L[B[i]] == 1) {
			Y[A[i]].push_back(B[i]);
			Y[B[i]].push_back(A[i]);
			sum += 2;
		}
	}
	if (sum == 0) {
		cout << "1" << endl;
		return 0;
	}
	for (int i = 1; i <= N; i++) {
		if (Y[i].size() % 2 == 1 && c[i] == 'B') { sum++; G[i] = 1; }
		if (Y[i].size() % 2 == 0 && c[i] == 'W') { sum++; G[i] = 1; }
	}
	if (N <= 1000) {
		int maxn = 0;
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) dist1[j] = -1;
			dfs1(i, G[i]);
			for (int j = 1; j <= N; j++) maxn = max(maxn, dist1[j]);
		}
		cout << sum - maxn * 2 << endl;
	}
	else {
		for (int i = 1; i <= N; i++) { dist1[i] = -1; dist2[i] = -1; }
		dfs1(t, G[1]);
		int maxn = -1, maxid = -1; for (int i = 1; i <= N; i++) { if (maxn < dist1[i]) { maxn = dist1[i]; maxid = i; } }
		dfs2(maxid, G[maxid]);
		int maxn2 = 0; for (int i = 1; i <= N; i++) maxn2 = max(maxn2, dist2[i]);
		cout << sum - maxn2 * 2 << endl;
	}
	return 0;
}

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

int main(){
  int N, M;
  vector<bool> broken(100010, false);

  cin >> N >> M;
  for(int i=0; i<M; i++){
    int a; cin >> a;
    broken[a] = true;
  }

  vector<int64_t> dp(100010); // dp[i] : i段目までの上り方
  
  dp[0] = 1; dp[1] = 1;
  if(broken[1]) dp[1] = 0;

  for(int i=2; i<=N; i++){
    if(broken[i-2] && broken[i-1]){
      dp[i] = 0;
    } else if (broken[i-2]){
      dp[i] = dp[i-1];
    } else if (broken[i-1]){
      dp[i] = dp[i-2];
    } else {
      dp[i] = (dp[i-1] + dp[i-2]) % 1000000007;
    }
  }

  cout << dp[N] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A,B,C;
    cin >>A>>B>>C;
    rep2(i,B+5){
        if((A*i)%B==C){
            cout<<"YES"<<endl;
            return 0;
        }
    }

    cout << "NO" << endl;


    return 0;
    

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

void _main() {
  int X;
  cin >> X;
  int ans = 0;
  while(ans*(ans+1)/2 < X) ++ans;
  cout << ans << "\n";
}

Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int a, b, n, s, i;

    for(;sc.hasNext();){
      a = sc.nextInt(); b = sc.nextInt(); n = sc.nextInt();
      s = 0;
      if(a >= b)a %= b;
      for(;n-- > 0;){
        a *= 10;
        s += a / b;
        a %= b;
      }
      out.println(s);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 18240
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  const ll P = 1e9+7;
  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  map<ll,ll> freq;
  rep(i,n) {
    freq[a[i]]++;
  }
  ll acc=0;
  ll S = 0;
  for(auto& p : freq) {
    S+=(acc*p.second)%P;
    S%=P;
    acc+=p.second;
    acc%=P;
  }
  ll a_tento=0;
  rep(i,n) {
    repeat(j,i+1,n) {
      if(a[i]>a[j])
	a_tento++;
    }
  }
  ll ans=(k*a_tento)%P;
  ll t = (k*(k-1)/2)%P;
  ans+=(S*t)%P;
  ans%=P;
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  ll ans = 0;
  for (int i=1; i<=N; i++) {
    for (int j=i; j<=N; j+=i) {
      ans += j;
    }
  }
  cout << ans << endl;
}

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

int main()
{
  int A, B, C;
  int p_1, p_2;
  
  cin >> A >> B >> C;
  
  p_2 = C - (A - B);
  
  if(p_2 < 0) p_2 = 0;
  
  cout << p_2 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <int> :: iterator sitr;
typedef set <ll> :: iterator sltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef mset <int> :: iterator msitr;
typedef mset <ll> :: iterator msltr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

map <ll,ll> card;
map <ll,ll> :: reverse_iterator itr;
int n,m;
ll sum,f;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>m;
    for(int i=1;i<=n;i++){
        int a;
        cin>>a;
        card[a]++;
    }
    for(int i=1;i<=m;i++){
        ll b,c;
        cin>>b>>c;
        card[c]+=b;
    }

    for(itr = card.rbegin();itr!= card.rend();itr++){
        ll number, amount;
        number = itr->first;
        amount = itr->second;
        if(f+amount>n){
            sum += (ll) abs(f-n) * number ;
            f=n;
            break;
        }
        else{
            f+=amount;
            sum += (ll) amount * number;
        }
    }
    cout<<sum<<newl;

}


Measured memory_bytes: 12800
import sys
kaito = int(0)
line = []
sagasu = str(input().upper())
#tukau = str(sagasu).upper()
while True:
    sonogyo = str(input())
    if sonogyo == "END_OF_TEXT":
        break
    line += sonogyo.upper().split( )
for a in line:
    if a == sagasu:
        kaito = kaito + 1
print(int(kaito))



Measured memory_bytes: 5564
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Y = sc.nextInt();

		for(int i=0;i<=N;i++) {
			for(int j=0;j<=N-i;j++) {
				int k = N-i-j;
				int yen = (10000 * i) + (5000 * j) + (1000 * k);
				if(yen == Y) {
					System.out.println(i+" "+j+" "+k);
					return;
				}
			}
		}
		System.out.println("-1 -1 -1");
	}
}

Measured memory_bytes: 23764
n, k = gets.split.map(&:to_i)
h    = gets.split.map(&:to_i)

inf = 10 ** 12
dp = Array.new(10**5+10,inf)
dp[0] = 0

(n-1).times do |i|
  k = n-i-1 if k > n-i-1
  k.times do |j|
    dp[i+j+1] = dp[i] + (h[i+j+1] - h[i]).abs  if dp[i+j+1] > dp[i] + (h[i+j+1] - h[i]).abs 
  end
end
 
 
p dp[n-1]

Measured memory_bytes: 8844