akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
    
    int H, W;
    
    while(1){
        cin >> H >> W;
        if(H==0 && W==0) break;
        for(int i=0; i<H; i+=1){
            for(int j=0; j<W; j+=1){
            cout << "#" ;
            }
        cout << endl;
        } 
        cout << endl;
    }
    
    return 0;
}


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

int main(){
  int S; cin>>S;
  int a=S/100;
  int b=S%100;
  if(1<=a && a<=12){
    if(1<=b&& b<=12) cout<<"AMBIGUOUS"<<endl;
    else cout<<"MMYY"<<endl;
  }
  else{
    if(1<=b&& b<=12) cout<<"YYMM"<<endl;
    else cout<<"NA"<<endl;
  }
}  

Measured memory_bytes: 256
X=[]
loop{
  x=[]
  x[0],x[1]=gets.split(" ").map{|v|v=v.to_i}
  X.push(x) if x!=[0,0]
  break if x==[0,0]
}
0.upto(X.length-1){|s|
  q=[]
  p=[]
  y=X[s]
  h=y[0]
  w=y[1]
  1.upto(w){|m|
    q.push("#")
  }
  1.upto(w-2){|n|
    p.push(".")
  }
  p.unshift("#")
  p.push("#")
  puts q.join
  1.upto(h-2){|o|
    puts p.join
  }
  puts q.join
  puts ""
}

Measured memory_bytes: 6124
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(stdR.readLine());
        int[] a = new int[N];;
        for(int i = 0 ; i < N ; i++) {
            a[i] = Integer.parseInt(stdR.readLine());
        }
        ArrayList<Integer> list = new ArrayList<Integer>();
        list.add(a[N - 1]);
        for(int i = N - 2 ; i >= 0 ; i--) {
            int index = binarySearch(list, a[i]);
            if(index == -1) {
                list.add(a[i]);
            }else {
                list.set(index, a[i]);
            }
        }
        System.out.println(list.size());
    }
    public static int binarySearch(ArrayList<Integer> S, int X) {
        int pLeft = 0;
        int pRight = S.size() - 1;

        do {
            int center = (pLeft + pRight) / 2;
            //System.out.println("center:"+center+","+X+","+S.get(center));
            if (X < S.get(center)) {
                if(center == 0) {
                    return center;
                }else if(X < S.get(center - 1)) {
                    pRight = center - 1;
                }else {
                    return center;
                }
            }else {
                pLeft = center + 1;
            }
        } while (pLeft <= pRight);
        return -1;
    }
}


