akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

int main() {
    string s, t;
    int a, b;
    string u;
    cin >> s >> t >> a >> b >> u;
    if (s == u) {
        a--;
    } else {
        b--;
    }
    cout << a << " " << b << endl;
}

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


using namespace std;

// vector<vector<int>> mat(N, vector<int>(M, 0));

int main(int argc, const char *argv[])
{
    //ABC141 A
    int N , K , Q;

    cin>>N>>K>>Q;
    std::vector<int> Ans (Q,0);
    std::vector<int> point(N,K-Q);

    for (int i = 0; i < Q; i++)
    {
        cin>>Ans[i];
    }

    for (int i = 0; i < Q; i++)
    {
        point[Ans[i] -1 ]++;
    }

    int count = 0;
    for (int i = 0; i < N; i++)
    {
        // std::cout<<point[i]<<std::endl;
        if(point[i] > 0)
        {
           cout<<"Yes"<<std::endl;
        }
        else
        {
            cout<<"No"<<std::endl;
        }
        
    }


    
    return 0;
}


Measured memory_bytes: 1408
def gcd(x, y):
# choose the smaller number
    if x > y:
        smaller = y
    else:
        smaller = x
    for i in range(1, smaller+1):
        if((x % i == 0) and (y % i == 0)):
            hcf = i 
    return hcf
a,b=input().strip().split(" ")
a,b=[int(a),int(b)]
c=gcd(a,b)
d=a*b
ans=d//c
print(ans)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.StringTokenizer;

public class Main  implements Runnable {
	public static void main(String[] args) {
		new Thread(null, new Main(), "", 32 * 1024 * 1024).start(); //
	}
	public void run() {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		int ans = 0;
		for (int i = 0; i < 3; i++) {
			if(s[i] == t[i])
			{
				ans++;
			}
		}
		out.println(ans);
		out.flush();
	}

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }
        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
    }
}

Measured memory_bytes: 24788
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    ll ans = 0;
    rep(i, n){
        vector<string> sn = s;
        rep(j, n){
            rep(k, n){
                sn[j][k] = s[j][(k + i) % n];
            }
        }
        bool ok = true;
        rep(j, n){
            rep(k, n){
                if(sn[j][k] != sn[k][j]) ok = false;
            } 
        }

        if(ok){
            ans += n;
        }
    }

    cout << ans << endl;
}

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define read            freopen("in.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)
#define loop(i,a,b)     for (ll i = a; i <= b; i++)
#define rloop(i,a,b)    for (ll i = a; i >= b; i--)
#define ms(a,x)         memset(a,x,sizeof a)
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        ((a)*(b))/(gcd(a,b))
#define sq(a)           (a)*(a)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              (2*acos(0.0))


int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll n,ans=0;
        cin>>n;
        ll a[n];
        loop(i,0,n-1) cin>>a[i];
        sort(a,a+n);
        loop(i,0,n-3)
        {
            loop(j,i+1,n-2)
            {
                ll x=a[i]+a[j];
                ll l=lower_bound(a,a+n,x)-a;
                l-=(j+1);
                ans+=max(l,0LL);
            }
        }
        cout<<ans;

    }
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<s<<endl; a=0;} return os;}
/*
 * Dijkstraクラス、使用はお勧めしない
 */

