akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
using namespace std;
string S;
int c=0;
int main(){
  cin >> S;
  if(S[0]!='A'){
    cout << "WA" << endl;
    return 0;
  }
  for(int i=1;i<S.size();i++){
    if(S[i]<='Z'){
      if(i>=2 && i<=S.size()-2){
        if(S[i]=='C' && c==0) c++;
        else{
          cout << "WA" << endl;
          return 0;
        }
      }
      else{
        cout << "WA" << endl;
        return 0;
      }
    }
  }
  if(c==0){
    cout << "WA" << endl;
    return 0;
  }
  cout << "AC" << endl;
  return 0;
}

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

using namespace std;

int main()
{
	for(;;){
		int ak, bk, ck;
		int data[1000][4];
		int n;
		
		cin >> ak;
		cin >> bk;
		cin >> ck;
		if((ak == 0) && (bk == 0) && ( ck == 0)){
			break;
		}
		
		vector<int> a(ak);
		vector<int> b(bk);
		vector<int> c(ck);
		vector<int> check_data(ak+bk+ck+1, 2);		//0ツ氾板姪堋づ債使ツ用ツつオツづ慊つケツづア
		
		int all = ak+bk+ck+1;
		cin >> n;
		
		for(int i = 0; i < n; i++){
			cin >> data[i][0];
			cin >> data[i][1];
			cin >> data[i][2];
			cin >> data[i][3];
		}
		
		/*ツ債格ツづ個閉板品ツづーツパツスツつキツづゥ*/
		/*0.ツ不ツ債格 1.ツ債格 2.ツ不ツ鳴セ*/
		for(int i = 0; i < n; i++){
			if(data[i][3] == 1){
				check_data[data[i][0]] = 1;
				check_data[data[i][1]] = 1;
				check_data[data[i][2]] = 1;
			}
		}
		
		/*ツ不ツ鳴セツづ個閉板品ツづ個チツェツッツク*/
		for(int i = 0; i < n; i++){
			if(data[i][3] != 1){
				if((check_data[data[i][0]] == 1)&&(check_data[data[i][1]] == 1)){
					check_data[data[i][2]] = 0;
				}
				if((check_data[data[i][0]] == 1)&&(check_data[data[i][2]] == 1)){
					check_data[data[i][1]] = 0;
				}
				if((check_data[data[i][1]] == 1)&&(check_data[data[i][2]] == 1)){
					check_data[data[i][0]] = 0;
				}
			}
		}
		
		for(int i = 1; i < all; i++){
			cout << check_data[i] << endl;
		}
	}
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <stdio.h>
#include <numeric>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	//freopen("input.txt", "rt", stdin);
	//freopen("out.txt", "wt", stdout);
	string s;
	cin >> s;
	int div = 1;
	vector<vector<int>> interms;
	long long mod = 1e9 + 7;
	int stat = 0;
	for (int i = s.length() - 1; i >= 0; --i) {
		if (s[i] == '?')
		{
			vector<int> interm(13);
			for (int j = 0; j < 10; ++j) {
				interm[div * j % 13] = 1;
			}
			interms.push_back(interm);
		}
		else {
			stat = (stat + div * (s[i] - '0')) % 13;
		}
		div = (div * 10) % 13;
	}
	if (!interms.size()) {
		cout << int(stat == 5) << endl;
	}
	else {
		vector<int> divs(interms[0]);
		for (int i = 1; i < interms.size(); ++i) {
			vector<int> tmp(13);
			for (int j = 0; j < 13; ++j) {
				for (int k = 0; k < 13; ++k) {
					tmp[(j + k) % 13] = (tmp[(j + k) % 13] + divs[j] * interms[i][k]) % mod;
				}
			}
			divs = tmp;
		}
		cout << divs[(18 - stat) % 13] << endl;
	}
	/*int n, m, k;
	cin >> n >> m >> k;
	vector <tuple<int, int, int>> edges(m);
	for (int i = 0; i < m; ++i) {
		int x, y, w;
		cin >> x >> y >> w;
		if (x > y) swap(x, y);
		edges[i] = make_tuple(w, x, y);
	}
	sort(edges.begin(), edges.end());
	vector <tuple<int, int, int>> paths;
	int curmin = get<0>(edges[0]);
	int ind = 0;
	int cnt = 0;
	while (get<0>(edges[ind]) == curmin && cnt < k) {
		paths.push_back(edges[ind]);
		++ind;
		++cnt;
	}
	while (cnt < k) {
		curmin = get<0>(edges[ind]);
		bool added = false;
		for (int i = 0; i < paths.size(); ++i)
			for (int j = i + 1; j < paths.size(); ++j) {
				int xi = get<1>(paths[i]);
			}

	}*/
	/*int n, m;
	cin >> n >> m;
	vector<vector<int>> graph(n);
	vector<int> powers(n);
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		graph[a].push_back(b);
		graph[b].push_back(a);
		++powers[a];
		++powers[b];
	}
	vector<pair<int, int>> sorted(n);
	for (int i = 0; i < n; ++i) {
		sorted[i].first = powers[i];
		sorted[i].second = i;
	}
	sort(sorted.begin(), sorted.end());
	if (m % 2) {
		cout << -1 << endl;
		return 0;
	}*/
	//cout << get<0>(paths[k - 1]);
	return 0;
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int ans=0;
	if(s.size()%2==0){
		int i=s.size()/2-1,j=s.size()/2;
		int t=0;
		while(i-t>=0){
			if(s[i-t]!=s[j+t])
				ans++;
			t++;
		}
	}
	else{
		int i=s.size()/2-1,j=s.size()/2+1;
		int t=0;
		while(i-t>=0){
			if(s[i-t]!=s[j+t])
				ans++;
			t++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
n=int(input())
w=list(map(int,input().split()))
min=1000000
total=sum(w)
for i in range(n-1):
    s1=sum(w[0:i+1])
    s2=total-s1
    dis=abs(s1-s2)
    if dis<=min:
        min=dis

print(min)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC171D()
{
	int N;
	cin >> N;
	map<int, int> A;
	ll sum = 0;
	for (int i = 0; i < N; ++i)
	{
		int x;
		cin >> x;
		++A[x];
		sum += x;
	}
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; ++i)
	{
		int B, C;
		cin >> B >> C;
		auto p = A.find(B);
		if (p != A.end())
		{
			int c = p->second;
			sum += (C - B)* c;
			A[C] += c;
			A.erase(B);
		}
		cout << sum << endl;
	}


}

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


Measured memory_bytes: 6556
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int main(void){
	int n,t,a,i,tmp;
	double sum=10000000;
	cin>>n>>t>>a;
	int h[n];
	for(i=0;i<n;i++)cin>>h[i];
	for(i=0;i<n;i++){
		if(sum>abs(a-(t-h[i]*0.006))){
			tmp=i;
			sum=abs(a-(t-h[i]*0.006));
		}
	}
	cout<<tmp+1<<endl;

}
/*reveres begin end
cout<<"\n";
  m.insert(std::make_pair('c', 30));
  .erase(v.begin() + 2)
*/


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		String S=scanner.nextLine();
		String result="a";
		if(Character.isUpperCase(S.charAt(0))) {
			result="A";
		}
		System.out.println(result);
	}
}

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