Measured memory_bytes: 34004
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
using Pair = pair<int, int>;

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

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  vector<Pair> ps;
  int prev = S[0] - '0';
  ps.push_back(Pair(prev, 0));
  for(int i = 0; i < S.size(); ++i) {
    if(prev != S[i] - '0') {
      ps.push_back(Pair(prev, i));
    }
    prev = S[i] - '0';
  }
  ps.push_back(Pair(prev, S.size()));
  int max = 0;
  for(int i = 1; i < ps.size(); ++i) {
    auto p = ps[i];
    int idx = -1;
    if(p.first == 0) {
      idx = min((int)ps.size() - 1, i + 2 * (K - 1) + 1);
    } else {
      idx = min((int)ps.size() - 1, i + 2 * K);
    }
    // cout << p.first << ": " << i - 1 << " -> " << idx << endl;
    chmax(max, ps[idx].second - ps[i - 1].second);
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 1656
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        char array[] = s.toCharArray();
        Arrays.sort(array);

        if(array[0]==array[1] && array[1]!=array[2] && array[2]==array[3]){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>
#include<math.h>


#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

int main(void) {
	int a = 0;
	int b = 0;
	int c = 0;
	int result = 0;

	CI a >> b >> c;

	for (int i = 0; i < 10000;++i) {
		if (c % (a + i) == 0) {
			++result;
		}

		if (a + i == b) {
			break;
		}
	}

	CO result E

}

Measured memory_bytes: 1164
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
typedef pair<double, int> P;

double INF = 1.0e+15;

struct edge{
    int to;
    double cost;
};

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

class GraphD{
public:
    int N;
    vector<double> d;
    vector<vector<edge>> G;

    GraphD(int n){
        N = n;
        d.resize(N, INF);
        G.resize(N, vector<edge>(0));
    }

    void makeEdge(int s, int t, double c){
        G[s].push_back(edge{t, c});
        G[t].push_back(edge{s, c});
    }

    void dijkstra(int s){
        fill(d.begin(), d.end(), INF);
        priority_queue<P, vector<P>, greater<P>> que;
        d[s] = 0;
        que.push(P(0, s));

        while(!que.empty()){
            P p = que.top();
            que.pop();
            int v = p.second;
            if(d[v] < p.first) continue;

            for(int i = 0; i < (int)G[v].size(); i++){
                edge e = G[v][i];
                if(d[e.to] > d[v] + e.cost){
                    d[e.to] = d[v] + e.cost;
                    que.push(P(d[e.to], e.to));
                }
            }
        }
    }

    double getCost(int t){
        return d[t];
    }
};

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

int main(){
    double xs, ys, xt, yt;
    int N;
    cin >> xs >> ys >> xt >> yt >> N;
    double x[N], y[N], r[N];

    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> r[i];
    }

    GraphD gr = GraphD(N + 2);

    //円どうしのきょり
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            double d = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
            d -= r[i] + r[j];
            d = max(0.0, d);
            gr.makeEdge(i, j, d);
        }
    }

    //sとの距離
    for(int i = 0; i < N; i++){
        double d = sqrt((x[i] - xs) * (x[i] - xs) + (y[i] - ys) * (y[i] - ys));
        d -= r[i];
        d = max(0.0, d);
        gr.makeEdge(i, N, d);
    }

    //tとの距離
    for(int i = 0; i < N; i++){
        double d = sqrt((x[i] - xt) * (x[i] - xt) + (y[i] - yt) * (y[i] - yt));
        d -= r[i];
        d = max(0.0, d);
        gr.makeEdge(i, N + 1, d);
    }

    //sとt
    gr.makeEdge(N, N + 1, sqrt((xs - xt) * (xs - xt) + (ys - yt) * (ys - yt)));

    gr.dijkstra(N);

    cout << fixed << setprecision(12) << gr.getCost(N + 1) << endl;
    return 0;
}


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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	string s1,s2;
	cin>>s1>>s2;
	int n1=s1.length(),n2=s2.length();
	int ans=10900,c;
	for(int i=0;i<=n1-n2;i++){
		c=0;
		for(int j=0;j<n2;j++){
			if(s1[i+j]!=s2[j])
				c++;
		}
		ans=min(ans,c);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3612
def resolve():
    n=int(input())
    l=list(map(int, input().split()))
    l.sort()
    while len(l)>=2:
        a=(l[0]+l[1])/2
        l.pop(1)
        l.pop(0)
        l.append(a)
        l.sort()
    print(l[0])
resolve()

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

#define MOD 1000000007
#define debug(x) cout << (#x) << " is " << (x) << endl
typedef long long int ll;
#define int ll
typedef pair < ll, ll > pll;
typedef vector < vector < ll > > matrix;
typedef vector < ll > vll;

#define pi 3.1415926536
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    cout << n*(n-1)/2  << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		long[] H = new long[N];
		for(int i = 0; i < N; i++) {
			H[i] = sc.nextLong();
		}
		boolean[] ret = new boolean[N];
		Arrays.fill(ret, true);
		for(int i = 0; i < M; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(H[b - 1] == H[a - 1]) {
				ret[a - 1] = false;
				ret[b - 1] = false;
			} else if(H[b - 1] > H[a - 1]) {
				ret[a - 1] = false;
			} else {
				ret[b - 1] = false;
			}
		}
		sc.close();
		int ans = 0;
		for(int i = 0; i < N; i++) {
			if(ret[i]) ans++;
		}
		System.out.println(ans);
	}
}


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

const long long MOD = 1000000007;
const long long MAX = 2000000;

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

int main()
{
    int D;
    int c[26];
    cin>>D;
    pair<int,int>s[D][26];
    for(int i=0;i<26;i++){
        cin>>c[i];
    }
    for(int i=0;i<D;i++){
        for(int j=0;j<26;j++){
            int tmp;
            cin>>tmp;
            s[i][j]=make_pair(tmp,j+1);
        }
        sort(s[i],s[i]+26);
    }
    for(int i=0;i<D;i++){
        cout<<s[i][25].second<<endl;
    }

    


    
    

}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	int ans;
	if(s[0]=='S'&&s[1]=='U'&&s[2]=='N')	ans=7;
	else if(s[0]=='M'&&s[1]=='O'&&s[2]=='N')	ans=6;
	else if(s[0]=='T'&&s[1]=='U'&&s[2]=='E')	ans=5;
	else if(s[0]=='W'&&s[1]=='E'&&s[2]=='D')	ans=4;
	else if(s[0]=='T'&&s[1]=='H'&&s[2]=='U')	ans=3;
	else if(s[0]=='F'&&s[1]=='R'&&s[2]=='I')	ans=2;
	else if(s[0]=='S'&&s[1]=='A'&&s[2]=='T')	ans=1;
	cout << ans << endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <tuple>
