akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int D=sc.nextInt();
		int G=sc.nextInt();
		int[][] prob=new int[D][2];
		int[] fills=new int[D];

		for(int i=0; i<D; i++) {
			prob[i][0]=sc.nextInt();
			prob[i][1]=sc.nextInt();
		}

		int rui=1;
		for(int i=0; i<D; i++) {
			rui*=2;
		}

		int tmp=0;
		int select=0;
		long p_sum=0;
		long solves=Integer.MAX_VALUE;
		long tmp_solve=0;
		for(int i=0; i<rui; i++) {
			tmp=i;
			for(int j=0; j<D; j++) {
				fills[j]=tmp%2;
				tmp/=2;
			}
			for(int j=0; j<D; j++) {
				select=j;
				p_sum=0;
				tmp_solve=0;
				for(int k=0; k<D; k++) {
					if(k!=select) {
						p_sum+=fills[k]*((k+1)*100*prob[k][0]+prob[k][1]);
						tmp_solve+=prob[k][0]*fills[k];
					}
				}
				if(p_sum>=G) {
					solves=Math.min(solves, tmp_solve);
				}
				else if(p_sum<G) {
					long ps=(G-p_sum)/((select+1)*100);
					if(ps*(select+1)*100+p_sum<G) {
						ps=Math.min(ps+1, prob[select][0]);
					}
					if(ps>prob[select][0]) {
						continue;
					}
					else if(ps==prob[select][0]) {
						p_sum+=ps*100*(select+1)+prob[select][1];
						tmp_solve+=prob[select][0];
					}
					else if(ps<prob[select][0]) {
						p_sum+=ps*100*(select+1);
						tmp_solve+=ps;
					}
				}
				if(p_sum>=G) {
					solves=Math.min(solves, tmp_solve);
				}
			}
		}
		System.out.println(solves);
	}
}

Measured memory_bytes: 24020
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n=int(input())
    s=set()
    for _ in range(n):
        s.add(int(input()))
    print(len(s))

main()

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iterator>
#include <set>
#include <functional>

using namespace std;

#define DT long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
#define all(x) (x).begin(), (x).end()


int main() {
	ifstream fin("Text.txt");
	DT i, j, q;
	DT n, m, ans,ans2;
	cin >> n >> m;
	ans = min(n, m / 2);
	n -= ans;
	m -= 2 * ans;

	cout << ans + (m / 4) << endl;
	return 0;
}

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