template<class E, class Q,typename C=typename remove_reference<decltype(get<0>(declval<Q&>()))>::type>
struct Dijkstra{
    C maxVal=numeric_limits<C>::max();
    int n;
    vector<vector<E>> edge;
    vector<C> distance;
    Dijkstra(int N):n(N){
        edge.resize(n);
        distance=decltype(distance)(n,maxVal); //距離の初期値（通常maxVal）
    }
    void add(int a, E stat, bool dir=true){
        edge[a].push_back(stat);
        if(!dir)return;
        swap(a,get<0>(stat));
        edge[a].push_back(stat);
    }
    C dist(int s,int g){
        auto cmp=[](Q a,Q b){return get<0>(a)>get<0>(b);};
        priority_queue<Q,vector<Q>,decltype(cmp)> pq(cmp);

        pq.emplace(0,s); //探索の初期値
        while(!pq.empty()){ //自由に探索しよう！
            int pos; ll cost;
            tie(cost,pos)=pq.top(); pq.pop();
            if(distance[pos]!=maxVal) continue;
            distance[pos]=cost;
            for(auto e:edge[pos]){
                int nxt; ll len;
                tie(nxt,len)=e;
                if(distance[nxt]==maxVal) pq.emplace(cost+len,nxt);
            }
        }
        return distance[g];
    }
};

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n,m,s,t;
	cin>>n>>m>>s>>t;
	s--,t--;
	
	using Edge=tuple<int,ll>;
	using Que=tuple<ll,int>;
	Dijkstra<Edge,Que> yen(n);
	Dijkstra<Edge,Que> snuke(n);
	rep(_,m){
	    int u,v; ll a,b;
	    cin>>u>>v>>a>>b;
	    u--,v--;
	    yen.add(u,Edge(v,a));
	    yen.add(v,Edge(u,a));
	    snuke.add(u,Edge(v,b));
	    snuke.add(v,Edge(u,b));
	}
	yen.dist(s,t);
	snuke.dist(t,s);
	vl cost(n);
	ll ini=1000000000000000ll;
	rep(i,n){
	    cost[i]=ini-(yen.distance[i]+snuke.distance[i]);
	}
	vl ans(n);
	ans[n-1]=cost[n-1];
	for(int i=n-2;i>=0;i--){
	    ans[i]=max(ans[i+1],cost[i]);
	}
	cout<<ans;
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    int i;
    long long ans=0;
    for(i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0)
            ans += i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