#include <queue>
#include <deque>
#include <unordered_set>
#include <unordered_map>

typedef long long ll;
using namespace std;

int main(void) {
  int N; cin >> N;
  int total = 0;
  vector<int> S(N);
  for (int i = 0; i < N; i++) { cin >> S[i]; total += S[i]; }
  sort(S.begin(), S.end());
  // for (auto v : S) { cout << v << " "; } cout << endl;


  for (int i = 0; i < N; i++) {
    if (total % 10 != 0) {
      cout << total << endl;
      return 0;
    } else {
      if (S[i] % 10 != 0) {
        total -= S[i];
      }
    }
  }
  cout << 0 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
char c;
int main() {
  scanf("%d",&N);
  bool flag = false;
  for(int i = 0; i < N; i++){
    scanf("%c",&c);
    if(c == 'Y')flag=true;
  
  }
  if(flag)puts("Four");
  else puts("Three");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int ac=0, wa=0;
    int acl[n]={}, wal[n]={};
    rep(i, m){
        int a;
        string s;
        cin >> a >> s;
        a--;
        if(s=="WA"){
            wal[a]++;
        }else{
            if(acl[a] != 1){
                ac++;
                acl[a] = 1;
                wa += wal[a];
            }
        }
    }

    cout << ac << ' ' << wa << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
  int D, N;
  cin >> D >> N;
  unsigned long long int ans = 0;
  if (D == 0) {
    ans = N;
    if (N == 100) {
      ans = N + 1;
    }
  } else if (D == 1) {
    ans = 100 * N;
    if (ans == 10000) {
      ans += 100;
    }
  } else {
    ans = 10000 * N;
    if (ans == 1000000) {
      ans += 10000;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long A, B;
    cin >> A >> B;
    if(B % A == 0) cout << A+B << endl;
    else cout << B-A << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

int main() {
    int n;cin>>n;
    int tmp=0;
    rep(i,n){
        int a,b;cin>>a>>b;
        if(a==b){
            ++tmp;
            if(tmp==3){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        else tmp=0;
    }
    cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    cout << (a-1)*(b-1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    string S,T;
    cin>>S>>T;
    ll ans=0;
    ll L=S.size();
    rep(i,L){
        if(S.at(i)!=T.at(i))ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3860
#include <cstdio>
#include <cmath>

int main() {
    double r;
    scanf("%lf", &r);

    double area = M_PI * r *r;
    double circumference = M_PI * 2.0 * r;

    printf("%.6f %.6f\n", area, circumference);
    return 0;
}


Measured memory_bytes: 2748
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
	int x,a,b;
	cin>>x>>a>>b;
	if(abs(x-a)<abs(x-b)){
		cout<<"A"<<endl;
	}
	else{
		cout<<"B"<<endl;
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 200005;
int cnt[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, x;
	cin>>n;
	memset(cnt, 0, sizeof(cnt));
	for(int i = 2; i <= n; i++){
		cin>>x;
		cnt[x]++;
	}
	for(int i = 1; i <= n; i++){
		cout<<cnt[i]<<'\n';
	}


	return 0;
}

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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long k, x;
        cin >> k >> x;

        long total = 500 * k;
        if (total >= x) puts("Yes");
        else puts("No");
    }
}


Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <set>
#include <cstring> 

using namespace std;

#ifdef DEBUG_MODE
#define DBG(n) n;
#else
#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;

int mp[111111];
ll a[111111];
ll b[111111];

int main() {

	int n; cin >> n;
	vector<pair<ll,ll>> v;

	ll Asum = 0;
	ll Bsum = 0;
	ll tmpSum = 0;
	ll ans = LLINF;
	
	REP(i, n) {
		cin >> a[i] >> b[i];
		v.PB(MP(a[i], i));
		v.PB(MP(b[i], i));
		Asum += a[i];
		Bsum += b[i];
	}

	sort(ALL(v));
	REP(i, n) {
		tmpSum += v[i].first;
		mp[v[i].SE]++;
	}

	REP(i, n) {
		ll now = tmpSum;
		if (mp[i] == 0) {
			now -= v[n - 1].first;
			now -= v[n - 2].first;
			now += a[i];
			now += b[i];
		}
		else if (mp[i] == 1) {
			if (v[n - 1].second == i) {
				now -= v[n - 2].first;
				now += max(a[i], b[i]);
			}
			else {
				now -= v[n - 1].first;
				now += max(a[i], b[i]);
			}
		}
		else {
		}
		ans = min(ans, now);
	}

	cout << min(ans, min(Asum, Bsum)) << endl;

	return 0;
}


Measured memory_bytes: 7536
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#define PI 3.14159265358979323846
using namespace std;

int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double n = (2*x)/(a*b);
    cout << std::setprecision(10);
    if(n > a){
        cout << 90 - (180 / PI) * atan(a/(2*b - (2*x)/(a*a))) << '\n';
    } else {
        cout << 90 - (180 / PI) * atan((2*x)/(a*b*b)) << '\n';
    }
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1
if p[n-1] == n:
    ans += 1
    
print(ans)

Measured memory_bytes: 14008
#include<iostream>
#include<string>

using namespace std;

int main(){
	string s, st = "CODEFESTIVAL2016";
	cin >> s;
	int ans = 0;
	for(int i = 0; i < st.size(); i++){
		if(s[i] != st[i]){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
int n,d,a,sum=0;

scanf("%d", &n);
a=n;

while(a>0)
{
d=a%10;
sum=sum+d;
a=a/10;
}

if(n%sum==0)
{
    printf("Yes\n");

}
else
{
    printf("No\n");
}

return 0;
}


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


int main(){
    int n,m,i,cn,sum,k,c;
    int ara[1101];

    scanf("%d %d",&n,&m);
    for(i=0,sum=0;i<n;i++){
     scanf("%d",&ara[i]);
     sum+=ara[i];
     }

    sort(ara,ara+n,greater<int>());
    c=4*m;
    if(sum%c==0) sum=(sum/c);
    else sum=(sum/c)+1;

    if(ara[m-1]>=sum) printf("Yes\n");
    else printf("No\n");

return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;


public class Main {

	public static void main(String[] args) throws Exception {
		new Main().solve();
	}
	void solve() throws Exception {
		FastScanner in = new FastScanner(System.in);

		long N = in.nextInt();

		long sum = 0;
		for (int i = 0; i <= N; i++) {
			sum += i;
			if (sum >= N) {
				System.out.println(i);
				return;
			}
		}

	}

	//
	//
	//
	//
	//
	//
	//
	//
	//
	//
	//
	//
	class FastScanner {

		private InputStream _stream;
		private byte[] _buf = new byte[1024];
		private int _curChar;
		private int _numChars;
		private StringBuilder _sb = new StringBuilder();

		FastScanner(InputStream stream) {
			this._stream = stream;
		}

		public int read() {
			if (_numChars == -1) throw new InputMismatchException();
			if (_curChar >= _numChars) {
				_curChar = 0;
				try {
					_numChars = _stream.read(_buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (_numChars <= 0) return -1;
			}
			return _buf[_curChar++];
		}

		public String next() {
			int c = read();
			while (isWhitespace(c)) {
				c = read();
			}
			_sb.setLength(0);
			do {
				_sb.appendCodePoint(c);
				c = read();
			} while (!isWhitespace(c));
			return _sb.toString();
		}

		public int nextInt() {
			return (int) nextLong();
		}
		public long nextLong() {
			int c = read();
			while (isWhitespace(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9') throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isWhitespace(c));
			return res * sgn;
		}

		public boolean isWhitespace(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}
}
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//


Measured memory_bytes: 20948
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    int a[n]; memset(a, 0, sizeof(a));
    int pena[n]; memset(pena, 0, sizeof(pena));
    int ansNum = 0, penalty = 0;
    for(int i = 0; i < m; ++i){
        int p; string s;
        cin >> p >> s;
        p--;
        if(a[p] == 0 && s == "WA") pena[p]++;
        if(a[p] == 0 && s == "AC") {
            ansNum++;
            a[p] = 1;
        }
    }
    for(int i = 0; i < n; ++i){
        if(a[i]) penalty += pena[i];
    }
    cout << ansNum << " " << penalty << endl;
    return 0;
}

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

typedef long long ll;

const ll N = 1e5+1;

const ll MAX = (1LL<<62);

int s[N], t[N], c[N];
int all[2*N], temp[2*N];

int main () {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, C, T = 0; cin >> n >> C; 
	for (int i = 0; i < n; i++) {
		cin >> s[i] >> t[i] >> c[i];
		T = max(T, t[i]);
	}

	for (int color = 1; color <= C; color++) {
		for (int i = 0; i < 2*T; i++)
			temp[i] = 0;
		for (int i = 0; i < n; i++)
			if (c[i] == color) {
				temp[2*s[i]-1]++;
				temp[2*t[i]]--;
			}
		for (int i = 1; i < 2*T; i++)
			temp[i] += temp[i-1];
		// put into actual
		for (int i = 0; i < 2*T; i++)
			all[i] += (temp[i] > 0);
	}

	int ans = 0;
	for (int i = 0; i < 2*T; i++)
		ans = max(ans, all[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2944
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, d: i64, a: i64,
        xh: [(i64, i64); n],
    }
    let mut xh = xh;
    xh.sort();
    let mut que = BinaryHeap::new();
    // 0: monster appears, -1: bombard effect disappears
    for &(x, h) in &xh {
        que.push((-x, 0, (h + a - 1) / a));
    }
    let mut aoe = 0i64;
    let mut tot = 0;
    while let Some((pos, kind, h)) = que.pop() {
        if kind == 0 {
            let diff = h - min(aoe, h);
            aoe += diff;
            tot += diff;
            que.push((pos - 2 * d, -1, diff));
        } else {
            aoe -= h;
        }
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 22780
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (int i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<long long, long long>;
const int INF = 1001001007;
const int MOD = 1000000007;

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    int n, k; cin >> n >> k;
    ll ans = 0;
    vector<ll> ar(k);
    for (int i = k; i >= 1; i--){
        ll a = k / i;
        ll s = modpow(a,n,MOD);
        reppl(j,a+1,2){
            s += MOD;
            s -= ar[i*j-1];
            s %= MOD;
        }
        ar[i-1] = (s + MOD) % MOD;
    }
    rep(i,k){
        ans += ((i+1) * ar[i]) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;  
}

Measured memory_bytes: 4000
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector.Unboxed as VU
import Data.List ((\\))

main :: IO ()
main = do
  let
    unsafeCharToInt :: Char -> Int
    unsafeCharToInt 'R' = 0
    unsafeCharToInt 'G' = 1
    unsafeCharToInt 'B' = 2
    tally :: VU.Vector Int -> VU.Vector Int
    tally= VU.accumulate (const . succ) (VU.replicate 3 0) . VU.map (flip (,) ())
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  cs <- VU.fromList . map unsafeCharToInt <$> getLine :: IO (VU.Vector Int)
  let
    counts = tally cs :: VU.Vector Int
  print $ VU.product counts - length [() | k <- [2..(n - 1)], l <- [1..(k `div` 2)], null ([0, 1, 2] \\ map (cs VU.!) [k - 2 * l, k - l, k])]

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 5308
#include <bits/stdc++.h>
using namespace std;
vector<int> dy = {1, 0, -1, 0};
vector<int> dx = {0, 1, 0, -1};
int INF = 100000;
int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> A(H + 2, vector<char>(W + 2, '#'));
  for (int i = 1; i <= H; i++){
    for (int j = 1; j <= W; j++){
      cin >> A[i][j];
    }
  }
  int ey, ex;
  for (int i = 1; i <= H; i++){
    for (int j = 1; j <= W; j++){
      if (A[i][j] == '%'){
        ey = i;
        ex = j;
      }
    }
  }
  vector<vector<int>> d(H + 2, vector<int>(W + 2, INF));
  d[ey][ex] = 0;
  queue<pair<int, int>> Q;
  Q.push(make_pair(ey, ex));
  while (!Q.empty()){
    int y = Q.front().first;
    int x = Q.front().second;
    Q.pop();
    for (int i = 0; i < 4; i++){
      int y2 = y + dy[i];
      int x2 = x + dx[i];
      if (d[y2][x2] == INF && A[y2][x2] != '#'){
        d[y2][x2] = d[y][x] + 1;
        Q.push(make_pair(y2, x2));
      }
    }
  }
  int p;
  for (int i = 1; i <= H; i++){
    for (int j = 1; j <= W; j++){
      if (A[i][j] == '@'){
        p = d[i][j];
      }
    }
  }
  bool ok = true;
  for (int i = 1; i <= H; i++){
    for (int j = 1; j <= W; j++){
      if (A[i][j] == '$' && d[i][j] <= p){
        ok = false;
      }
    }
  }
  if (ok){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3292
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000
#define F first
#define S second
#define forn(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)

using namespace std;



int main(){
	ll a,b;
	scanf("%lld %lld", &a, &b);
	if(labs(a-b)<=1) printf("Brown\n");
	else printf("Alice\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <fstream>
#define inputtxt() std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf())
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define foreach(e, v) for (auto e : v)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];

int main(){
    char c; cin >> c;
    char ans['Z'];
    ans['A'] = 'T';
    ans['T'] = 'A';
    ans['C'] = 'G';
    ans['G'] = 'C';
    cout << ans[c] << endl;
    return 0;
}

Measured memory_bytes: 256
r,c = map(int, input().split())
f = [0 for i in range(c)]
for i in range(r):
  e = list(map(int,input().split()))
  for j in range(c) :
    print("{} ".format(e[j]),end="")
    f[j] += e[j]
  print(sum(e))

for j in range(c) :
  print("{} ".format(f[j]),end="")
print(sum(f))



Measured memory_bytes: 5632
from bisect import bisect_left,bisect_right;N=int(input());A=sorted([int(i) for i in input().split()]);B=[int(i) for i in input().split()];C=sorted([int(i) for i in input().split()]);print(sum([bisect_left(A,B[i])*(N-bisect_right(C,B[i])) for i in range(N)]))

Measured memory_bytes: 23616
from math import gcd, sqrt, cos, radians, pi, floor, ceil
from collections import defaultdict as d
from itertools import combinations as c
from string import ascii_lowercase as a

def bfs(s):
	global dico, visited
	queue = []
	queue.append(s)
	visited[s] = 1
	count = 1
	while queue:
		s = queue.pop(0)
		for i in dico[s]:
			if not visited[i]: 
				queue.append(i) 
				visited[i] = 1
				count += 1
	return count
	

n, m = map(int, input().split())
dico = d(set)
visited = [0] * (n + 1)
for i in range(m):
	a, b = map(int, input().split())
	dico[a].add(b)
	dico[b].add(a)

maxi = 0

for i in range(1, n + 1):
	if not visited[i]:
		maxi = max(maxi, bfs(i))

print(maxi)

Measured memory_bytes: 82272
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.nextLine();
        String endS = S.substring(S.length() - 1);

        if (endS.equals("s")){
            S += "es";
            System.out.println(S);
        }else{
            S += "s";
            System.out.println(S);
        }
        sc.close();
    }
}

Measured memory_bytes: 38488
import math
a, b, x = map(int, input().split())
if x > b * a ** 2 / 2:
    print(math.degrees(math.atan(2 / a * (b - (x / a ** 2)))))
else:
    print(math.degrees(math.atan((a * b ** 2) / (2 * x))))


Measured memory_bytes: 2940
from itertools import product

h, w = map(int, input().split())
maze = [input() for _ in range(h)]


def neighbors(ih, iw):
    for ih1, iw1 in (
        (ih - 1, iw),
        (ih + 1, iw),
        (ih, iw - 1),
        (ih, iw + 1),
    ):
        if 0 <= ih1 < h and 0 <= iw1 < w and maze[ih1][iw1] == '.':
            yield (ih1, iw1)



def len_maze(ih, iw):
    # BFS
    if maze[ih][iw] == '#':
        return 0

    stepped = [[False] * w for _ in range(h)]
    q0 = [(ih, iw)]
    l = -1
    while q0:
        q1 = set()
        for ih0, iw0 in q0:
            stepped[ih0][iw0] = True
            for ih1, iw1 in neighbors(ih0, iw0):
                if not stepped[ih1][iw1]:
                    q1.add((ih1, iw1))
        q0 = list(q1)
        l += 1

    return l


answer = max(len_maze(ih, iw) for ih, iw in product(range(h), range(w)))
print(answer)


Measured memory_bytes: 9116
import java.util.*

fun main(args: Array<String>){
    val k = readLine()!!.toInt()
    val q: Queue<Long> = LinkedList<Long>(listOf(1,2,3,4,5,6,7,8,9))

    for (i in 1 until k){
        val x = q.remove()
        if(x % 10 != 0L) q.add(10*x+(x % 10)-1)
        q.add(10*x + (x % 10))
        if(x % 10 != 9L) q.add(10*x+(x % 10)+1)
    }
    println(q.remove())
}

Measured memory_bytes: 49596
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

double dp[4000][4000];

int main(){
	int n; cin >> n;
	vector<double> p(n);
	for( auto &k : p ) cin >> k;
	dp[0][0] = 1-p[0];
	dp[0][1] = p[0];
	for( int i = 1; i < n; ++i ){
		for( int j = 0; j <= (i+1); ++j ){
			if( j > 0 ) dp[i][j] += dp[i-1][j-1] * p[i];
						dp[i][j] += dp[i-1][j] * (1-p[i]);
		}
	}
	double ans = 0.0;
	/*
	for( int j = 0; j <= n-1; ++j ){
		cout << dp[n-2][j] << endl;
	}
	*/
	
	for( int j = 1+(n-n%2)/2; j <= n; ++j ){
		ans += dp[n-1][j];
	}
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}

Measured memory_bytes: 92672
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pII;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define clr(x,y) memset(x,y,sizeof(x))
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=1e6+5;
//ll fmod(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;y>>=1;x=x*x%mod;}return res;}
//ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
int a[505][505];
vector<pair<pair<int,int>,pair<int,int> > >p;
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        p.clear();
        FOR(i,1,n+1)
        FOR(j,1,m+1)
        cin>>a[i][j];
        FOR(i,1,n+1)
        FOR(j,1,m+1)
        {
            if(i == n&&j == m)continue;
            if(a[i][j]%2)
            {
                if(j == m)
                {
                   p.pb({{i,j},{i+1,j}});
                   a[i+1][j]++;
                }
                else
                p.pb({{i,j},{i,j+1}}),a[i][j+1]++;
            }
        }
        cout<<p.size()<<endl;
        FOR(i,0,p.size())
            cout<<p[i].fi.fi<<" "<<p[i].fi.se<<" "<<p[i].se.fi<<" "<<p[i].se.se<<endl;

    }

}
















Measured memory_bytes: 5232
from collections import defaultdict, deque

N, M = map(int, input().split())
es = [[int(x) for x in input().split()] for _ in range(M)]

outs = defaultdict(list)
ins = defaultdict(int)
for v1, v2 in es:
    outs[v1].append(v2)
    ins[v2] += 1
length=defaultdict(int)

q = deque(set(i for i in range(1,N+1))-set(ins.keys()))
length=defaultdict(int)
while q:
    v1 = q.popleft()
    for v2 in outs[v1]:
        ins[v2] -= 1
        if length[v2]<=length[v1]:
            length[v2]=length[v1]+1
        if ins[v2] == 0:
            q.append(v2)

print(max(length.values()))

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

using namespace std;

int main() {
  int N;
  
  cin >> N;
  
  long long sum = 0;
  vector<long long> A, A_sum_excepted;
  
  for (int i = 0; i < N; i++) {
    long long inA;
    
    cin >> inA;
    
    sum += inA;
    A.push_back(inA);
  }
  
  for (int i = 0; i < N - 1; i++) {
    sum -= A[i];
    A_sum_excepted.push_back((sum % 1000000007));
  }
  
  long long ans = 0;
  for (int i = 0; i < N - 1; i++) {
    ans += A_sum_excepted[i] * A[i];
    ans %= 1000000007;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 7876
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;

int main() {
	unsigned int a, b, count = 0;
	string tmp;
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		tmp = to_string(i);
		if (tmp[0] == tmp[4] && tmp[1] == tmp[3]) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

string fb(ll x) {
    if(x%5==0) {
        if(x%3==0) {
            return "FizzBuzz";
        } else {
            return "Buzz";
        }
    } else {
        if(x%3==0) {
            return "Fizz";
        } else {
            return to_string(x);
        }
    }
}

string fbGroup(ll pre) {
    stringstream ss;
    for(ll i=1; i<=30; i++) {
        ss << fb(pre+i);
    }
    return ss.str();
}

// AOJ 2441
int main() {
    ll n;
    cin >> n;
    ll pre = 0;
    ll lim = 9;
    while(true) {
        // kuriagari
        string fb = fbGroup(pre);
        if(n <= fb.size()) {
            fb += fbGroup(pre+30);
            string res = fb.substr(n-1, 20);
            cout << res << endl;
            return 0;
        }
        n -= fb.size();
        pre += 30;
        lim = 10 * lim + 9;
        // normal
        fb = fbGroup(pre);
        ll siz = fb.size();
        ll ngrp = ((lim - pre) / 30);
        if(n <= ngrp * siz) {
            // do hogehoge
            ll kgrp = (n - 1) / siz;
            fb = fbGroup(pre+30*kgrp) + fbGroup(pre+30*(kgrp+1));
            n -= kgrp * siz;
            string res = fb.substr(n-1, 20);
            cout << res << endl;
            return 0;
        }
        n -= ngrp * siz;
        pre += 30 * ngrp;
    }
    
    return 0;
}




Measured memory_bytes: 3284
import std.stdio, std.string, std.conv, std.array, std.algorithm;
import std.uni, std.range, std.math, std.container, std.datetime;
import core.bitop, std.typetuple, std.typecons;

immutable long MOD = 1_000_000_007;
alias tie = TypeTuple;
alias triplet = Tuple!(int, int, int);

void main(){
    int A, B, C;
    readVars(A, B, C);

    if (C % gcd(A, B) == 0) {
        writeln("YES");
    } else {
        writeln("NO");
    }

}

int gcd(int x, int y){
    return y ? gcd(y, x % y) : x;
}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}

Measured memory_bytes: 256
<?php
list($A, $B, $M) = ints();
$a = ints();
$b = ints();
$min = min($a) + min($b);
for ($i = 0; $i < $M; ++$i) {
    list($x, $y, $c) = ints();
    --$x;
    --$y;
    $min = min($min, $a[$x] + $b[$y] - $c);
}
echo $min;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

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

    if (n >= m) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> x(m);
    rep(i,m) cin >> x[i];
    sort(x.begin(), x.end());

    int ans = 0;
    vector<int> d(m-1);

    rep(i,m-1) {
        d[i] = x[i+1] - x[i];
    }

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

    for (int i=m-2; i>=m-n; i--) ans += d[i];

    cout << x[m-1] - x[0] -ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

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

	if (X < A) {
		printf("0\n");
	}
	else {
		printf("10\n");
	}


ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for(auto it = v.begin();it != v.end();it++) 
		min = std::min(min,*it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}


Measured memory_bytes: 504
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

c1 = ns()
c2 = ns()
if c1[0] == c2[2] and c1[1] == c2[1] and c1[2] == c2[0]:
    print("YES")
else:
    print("NO")


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

const int ac = 1e6 + 6;
int A[ac];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b; cin >> a >> b;
	if ((a % 2) ^ (b % 2)) cout << "IMPOSSIBLE\n";
	else cout << (a + b) / 2 << '\n';
}


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


#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

using namespace std;

int main()
{
  double n;
  cin >>n;
  double na= n/1.08;

  
  int s = na;

  if(s*1.08==n)
  {
    cout << s;
  }
  else if((s+1)*1.08 >= n && (s+1)*1.08 <n+1 )
  {
    cout << s+1;
  }
  else if((s-1)*1.08 >= n && (s-1)*1.08 <n+1)
  {
    cout << s-1;
  }
  else
  {
    cout <<":(";
  }

	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t h,w;cin>>h>>w;
  if(h==1||w==1){
    if(h*w==1){
      cout <<1<<endl;
      return 0;
    }
    cout <<h*w-2<<endl;
    return 0;
  }
  cout <<h*w-2*h-2*(w-2)<<endl;
}

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

namespace AtCoder
{
    class C
    {
        public static void Main()
        {
            var ab = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int a = ab[0];
            int b = ab[1];

          int i;
            for (i = 1; i <= 1250; i++)
                if ((int)(i * 0.08) == a && (int)(i * 0.1) == b)
                    break;

            if (i > 1250)
                Console.WriteLine("-1");
            else
                Console.WriteLine(i);
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  int n,x;cin >> n >> x;
  vector<int> m(n);
  int ans = 0;
  for(auto&i:m) cin >> i;
  sort(m.begin(),m.end());
  for(int i=0;i<n;i++){
    if(x>=m[i]){
      ans++;
      x-=m[i];
    }
  }
  ans+=x/m[0];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

const ll dp_H = 222222;
const ll dp_W = 111;

ll dp[dp_H][dp_W];

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

	ll n, t;cin >> n >> t;
	vector<pair<double, P>> v;
	vector<ll> g;
	REP(i, n){
		ll a, b;cin >> a >> b;

		if(a == 0){
			g.PB(b+1);
		}
		else {
			ll c = a + 1;
			ll d = a + b + 1;
			v.EB(-(c - 1.) / d, MP(c, d));
		}
	}
	g.PB(0);

	sort(ALL(v));
	sort(ALL(g));
	REP(i, g.size() - 1)g[i+1] += g[i];

	REP(i, 222222)REP(j, 111)dp[i][j] = 2 * INF;
	dp[0][0] = 0;

	REP(i, v.size()){
		auto now = v[i].SE;
		REP(j, dp_W){
			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
			if(j != dp_W - 1)dp[i+1][j+1] = min(dp[i+1][j+1], now.FI * dp[i][j] + now.SE);
		}
	}

	ll ans = 0;
	REP(i, 111){
		REP(j, g.size()){
			if(dp[v.size()][i] + g[j] <= t)ans = max(ans, i + j);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 199152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int r;
    cin>>n>>r;
    int ans=0;
    if(n<10)
    {
        ans=100*(10-n)+r;
        cout<<ans<<endl;
    }
    else
    {
        cout<<r<<endl;
    }
}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

# A[i]>B[i]を満たす最小のB[i]を残して終える

N = I()
A,B = LIR(N,2)
min_ = 10**10
for i in range(N):
    if A[i] > B[i]:
        if min_ > B[i]:
            min_ = B[i]

if min_ == 10**10:
    print(0)
else:
    print(sum(A)-min_)

Measured memory_bytes: 47008