int main(){
  long int a,b,c;
  int N;
  cin>>N;
  
  a=2;
  b=1;
  if(N==1){
    cout<<1<<endl;
  }else{
    for(int i=0;i<N-1;i++){
      c=a+b;
      a=b;
      b=c;
    }
    printf("%ld\n",c);
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <stdio.h>

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

  if(s=="Sunny"){
    std::cout << "Cloudy";
  }else if(s=="Cloudy"){
    std::cout << "Rainy";
  }else{
    std::cout << "Sunny";
  }
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, a[200010];

int main() {
    cin >> n;
    rep(i, n) cin >> a[i];

    ll ans = 0, sum = 0, xors = 0;
    int r = 0;
    rep(l, n) {
        while (r < n && (xors ^ a[r]) == (sum + a[r])) {
            sum += a[r];
            xors ^= a[r];
            r++;
        }
        ans += r - l;
        if (r == l) r++;
        else {
            sum -= a[l];
            xors ^= a[l];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int count=0;
    for (int i=a;i<=d;i++) {
        if (i>=a&&i<=b&&i>=c&&i<=d) {
            count++;
        }
    }
    if (count!=0) {
        cout<<count-1<<endl;
    } else {
        cout<<0<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,tmp,x=0,ans=0,i;
bool a[8];
int main() 
{
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>tmp;
		if(tmp<400)a[0]=1;
		else if(tmp<800)a[1]=1;
		else if(tmp<1200)a[2]=1;
		else if(tmp<1600)a[3]=1;
		else if(tmp<2000)a[4]=1;
		else if(tmp<2400)a[5]=1;
		else if(tmp<2800)a[6]=1;
		else if(tmp<3200)a[7]=1;
		else x++;
	}
	for(i=0;i<8;i++)if(a[i])ans++;
	if(ans==0)cout << 1<<" ";
	else cout << ans<<" ";
	cout <<ans+x; 
}

Measured memory_bytes: 256
program main
	implicit none
	integer :: N, S, i
		read(*,*) N
		S=1000
		if(N<=1000)	then
			write(*,*) S*1-N
		else if(1000<N .and. N<=2000) then
			write(*,*) S*2-N
		else if(2000<N .and. N<=3000) then
			write(*,*) S*3-N
		else if(3000<N .and. N<=4000) then
			write(*,*) S*4-N
		else if(4000<N .and. N<=5000) then
			write(*,*) S*5-N
		else if(5000<N .and. N<=6000) then
			write(*,*) S*6-N
		else if(6000<N .and. N<=7000) then
			write(*,*) S*7-N
		else if(7000<N .and. N<=8000) then
			write(*,*) S*8-N
		else if(8000<N .and. N<=9000) then
			write(*,*) S*9-N
		else if(9000<N .and. N<=10000) then
			write(*,*) S*10-N
		endif
end program main

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

using namespace std;
using ll=long long;
using ld=long double;
template<typename T>
using v=vector<T>;
template<typename T>
using vv=vector<vector<T>>;
template<typename T>
using vvv=vector<vector<vector<T>>>;
template<typename T>
using pql=priority_queue<T,vector<T>,greater<T>>;
template<typename T>
using li=list<T>;
template<typename T>
using fl=forward_list<int>;
template<typename T>
using st=stack<T>;
template<typename T>
using qu=queue<T>;
template<typename T>
using dq=deque<T>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define rbe rbegin()
#define en end()
#define ren rend()
#define sz(x) x.size()
#define all(x) x.be,x.en
#define ral(x) x.rbe,x.ren
#define Vsort(v) sort(v.begin(), v.end());
#define Vrev(v) reverse(v.begin(), v.end());
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)
#define repr(i, n) rep2(i,n,0)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define chmin(mi, val) mi = min(mi, val)
#define chmax(ma, val) ma = max(ma, val)
#define MOD 1e9+7

int dx[4] = {1, 0, -1, 0},dy[4] = {0, 1, 0, -1};
template<typename T> void In(T &e){cin>>e;}
template<typename T,typename U>void Inparray(T &f,U n){for(U i=0;i<n;i++) cin>>f[i];}
template<typename T,typename U>void Inparray2(T &f,U n){for(U i=0;i<n;i++)for(U j=0;i<n;i++)cin>>f[i][j];}
template<typename T,typename U,typename V>void Inparray3(T &f,U a,V b){for(U i=0;i<a;i++)for(U j=0;i<b;i++)cin>>f[i][j];}
template<typename T> void co(T e){cout<<e;}
template<typename T> void co2(T e){cout<<e<<"\n";}
template<typename T,typename U>void Printarray(T f,U n){for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i]<<"\n";}
template<typename T,typename U>void Printarray2(T f,U n){for(int i=0;i<n;i++){cout<<f[i]<<"\n";}}
template<typename T,typename U,typename V>void Printarray3(T f,U n){for(U i=0;i<n;i++){for(U j=0;j<n;j++){cout<<f[i][j];}cout<<"\n";}}
template<typename T,typename U,typename V>void Printarray4(T f,U a,V b){for(U i=0;i<a;i++){for(U j=0;j<b;j++){cout<<f[i][j];}cout<<"\n";}}
template<typename T>void flagfunc(bool flag,T A,T B){cout<<(flag?A:B)<<"\n";}
void flag2func(bool flag){cout<<(flag?"Yes":"No")<<"\n";}
void flag3func(bool flag){cout<<(flag?"YES":"NO")<<"\n";}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  int a,b,c,d;cin>>a>>b>>c>>d;
  cout<<(d==1?1:0)<<endl;
}


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

using namespace std;

typedef long long ll;

const int MAX_LG = 17;
const int MAX_N = 1e5 + 5;
const ll INF = 1e18 + 1337;

ll _qry [MAX_N];
int keep [MAX_N];
vector<pair<int, ll>> prevs [MAX_N];
// <idx, coef>; positive idx is query idx, negative is basis vector

ll lin [MAX_N];
ll bas [MAX_N];

int main () {
  int n, q;
  cin >> n >> q;
  
  for (int i = 0; i < q; i++) {
    cin >> _qry[i];
  }

  ll suffm = INF;
  for (int i = q - 1; i >= 0; i--) {
    if (_qry[i] < suffm) {
      keep[i] = 1;
      suffm = _qry[i];
    }
  }

  vector<ll> qs;
  if (n < suffm) {
    qs.push_back(n);
  }
  for (int i = 0; i < q; i++) {
    if (keep[i]) {
      qs.push_back(_qry[i]);
    }
  }

  q = qs.size();
  prevs[0] = vector<pair<int, ll>> (1, make_pair(-qs[0], 1));
  for (int i = 1; i < q; i++) {
    ll cur = qs[i];

    while (true) {
      if (cur == 0) {
        break;
      } else if (cur < qs[0]) {
        prevs[i].push_back(make_pair(-cur, 1));
        break;
      } else {
        // search for the largest k with qs[k] <= cur
        int idx = 0;
        for (int k = 1 << MAX_LG; k != 0; k /= 2) {
          if (idx + k < i && qs[idx + k] <= cur) {
            idx += k;
          }
        }

        prevs[i].push_back(make_pair(idx, cur / qs[idx]));
        cur %= qs[idx];
      }
    }
  }

  lin[q - 1] = 1;
  for (int i = q - 1; i >= 0; i--) {
    ll coef = lin[i];
    lin[i] = 0;
    for (auto pr : prevs[i]) {
      if (pr.first < 0) {
        bas[-pr.first] += coef * pr.second;
      } else {
        lin[pr.first] += coef * pr.second;
      }
    }
  }

  for (int i = n - 1; i >= 0; i--) {
    bas[i] += bas[i + 1];
  }
  for (int i = 1; i <= n; i++) {
    cout << bas[i] << '\n';
  }
}


Measured memory_bytes: 25988
// AtCoder Beginner Contest 075
// C - Bridge
// https://atcoder.jp/contests/abc075/tasks/abc075_c
#include <bits/stdc++.h>
using namespace std;

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

int dfs(vector<vector<bool>>& g, vector<bool>& f, int v)
{
    int res = 1;
    f[v] = true;
    rep(i, g[v].size()) {
        if (i != v && g[v][i] && !f[i])
            res += dfs(g, f, i);
    }
    return res;
}

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

    int N, M; cin >>N>>M;
    vector<int> a(M), b(M);
    rep(i, M) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }

    vector<vector<bool>> g(N, vector<bool>(N, false));
    rep(i, M) {
        g[a[i]][b[i]] = g[b[i]][a[i]] = true;
    }

    int ans = 0;

    rep(i, M) {
        g[a[i]][b[i]] = g[b[i]][a[i]] = false;
        vector<bool> f(N, false);
        if (dfs(g, f, 0) != N) ans++;
        g[a[i]][b[i]] = g[b[i]][a[i]] = true;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import math as mt
input=sys.stdin.buffer.readline  
t=1
#t=int(input())
for _ in range(t):
    y=1000
    n=int(input())
    while y+1000<=n:
        y+=1000
    if y<n:
        y+=1000
    print(y-n)    
    #x,y,n=map(int,input().split())
    #l=list(map(int,input().split()))
    

Measured memory_bytes: 61752
let id x = x
let split_string ?(pattern=" ") = Str.split @@ Str.regexp pattern

let (n, m, x) = Scanf.sscanf (read_line ()) "%d %d %d" (fun n m x -> (n, m, x))
let ca = Array.init n (fun _ -> 
  let t = split_string @@ read_line () in
  (
    int_of_string @@ List.hd t,
    Array.of_list @@ List.map int_of_string @@ List.tl t
  )
)

let ans = ref max_int

let sum arr =
  let mm = Array.make m 0 in
  for i = 0 to n - 1 do
    if arr.(i) = 1 then
      for j = 0 to m - 1 do
        mm.(j) <- mm.(j) + (snd ca.(i)).(j)
      done
  done;
  mm

let g arr = 
  let s = ref 0 in
  for i = 0 to n - 1 do
    s := !s + (fst ca.(i)) * arr.(i)
  done;
  !s

let rec loop arr i =
  if i == n then begin
    let sum = sum arr in
    if Array.for_all (fun i -> i >= x) sum then
      ans := min !ans (g arr)
  end
  else begin
    arr.(i) <- 0; loop arr (i + 1);
    arr.(i) <- 1; loop arr (i + 1)
  end

let () =
  loop (Array.make n 0) 0;
  print_int @@ if !ans = max_int then -1 else !ans


Measured memory_bytes: 4472
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n, a, b;
  cin >> n >> a >> b;
  
  if ((b - a) % 2 == 0)
    cout << abs((b - a)/2) << endl;
  else {
    if (abs(a - b) <= 1){
      cout << min(max(a, b) - 1, n - min(a, b)) << endl;
    }
    else {
      if (a > b){
        ll c = a;
        a = b;
        b = c;
      }
      ll res = n - b + 1 + (b - a - 1) / 2;
      res = min(res, a + (b - a - 1) / 2);
      cout << res << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll arr[100005];

int main() {
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
	}
	sort(arr, arr + N);
	// for(int i = 0; i < N; i++) {
	// 	cout << arr[i] << " ";
	// }
	// cout << "\n";
	ll toCheckInd1 = (N / 2) - 1;
	ll toCheckInd2 = (N / 2);
	if(arr[toCheckInd1] == arr[toCheckInd2]) {
		printf("0\n");
	}
	else {
		ll ans = arr[toCheckInd2] - arr[toCheckInd1];
		// ans += arr[to]
		printf("%lld\n", ans);
	}

	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 1024
//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(),_obj.end()
#define F first
#define S second
#define INF 1e18
#define pll pair<ll, ll> 
#define vll vector<ll>
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=1e5+11,mod=1e9+7;
inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline vll read(int n) {vll v(n);for (int i = 0; i < v.size(); i++)cin>>v[i];return v;}
ll factorial[1000000];
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
long long binomial_coefficient(int n, int k) 
{
    return factorial[n] * modInverse(factorial[k] * factorial[n - k] % mod) % mod;
}
void sol(void)
{
cin>>n;
factorial[0] = 1;
for (int i = 1; i <= MAXN; i++) {
    factorial[i] = factorial[i - 1] * i % mod;
}
ll ans=0;
for(int len=1;len<=n/3;len++)
{
    ll sum=n-3*len;
    ans+=binomial_coefficient(sum+len-1,len-1);
    ans%=mod;
}
cout<<ans;
return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    for(int i=1;i<=test;i++)
    sol();
}


Measured memory_bytes: 4440
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <limits>
#include <map>
#include <bitset>
#include <iomanip>

#define rep(i,n) for(int (i) = 0; (i)<(n); (i)++)
#define FOR(i,s,e) for(int (i) = (s); (i)<(e); (i)++)
#define vecall(itr,vec) for(auto (itr) = (vec).begin(); (itr) != (vec).end(); (itr)++)
#define vecshow(vec) for(auto itr = (vec).begin(); itr != (vec).end(); itr++)cout << *itr << " ";

using namespace std;
using p = pair<int, int>;
using ll = long long;

int gcd(int a, int b) {
	int l = max(a, b);
	int s = min(a, b);
	while (l * s != 0) {
		int tmp = s;
		s = l % s;
		l = tmp;
	}

	return l;
}



int main() {
	int n;
	int c[4] = { 0 };
	string results[4] = { "AC", "WA", "TLE", "RE" };
	cin >> n;
	string tmp;
	
	rep(i, n) {
		cin >> tmp;
		rep(j, 4) {
			if (tmp == results[j]) {
				c[j]++;
				break;
			}
		}
	}
	rep(i, 4) cout << results[i] << " x " << c[i] << endl;
	return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<math.h>
int cal(int);
int main(){
  int num,i,str1;
  scanf("%d",&num);
  int str[num];
  
  for(i=0;i<num;i++){
    scanf("%d",&str[i]);
    str1=cal(str[i]);
  }
  printf("%d\n",str1);
  return 0;
}
int cal(int num){
  int i,flag=0;
  static int str=0;
  if(num==1)flag=1;
  if(num==2)flag=0;
  else if(num%2==0)flag=1;
  for(i=3;i<=sqrt(num);i+=2){
    if(num%i==0){
      flag=1;
    } 
  }
  if(flag==0){
  str++;
  }
  return str;
}



Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PA pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e16+7;
const ll MOD=1e9+7;


//無向グラフ
// http://kagamiz.hatenablog.com/entry/2013/10/05/005213
struct Articulation_point_and_Bridge{
int V,E=0;
vector< vector<int> > G;
vector<int> ord,low;
vector<bool> vis;
vector< pair<int, int> > bridge;
vector<int> articulation;
Articulation_point_and_Bridge(int V_){
	V=V_;
	G.resize(V);
	ord.resize(V,0);
	low.resize(V,0);
	vis.resize(V,false);
}
void dfs(int v, int p, int &k){
	vis[v] = true;
	ord[v] = k++;
	low[v] = ord[v];
	bool isArticulation = false;
	int ct = 0;
	for (int i = 0; i < G[v].size(); i++){
		if (!vis[G[v][i]]){
			ct++;
			dfs(G[v][i], v, k);
			low[v] = min(low[v], low[G[v][i]]);
			if (~p && ord[v] <= low[G[v][i]]) isArticulation = true;
			if (ord[v] < low[G[v][i]]) bridge.push_back(make_pair(min(v, G[v][i]), max(v, G[v][i])));
		}
		else if (G[v][i] != p){
			low[v] = min(low[v], ord[G[v][i]]);
		}
	}
	
	if (p == -1 && ct > 1) isArticulation = true;
	if (isArticulation) articulation.push_back(v);
}
void add_edge(int v1,int v2){
	G[v1].push_back(v2);
	G[v2].push_back(v1);
	E++;
}
void calc(){
	int k=0;
	for(int i=0;i<V;i++){
		if(!vis[i])dfs(i,-1,k);
	}
	sort(bridge.begin(), bridge.end());
	sort(articulation.begin(), articulation.end());
}

};

int main(){
	int n,m;
	cin >> n >> m;
	Articulation_point_and_Bridge apb(n);
	FOR(i,0,m){
		int a,b;
		cin >> a >> b;
		a--;b--;
		apb.add_edge(a,b);
	}
	apb.calc();
	cout << apb.bridge.size() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
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; }
int Inf = (1<<30);
ll inf = (1LL<<60);
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; }
using G = vector<vector<int>>; 
int main() {
	int n;
	cin >> n;
	int m;
	cin >> m;
	int i;
	G g(n);
	for (i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	queue<int> que;
	for (auto v : g[0]) {
		que.push(v);
	}
	while (!que.empty()) {
		int x = que.front();
		que.pop();
		for (auto v : g[x]) {
			if (v == n - 1) {
				cout << "POSSIBLE";
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 12400
L,R = map(int,input().split())

# Rが2019未満のとき
if R < 2019 :
    print((L * (L + 1)) % 2019)
# 範囲内に2019を含む時
elif L <= 2019 and R >= 2019 :
    print(0)
# LもRも2019より高い場合
else :
    R = min(R, L + 2018)
    ans = 2018
    for i in range(L,R + 1):
        b = i + 1
        for j in range(b,R + 1):
            x = (i * j) % 2019
            ans = min(ans, x)
    print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
 
using namespace std;
 
const int  INF = 1e9 ;

int min(int a,int b)
{
 	return (a<b)?a:b; 
}
 
int main()
{
 	int n,k;

  	cin>>n;
  
    cin>>k;

  	vector<int> v(n);
  	
  	for(auto& i:v)
  		cin>>i;
  
  	vector<int> dp(n,INF);
  
  	dp[0]=0;
 
  	for(int i=0;i<n;i++)
    {	
        for(int j=i+1;j<=i+k&&j<n;j++)
    	dp[j]=min(abs(v[j]-v[i])+dp[i],dp[j]);
    
    }  

  

  
  
  	cout<<dp[n-1];
 
}

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

int main() {
  int yen;
  int Max;
  int Min;
  cin >> yen;
  
  Max = yen / 100;
  Min = (yen % 100 + 4) / 5;
  
  if(Min <= Max){
    cout << 1;
  }else{
    cout << 0;
  }
}


Measured memory_bytes: 3644
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    int a[]=new int[m];
    int total=0;
    for (int i=0;i<m;i++) {
      a[i]=sc.nextInt();
      total+=a[i];
    }

    int ans=n-total;

    if (ans>=0) {
      System.out.println(ans);
    }else{
      System.out.println(-1);
    }


  }
}


Measured memory_bytes: 39128
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();    
        int N = r.i();
        int[][] F = new int[N][];
        for(int i = 0; i < N; i++)
            F[i] = r.ii();
        int[][] P = new int[N][];
        for(int i = 0; i < N; i++)
            P[i] = r.ii();
        int max = Integer.MIN_VALUE;
        for(int i = 1; i < 1024; i++){
            int prf = 0;               
            for(int j = 0; j < N; j++){
                int c = 0;
                for(int k = 0; k < 10; k++)
                    if(F[j][k]*bin(i, k) == 1)
                        c++;
                prf += P[j][c];
            }
            if(max < prf)
                max = prf;
        }
        println(max);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static int bin(int n, int right){
        int temp = n >> right;
        return temp%2;
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}


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

int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i=0;i < n;i++){
    int x;
    cin >> x;
    if((i+1) % 2 == 1){
      if(x % 2 == 1){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3564
import java.io.*;

class Main{
	
	public static void main(String[] args)throws IOException{
	
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] div = str.split(" ");
		int a = Integer.parseInt(div[0]);
		int b = Integer.parseInt(div[1]);
		
		if(a < b){
			System.out.println("a < b");
		}else if(a > b){
			System.out.println("a > b");
		}else{
			System.out.println("a == b");
		}
	
	}
	
}

Measured memory_bytes: 17084
#include <bits/stdc++.h>
#define ll long long
#define dl double
#define mp make_pair
#define pb push_back
#define S second
#define F first
using namespace std;


void solve()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    int i=0;
    int j=n-1;
    int cnt=0;
    while(i<j)
    {
        if(s[i]=='R')
        {
            i++;
            continue;
        }
        if(s[j]=='W')
        {
            j--;
            continue;
        }
        cnt++;
        i++;
        j--;
    }   
    cout << cnt << endl;
}

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

    return 0;
}

Measured memory_bytes: 3772
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

signed main(void) {
  int i,j;
  int m,a,b;
  vi p(100005,true);
  for(i=2;i<100005;i++)if(p[i])
    for(j=2;i*j<100005;j++)
      p[i*j]=false;
  vi prime;
  loop(i,2,100005)if(p[i])
    prime.push_back(i);
  while(1){
    cin>>m>>a>>b;
    if(m+a+b==0)break;
    int g=__gcd(a,b);
    a/=g;
    b/=g;
    int x,y;
    int ans=0;
    rep(i,prime.size())loop(j,i,prime.size())
      if(prime[i]*prime[j]>m || b*prime[i]<a*prime[j])break;
      else if(prime[i]*prime[j]>ans){
	ans=prime[i]*prime[j];
	x=prime[i];y=prime[j];
	//	cout<<x<<" "<<y<<" "<<ans<<endl;
      }
    cout<<x<<" "<<y<<endl;
  }
}

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

int main() {
    int k, x;
    cin >> k >> x;
    string ans = "No";
    if (500 * k >= x) {
        ans = "Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
// D - We Love ABC

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
const ll MOD = 1e9 + 7;

ll dp[100001][3]; // dp[i][j]: i文字目まででj（0:'A', 1:'AB', 2:'ABC'）を作れる数

ll mod_pow(ll a, ll n, ll mod) {
	ll result = 1;
	while (n > 0) {
		if (n & 1) result = result * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return result;
}

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

	int N = S.size();
	S = " " + S;
	ll hatena = 0;

	for (int i=0; i<N; i++) {
		if (S[i+1] == 'A') {
			dp[i+1][0] = dp[i][0] + mod_pow(3, hatena, MOD);
			dp[i+1][1] = dp[i][1];
			dp[i+1][2] = dp[i][2];
		}

		if (S[i+1] == 'B') {
			dp[i+1][0] = dp[i][0];
			dp[i+1][1] = dp[i][1] + dp[i][0];
			dp[i+1][2] = dp[i][2];
		}

		if (S[i+1] == 'C') {
			dp[i+1][0] = dp[i][0];
			dp[i+1][1] = dp[i][1];
			dp[i+1][2] = dp[i][2] + dp[i][1];
		}

		if (S[i+1] == '?') {
			// ? = A
			dp[i+1][0] = dp[i][0] + mod_pow(3, hatena, MOD);
			dp[i+1][1] = dp[i][1];
			dp[i+1][2] = dp[i][2];

			// ? = B
			dp[i+1][0] += dp[i][0];
			dp[i+1][1] += dp[i][1] + dp[i][0];
			dp[i+1][2] += dp[i][2];

			// ? = C
			dp[i+1][0] += dp[i][0];
			dp[i+1][1] += dp[i][1];
			dp[i+1][2] += dp[i][2] + dp[i][1];

			hatena++;
		}

		dp[i+1][0] %= MOD;
		dp[i+1][1] %= MOD;
		dp[i+1][2] %= MOD;

		//cerr << "i=" << i+1 << " A:" << dp[i+1][0] << " AB:" << dp[i+1][1] << " ABC:" << dp[i+1][2] << endl; // **** debug ****
	}

	ll ans = dp[N][2];

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6188
#include <iostream>
#include <utility>
#include <cstdio>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <assert.h>
#include <cmath>
using namespace std;

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

using ll = long long;
using P = pair<int, int>;

struct State {
    int v, cost;

    State(int v, int cost): v(v), cost(cost) {}

    // 昇順
    bool operator<(const State& s) const {
        return cost < s.cost;
    }
    // 降順
    bool operator>(const State& s) const {
        return cost > s.cost;
    }
};

template<typename T>
void dump_vector(vector<T> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << (i < vec.size() - 1 ? " " : "\n");
    }
}

int n;

const int MAX_N = 100010;
const int INF = (1 << 28);

int memo[MAX_N];
vector<int> children[MAX_N];

int solve(int v) {
    if (memo[v] >= 0) return memo[v];
    if (children[v].size() == 0) return memo[v] = 0;
    // puts("a")
    vector<int> depths;
    for (int child : children[v]) {
        depths.push_back(solve(child));
    }
    sort(ALL(depths));
    int ans = 0;
    for (int i = depths.size() - 1; i >= 0; i--) {
        ans = max(ans, depths[i] + ((int)depths.size() - i));
    }
    // printf("[v] %d [min_res] %d [max_res] %d\n", v, min_res, max_res);
    return memo[v] = ans;
}

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

    for (int i = 1; i < n; i++) {
        int a;
        cin >> a;
        children[a - 1].push_back(i);
    }

    memset(memo, -1, sizeof(memo));
    cout << solve(0) << endl;

    /*
    int m;
    while (cin >> m, m >= 0) {
        cout << solve(m) << endl;
    }
    */

    return 0;
}


Measured memory_bytes: 15488
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
signed main(){
    int a[3]; cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    cout << a[0] << " " << a[1] << " " << a[2] << endl;

}





Measured memory_bytes: 3116
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e4+5;
const int mod=1e9+7;
using namespace std;
int n,m,i,j,nr[123],idx,grups[nmax];
char a[101][101];
set<pair<int,char> >s;
map<pair<int,int>,int>mp;
int main() 
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m;
	for(i=1;i<=n;i++)
	 for(j=1;j<=m;j++)
	  cin>>a[i][j],nr[a[i][j]]++;
	for(i='a';i<='z';i++)if(nr[i])s.in(make_pair(nr[i],(char)(i)));
    for(i=1;i<=n;i++)
	 for(j=1;j<=m;j++)
      if(!mp[make_pair(i,j)])
	  {
		grups[++idx]++;
		if(n-i+1!=i)grups[idx]++;
		if(m-j+1!=j)grups[idx]++;
		if(n-i+1!=i && m-j+1!=j)grups[idx]++;
		mp[make_pair(i,j)]=mp[make_pair(n-i+1,j)]=mp[make_pair(i,m-j+1)]=mp[make_pair(n-i+1,m-j+1)]=1;
	  }
	sort(grups+1,grups+idx+1);
	for(i=idx;i>=1;i--)
	{
		pair<int,char>p=(*s.rbegin());
		if(p.fr>=grups[i])s.er(s.find(p)),s.in(make_pair(p.fr-grups[i],p.sc));
		else rc("No");
	}
	rc("Yes");
}  

Measured memory_bytes: 896
read A; read B; read C; read X

for a in $(seq 0 $A); do
    for b in $(seq 0 $B); do
        c=$(( ( X - 500 * a - 100 * b ) / 50 ))
        [ 0 -le $c -a $c -le $C ] && echo y
    done
done | wc -l


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

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

	static final int A = 1000000, MD = 1000000007;
	int power(long a, int k) {
		long p = 1;
		while (k > 0) {
			if ((k & 1) == 1)
				p = p * a % MD;
			a = a * a % MD;
			k >>= 1;
		}
		return (int) p;
	}
	void main() {
		int n = sc.nextInt();
		int[] kk = new int[A];
		long ans = 0;
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			ans = (ans + power(a, MD - 2)) % MD;
			for (int p = 2; p <= a / p; p++)
				if (a % p == 0) {
					int k = 0;
					while (a % p == 0) {
						k++;
						a /= p;
					}
					kk[p] = Math.max(kk[p], k);
				}
			if (a > 1)
				kk[a] = Math.max(kk[a], 1);
		}
		for (int a = 2; a < A; a++)
			if (kk[a] > 0)
				ans = ans * power(a, kk[a]) % MD;
		println(ans);
	}
}


Measured memory_bytes: 52388
#!/usr/bin/env python
import sys
import re
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor
sys.setrecursionlimit(1000000)


def main():
    input = sys.stdin.readline
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())
    #ps = list(map(int, input().split()))

    N = int(input())
    As = list(map(int, input().split()))
    Bs = list(map(int, input().split()))
    Cs = list(map(int, input().split()))

    sat = 0
    prev = None
    for i in range(N):
        A = As[i]
        sat += Bs[A-1]
        if prev is not None and prev + 1 == A:
            sat += Cs[prev - 1]
        prev = A

    print(sat)





if __name__ == '__main__':
    main()


Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define msll multiset<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define gpl greater<pll>
#define spl set<pll>
#define mspl multiset<pll>
#define lb lower_bound
#define bp __builtin_popcount
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x, y, sizeof x)
#define endl "\n"
#define sz(x) (ll)x.size()
#define sqr(x) x*x
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef long double ld;
ll mx=INT_MAX;
ll mn=INT_MIN;
ll MOD=1e9+7;
const ll maxs=1e5+5;
ll INF = 1e18;
const ll lg=22; 

ll fast(ll base , ll expo){
    ll res = 1;
    while(expo>=1){
        if(expo%2) res *= base;
        base *= base;
        expo /= 2;
    }
    return base;
}

void code_idhr_h(){
    ll N; cin>>N;
    ll A[N+1], pref[N+2], suf[N+2]; mem(pref , 0); mem(suf , 0);
    for(ll i=1; i<=N; i++){
        cin>>A[i];
        if(i==1) pref[1] = A[i];
        else pref[i] = pref[i-1] ^ A[i];
    }
    for(ll i=N; i>=1; i--){
        if(i==N) suf[i] = A[i];
        else suf[i] = suf[i+1] ^ A[i];
    }
    for(ll i=1; i<=N; i++) cout<<(pref[i-1] ^ suf[i+1])<<" ";
}

int main(){
    rapido;
    ll T=1; //cin>>T;
    while(T--){
        code_idhr_h();
    }
    return 0;
}

Measured memory_bytes: 8232
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const ll MOD=1000000007,INF=1ll<<60;
int dx[]={0,0,1,-1},dy[]={-1,1,0,0};

int N,a[5],mi=INF,now=0;

signed main() {
    IOS();
    cin>>N;
    rep(i,0,5)cin>>a[i];
    rep(i,0,5){
        if(mi>a[i]){
            mi=a[i];
            now=(N+a[i]-1)/a[i];
        }
    }
    cout<<now+4<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

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

int main(void) {
  long long a, b, k;
  cin >> a >> b >> k;
  cout << max((long long)0, a - k) << " "
       << min(b, max((long long)0, b - (k - a))) << endl;
  return 0;
}


Measured memory_bytes: 256
N,Y=map(int,input().split())
sum=0
x,y,z=0,0,0
f=False
for i in range(N+1):
    for j in range(N+1-i):
        if((10000*i+5000*j+1000*(N-i-j)) == Y):
            print(i, j, N-i-j)
            f=True
            break
    else:
        continue
    break
if(not f):
    print("-1 -1 -1")


Measured memory_bytes: 3188
N,K=map(int,input().split())
if int((N-1)*(N-2)/2)<K:
 print(-1)
else:
 if N==2:
  print(1)
  print(*[1,2])
 else:
  S=int((N-1)*(N-2)/2)-K
  print(N-1+S)
  for i in range(N-1):
   print(*[1,2+i])
  t=0
  l=2
  r=3
  while t<S:
   print(*[l,r])
   t+=1
   if r==N:
    l+=1
    r=l+1
   else:
    r+=1


Measured memory_bytes: 3608
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = min(A) + min(B)
for i in range(m):
    x, y, c = map(int, input().split())
    ans = min(ans, A[x - 1] + B[y - 1] - c)
print(ans)


Measured memory_bytes: 18608
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln         PIC X(30).
01 A          PIC S9(10).
01 B          PIC S9(10).
01 ans        PIC S9(10).
01 zs         PIC -Z(9)9.

PROCEDURE DIVISION.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO A B.
  COMPUTE ans = FUNCTION MAX(A + B, A - B, A * B).
  MOVE ans TO zs.
  DISPLAY FUNCTION TRIM(zs).
  STOP RUN.


Measured memory_bytes: 3752
using System;
using System.Collections.Generic;

namespace AtCoder.ABC101
{
    class c
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var spl = line.Split(' ');
            var N = int.Parse(spl[0]);
            var K = int.Parse(spl[1]);
            line = Console.ReadLine().Trim();
            var A = Array.ConvertAll<string, int>(line.Split(' '), new Converter<string, int>(s => int.Parse(s)));
            var min = A[0];
            foreach (int a in A)
            {
                if (a < min) min = a;
            }
            var cnt = 0;
            for (var i = 0; i < N; ++i)
            {
                if (A[i] == min)
                {
                    continue;
                }
                else
                {
                    ++cnt;
                    var containMin = false;
                    for (var j = 1; j < K && i + j < N; ++j)
                    {
                        if (A[i + j] == min)
                        {
                            containMin = true;
                        }
                    }
                    if (containMin)
                    {
                        i += K - 1;
                    }
                    else
                    {
                        i += K - 2;
                    }
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


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

int main(void) {
  char s[3];
  int a=0,b=0,i;
  for(i=0;i<3;i++){
  scanf("%c",&s[i]);
    if(s[i]=='A'){
      a++;
    }
    else if(s[i]=='B'){
      b++;
    }
  }
  if(a&&b){
    printf("Yes");
  }
  else printf("No");

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    map<int,int>f;
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                f[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }
    for(int i=1;i<=n;i++){
        cout << f[i]<<endl;
    }
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  string s;
  bool flag=true;
  cin>>s;
  if(s.size()%2==0){
    s.pop_back();
    s.pop_back();
  }else{
    s.pop_back();
  }
  while(true){
    flag=true;
    for(int i=0;i<s.size()/2;i++){
      if(s[i]!=s[i+s.size()/2]){
        flag=false;
      }
    }
    if(flag){
      break;
    }else{
      s.pop_back();
      s.pop_back();
    }
  }
  cout<<s.size()<<endl;
  
  
  
  
  
}
///////////////////////////

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

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

    int a, b;
    vector<pii> vp(N);
    rep(i, N) {
        cin >> a >> b;
        vp[i] = make_pair(a, b);
    }

    sort(vp.begin(), vp.end());
    ll num = 0;
    rep(i, vp.size()) {
        num += vp[i].second;
        if (K <= num) {
            cout << vp[i].first << endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 1024
N=int(input())
S=[]
T=[]
for i in range(1,N+1):
    s, t=input().split()
    S.append(s)
    T.append(t)
X=input()
T = [int(n) for n in T]

for i in range(N):
    if S[i] == X:
        if i == N:
            c=0
        else:
            c=sum(T[i+1:N+1])
            break

print(c)

Measured memory_bytes: 3060
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

const int N=100000+19;
const int oo=(1<<30)-1;

int A[N],mx[N];
int n,res,tmp=-oo;

int main(){
	n=IN();IN();
	For(i,1,n+1) A[i]=IN();
	for (int i=n;i>=1;i--) mx[i]=max(mx[i+1],A[i]);
	For(i,1,n+1)
		if (mx[i]-A[i]>tmp){
			tmp=mx[i]-A[i];
			res=1;
		} else{
			if (mx[i]-A[i]==tmp) res++;
		}
	printf("%d\n",res);
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
#include <string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<math.h>

#define ok printf("ok\n");
#define MAX 1000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define pb push_back

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

int main()
{
	int X,A,B;
	cin >> X >> A >> B;
	if((A-B)>=0)
		puts("delicious");
	else if((B-A)>=(X+1))
		puts("dangerous");
	else
		puts("safe");
 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x, a;
    cin >> x >> a;
    if(x < a) cout << 0 << endl;
    else cout << 10 << endl;
}

Measured memory_bytes: 764
#include<stdio.h>

void trace(int A[], int N) {
  int i;
  for ( i = 0; i < N; i++ ) {
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void insertionSort(int A[], int N) {
  int j, i, v;
  for ( i = 1; i < N; i++ ) {
    v = A[i];
    j = i - 1;
    while ( j >= 0 && A[j] > v ) {
       A[j + 1] = A[j];
       j--;
    }
    A[j + 1] = v;
    trace(A, N);
  }
}

int main() {
  int N, i, j;
  int A[100];

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

  trace(A, N);
  insertionSort(A, N);

  return 0;
}


Measured memory_bytes: 2752
N, M = map(int, input().split())
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

tab = divisor(M)
ans = []
for i in tab:
    j = M // i
    if j >= N:
        ans += [i]
print(max(ans))

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

using namespace std;
int n;
string s1,s2,s;
int main()
{
	cin>>n;
	cin>>s1>>s2;
	for(int i=0;i<n;++i)
	{
		s+=s1[i];
		s+=s2[i];
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> d(101);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (d[a] == 0) d[a] = 1;
  }
  int ans = 0;
  for (int i = 1; i <= 100; i++) {
    ans += d[i];
  }
  cout << ans << endl;
  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W,K;
int SY,SX,TY,TX;
string S[1010101];
vector<int> D[4][1010101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W>>K;
	cin>>SY>>SX>>TY>>TX;
	SY--,SX--,TY--,TX--;
	FOR(y,H) {
		cin>>S[y];
		FOR(i,4) D[i][y].resize(W);
	}
	
	FOR(y,H) FOR(x,W) FOR(i,4) D[i][y][x]=1<<30;
	priority_queue<pair<int,int>> Q;
	FOR(i,4) {
		D[i][SY][SX]=0;
		Q.push({0,i*1000000+SY*W+SX});
	}
	while(Q.size()) {
		int co=-Q.top().first;
		int dir=Q.top().second/1000000;
		int cy=Q.top().second%1000000/W;
		int cx=Q.top().second%1000000%W;
		Q.pop();
		
		if(D[dir][cy][cx]!=co) continue;
		
		
		if(cy==TY&&cx==TX) {
			cout<<(co+K-1)/K<<endl;
			return;
		}
		int dy[4]={0,1,0,-1};
		int dx[4]={1,0,-1,0};
		FOR(i,4) {
			if(i==dir) {
				int ty=cy+dy[i];
				int tx=cx+dx[i];
				if(ty<0 ||ty>=H || tx<0 || tx>=W || S[ty][tx]=='@') continue;
				if(D[i][ty][tx]>co+1) {
					D[i][ty][tx]=co+1;
					Q.push({-D[i][ty][tx], i*1000000+ty*W+tx});
				}
			}
			else {
				int nco=(co+K-1)/K*K;
				if(D[i][cy][cx]>nco) {
					D[i][cy][cx]=nco;
					Q.push({-D[i][cy][cx], i*1000000+cy*W+cx});
				}
			}
		}
	}
	cout<<-1<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

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

if (S[0]==S[1] && S[0]==S[2] && S[0]==S[3] ){
cout <<"No"<< endl;
}
    
else if( ((S[0]==S[2])&& (S[1]==S[3])) || ((S[0]==S[3]) && (S[1]==S[2])) || ((S[0]==S[1]) && (S[2]==S[3])) ){
cout <<"Yes"<< endl;
}

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


Measured memory_bytes: 256