int main() {
	vector<string> v(3);
	int pos = 0,tmp;
	cin >> v[0]>>v[1]>>v[2];
	while(1){
		if (v[pos].size() < 1) {
			cout << (char)(pos + 'A') << endl;
			return 0;
		}
		tmp = (v[pos][0])-'a';
		v[pos].erase(0,1);
		pos = tmp;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int seconds;
    int h,m,s;
    scanf("%d",&seconds);
    h=seconds/3600;
    m=(seconds-(h*3600))/60;
    s=seconds-((h*3600)+(m*60));
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2100
N=int(input())
import math
x=[0]*N
y=[0]*N
sum = 0.0
for i in range(N):
    x[i],y[i]=map(int, input().split())
for i in range(N):
    for j in range(N):
        sum = sum + math.sqrt(pow((x[i]-x[j]),2)+pow((y[i]-y[j]),2))
        #print(x[i],y[i],x[j],y[j],sum)
print(sum/N)


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

class Baseball {
	private:
		int out;
		int runner;
		int point;
		
	public:
		Baseball(){
			out = 0;
			runner = 0;
			point = 0;
		}
		
		int getOut(){
			return out;
		}
		void addOut(){
			++out;
		}
		
		void hit(){
			++runner;
			if(runner == 4){
				++point;
				--runner;
			}
		}
		void homerun(){
			point += runner + 1;
			runner = 0;
		}
		
		int getRunner(){
			return runner;
		}
		
		int getPoint(){
			return point;
		}
};

int main(){
	int inning;
	std::cin >> inning;
	
	for(int i=0; i<inning; ++i){
		Baseball bs;
		
		while(bs.getOut() < 3){
			std::string str;
			std::cin >> str;
			
			if(str == "HIT"){
				bs.hit();
			}
			if(str == "HOMERUN"){
				bs.homerun();
			}
			if(str == "OUT"){
				bs.addOut();
			}
		}
		std::cout << bs.getPoint() << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define ll long long
#define INF 1<<30
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  ll lc[N]={},rc[N]={},a=1,b=1;

//  for (int i=0;i<N;i++) {lc[i]=INF;rc[i]=INF;}
  for (int i=0;i<N;i++){
    ll t;
    cin>>t;
    if (t<0) {lc[a]=abs(t);a++;}
    else {rc[b]=abs(t);b++;}
  }
    for(ll i=1;2*i<a;i++){
//      cout<<lc[i]<<","<<lc[a-i]<<endl;

      ll tmp=lc[i];
      lc[i]=lc[a-i];
      lc[a-i]=tmp;
  //    cout<<lc[i]<<","<<lc[a-i]<<endl;

    }
    //cout<<a<<","<<b<<endl;
    //for(int i=0;i<a;i++)cout<<lc[i]<<endl;
    //cout<<endl;
    //for(int i=0;i<b;i++)cout<<rc[i]<<endl;
    ll only_left;
    if (K<a) only_left=lc[K];else only_left=INF;

    ll only_right;
    if (K<b) only_right=rc[K];else only_right=INF;

    ll left_right=INF;
    for (int i=1;i<K;i++){
      if (i>=a or K-i>=b)continue;
      left_right=min(left_right,lc[i]+lc[i]+rc[K-i]);
    }

    ll right_left=INF;
    for (int i=1;i<K;i++){
      if (i>=b or K-i>=a)continue;
      right_left=min(right_left,rc[i]+rc[i]+lc[K-i]);
    }
    //cout<<only_left<<endl;
    //cout<<only_right<<endl;
    //cout<<right_left<<endl;
    //cout<<left_right<<endl;
    cout<<min({only_left,only_right,right_left,left_right})<<endl;


  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef pair <int, int> PII;
typedef pair <PII, PII> PPP;
typedef vector <PPP> VPPP;
typedef vector <int> VI;

int main() {
    int n;
    while ( cin >> n && n ) {
        VPPP L(n);
        VI H(1000,0);
        for ( int i = 0; i < n; ++ i ) {
            cin >> L[i].second.first >> L[i].second.second;
            cin >> L[i].first.first >> L[i].first.second;
            L[i].second.first = 1000 - L[i].second.first;
            L[i].second.second = 1000 - L[i].second.second;
            L[i].first.second = 100000 - L[i].first.second;
        }
        sort( L.rbegin(), L.rend() );
        int cnt = 0;
        for ( int i = 0; i < n; ++ i ) {
            int ID = 1000 - L[i].second.first;
            int AF = 1000 - L[i].second.second;
            bool flag = false;
            if ( cnt < 10 ) {
                if ( H[AF] < 3 ) {
                    cnt ++;
                    H[AF] ++;
                    flag = true;
                }
            } else if ( cnt < 20 ) {
                if ( H[AF] < 2 ) {
                    cnt ++;
                    H[AF] ++;
                    flag = true;
                }
            } else if ( cnt < 26 ) {
                if ( H[AF] < 1 ) {
                    cnt ++;
                    H[AF] ++;
                    flag = true;
                }
            }
            if ( flag ) cout << ID << endl;
        }
    }
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  cin >> S >> T;
  int len = S.length();
  int num = 0;
  for (int i = 0;i < len;i++) {
    if (S.at(i) != T.at(i)) {
      num++;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 3912
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;



     cin>>n;

     for(i=0; i<n; i++)
     {
         cin>>a;

         cnt=max(cnt,a);

         ans+=a;
     }

     ans-=cnt;

     if(cnt<ans)
        cout<<"Yes"<<endl;

     else cout<<"No"<<endl;





}



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

void solve(string S)
{
    if (S.at(S.size() - 1) == 's')
    {
        cout << S << "es" << endl;
    }
    else
    {
        cout << S << "s" << endl;
    }
}

int main()
{
    string S;
    cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<cmath>
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;

int main()
{
    fastio;
    long double a;
    long double b;
    ull c;
    cin>>a>>b;
    c=a*b;
    cout<<c<<endl;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    while (1) {
        int N;
        cin >> N;
        if (N == 0) break;
        vector<int> imos(86402, 0);
        rep(i, N) {
            int fh, fm, fs, th, tm, ts;
            scanf("%d:%d:%d %d:%d:%d", &fh, &fm, &fs, &th, &tm, &ts);
            int secf = fh * 3600 + fm * 60 + fs;
            int sect = th * 3600 + tm * 60 + ts;
            imos[secf]++; imos[sect]--;
        }

        repd(i, 1, imos.size()) {
            imos[i] += imos[i - 1];
        }

        int res = 0;
        rep(i, imos.size()) {
            chmax(res, imos[i]);
        }

        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3456
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	long INF = Long.MAX_VALUE >> 1;

	
	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		List<int[]> edges = new ArrayList<>();
		for (int i = 0; i < M; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			edges.add(new int[] { a, b, -c }); // 最短経路問題として解くために符号を反転する
		}

		sc.close();

		// gについて、1からNへの最短経路を求めれば、それ（の符号を反転したもの）が解

		// 1からのコスト
		long[] d = new long[N + 1];
		Arrays.fill(d, INF);

		d[1] = 0; // 始点

		// 負の閉路を経由して更新されたか
		boolean[] negative = new boolean[N+1];
		Arrays.fill(negative, false);

		// ベルマンフォード法
		for (int i = 0; i < N; i++) {
			for (int[] edge : edges) {
				int from = edge[0];
				int to = edge[1];
				int cost = edge[2];

				if (d[from] == INF) {
					// fromが決まっていないので計算できない
					continue;
				}

				if (d[to] > cost + d[from]) { // fromを経由したほうがcostが小さければ更新する
					d[to] = cost + d[from];

					if (i == N - 1) {
						// iのループ1回につき、少なくとも1つの頂点が決まる
						// 始点はコスト0で最初から決まっているので、N-1回のループですべての頂点についてきまるはず
						// にもかかわらず、N回目のループ（i==N-1）でも更新がある場合は、グラフに負の閉路がある場合
						negative[to] = true;
					}
				}

			}
		}
		
		
		// グラフ中に負の閉路があったとしても、そこを通ってNに到達できなければスコアを無限大にはできない。
		
		// 負の閉路を経由して到達可能なノードをすべて negative == true にする
		for(int i=1;i<=N;i++) {
			if(negative[i]) {
				for(int[] edge:edges) {
					if(edge[0] == i) {
						negative[edge[1]] = true;
					}
				}
			}
		}

		
		
		if (negative[N]) {
			out.println("inf");
		} else {
			out.println(-d[N]);
		}

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 28220
#include <stdio.h>

int main(void){
	int P,Q,R;
	int sum=0;
	int a=0;
	scanf("%d %d %d",&P,&Q,&R);
	if(a<P)a=P;
	if(a<Q)a=Q;
	if(a<R)a=R;
	printf("%d\n",P+Q+R-a );
}

Measured memory_bytes: 128
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int H,W;
        while(true){
            H = sc.nextInt();
            W = sc.nextInt();
            if(H == 0 && W == 0){
                break;
            }
            else{
                for(int i = 0; i < H; i++){
                    for(int n = 0; n < W; n++){
                        if(i == 0 || i == H - 1){
                            if(i == H - 1 && n == W - 1){
                            System.out.println("#\n");
                            }
                            else if(n == W - 1){
                                System.out.print("#\n");
                            }
                            else{
                                System.out.print("#");
                            }
                        }else{
                        if(i == H - 1 && n == W - 1){
                            System.out.println("#\n");
                        }
                        else if(n == 0){
                            System.out.print("#");
                        }
                        else if(n == W - 1){
                            System.out.print("#\n");
                        }
                        else{
                            System.out.print(".");
                        }
                        }
                    }
                }
            }
        }
    }
}



Measured memory_bytes: 34124
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
c = Counter(a).most_common()

if len(c) == 3 and c[0][1] == c[1][1] == c[2][1]:
    x = c[0][0]
    y = c[1][0]
    z = c[2][0]
    if x^y^z == 0:
        ans = "Yes"
    else:
        ans = "No"
elif len(c) == 2 and c[0][1] == 2*c[1][1]:
    x = c[0][0]
    y = c[1][0]
    if x^x^y == 0:
        ans = "Yes"
    else:
        ans = "No"
elif len(c) == 1 and c[0][0] == 0:
    ans = "Yes"
else:
    ans = "No"

print(ans)

Measured memory_bytes: 22464
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int A , B , K;
    cin >> A >> B >> K;
    for(int i = A; i <= min(B , A + K - 1); i++){
        cout << i << endl;
    }
    for(int i = max(A + K , B - K + 1); i <= B; i++){
        cout << i << endl;
    }
}

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

int main()
{
    string A, B, C;
    cin >> A >> B >> C;
    if(A[A.size()-1] == B[0] && B[B.size()-1] == C[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

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

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> A(N + 1), B(N);
    for(int i = 0; i < N + 1; i++) cin >> A.at(i);
    for(int i = 0; i < N; i++) cin >> B.at(i);

    int64_t ans = 0;
    for(int i = 0; i < N; i++){
        if(A.at(i) < B.at(i)){
            ans += A.at(i);
            B.at(i) -= A.at(i);
            A.at(i) = 0;
            if(A.at(i + 1) < B.at(i)){
                ans += A.at(i + 1);
                B.at(i) -= A.at(i + 1);
                A.at(i + 1) = 0;
            }else{
                ans += B.at(i);
                A.at(i + 1) -= B.at(i);
                B.at(i) = 0;
            }
        }else{
            ans += B.at(i);
            A.at(i) -= B.at(i);
            B.at(i) = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;
using pint = pair<int, int>;

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 main()
{
  int d;
  cin >> d;
  int c[30] = {}, last[30] = {}, s[400][30] = {}, v = 0, ans[400] = {};
  rep(i, 26)
          cin >>
      c[i];

  rep(i, d) rep(j, 26)
          cin >>
      s[i][j];

  rep(i, 26)
      last[i] = 0;

  rep(i, d)
  {
    int vinit = v;
    int vmax = v;
    rep(k, 26)
    {
      v += s[i][k];
      int lastk = last[k];
      last[k] = i + 1;

      rep(j, 26)
      {
        if (j == k)
          continue;
        v -= c[j] * (i + 1 - last[j]);
      }

      if (vmax < v)
      {
        vmax = v;
        ans[i] = k;
      }
      v = vinit;
      last[k] = lastk;
    }
    v = vmax;
    last[ans[i]] = i + 1;
  }

  rep(i, d)
  {
    cout << ans[i] + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
int n,K,m;
ll f[305][305],c[605][605];
int main(){
	scanf("%d%d%d",&n,&K,&m);
	n++;
	const int mod=m;
	for(int i=0;i<=602;i++){
		c[i][0]=1;
		for(int p=1;p<=i;p++) c[i][p]=(c[i-1][p]+c[i-1][p-1])%mod;
	}
	for(int i=1;i<=K;i++) f[0][i]=1;
	for(int i=1;i<=n;i++){
		f[i][1]=1;
		for(int p=2;p<=K;p++){
			for(int j=1;j<=i;j++) f[i][p]=(f[i][p]+f[j][p-1]*c[i-1][j-1]%mod*f[i-j][p])%mod;
		}
	}
	printf("%lld",f[n][K]);
	return 0;
}

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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Edge{
	int src,dst,weight;
	Edge(){}
	Edge(int s,int d,int w):src(s),dst(d),weight(w){}
};
typedef vector<vector<Edge>> Graph;
bool operator<(const Edge& a,const Edge& b){return a.weight<b.weight;}
bool operator>(const Edge& a,const Edge& b){return a.weight>b.weight;}

void Dijkstra(const Graph& g,int v,vi& dist)
{
	priority_queue<Edge,vector<Edge>,greater<Edge>> pq;
	pq.emplace(-1,v,0);
	while(pq.size()){
		Edge cur=pq.top(); pq.pop();
		if(dist[cur.dst]!=INF) continue;
		dist[cur.dst]=cur.weight;
		for(Edge e:g[cur.dst])
			pq.emplace(e.src,e.dst,cur.weight+e.weight);
	}
}

int main()
{
	for(int r,m,cap;cin>>r>>m>>cap && r|m|cap;){
		cap*=10;
		map<string,int> f;
		string src,dst; cin>>src>>dst;
		f[src]=0,f[dst]=1;
		Graph g(2);
		rep(i,r){
			string s,t; int w; cin>>s>>t>>w;
			if(!f.count(s)) f.insert(mp(s,f.size())),g.resize(g.size()+1);
			if(!f.count(t)) f.insert(mp(t,f.size())),g.resize(g.size()+1);
			int u=f[s],v=f[t];
			g[u].emplace_back(u,v,w);
			g[v].emplace_back(v,u,w);
		}
		int n=f.size();
		
		vi lpg(m);
		rep(i,m){
			string s; cin>>s;
			lpg[i]=f[s];
		}
		
		vvi dists(m+2,vi(n,INF));
		rep(i,m) Dijkstra(g,lpg[i],dists[i]);
		rep(i,2) Dijkstra(g,i,dists[m+i]);
		
		vvi dp(m+2,vi(m+2,INF));
		rep(i,m+2){
			rep(j,m) if(dists[i][lpg[j]]<=cap)
				dp[i][j]=dists[i][lpg[j]];
			rep(j,2) if(dists[i][j]<=cap)
				dp[i][m+j]=dists[i][j];
		}
		
		rep(k,m+2) rep(i,m+2) rep(j,m+2)
			dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
		
		if(dp[m][m+1]==INF)
			cout<<-1<<endl;
		else
			cout<<dp[m][m+1]<<endl;
	}
}

Measured memory_bytes: 5668
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

#[allow(non_snake_case)]
fn main() {
    input! {
        A:usize,
        B:usize,
        N:usize,
    }
    let ans;
    if N >= B {
        ans = A * (B - 1) / B - A * ((B - 1) / B);
    } else {
        ans = A * N / B - A * (N / B);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2152
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    H, W = [int(x) for x in input().split()]
    S = [list(input().strip()) for _ in range(H)]

    dp = [[10 ** 9] * W for j in range(H)]

    if S[0][0] == '#':
        dp[0][0] = 1
    else:
        dp[0][0] = 0

    for j in range(H):
        for i in range(W):
            if j != H - 1:
                x = 1 if S[j + 1][i] == '#' and S[j][i] == '.' else 0
                dp[j + 1][i] = min(dp[j + 1][i], dp[j][i] + x)
            if i != W - 1:
                x = 1 if S[j][i + 1] == '#' and S[j][i] == '.' else 0
                dp[j][i + 1] = min(dp[j][i + 1], dp[j][i] + x)

    print(dp[-1][-1])


if __name__ == '__main__':
    main()


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

int main() {
    int n, h, w;
    cin >> n >> h >> w;
    int ans = 0;
    rep(i,n){
        int a, b;
        cin >> a >> b;
        if (h <= a && w <= b) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int n;
  cin >> n;
  map<int, bool> mp;
  REP(i,n){
    int a;
    cin >> a;
    if(mp[a]) mp[a] = false;
    else mp[a] = true;
    }

  int cnt = 0;
  for(auto x: mp){
    if(x.second) cnt++;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 8140
N,M=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(N)]
a=sorted(A, key=lambda x:x[0])
cst=0
for t in range(N):
    if a[t][1]>=M:
        cst+=(M*a[t][0])
        break
    else:
        cst+=(a[t][1]*a[t][0])
        M-=a[t][1]
print(cst)

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

using namespace std;

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

int main(){
    while(1){
        int a,b;
        cin >> a >> b;
        if(a == 0 && b == 0)return 0;

        rep(i,a){
            rep(j,b)cout << "#";
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int H,W,A,B;
  cin >> H >> W >> A >> B;
  COMinit();
  long long ans=0;
  for (int i=0;i<W-B;i++){
    ans=(ans+COM(H-A+B+i-1,B+i)*COM(W+A-B-i-2,A-1)%MOD)%MOD;
  }
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))

int main() {
    string s;
    cin >> s;
    ll n = s.size();
    if(s[n-1] == '2' || s[n-1] == '4' || s[n-1] == '5'|| s[n-1] == '7' || s[n-1] == '9') {
        cout << "hon" << endl;
    }
    else if(s[n-1] == '0' || s[n-1] == '1' || s[n-1] == '6'|| s[n-1] == '8') {
        cout << "pon" << endl;
    }
    else {
        cout << "bon" << endl;
    }
    return 0;
}


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

int main(void)
{
  int S, h, m, s;

  cin >> S;
  h = S / 3600;
  m = (S % 3600) / 60;
  s = (S % 3600) % 60;
  cout << h << ":" << m << ":" << s << endl;
}

Measured memory_bytes: 1164
#include <iostream>

using namespace std;

int main(void) {
  int N, a;
  cin >> N;

  a = N % 10;
  if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9) {
    cout << "hon" << endl;
  }else if(a == 0 || a == 1 || a == 6 || a == 8){
    cout << "pon" << endl;
  }else{
    cout << "bon" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
input = gets.split(" ")
m = input[1].to_i
arr_tokuhyousuu = gets.split(" ").map(&:to_i)
soutouhyousuu = arr_tokuhyousuu.sum

cnt_select = 0

arr_tokuhyousuu.each do |tokuhyousuu|
  if tokuhyousuu >= soutouhyousuu*1.0/(4*m)
    cnt_select += 1
  end
end

if cnt_select >= m
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14336
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
int a,b,c,d,e;
cin>>a>>b>>c>>d>>e;

    if( a<40)a=40;

	if( b<40)b=40;

    if( c<40)c=40;

    if( d<40)d=40;

	if( e<40)e=40;
	cout<<(a+b+c+d+e)/5<<endl;
}

Measured memory_bytes: 3120
#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;

int main(){
  int H,W;
  cin >> H >> W;
  int h,w;
  cin >> h >> w;
  cout << (H-h)*(W-w) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
a,b,c,k=list(map(int,input().split()))
li=[[1,0,-1],[a,b,c]]
ans=0
for i,l in enumerate(li[1]):
  if k < l:
    ans += li[0][i]*k
    break
  ans += li[0][i]*l
  k -= l
  
print(ans)

Measured memory_bytes: 9196
A,B,C,K =map(int,input().split())

sum =0 

flg = False

if K-A > 0:
    sum+= A
    K = K- A
else:
    sum += K
    flg = True

    
if flg ==False:
    if K-B > 0:
        K= K-B
    else:
        flg = True
        
if flg ==False:
    if K-C >0:
        sum = sum - C
    else:
        sum = sum - K
        
        
print(sum)

Measured memory_bytes: 9224
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

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

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  int n;
  cin >> n;
  ll pcost = 0, ncost = 0;
  ll pdif = 0, ndif = 0;

  REP(i, n) {
    ll a;
    cin >> a;
    ll pa = a + pdif, na = a + ndif;
    if (i % 2 == 0) {
      pcost += max(1 - pa, 0LL);
      ncost += max(na + 1, 0LL);
      pdif = pa + max(1 - pa, 0LL);
      ndif = na - max(na + 1, 0LL);
    } else {
      pcost += max(pa + 1, 0LL);
      ncost += max(1 - na, 0LL);
      pdif = pa - max(pa + 1, 0LL);
      ndif = na + max(1 - na, 0LL);
    }
  }

  cout << min(pcost, ncost) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <functional>
#include <cassert>

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

using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;

int main() {
    char a[500][501];
    int h, w;
    cin >> h >> w;

    REP(i,h) scanf("%s", a[i]);
    REP(i,h){
        REP(j,w){
            cout << (j==0 || (j != w-1 && i%2==0) ? '#' : a[i][j]);
        }
        cout << endl;
    }
    cout << endl;
    REP(i,h){
        REP(j,w){
            cout << (j==w-1 || (j != 0 && i%2==1) ? '#' : a[i][j]);
        }
        cout << endl;
    }
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int main(void)
{
  char a[100];
  char b[] = "ABC";
  char c[] = "ARC";
  scanf("%s",&a);
  if(strcmp(a,b)==0)
  {
    printf("ARC");
  }
  if(strcmp(a,c)==0)
  {
    printf("ABC");
  }
  return 0;
}

Measured memory_bytes: 1676
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
using namespace std;

const int N = 1e5+7;

int n, s, ans;

int x[N];
int sub[1<<15];
int dp[1<<15];

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

	cin >> n;

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

	for(int i = 1; i <= n; ++i)
	{
		if(!x[i])
			++ans;
		else 
		{
			s ^= 1<<x[i];

			if((s&(1<<x[i]))==0)
				++ans;
		}
	}

	for(int i = 0; i < 1<<15; ++i)
	{
		for(int j = 0; j < 15; ++j)
		{
			if(i&(1<<j))
				sub[i] ^= j+1;
		}

		dp[i] = -inf;
	}

	dp[0] = 0;

	for(int i = 1; i < 1<<15; ++i)
	{
		for(int j = i; j > 0; j = (j-1)&i)
		{
			if(!sub[j])
				dp[i] = max(dp[i], dp[i^j]+1);
		}
	}

	cout << n-ans-dp[s>>1];
}

Measured memory_bytes: 896
N,K = map(int,input().split())
z = [0]*N
for i in range(N):
    x,y = map(int,input().split())
    z[i] = (x,y)
z.sort(key=lambda x:x[1])
H = z[N-1][1]-z[0][1]
z.sort()
W = z[N-1][0]-z[0][0]
ans = H*W
for i in range(N-K+1):
    for j in range(i+K-1,N):
        z_ = z[i:j+1].copy()
        W = z_[-1][0]-z_[0][0]
        z_.sort(key=lambda x:x[1])
        for k in range(len(z_)-K+1):
            H = z_[k+K-1][1]-z_[k][1]
            if H*W < ans:
                ans = H*W
print(ans)

Measured memory_bytes: 3064
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let s: Vec<u32> = read_vec();
    let k = s[0];
    let x = s[1];

    if k * 500 >= x {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)
#define SORT(a) sort(ALL(a))
#define VSORT(a, type) sort(ALL(a),greater<type>())
#define MAPIN(a,i,j) (a).insert(make_pair(i,j))

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef unsigned long long lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > Matrix;

vll a,lg,rg;
ll n;

ll gcd(ll a,ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
ll leftgcd(ll i){
    if(i==0)return 0;
    else{
        if(lg[i-1]==0)lg[i-1]=leftgcd(i-1);
        return gcd(max(lg[i-1],a[i-1]),min(lg[i-1],a[i-1]));
    } 
}
ll rightgcd(ll i){
    if(i==n)return 0;
    else{
        if(rg[i+1]==0)rg[i+1]=rightgcd(i+1);
        return gcd(max(rg[i+1],a[i]),min(rg[i+1],a[i]));
    }
}

int main() {
    ll i,j,k,m,x,y;

    cin>>n;
    SIZE(a,n);
    SIZE(lg,n);
    SIZE(rg,n+1);

    rep(i,n){
        cin>>a[i];
    }
    rg[n]=0;
    k=0;
    rep(i,n){
        x=leftgcd(i);
        y=rightgcd(i+1);
        m=gcd(max(x,y),min(x,y));
        k=max(k,m);
    }
    cout<<k;
	
	return 0;
}


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

int main(){
	string s,t;
	cin >> s >> t;
	int len = s.size();
    string u = s;
	rep(i,len){
		u = u[len-1] + u;
		u.erase(len);
		if(u == t){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

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

using namespace std;

//0繰り上がりなし, 1繰り上がりあり
//long long dp[1000][2];
long long dp[1000100][2];
const long long INF = 1LL << 61;

int main(){
    string money = "0";
    string s;
    cin >> s;

    money += s;

    long long n = money.size();
    long long ans = 0;

    //init
    for(int i=0; i< 1000100; ++i){
        for(int j=0; j<2; ++j){
            dp[i][j] = INF;
        }
    }

    //後ろから数える
    int first = money[n-1] - '0';
    dp[n-1][0] = first;
    dp[n-1][1] = 10 - first;


    for(long long  i=n-2; i >= 0; --i){

        int num = money[i] - '0';
        // if(num == 9){

        //     //繰り上がりあり
        //     dp[i][1] = min(dp[i][1], dp[i+1][0] + (10 - num) );
        //     dp[i][1] = min( dp[i][1], dp[i+1][1] + (10 - (num+1) ) );
        // }else{
            //繰り上がりなし
            dp[i][0] = min(dp[i][0], dp[i+1][0] + num);
            dp[i][0] = min(dp[i][0], dp[i+1][1] + (num+1) );

            //繰り上がりあり
            dp[i][1] = min(dp[i][1], dp[i+1][0] + (10 - num) );
            dp[i][1] = min( dp[i][1], dp[i+1][1] + (10 - (num+1) ) );

        // }
    }

    cout << min(dp[1][0], dp[1][1]+1) << endl;
}

Measured memory_bytes: 20788
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  ll n,k;
  cin >> n >> k;
  ll a[n];
  ll b[n];
  rep(i,n)cin >> a[i] >> b[i];
  ll ans=0;
  ll u=0;
  rep(i,30){
    if(i==0)u=k;
    else if(k&(1<<i)){
      u=(k^(1<<i))|((1<<i)-1);
    }
    else continue;
    ll an=0;
    rep(j,n){
      if((u|a[j])==u)an+=b[j];
    }
    ans=max(ans,an);
  }
  cout << ans << endl;
}


Measured memory_bytes: 5200
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define see(x) cout<<#x<<" : "<<(x)<<endl;
typedef long long ll;
using namespace std;

const int N=10000009;
ll divv[N];

int main()
{
    ll n,i,j;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
        for(j=i;j<=n;j+=i)
            divv[j]++;
    for(i=1;i<=n+1;i++)
    {
        divv[i]=divv[i]*i;
        divv[i]+=divv[i-1];
    }
    cout<<divv[n]<<endl;
    return 0;
}


Measured memory_bytes: 81900