int n, dig = 1;

int dfs(int depth, int max, long long now) {
  if (depth == max) {
    if (now > n) return 0;
    bool c[3] = {};
    for (int i= 0; i < max; i++) {
      if (now % 10 == 3) c[0] = true;
      if (now % 10 == 5) c[1] = true;
      if (now % 10 == 7) c[2] = true;
      now /= 10;
    }
    if (c[0] && c[1] && c[2]) return 1;
    else return 0;
  }
  return dfs(depth + 1, max, now * 10 + 3) + dfs(depth + 1, max, now * 10 + 5) + dfs(depth + 1, max, now * 10 + 7);
}

int main(void) {
  int ans = 0;
  cin >> n;
  int div = 10;
  while (n / div) {
    dig++;
    div *= 10;
  }
  for (int i = 3; i <= dig; i++) {
    ans += dfs(1, i, 3) + dfs(1, i, 5) + dfs(1, i, 7);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N=1e7+9;
ll d[N];
int main()
{
    FASTINOUT;
    for (int i=1; i<=1e7; i++)
    {
        for (int j=i; j<=1e7; j+=i)
        {
            d[j]++;
        }
    }
    ll x;
    cin>>x;
    ll ans=0;
    for (ll i=1;i<=x;i++){
        ans=ans+i*d[i];
       // cout<<"i = "<<i<<"   "<<d[i]+1<<endl;
    }
    cout<<ans<<endl;
    /* ll n,m,k;
     cin>>n>>m>>k;
     ll a[n],b[m];
     for (int i=0; i<n; i++)
         cin>>a[i];
     for (int i=0; i<m; i++)
         cin>>b[i];
     ll sum=0,ans=0,i=0,j=0,fr,sc;
     while (sum<k)
     {
         fr=1e10;
         sc=1e10;
         if (i<n)
             fr=a[i];
         if (j<m)
             sc=b[j];
         if (fr==sc&&fr==1e10)
             break;
         if (fr<sc)
         {
             if (sum+a[i]>k)
                 break;
             sum+=a[i];
             ans++;
             i++;
         }
         else if (sc<fr)
         {
             if (sum+b[j]>k)
                 break;
             sum+=b[j];
             j++;
             ans++;
         }
         else
         {
             int o=i,l=j;
             while (o<n-1&&l<m-1&&a[o]!=b[l])
             {
                 o++;
                 l++;
             }
             if (a[o]<=b[l])
             {
                 if (sum+a[i]>k)
                     break;
                 sum+=a[i];
                 ans++;
                 i++;
             }
             else
             {
                 if (sum+b[j]>k)
                     break;
                 sum+=b[j];
                 j++;
                 ans++;
             }
         }
     }
     cout<<ans<<endl;*/
    return 0;
}

Measured memory_bytes: 81764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N;
    cin >> N;
    vector<ll> as(N);
    repX(i,N+1,2){
        int a;
        cin >> a;
        as[--a]++;
    }
    rep(i,N){
        cout << as[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4844
#include <stdio.h>
#include <string.h>

int main()
{
    int k, l, i;
    char s [100];

    scanf("%d", &k);
    scanf("%s", s);

    l = strlen(s);

    if((k >= 1 && k <= 100) && (l >= 1 && l <= 100))
    {

        if(l <= k)
        {
            printf("%s", s);
        }

        if(l > k)
        {
            for(i = 0; i < k; i++)
            {
                printf("%c", s[i]);
            }
            printf("...");
        }
    }

    return 0;
}


Measured memory_bytes: 1716
#include<iostream>

using namespace std;

int gcd(int x, int y)
{
	int r;

	// ユーグリッドの互除法
	while ((r = x % y) != 0) // yで割り切れるまでループ
	{
		x = y;
		y = r;
	}
	return y;
}

int lcm(int number1, int number2) {
	return number1 * number2 / gcd(number1, number2);
}

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

	cout << lcm(2, N);

	cin >> N;

	return 0;
}

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

#define int long long int
int n, capc;

void fill_knapsack(int val[], int wt[]){
    int dp[n+1][capc+1];

    for(int i=0; i<=n; i++)
        dp[i][0] = 0;
    for(int i=0; i<=capc; i++)
        dp[0][i] = 0;

    for(int i=1; i<=n; i++) {
        for(int j=1; j<=capc; j++) {
            if(j < wt[i-1])                      // item cannot contribute in knapsack
                dp[i][j] = dp[i-1][j];      // best can do without including the item

            else
                dp[i][j] = max(val[i-1] + dp[i-1][j-wt[i-1]], dp[i-1][j]);
        }
    }
    cout << dp[n][capc] << "\n";
}

void solve() {
    cin >> n >> capc;
    int val[n];
    int wt[n];

    for(int i=0; i<n; i++)
        cin >> wt[i] >> val[i];

    fill_knapsack(val, wt);
}

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

    solve();
}

Measured memory_bytes: 79232
#include<stdio.h>

int main(void){

  char S[4];
  int i,ans = 0;

  scanf("%s",S);
  for(i = 0;i < 3;i++){
    if(S[i] == '7') ans++;
  }

  if(ans > 0)printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 1660
program main
	implicit none
    integer(16)::a,b,c,k,d
    read(*,*) a,b,c,k
    d=0
    if(mod(k,2)==1)then
    	d=b-a
    else
    	d=a-b
    end if
    if(abs(d)>=10**18_16)then
    	write(*,*) 'Unfair'
    else
    	write(*,*) d
    end if
    stop
end program main



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <eigen3/Eigen/Dense>
using namespace std;
//using namespace Eigen;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v) cout << i << ' ' << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vin2(v, w) for (ll i = 0; i < v.size(); ++i) cin >> v[i] >> w[i];
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 (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(18);
	string str;
	cin >> str;
	if(str.at(str.size() - 1) == 's') {
		cout << str;
		cout << "es";
	}else{
		cout << str;
		cout << "s";
	}
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
     
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
     
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main() {
  int n, i;
  cin >> n;
  vi a(3 * n);
  for (i = 0; i < 3 * n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  ll sum = 0;
  for (i = 0; i < n; i++) {
    sum += a[2*i + 1];
  }
  cout << sum << endl;
}
  


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

int a[4],b[4];
void search()
{
	int hit=0,blow=0;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			if(a[i] == b[j] && i==j)
				hit++;
			else if(a[i]==b[j])
				blow++;
		}
	}
	cout << hit << ' ' << blow << endl;
}

int main()
{
	int m,n;
	while(cin >> m && cin >> n){
		if(m==0&&n==0)
			break;
		int j=10;
		for(int i=3;i>=0;i--){
			a[i] = m%j;
			b[i] = n%j;
			m/=j;
			n/=j;
		}
		search();
	}
	return 0;
}

Measured memory_bytes: 868
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String sa = sc.next();
        String sb = sc.next();
        String scc = sc.next();
        int[] idx = new int[3];
        String[] can = new String[]{sa,sb,scc};
        int cur = 0;
        while(idx[cur]<can[cur].length()){
            int next = can[cur].charAt(idx[cur])-'a';
            idx[cur]++;
            cur=next;
        }
        String[] res = new String[]{"A","B","C"};
        System.out.println(res[cur]);
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define endl '\n'
#define inf 922337203685477580
#define maxn 3000001
#define mod (ll)(1e9+7)
#define int ll
 
using namespace std;
 
void io(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

int t,n,m,l,r,x,y,z,a,b,c,mn=inf,mx=-inf,w;
int ar[maxn];
int dp[105][100005];
int wei[maxn];
int val[maxn];

int32_t main(){
io();
IOS;    
		
		cin>>n>>w;
		for(int i=1;i<=n;i++){
			cin>>wei[i];cin>>val[i];
		}

		for(int i=0;i<=n;i++)dp[i][0]=0;
		for(int i=1;i<=w;i++){
			dp[0][i]=0;
		}

		for(int i=1;i<=n;i++){
			for(int j=1;j<=w;j++){
				dp[i][j]=max(dp[i-1][j],dp[i][j]);
				if(j>=wei[i])dp[i][j]=max(dp[i-1][j-wei[i]]+val[i],dp[i][j]);
			}
		}

		cout<<dp[n][w]<<endl;
		




        

        


        
    
        
        
                


 
        
 
 
 
        
 
 
 
 
        
        
 
        
        
 
    
    
    
    
 
 
       
 
 
 
 
      
   
 
 
 
 
}

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

int main(){
  string S; cin >> S;
  int res=0;
  string T="CODEFESTIVAL2016";
  for(int i=0; i<16; i++){
    if(S[i]!=T[i]) res++;
  }
  cout << res << endl;
}

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

int main(){
	int x1, y1, x2, y2, dx, dy;
	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
	dx = x2 - x1; dy = y2 - y1;
	printf("%d %d %d %d\n", x2 - dy, y2 + dx, x2 - dy - dx, y2 + dx - dy);
	return 0;
}


Measured memory_bytes: 3768
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){
    ll n,h,w;
    cin >> n >> h >> w;

    ll ans = 0;
    rep(i,0,n){
	ll a,b;
	cin >> a >> b;
	if(h <= a && w <= b)ans ++;
    }
    P(ans);
    
    return  0;
}


Measured memory_bytes: 256
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 
 
const int N = 1e6 + 100, OO = 1e16 + 1000, T = 10, M = 998244353, P = 6151, SQ = 300, lg = 44;
typedef pair <int, int> pii;
int a[N], b[N];

int32_t main() {
	use_fast;
	int n, m, q, mn = OO, mx = OO;
	cin >> n >> m >> q;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		mn = min(mn, a[i]);
	}
	for(int i = 1; i <= m; i++) {
		cin >> b[i];
		mx = min(mx, b[i]);
	}
	int ans = mn + mx;
	while(q--) {
		int x, y, z;
		cin >> x >> y >> z;
		ans = min(ans, a[x] + b[y] - z);
	}
	cout << ans << endl;
	return 0; 
} 
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/

Measured memory_bytes: 5120
N=int(input())
W=list(map(int,input().split()))
even=[]
for i in range(N):
  if W[i]%2==0:
    even.append(W[i])
ans=0
for j in range(len(even)):
  while even[j]%2==0:
    even[j]=even[j]/2
    ans+=1
print(ans)


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int ans = 0;
	string S;
	
	cin >> S;
	
	rep(i, S.length() - 1)
		if(S[i] != S[i+1])
			ans++;
	
	cout << ans;
	
	return 0;
}

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

typedef long long ll;

int main() {
  ll A, B, Q, q, aa[2], bb[2];
  cin >> A >> B >> Q;
  vector<ll> a(A),b(B);
  for (ll i=0; i<A; i++) cin >> a.at(i);
  for (ll i=0; i<B; i++) cin >> b.at(i);
  a.push_back(-1e18);
  a.push_back(1e18);
  b.push_back(-1e18);
  b.push_back(1e18);
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  for (ll i=0; i<Q; i++) {
    cin >> q;
    aa[0] = lower_bound(a.begin(), a.end(), q) - a.begin();
    aa[1] = aa[0] - 1;
    bb[0] = lower_bound(b.begin(), b.end(), q) - b.begin();
    bb[1] = bb[0] - 1;
    ll res = 1e18;
    for (int j=0; j<2; j++) {
      for (int k=0; k<2; k++) {
        ll d1 = abs(a[aa[j]]-b[bb[k]]) + abs(q-a[aa[j]]);
        ll d2 = abs(a[aa[j]]-b[bb[k]]) + abs(q-b[bb[k]]);
        res = min({res, d1, d2});
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 2912
/*
  AUTHOR:SOURABH
  CREATED:27:08:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pll , null_type, less< pll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("input.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,n,i,j,v,f,g;
    set<ll> b;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>n;
        vll a(n);
        fn(i,n)
        cin>>a[i];
        f=1;
        fn(i,n)
        {
            v=a[i];
            for(j=2;j*j<=v;j++)
            {
                if(v%j==0)
                {
                    if(b.find(j)!=b.end())
                    {f=0;goto e;}
                    W(v%j==0)
                    v/=j;
                    b.insert(j);
                }
            }
            if(v>1)
            {
                if(b.find(v)!=b.end())
                   {f=0;goto e;}
                else
                b.insert(v);
            }
                
        }
        e:
        if(f)
            cout<<"pairwise coprime";
        else
        {
            g=0;
            fn(i,n)
            g=__gcd(g,a[i]);
            if(g==1)
                cout<<"setwise coprime";
            else
                cout<<"not coprime";
        }
    }
    return 0;
}







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

int main(){
    long long n;cin>>n;
    long long acc = 0;
    for (long long i=1;i<=n;i++){
        if (i % 3 == 0 || i % 5 == 0){
            continue;
        } else {
            acc += i;
        }
    }
    cout << acc << endl;
    return 0;
}


Measured memory_bytes: 3560
#O(ElogV)
import heapq
import sys
input = sys.stdin.readline

def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

################################
n = int(input())

edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(n-1):
    x,y,z = map(int,input().split())
    edge[x-1].append([z,y-1])
    edge[y-1].append([z,x-1]) 
q,k = map(int,input().split())
p = dijkstra_heap(k-1)
for i in range(q):
    a,b = map(int,input().split())
    print(p[a-1]+p[b-1])
    


Measured memory_bytes: 55964
l = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
dp = [-1] * (n + 10)
dp[0] = 0
for i in range(n):
    for num in a:
        dp[i + l[num]] = max(dp[i + l[num]], dp[i] * 10 + num)
print(dp[n])

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

int main(){
    long long n, flag1, flag2, total1 = 0, total2 = 0;
    cin >> n;
    long long a, sum1 = 0, sum2 = 0;
    flag1 = 1, flag2 = -1;
    for(int i = 0; i < n; ++i){
        cin >> a;
        sum1 += a;
        sum2 += a;
        if(flag1 == -1 && sum1 >= 0){
            total1 += 1 + sum1;
            sum1 = -1;
        }
        if(flag1 == 1 && sum1 <= 0){
            total1 += 1 - sum1 ;
            sum1 = 1;
        }
        flag1 *= -1;
        if(flag2 == -1 && sum2 >= 0){
            total2 += 1 + sum2;
            sum2 = -1;
        }
        if(flag2 == 1 && sum2 <= 0){
            total2 += 1 - sum2;
            sum2 = 1;
        }
        flag2 *= -1;
    }
    total1 = min(total1, total2);
    cout << total1 << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    s = input()
    if s == "SUN":
        print(7)
    elif s == "MON":
        print(6)
    elif s == "TUE":
        print(5)
    elif s == "WED":
        print(4)
    elif s == "THU":
        print(3)
    elif s == "FRI":
        print(2)
    elif s == "SAT":
        print(1)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  string S;
  cin >> S;
  if(S == "SUN") cout << 7 << endl;
  if(S == "MON") cout << 6 << endl;
  if(S == "TUE") cout << 5 << endl;
  if(S == "WED") cout << 4 << endl;
  if(S == "THU") cout << 3 << endl;
  if(S == "FRI") cout << 2 << endl;
  if(S == "SAT") cout << 1 << endl;
      
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) os << "[" << el.first << " " << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) os << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> A;

void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N;
    for (int i = 0; i < N; i++)
    {
      int a;
      cin >> a;
      A.push_back(a);
    }
    
}

double dp[310][310][310];
bool used[310][310][310];

// 直接DP書くより再帰関数書いたほうがいい例
double dfs(int i, int j, int k){
  if(used[i][j][k]) return dp[i][j][k];
  if(!i && !j && !k) return dp[i][j][k]=0;
  double ret=0;
  int s = i+j+k;
  if(i) ret += (double)i/s*dfs(i-1,j,k);
  if(j) ret += (double)j/s*dfs(i+1,j-1,k);
  if(k) ret += (double)k/s*dfs(i,j+1,k-1);
  ret += (double)N/s;
  used[i][j][k] = true;
  return dp[i][j][k] = ret;
}

// 足す順番を間違えたせいで全く機能しなかった。
int solve(){
  int cnt[5];
  memset(cnt,0,sizeof(cnt));
  memset(dp,0,sizeof(dp));
  dp[0][0][0] = 0;
  for(auto a:A) cnt[a]++;

  // dp[1][0][0],dp[0][1][0],dp[0][0][1]の順に計算していく。
  // てか足す順番が怪しかったらそのまま再帰関数にすればよかった。
  // for (int l = 1; l <= N; l++)
  // for (int i = l; i >=0 ; i--)
  // for (int j = l; j >=0 ; j--)
  //     {
  //       int k = l-(i+j);
  //       if(k<0) continue;
  //       if(i==0 && j==0 && k==0) continue;
  //       if(i+j+k>N) continue;
  //       double s = i+j+k;
  //       if(i>=1) dp[i][j][k] += (double)i/s*dp[i-1][j][k];
  //       if(j>=1) dp[i][j][k] += (double)j/s*dp[i+1][j-1][k];
  //       if(k>=1) dp[i][j][k] += (double)k/s*dp[i][j+1][k-1];
  //       dp[i][j][k] += (double)N/s;

  //     } 
  // cout << fixed << setprecision(10) << dp[cnt[1]][cnt[2]][cnt[3]] << endl;
  cout << fixed << setprecision(10) << dfs(cnt[1],cnt[2],cnt[3]) << endl;
  return 0;
}

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


Measured memory_bytes: 262144
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, L;
	cin >> n >> L;
	vector<string> s(n);
	rep(i, n) cin >> s[i];
	sort(s.begin(), s.end());
	for (string c : s) cout << c;
	cout << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
  int mi = min(x, y);
  x -= mi;
  y -= mi;
  int ans = min(a + b, 2 * c) * mi;
  if (x > 0) ans += x * min(a, 2 * c);
  else ans += y * min(b, 2 * c);
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
import java.util.*

fun xx(a: Long, b: Long): Long {
    var m = a
    var n = b
    if (m > n) {
        n = a
        m = b
    }
    var k: Long = n % m
    while (k != 0.toLong()) {
        n = m
        m = k
        k = n % m
    }
    return m
}
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val a = cin.nextLong() - 1
    val b = cin.nextLong()
    val c = cin.nextLong()
    val d = cin.nextLong()

    val c_able: Long = b/c - a/c
    val d_able: Long = b/d - a/d
    val cd: Long = c / xx(c.toLong(), d.toLong()) * d
    val cd_able: Long = b/cd - a/cd
    println(b - a - c_able - d_able + cd_able)
}

Measured memory_bytes: 31268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
vector<ll> a,ans;
vector<ll> p;
vector<int> ki[220000];
const ll INF = 100100100100100100LL;
void dfs(int now,int last = -1){
    int ind = lower_bound(p.begin(),p.end(),a[now])- p.begin();
    ll old = p[ind];
    
    p[ind] = a[now];
    ans[now] = lower_bound(p.begin(),p.end(),INF)-p.begin() -1;
    
    for(auto next:ki[now]){
        if(next == last)continue;

        dfs(next,now);
    }
    p[ind] = old;
}
int main()
{
    int n;cin >> n;
    a.resize(n);
    ans.resize(n);
    p = vector<ll>(n+1,INF);
    p[0] = -INF;
    rep(i,n)cin >> a[i];
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        ki[a].push_back(b);
        ki[b].push_back(a);
    }
    dfs(0);
    rep(i,n)cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 30576
# coding: utf-8
# Your code here!

n=int(input())
aa = [int(i) for i in input().split()]
import sys
sys.setrecursionlimit(10**7)
from itertools import accumulate

acc = list(accumulate([0]+aa))

memo = [[0]*(i+1) for i in range(n+1)]

def dp(r,l):
    if memo[r][l] > 0:
        return memo[r][l]
    if r-l==1:
        memo[r][l] = 0
        return 0
    res=0
    res = min([dp(c,l) + dp(r,c) for c in range(l+1,r)])
    res += acc[r]- acc[l]

    memo[r][l] = res
    return res

dp(n,0)
print(memo[n][0])

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

ll res[500005];

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    string s; cin >> s;
    int n = s.length();
    for (int i = 0; i < n; i++) {
        if (s[i] == '<') {
            res[i + 1] = max(res[i + 1], res[i] + 1);
        }
    }
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == '>') {
            res[i] = max(res[i], res[i + 1] + 1);
        }
    }

    ll sum = 0;
    for (int i = 0; i <= n; i++) {
        sum += res[i];
    }
    cout << sum << '\n';

    return 0;
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1000000
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int a[N]; vector<int> v,b;
int main()
{	int n,k,q,ans=1e9; cin>>n>>k>>q;
	for(rint i=1;i<=n;i++) scanf("%d",&a[i]);
	for(rint i=1;i<=n;i++)
	{	b.clear(); int p=1;
		while(p<=n)
		{	if(a[p]<a[i]){p++;continue;}
			v.clear();
			while(a[p]>=a[i]&&p<=n) v.pb(a[p]),p++;
			if(v.size()<k) continue;
			sort(v.begin(),v.end());
			for(rint j=0;j<=(int)v.size()-k;j++) b.pb(v[j]); 
		}
	//	debug(a[i]);debug(b.size());if(a[i]==1) debug(b[0]),debug(b[1]),debug(b[2]);
		if(b.size()<q) continue;
		sort(b.begin(),b.end()); ans=min(ans,b[q-1]-b[0]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int s , i = 1;
  cin >> s;
  while(true)
  {
    if(s==4)
    {
      cout << i+3 ;
      break;
    }
    else if(s==2)
    {
      cout << i+3 ;
      break;
    }
    else if(s==1)
    {
      cout << i+3 ;
      break;
    }
    if(s%2==0)
      s/=2;
    else
      s=3*s+1;
    i++;
  }
}

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

int main()
{
	int n,m,k;
	while(scanf("%d%d%d",&n,&m,&k)!=EOF)
	{
		int i,j,tp;
		int flag=0;
		for(i=0;i<=n;i++)
		{
			for(j=0;j<=m;j++)
			{
				tp=(m-j)*i+(n-i)*j;
				if(tp==k)
				{
					flag=1;
				}
			}
		}
		if(flag==0)printf("No\n");
		else printf("Yes\n");
	}
	return 0;
}

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

signed main() {
  string S;
  cin >> S;
  
  for( int i = 1; i < S.size(); i++ ){
    if( S.at(i-1) == 'A' && S.at(i) == 'C' ){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

ll kai[1000001];
ll mokai[1000001];

ll mod_pow (ll x, ll y) {
    ll ret = 1;
    while (y) {
        if (y&1) ret = ret*x%MOD;
        x = x*x%MOD;
        y /= 2;
    }
    return ret;
}

void init (int _n) {
    kai[0] = 1;
    for (int i = 1; i <= _n; i++) kai[i] = kai[i-1]*i%MOD;
    for (int i = 0; i <= _n; i++) mokai[i] = mod_pow(kai[i],MOD-2);
}

ll conb (ll x, ll y) {
    ll z = x-y;
    if (z < 0) return 0;
    ll ret = kai[x]*mokai[y]%MOD;
    ret = ret*mokai[z]%MOD;
    return ret;
}

ll N, M, L, R;

ll core (ll x, ll z, ll T) {
    if (x*M > T) return 0;
    ll ret = 0;
    for (ll i = 0; i <= N-M; i++) {
        ll tmp = ((i%2?-1:1)*conb(N-M, i)+MOD)%MOD;
        ll t = T - x*M + N - i*z;
        if (t < N) break;
        tmp = tmp * conb(t, N) % MOD;
        ret = (ret + tmp) % MOD;
    }
    ret = ret * conb(N,M) % MOD;
    return ret;
}

ll solve (ll T) {
    ll ret = 0;
    for (ll i = 1; ; i++) {
        if (M*i > T) break;
        ret = (ret + core(i, i, T) - core(i+1, i, T) + MOD) % MOD;
    }
    ret = (conb(T+N,N) - ret + MOD) % MOD;
    return ret;
}

int main() {
    cin >> N >> M >> L >> R;
    init(1000000);
    cout << (solve(R) - solve(L-1) + MOD) % MOD << endl;
}

Measured memory_bytes: 15872
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  int n,m;
  cin >> n >> m;
  int l[m],r[m];
  rep(i,m){
    cin >> l[i] >> r[i];
  }
  int left=0,right=inf;
  rep(i,m){
    left=max(left,l[i]);
    right=min(right,r[i]);
  }
  cout << max(0,right-left+1) << endl;
return 0;}

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


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

long long int lcm(long long int a,long long int b)
{
   return a * b / gcd(a, b);
}
int main() {
  long long int a,b;
  cin>>a>>b;
  long long int ans=lcm(a,b);
  cout<<ans<<endl;
  
}

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

struct flower{
    long first, between;
};

int main(){
    int N;
    cin >> N;
    long K;
    cin >> K;
    flower flowers[N];
    for(int i = 0; i < N; i++){
        cin >> flowers[i].first >> flowers[i].between;
    }
    long left = -1, right = 2e18; // (left, right]
    while (left + 1 < right) {
        long middle = (left + right) / 2;
        long this_ans = 0;
        for(int i = 0; i < N && this_ans < K; i++){
            this_ans += max(0l, (middle - flowers[i].first + flowers[i].between) / flowers[i].between);
        }
        if(this_ans < K){
            left = middle;
        }else{
            right = middle;
        }
    }
    cout << right << endl;
}


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

const int N = 100010;

int n, a[N], b[N], ans[N];
char s[N];

bool check(int x, int type){
	ans[x] = type;
	for (int i = x; ; i = (i + 3) % n){
		int y = (i + 3) % n, ret = ans[i] ^ b[i];
		if (y == x){
			return ret == ans[x];
		}
		ans[y] = ret;
	}
}

bool check1(){
	for (int i = 0; i < n; ++ i){
		if (ans[i] ^ ans[(i + 1) % n] ^ ans[(i + 2) % n] != a[i]){
			return false;
		}
	}
	return true;
}

void print(){
	for (int i = 0; i < n; ++ i){
		putchar(ans[(i + 1) % n] ? 'W' : 'S');
	}
	putchar('\n');
	exit(0);
}

int main(){
	scanf("%d%s", &n, s);
	for (int i = 0; i < n; ++ i){
		if (s[i] == 'x'){
			a[i] = 1;
		}
	}
	for (int i = 0; i < n; ++ i){
		b[i] = a[i] ^ a[(i + 1) % n];
	}
	if (n == 3){
		if (!a[0] && !a[1] && !a[2]){
			return printf("SSS\n"), 0;
		}
		if (a[0] && a[1] && a[2]){
			return printf("WWW\n"), 0;
		}
		return printf("-1\n"), 0;
	}
	if (n % 3){
		if (check(0, 0) && check1()){
			print();
		}
		if (check(0, 1) && check1()){
			print();
		}
		return printf("-1\n"), 0;
	}
	for (int i = 0; i < 1 << 3; ++ i){
		bool flag = check(0, i & 1) && check(1, i >> 1 & 1) && check(2, i >> 2 & 1);
		if (flag && check1()){
			print();
		}
	}
	return printf("-1\n"), 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long int
#define mod_ceil(a, b) (a % b) ? a / b + 1 : a / b
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    if (s == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
}

Measured memory_bytes: 3568
#include<stdio.h>
int main()
{
    int a,b,c,d,e;
    scanf("%d %d",&a,&b);
    c=a+b;
    d=a-b;
    e=a*b;
   // f=a/b;

    if(c>=d&&c>=e)
    {
        printf("%d",c);
    }
    else if(d>=c&&d>=e)
    {
        printf("%d",d);
    }
    else if(e>=d&&e>=c)
    {
        printf("%d",e);
    }

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (200001)
#define MOD (1000000007)

char s[MAXN+1];
int main(void)
{
    ll n;
    scanf("%ld",&n);
    scanf("%s",s);

    ll ans=1;
    for(int i=1;i<n;i++)
    {
        if(s[i]!=s[i-1]) ans++;
    }
    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))




signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int>h(n); rep(i, n)cin >> h[i];
	int now = 0;
	int ans = 0;
	rep(i, n-1) {
		if (h[i] >= h[i + 1]) {
			now++;
		}
		else {
			chmax(ans, now);
			now = 0;
		}
	}
	chmax(ans, now);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys

n, k = map(int, input().split())
a = list(map(int, input().split()))
d = {}
d2 = {}
d3 = {}
loopc = 0
for i in range(1, n + 1):
    d[i] = a[i - 1]


b = d[1]
d2[b] = 1
d3[i] = b
amari = 0
if k >= 2:
    if n >= k:
        for i in range(2, k + 1):
            if b in d:
                b = d[b]
        print(b)
    else:
        for i in range(2, n + 1):
            if b in d:
                b = d[b]
                if b not in d2:
                    d2[b] = i
                    d3[i] = b
                elif b in d2:
                    loopc = i - d2[b]
            else:
                print(b)
                sys.exit()

        amari = k - n
        amari = amari % loopc
        for i in range(amari):
            b = d[b]
        print(b)
else:
    print(b)


Measured memory_bytes: 55012
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define int long long
signed main() {
	int a, b, ab; cin >> a >> b >> ab;
	ab = min(ab * 2, a + b);
	int x, y; cin >> x >> y;
	int k = min(x, y);
	x -= k; y -= k;
	cout << x * min(a,ab) + y * min(ab,b) + k * ab << endl;
}

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

int main()
{
	int n;
	cin>>n;
	long long int sum = 0;
	while(n!=0)
	{
		if(n%3!=0&&n%5!=0)
			sum += n;
		n--;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3636