akhauriyash/Code-Regression huggingface dataset:
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define int long long
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define deb(x) cout<<#x<<" "<<x<<endl;
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 2e6 + 7;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    int v[MAX];
    int sum;
    void solve()
    {
        cin>>n>>k;
        fo(i,0,n)
        {
            cin>>v[i];
        }
        sort(v,v+n);
        fo(i,0,n-k)
        {
            sum+=v[i];
        }
        cout<<sum<<endl;

    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //

    int32_t main() 
      {
        
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        
        // cin>>t;while(t--)
        solve();
        
      return 0;
      }

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

int main() {
  int n;
  cin>>n;
 bool ans=true;
  rep(i,n){
    int a;
    cin>>a;
    if(a%2==0){
      if(a%3!=0 && a%5!=0){ans=false;
      break;}
    }

  }
  
  if(ans)cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
}
  
 

Measured memory_bytes: 256
#![allow(dead_code)]
use std::io;

fn main() {
    solve_b();
}

fn solve_b() {
    loop {
        let mut deck = String::new();
        io::stdin().read_line(&mut deck).unwrap();
        if deck.trim() == "-" {
            break;
        }
        let mut deck = deck.trim().to_string();

        let mut m = String::new();
        io::stdin().read_line(&mut m).unwrap();
        let m: u32 = m.trim().parse::<u32>().unwrap();
        for _i in 0..m {
            let mut h = String::new();
            io::stdin().read_line(&mut h).unwrap();
            let h: usize = h.trim().parse::<usize>().unwrap();

            let ws = deck.clone();
            let (first, last) = ws.split_at(h);
            deck = last.to_string() + first;
        }
        println!("{}", deck);
    }
}



Measured memory_bytes: 5028
X1,X2,X3,X4,X5 = map(int,input().split())

if X1 == 0:
  print(1)
elif X2 == 0:
  print(2)
elif X3 == 0:
  print(3)
elif X4 == 0:
  print(4)
elif X5 == 0:
  print(5)

Measured memory_bytes: 9172
// Comparing Strings
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    std::string str;
    int a,b;
    cin >> a >> b;
    vector<string> A(2);
    for(int i=0; i<b; i++){
        str=std::to_string(a);
        A[0]+=str;
    }
    for(int i=0; i<a; i++){
        str=std::to_string(b);
        A[1]+=str;
    }
    sort(A.begin(), A.end());
    cout << A[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int lli;

struct UnionFindTree{
    vector<int> v;
    vector<int> rank;
    
    UnionFindTree(int n): v(n, -1), rank(n, 0){}
    int Find(int x){
        if(v[x] < 0) return x;
        return v[x] = Find(v[x]);
    }
    void Union(int a, int b){
        a = Find(a);
        b = Find(b);
        if(a == b) return;
        if(rank[a] < rank[b]) swap(a, b);
        if(rank[a] == rank[b]) rank[a]++;
        v[b] = a;
    }
};

lli solve(vector<int> &c, vector<vector<int> > &adj){
	int n = c.size();
	//unite nodes that must be equal
	UnionFindTree uft(n);
	for(int i=0; i<n; i++){
		map<int, vector<int> > ctoi;
		for(int j: adj[i]){
			ctoi[c[j]].push_back(j);
		}
		for(auto itr: ctoi){
			vector<int> &a = itr.second;
			for(int j=0; j<(int)a.size()-1; j++){
				if(c[a[j]] == c[a[j+1]]) uft.Union(a[j], a[j+1]);
			}
		}
	}
	
	map<int, set<int> > tmp;
	for(int i=0; i<n; i++){
		tmp[uft.Find(i)].insert(i);
	}
	map<int, set<int> > eq;//
	for(auto itr : tmp){
		set<int> &a = itr.second;
		if((int)a.size() <= 1) continue;
		eq[*max_element(a.begin(), a.end())] = a;
	}
	vector<pair<int, int> > con(n);//
	for(int i=0; i<n; i++){
		con[i] = make_pair(c[i], i);
	}
	sort(con.begin(), con.end());
	
	//calc saraly
	vector<int> salary(n);
	vector<int> slast(n, 0), clast(n, 0);
	for(int i=0; i<n; i++){
		int node = con[i].second;
		int s = 1;
		for(int j: adj[node]){
			if(clast[j] < c[node]){
				s = max(s, slast[j] +1);
			}else{
				s = max(s, slast[j]);
			}
		}
		for(int j: adj[node]){
			slast[j] = s;
			clast[j] = c[node];
		}
		salary[node] = s;
		
		//propagation
		if(eq.count(node) != 0){
			int s = 1;
			for(int j: eq[node]){
				s = max(s, salary[j]);
			}
			for(int j: eq[node]){
				salary[j] = s;
				for(int k: adj[j]){
					slast[k] = s;
				}
			}
		}
	}
	
	lli ret = 0;
	for(int i=0; i<n; i++){
		ret += salary[i];
	}
	return ret;
}

int main(){
	int n;
	cin >> n;
	vector<int> c(n);
	for(int i=0; i<n; i++){
		cin >> c[i];
	}
	
	int m;
	cin >> m;
	vector<vector<int> > adj(n);
	for(int i=0; i<m; i++){
		int a,b;
		cin >> a >> b;
		a--; b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for(int i=0; i<n; i++){
		adj[i].push_back(i);
	}
	
	cout << solve(c, adj) << endl;
	return 0;
}



Measured memory_bytes: 27660
def main():
    inputs = list(map(int, input().split()))

    max_value = max(inputs)
    max_i = inputs.index(max_value)

    ct = 0
    total = 0
    for input_i in inputs:
        if input_i == max_value:
            continue
            
        total += int((max_value - input_i)/2)
        if (max_value - input_i) % 2:
            ct += 1
        
    
    if ct == 0:
        ans = total
    elif ct == 1:
        ans = total + 2
    elif ct == 2:
        ans= total + 1
    
    print(ans)


main()


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

vector<ll> inv,fact,invfact;
void mod_build(int n=101010){
    fact.resize(n+1);
    inv.resize(n+1);
    invfact.resize(n+1);
    fact[0]=inv[0]=invfact[0]=1;
    inv[1]=1;
    rep(i,n){
        fact[i+1]=fact[i]*(i+1)%mod;
        if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
        invfact[i+1]=invfact[i]*inv[i+1]%mod;
    }
}
ll perm(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
    k%=mod-1;
    if(k<0)k+=mod-1;
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int m=s.size();
    ll ans=0;
    mod_build(n+m);
    REP(i,m,n+m+1){
        ans += comb(n+m,i)*powmod(25,n+m-i)%mod;
    }
    cout<<ans%mod<<endl;
    return 0;
}

Measured memory_bytes: 51188
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n, m; cin >> n >> m;
  vector<ll> t(m);
  vector<vector<pair<ll,ll>>> v(n);
  rep(i, m){
    ll a, b; cin >> a >> b;
    a--;
    t[i] = a;
    v[a].emplace_back(pair<ll,ll>(b, i));
  }
  vector<ll> ans(m, 0);
  rep(i, n){
    sort(v[i].begin(), v[i].end());
    for(int j = 0; j < v[i].size(); j++){
      ans[v[i][j].second] = j+1;
    }
  }
  for(int i = 0; i < m; i++){
    printf("%06d", t[i]+1);
    printf("%06d\n", ans[i]);
  }
  system("pause");
}


Measured memory_bytes: 8704
// Justice will be served
// شهید حاج قاسم سلیمانی

#include<bits/stdc++.h>
using namespace std ;

int main() {
  int a ;
  string s ;
  cin >> a >> s ;
  if (a >= 3200)
    cout << s ;
  else
    cout << "red" ;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;
const ll INF = 1LL << 60;
using namespace std;

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

  int N, M; cin >> N >> M;
  vector<pair<int, int> > vec(N);
  rep(i, N) cin >> vec[i].first >> vec[i].second;
  sort(vec.begin(), vec.end());

  ll ans = 0, sum = 0;
  rep(i, N) {
      ll buy = min(M, vec[i].second);
      ans += buy*vec[i].first;
      M -= buy;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
 
 
void get(char &x){
	if(x == '1') x = '0';
	else x = '1';
}
vector<int> g[N];
int used[N];
int dp[N];
void solve()
{
	int n;
	cin >> n;
	int a[n + 1];
	for(int i = 2; i <= n; ++i){
		cin >> a[i];
		dp[a[i]]++;
	}
	for(int i = 1; i <= n; ++i){
		cout << dp[i] << '\n';
	}
}
 
 
 
 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
 
}

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

#define P 100

int main(void){
  int deg[P+1];
  int a,b;
  
  for (int i=0; i<=P; i++) deg[i]=0;
  while (cin >> a >> b){
    if (a==0 && b==0){
      int ans=1;
      if (deg[1]%2==0 || deg[2]%2==0) ans = 0;
      for (int i=3; i<=100; i++){
        if (deg[i]%2==1) ans = 0;
      }
      cout << (ans?"OK":"NG") << endl;
      // reset
      for (int i=0; i<=P; i++) deg[i]=0;
    } else {
      deg[a]++;
      deg[b]++;
    }
  }
  return 0;
}


Measured memory_bytes: 3088
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

PII solve(int x, int y) {
	int a1, a2 = 0;
	if (x < y)swap(x, y);

	while (y != 0) {
		x = x % y;
		swap(x, y);
		a2++;
	}
	a1 = x;

	return mp(a1, a2);
}

int main() {
	while (true) {
		int x, y; cin >> x >> y;
		if (x == 0 && y == 0)break;

		PII a = solve(x, y);
		Cout2(a.first, a.second);
	}
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,c,sum=0;
  string s;
  cin>>a>>b>>c;
  if(c-(a-b)<0) cout<<0<<'\n';
  else cout<<c-(a-b)<<'\n';
  return 0;
}


Measured memory_bytes: 256
n,x=map(int, input().split())
a=list(map(int, input().split()))
b=a[:]
ans=float('inf')
for i in range(n):
    for j in range(n):
        b[j]=min(b[j],a[j-i])
    ans=min(ans,sum(b)+x*i)
print(ans)

Measured memory_bytes: 3188
n = int(input())
ans,i = "",0
if n==0: ans = "0"
while n!=0:
	if i%2==0:
		if n%2==0: ans,n = "0"+ans,n//2
		else: ans,n = "1"+ans,(n-1)//2
	else:
		if n%2==0: ans,n = "0"+ans,n//2
		else: ans,n = "1"+ans,(n+1)//2
	i+=1
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        String p = sc.next();
        
        s += s;
        
        if(s.indexOf(p) != -1){
        	System.out.println("Yes");
        }
        else{
        	System.out.println("No");
        }
    }
}



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

int N, A, B, C;
int* l;
int INF = 10000000;

int dfs(int num, int a, int b, int c) {

    if (num == N) {
        if (min(a, min(b, c)) > 0) {
            return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        }
        else return INF;
    }
    int ret0 = dfs(num + 1, a, b, c);
    int ret1 = dfs(num + 1, a + l[num], b, c) + 10;
    int ret2 = dfs(num + 1, a, b + l[num], c) + 10;
    int ret3 = dfs(num + 1, a, b, c + l[num]) + 10;
    
    return min(ret0, min(ret1, min(ret2, ret3)));
    
}

int main() {

    cin >> N >> A >> B >> C;
    //vector<int> l(N);
    l = (int*)malloc(sizeof(int)*N);
    for (int i=0; i<N; i++) {
        cin >> l[i];
    }
    
    cout << dfs(0, 0, 0, 0) << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N;

  cin >>  N ;

  bool ans=false;

  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(i*j==N) ans=true;    
    }
  }

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

  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<iostream>
#include<algorithm>
#include <string.h>
#include<string>
using namespace std;
int main()
{	
	/*freopen("input.txt","r",stdin);*/
	int a,b,c;
	while (scanf("%d%d%d",&a,&b,&c)!=EOF)
	{
		if(b+b==a+c)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

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

int main() {
    int N, a[100], i;
    cin >> N;
    for (i=0;i<N;i++) cin >> a[i];
    float bo = 0;
    for (i=0;i<N;i++){
        bo += 1 / float(a[i]);
    }
    bo = 1 / bo;
    cout << bo << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int A=0,B=0;
	cin>>A>>B;
	if(A>B){
		cout<<A+A-1<<endl;
	}else if(A<B){
		cout<<B+B-1<<endl;
	}else if(A=B){
		cout<<A+B<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10e+6
#define DEKA 1000000007

using namespace std;

int main(){
    long n,m;
    cin >> n >>m;
    //通り
    long d[n+10];
    d[0]=0;d[1]=1;d[2]=2;
    for(int i=3;i<=n;i++){
        d[i]=d[i-1]+d[i-2];
        d[i]%=DEKA;
    }
    long a[n+10];a[0]=-1;a[m+1]=n+1;
    long ans=1;
    for (int i=1;i<=m+1;i++){
        cin >> a[i];
        long t=a[i]-a[i-1]-2;
        if(t==0) t=1;
        else if(t==-1) t=0;
        else if(t==-2) t=1;
        ans*=d[t];
        ans%=DEKA;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <queue>

typedef std::pair<int, int> value_type;

struct second_order {
    bool operator()(const value_type& x, const value_type& y) const {
        return x.second > y.second;
    }   
};

int main(void)
{

    int N=0, K=0;
    std::cin >> N >> K;

    std::map<int, int> A;
    int buf=0;
    for(int i=0; i<N; i++){
        std::cin >> buf;
        if(A.find(buf) == A.end()){
            A[buf] = 1;
        } else {
            A[buf]++;
        }   
    }   


    std::priority_queue<value_type, std::vector<value_type>, second_order> que;
    
    for(auto& vec : A){ 
        que.push(vec);
    }   

    int result = 0;
    while ( K++<A.size() && !que.empty() ) { 
        result += que.top().second;
        que.pop();
    }   

    std::cout << result << std::endl;

    return 0;
}

Measured memory_bytes: 11768
#include <climits>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (auto &v : vec)
    cin >> v;

  bool flag = true;
  int prev = INT_MAX;
  for (auto itr = vec.rbegin(); itr != vec.rend(); ++itr) {
    if (*itr <= prev)
      prev = *itr;
    else if (*itr - 1 == prev)
      prev = *itr - 1;
    else
      flag = false;
  }
  cout << (flag ? "Yes" : "No") << endl;
}

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

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

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

using namespace std;

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

//1-indexであることに注意
struct BIT {
    int n;
    vector<ll> data;

    BIT(int n) : n(n), data(n + 1, 0) {}
    
    ll sum(int i) {
        ll s = 0;
        while (i > 0) {
            s += data[i];
            i -= i & -i;
        }
        return s;
    }
    
    void add(int i, ll x) {
        while (i <= n) {
            data[i] += x;
            i += i & -i;
        }
    }
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll K;
	cin >> n >> K;
	vector<ll> a(n + 1);
	a[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] -= K;
	}

	for (int i = 1; i <= n; i++) a[i] += a[i - 1];
	vector<P> pp;
	for (int i = 0; i <= n; i++) {
		pp.emplace_back(a[i], i);
	}
	sort(pp.rbegin(), pp.rend());
	BIT b(n + 1);
	ll ans = 0;
	for (P& p : pp) {
		ans += b.sum(n + 1) - b.sum(p.second + 1);
		b.add(p.second + 1, 1);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    map<string,int> m;
    rep(i,n){
        string tmp;
        cin>>tmp;
        m[tmp]++;
    }
    int mx=0;
    for(auto itr=m.begin();itr!=m.end();++itr){
        if(itr->second>mx)mx = itr->second;
    }
    for(auto itr=m.begin();itr!=m.end();++itr){
        if(itr->second==mx) cout<< itr->first<<endl;
    }
    return 0;
}

Measured memory_bytes: 25216
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;

char s[1010];


int main()
{
	scanf("%d", &n);
	
	long long ans = n * n * n;
	printf("%lld\n", ans);
	
		
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
ll INF = (1LL << 50) - 1;
int MOD = 1e9+7;
main(){
    int N,C;
    cin >> N >> C;
    int D[C][C];
    rep(i,0,C)rep(j,0,C)cin >> D[i][j];
    ll arr[C][3];
    rep(i,0,C)rep(j,0,3)arr[i][j] = 0;
    rep(i,0,N)rep(j,0,N){
        int num;
        cin >> num;
        num--;
        rep(k,0,C){
            arr[k][(i+j)%3] += D[num][k];
        }
    }
    ll mini = INF;
    rep(i,0,C)rep(j,0,C)rep(k,0,C){
        if(i == j || i == k || j == k)continue;
        mini = min(mini, arr[i][0] + arr[j][1] + arr[k][2]);
    }
    cout << mini << endl;
}

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

const Int inf = 1LL<<55;

Int n;
Int p[111];
vector<Int> graph[111];

map<Int, Int> mp;

using Pi = pair<Int, Int>;

Pi val[111][222][222];
Int dp_min[111][222][222];
Int dp_max[111][222][222];
bool visited[111][222][222];

Pi dfs(Int v, Int a, Int b) {
  if(visited[v][mp[a]][mp[b]]) return val[v][mp[a]][mp[b]];
  visited[v][mp[a]][mp[b]] = true;  
  if(graph[v].empty()) {
    dp_min[v][mp[a]][mp[b]] = 1;
    dp_max[v][mp[a]][mp[b]] = 1;
    val[v][mp[a]][mp[b]] = Pi(p[v], p[v]);
    //cout<<v<<" "<<val[v][mp[a]][mp[b]].first<<" "<<val[v][mp[a]][mp[b]].second<<endl;
    return val[v][mp[a]][mp[b]];
  }
  val[v][mp[a]][mp[b]] = Pi(-inf, inf);
  dp_min[v][mp[a]][mp[b]] = inf;
  dp_max[v][mp[a]][mp[b]] = -inf;  
  do {
    Pi a_tmp = Pi(a, a), b_tmp = Pi(b, b);
    Int mn = 0, mx = 0;
    bool f_mn = true, f_mx = true;
    for(Int u : graph[v]) {
      if(f_mn) {
	Int x = -dfs(u, -b_tmp.first, -a_tmp.first).first;
	mn += dp_min[u][mp[-b_tmp.first]][mp[-a_tmp.first]];
	if(x >= b_tmp.first) {
	  a_tmp.first = x;
	  f_mn = false;
	} else if(x > a_tmp.first) {
	  a_tmp.first = x;
	}
      }
      if(f_mx) {
	Int x = -dfs(u, -b_tmp.second, -a_tmp.second).second;
	mx += dp_max[u][mp[-b_tmp.second]][mp[-a_tmp.second]];	
	if(x >= b_tmp.second) {
	  a_tmp.second = x;
	  f_mx = false;
	} else if(x > a_tmp.second) {
	  a_tmp.second = x;
	}
      }
    }
    if(dp_min[v][mp[a]][mp[b]] >= mn) {
      dp_min[v][mp[a]][mp[b]] = mn;
      val[v][mp[a]][mp[b]].first = max(val[v][mp[a]][mp[b]].first, a_tmp.first);
    }
    if(dp_max[v][mp[a]][mp[b]] <= mx) {
      dp_max[v][mp[a]][mp[b]] = mx;
      val[v][mp[a]][mp[b]].second = min(val[v][mp[a]][mp[b]].second, a_tmp.second);
    }
  }while(next_permutation(graph[v].begin(), graph[v].end()));
  //cout<<v<<" "<<val[v][mp[a]][mp[b]].first << " " << val[v][mp[a]][mp[b]].second << endl;
  //assert(val[v][mp[a]][mp[b]].first == val[v][mp[a]][mp[b]].second); 
  return val[v][mp[a]][mp[b]];
}

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

  cin >> n;
  for(Int i = 0; i < n; ++i) cin >> p[i];
  for(Int i = 0; i < n; ++i) {
    Int k; cin >> k;
    for(Int j = 0; j < k; ++j) {
      Int t; cin >> t; --t;
      graph[i].push_back(t);
    }
    sort(graph[i].begin(), graph[i].end());
  }
  vector<Int> vec;
  vec.push_back(-inf);
  vec.push_back(inf);
  for(Int i = 0; i < n; ++i) {
    vec.push_back(p[i]);
    vec.push_back(-p[i]);
  }
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  for(Int i = 0; i < n; ++i) {
    mp[p[i]] = lower_bound(vec.begin(), vec.end(), p[i])-vec.begin();
    mp[-p[i]] = lower_bound(vec.begin(), vec.end(), -p[i])-vec.begin();
  }
  memset(visited, false, sizeof(visited));
  dfs(0, -inf, inf);
  cout << dp_min[0][mp[-inf]][mp[inf]] << " " << dp_max[0][mp[-inf]][mp[inf]] << endl;
  
  return 0;
}



Measured memory_bytes: 28224
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


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

    Int n;
    Int a[100000], b[100000];
    cin >> n;
    for(Int i=0; i<n; i++){
        cin >> a[i];
    }

    Int sum=0;
    for(Int i=0; i<n; i++){
        if((i+1)%2==0){
            sum-=a[i];
        }else{
            sum+=a[i];
        }
    }
    b[0] = sum;
    for(Int i=1; i<n; i++){
        b[i] = 2*a[i-1]-b[i-1];
    }
    for(Int i=0; i<n; i++){
        cout << b[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2944
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    FAST_IO
    ll n,l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    sort(ALL(s));
    rep(i,n) cout << s[i];
    cout << endl;
    return 0;
}

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

int n, k, ans;
string save, cards[11];
vector<string> v;

void solve(int a, int b, int c){
	for(int i = 1; i <= n; i++){
		if(a != b && a != c && a != i && b != c && b != i && c != i){
			if(k == 3){
				v.push_back(save + cards[i]);
			} else{
				if(c == -1){
					solve(a, b, i);
				} else{
					v.push_back(save + cards[c] + cards[i]);
				}
			}
		}
	}
}

int main() {
	while(1){
		cin >> n >> k;
		if(n == 0 && k == 0){
			break;
		}
		
		for(int i = 1; i <= n; i++){
			cin >> cards[i];
		}
		
		for(int a = 1; a <= n; a++){
			for(int b = 1; b <= n; b++){
				if(a != b){
					save = cards[a] + cards[b];
					if(k >= 3){
						solve(a, b, -1);
					} else{
						v.push_back(save);
					}
				}
			}
		}
		
		ans = 1;
		sort(v.begin(), v.end());
		for(int i = 1; i < v.size(); i++){
			if(v[i] != v[i - 1]){
				ans++;
			}
		}
		
		cout << ans << endl;
		
		int x = v.size();
		for(int i = 0; i < x; i++){
			v.pop_back();
		}
	}
	return 0;
}

Measured memory_bytes: 1504
input = gets

N = input.split(" ")[0].to_i

rt_n = Math.sqrt(N).to_i
ans = []

# 対象性により、a >= bとできるので、a*aの二次元配列を探索すれば良い
# 上記の平方根をとって、a <= sqrt(N)の範囲で、N = a * bとなるbを求める
1.upto(rt_n) do |a|
  if N%a == 0
    b = N / a
    
    # 移動回数(ido)は、a + b -2で求まる
    ido = a + b -2
    ans.push(ido)
  else
    next
  end
end

# 移動回数が最小の値を返す
p ans.min

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
using namespace std;
#define LL	long long
const int MAXN = 2e5+10;

int N;
int c[MAXN];
//vector<int> G[MAXN];
int tot = 0;
int head[MAXN], Next[2*MAXN], to[2*MAXN];

// sub[i]: 顶点i下子树顶点的个数
int sub[MAXN];
// cnt[i]: 颜色为i的顶点下子树顶点的个数
int cnt[MAXN]; 
// ans[i]: 颜色为i的顶点下不经过颜色i的顶点数
LL ans[MAXN];

// 一开始起名count结果和c++ count()冲突，调试了半天, md
inline LL cal(int n) {
	// C(n,2) + n
	return 1LL*n*(n+1)/2;
}

void dfs(int v, int fa) {
	int tmp = cnt[c[v]];
	sub[v] = 1;
	for(int i=head[v]; i; i=Next[i]) {
		int u = to[i];
		if(u == fa) continue;
		cnt[c[v]] = 0;	// 置0重新计数
		dfs(u, v);
		sub[v] += sub[u];
		ans[c[v]] += cal(sub[u] - cnt[c[v]]);
	}
	cnt[c[v]] = tmp + sub[v];
}
inline void add(int a, int b) {
	++tot;
	Next[tot] = head[a];
	to[tot] = b;
	head[a] = tot;
}

/*
void dfs(int v, int fa) {
	int tmp = cnt[c[v]];
	sub[v] = 1;
	for(int u:G[v]) {
		if(u==fa) continue;
		cnt[c[v]] = 0;
		dfs(u, v);
		sub[v] += sub[u];
		ans[c[v]]+=cal(sub[u]-cnt[c[v]]);
	}
	cnt[c[v]] = tmp + sub[v];
}
* */

int main() {
	std::ios::sync_with_stdio(false);
	cin>>N;
	for(int i=1; i<=N; i++) {
		cin >> c[i];
	}
	int a, b;
	for(int i=1; i<N; i++) {
		cin>>a>>b;
	
		add(a, b);
		add(b, a);
		
		//G[a].push_back(b);
		//G[b].push_back(a);
	}

	//dfs1(1, 0);
	dfs(1, 0);
	for(int i=1; i<=N; i++) {
		cout << cal(N) - ans[i] - cal(N-cnt[i]) << endl;
	}
	return 0;
}


Measured memory_bytes: 26912
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,k;
int main(){
	cin>>n>>k;
	cout<<n-k+1;
	return 0;
}

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

int main() {
  int A, B;

  cin >> A >> B;

  int ans = 0;
  for (int i = A; i <= B; i++) {
    int itmp = i;
    int irev = 0;
    rep(j, 5) {
      irev += pow(10, (4-j)) * (itmp % 10);
      itmp /= 10;
    }
    if (irev == i) ans++;
  }

  cout << ans << endl;

  return 0;

}

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

class UnionFind {
private:
	vector<int> v;
public:
	UnionFind(int n) {
		for (int i = 0; i < n; i++) v.emplace_back(-1);
	}
	int root(int x) {
		return v[x] < 0 ? x : v[x] = root(v[x]);
	}
	void unite(int x,int y) {
		if (root(x) == root(y)) {
			return;
		}
		v[root(x)] = root(y);
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
};

int main() {
	int n, q;
	cin >> n >> q;
	UnionFind uf(n);
	for (int i = 0; i < q; i++) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com) {
			cout << uf.same(x, y) << endl;
		}
		else {
			uf.unite(x, y);
		}
	}
	return 0;
}

Measured memory_bytes: 3276
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
  auto n = readln.chomp.to!int;
	while (1) {
    if (!n) break;
    auto team = new string[](n);
    auto score = new int[][](n, 2);
    
    foreach (i; 0..n) {
      auto x = readln.chomp.split.array;
      auto game = x[1..$].map!(to!int);
      score[i][0] = game[0] * 3 + game[2];
      score[i][1] = i;
      team[i] = x[0];
    }

    score = score.sort!((a,b)=>a[0]==b[0]?a[1]<b[1]:a[0]>b[0]).array;
    foreach (i; 0..n) {
      writeln(team[score[i][1]], ",", score[i][0]);
    }
    n = readln.chomp.to!int;
    if (n) writeln("");
  }
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    int a, b;
 
    cin >> a >> b;
 
    int ans = 0;
 

    ans = ceil(1.0 * (b-1) / (a-1));
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  ll N;
  cin>>N;
  ll A[N];
  ll count=0;
  rep(i,N){
    cin>>A[i];
    count+=abs(A[i]);
  }
  
  ll count1=0;
  ll fm=-1*INF;
  ll nm=INF;
  rep(i,N){
    if(A[i]<0) {
      count1++;
      fm=max(fm,A[i]);
    }
    else
      nm=min(nm,A[i]);         
  }
  
  ll ans;
  if(count1%2==0) ans=count;
  else {
    ll a=count+2*fm;
    ll b=count-2*nm;
    ans=max(a,b);
  }
  
  cout<<ans<<endl;
}

             
             
  

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		//????????£?????????????????????
		Scanner sc	= new Scanner(System.in);
		//
		int Answer = 0;
		//??°?????????
		while(true){
			//??????????????????
			String line = sc.nextLine();
			//??????????????????0?????´??? ??????
			if(line.equals("0")){
				break;
			}
			//???????????????????????????
			for(int i = 0; i < line.length(); i++){
			//??????????????????????????´ ?????´??????????????????????????????????????°???????????´
			Answer += Integer.parseInt(line.valueOf(line.charAt(i)));
			}

			//?¨???????????????¨???
			System.out.println(Answer);
			Answer = 0; //??????????????????
		}
	}
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int ans;
    int n;cin >>n;
    vector<int>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    sort(all(a));
    ans=a[n-1]-a[0];
    cout <<ans<<endl;
    return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());;
		int m = Integer.parseInt(sc.next());;
		long[] array = new long[n];
		Long[][] bc = new Long[m][2];
		long sum=0;
		int count=0;

		for(int i=0;i<n;i++) {
			array[i]=Long.parseLong(sc.next());
		}
		Arrays.sort(array);

		for(int i=0;i<m;i++) {
			bc[i][1]=Long.parseLong(sc.next());
			bc[i][0]=Long.parseLong(sc.next());
		}
		Arrays.sort(bc, (a, b) -> Long.compare(a[0], b[0]));

		for(int i=m-1;i>=0;i--) {
			for(int j=count;j<n;j++) {
				if(array[j]<bc[i][0]) {
					array[j] = bc[i][0];
					bc[i][1]--;
					count++;
				}
				if(bc[i][1]<1) {
					break;
				}
			}
			if(bc[i][1]>0) {
				break;
			}
		}
		for(long i:array) {
			sum+=i;
		}
		System.out.println(sum);
	}

}




Measured memory_bytes: 72816
while True:
    dataset = input().split(" ")

    H = int(dataset[0])
    W = int(dataset[1])

    if H==0 and W==0:
        break

    for i in range(H):
        if i%2==0:
            first = "#"
            second = "."
        else:
            first = "."
            second = "#"
            
        for j in range(W):
            if j%2 == 0:
                print(first, end="")
            else:
                print(second, end="")
        print()

    print()



Measured memory_bytes: 7004
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;

/*
const ll M = 1000000007;
vector<ll> fac(3001);
vector<ll> ifac(3001);
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
*/


ll lcm(ll a,ll b){
 
  ll r, x, tmp;
  x = a * b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;
}

ll gcd(ll a ,ll b){
    if(a==0){return b;}
    else if(b==0){return a;}
    else{
    ll tmp,r;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
    }
}




int main(void){
    const ll INF = 1000000007;
    ll ans = 0;
    ll n;
    cin >> n;
    ll h[n];
    for(ll i=n-1;i>=0;i--){
        cin >> h[i];
    }
    ll tmp = 0;
    for(ll i=0;i<n-1;i++){
        if(h[i]<=h[i+1])tmp++;
        else {ans = max(ans,tmp);tmp=0;}
        if(i==n-2&&tmp==n-1)ans=n-1;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメモ
数値型から文字列に変換　to_string(number);これは簡単
文字列から数値型に変換　stoi(number)
文字列からllに変換　stoll(number)*/

//ここから書き始める
int main(){
	bool judge = 1;
	ll n ;  cin >> n;
	vector<ll> h(n);
	rep(i,n){
		cin>>h[i];
		if(i==0) h[i]--; 
	}
	for(int i = 1 ; i < n ; i ++ ){
		if(h[i]==h[i-1]){
			judge = 1;
		}
		else if(h[i]-1>=h[i-1]){
			h[i]--;
			judge = 1;
		}
		else{
			judge = 0;
			break;
		}
	}
	if(judge) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
	


Measured memory_bytes: 1024
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
#include <utility>
//#include <set>
//#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
//void chmin(ll &a,ll b){if(a>b) a = b ;}

int main(){
	ll n,m ;
	cin >> n >> m ;
	vector<vector<pll>> g(n,vector<pll>(0)) ;
	for(int i=0;i<m;i++){
		ll a,b,c ;
		cin >> a >> b >> c ;
		a-- ; b-- ;
		g.at(a).emplace_back(b,c) ;
		g.at(b).emplace_back(a,-c) ;
	}
	vll x(n,INF) ;
	queue<ll> q ;
	for(int i=0;i<n;i++){
		if(x.at(i)==INF){
			x.at(i) = 0 ;
			q.push(i) ;
			ll mx = 0 ;
			ll mn = 0 ;
			while(!q.empty()){
				ll p = q.front() ;
				q.pop() ;
				for(int j=0;j<g.at(p).size();j++){
					if(x.at(g.at(p).at(j).first)==INF){
						x.at(g.at(p).at(j).first) = x.at(p)+g.at(p).at(j).second ;
						q.push(g.at(p).at(j).first) ;
						mx = max(mx,x.at(g.at(p).at(j).first)) ;
						mn = min(mn,x.at(g.at(p).at(j).first)) ;
					}else{
						if(x.at(g.at(p).at(j).first)!=x.at(p)+g.at(p).at(j).second){
							cout << "No" << endl ;
							return 0 ;
						}
					}
				}
			}
			if(mx-mn>1000000000){
				cout << "No" << endl ;
				return 0 ;
			}
		}
	}
	cout << "Yes" << endl ;
}


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

int main() {
  
  string S; cin >> S;
  
  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 0 && S.at(i) == 'L') {
      cout << "No" << endl;
      return 0;
    }
    if (i % 2 == 1 && S.at(i) == 'R') {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  
}

Measured memory_bytes: 384
#include <cstdio>
using namespace std;

#define N 10
// init map
int MAP[N][N];
int D_MAX = 5;
int DROP[3][5][5] = {
  {
    {0,0,0,0,0},
    {0,0,1,0,0},
    {0,1,1,1,0},
    {0,0,1,0,0},
    {0,0,0,0,0},
  },
  {
    {0,0,0,0,0},
    {0,1,1,1,0},
    {0,1,1,1,0},
    {0,1,1,1,0},
    {0,0,0,0,0},
  },
  {
    {0,0,1,0,0},
    {0,1,1,1,0},
    {1,1,1,1,1},
    {0,1,1,1,0},
    {0,0,1,0,0},
  },
};

int main() {
  int x,y,size;
  while(~scanf("%d,%d,%d",&x,&y,&size)) {
    size = size - 1;
    for(int i=0;i<D_MAX;i++) {
      int xi = x + i - 2;
      if(xi <= -1 || xi >= N) continue;
      for(int j=0;j<D_MAX;j++) {
        int yi = y + j - 2;
        if(yi <= -1 || yi >= N) continue;
        MAP[xi][yi] += DROP[size][i][j];
      }
    }
  }

  int max_z = 0;
  int cnt = 0;
  for(int i=0;i<N;i++) {
    for(int j=0;j<N;j++) {
      if(MAP[i][j] == 0)
        cnt++;
      if(MAP[i][j] > max_z) {
        max_z = MAP[i][j];
      }
    }
  }
  printf("%d\n%d\n",cnt,max_z);
}

Measured memory_bytes: 1028
import java.util.Scanner;

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

		for (int i = sc.nextInt(); i < 25; i++) {
			sb.append(" Eve");
		}

		System.out.println(sb);

		sc.close();
	}
}



Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
vector<int>g[N];
int d[N],ans[N]={0},vis[N]={0};
void bfs(int u){
    queue<int>q;
    q.push(u);
    while(!q.empty()){
        int a=q.front();
        q.pop();
        for(int b:g[a]){
            if(!vis[b]) {
                if(d[b]>d[a]+1){
                    d[b]=d[a]+1;
                    ans[b]=a;
                }
                vis[b]=1;
                q.push(b);
            }
        }
    }
}

main(){
    int n,m;
    cin>>n>>m;
    fill(d,d+n+1,10000000);
    while(m--){
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    d[1]={0};
    bfs(1);
    for(int i=2;i<=n;i++){
        if(ans[i]==0) {
            puts("No");
            exit(0);
        }
    }
    puts("Yes");
    for(int i=2;i<=n;i++){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,i;
  string arare;
  cin >> N ;
 
  for (i=0;i<N;i++){
    cin >> arare;
    if (arare=="Y"){
      cout  << "Four"<<endl;
      break;
    }
    if (i==N-1){
      cout  << "Three"<<endl;
    }
  }
}

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




int main(){
  int n;
  cin >>n;
  map<int,int>s;
  long long ma1=0;
  long long ma2=0;
  long long ma3=0;
  for(int i=0;i<n;i++){
    long long a;
    cin>>a;
    s[a]++;
    int b= s.at(a);
    if(b>=4){
      ma1=max(ma1,a);
    }
    if(b>=2&&a!=ma2&&a!=ma3){
      if(a>ma2){
        ma3=ma2;
        ma2=a;
      }
      else if(a>ma3){
        ma3=a;
      }
    }
  }
  cout << max(ma1*ma1,ma3*ma2)<<endl;
}

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

int main() {
	int n;
	int i;
	long long j;
	long long k;
	long long p;

	cin >> n;

	long long  a[n+1]; // n個の整数
  	int b[1000010]{0};
  
	if(n==1){
		cout << 1 << endl;
		return 0;
	}
	for(i=0;i<n;i++) {
      cin >> a[i];
    }
	for(i=0;i<n;i++){
		p=a[i];
      	if(b[p]>0){
          b[p]++;
        	continue;
        }
		k=1000010;
      	for(j=p;j<k;j+=p) b[j]++;
	}
	p=0;
	for(i=0;i<n;i++){
		if(b[a[i]]==1) p++;
	}
	cout << p << endl;
	return 0;
}


Measured memory_bytes: 9044
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

	ll n;
	cin >> n;
	vector<ll> cnt(n+1, 0);
	for(ll x=1; x*x<=n; x++){
        for(ll y=1; y*y<=n; y++){
            for(ll z=1; z*z<=n; z++){
                ll val=(x*x)+(y*y)+(z*z)+(x*y)+(x*z)+(y*z);
                if(val>n)
                    break;
                cnt[val]++;
            }
        }
	}
	for(ll i=1; i<=n; i++)
        cout << cnt[i] << endl;

	return 0;
}


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

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

int main() {
	string S;
	string T;
	cin >> S >> T;
	int count = 0;
	int i = 0;
	rep(i, 3) {
		if (S[i] == T[i]) {
			count++;
		}
	}
	cout << count;
	return 0;
}



Measured memory_bytes: 256
let is_uppercase = function
  | 'A' .. 'Z' -> true
  | _ -> false

let toggle_case str =
  let buf = Buffer.create 1024 in
  let len = String.length str in
  let rec iter i = match len-i with
    | 0 -> Buffer.contents buf
    | _ ->
      let c = str.[i] in
      Buffer.add_char buf (if is_uppercase c then Char.lowercase c
                           else Char.uppercase c);
      iter (i+1)
  in iter 0

let () =
  let line = read_line () in
  let toggled = toggle_case line in
  print_endline toggled

Measured memory_bytes: 1996
#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int x[100000],y[100000],z[100000];
signed main(){
	int n,ans=0,k;
	cin>>n>>k;
	string s;
	cin>>s;
	f(i,n){
		if(i&&s[i]!=s[i-1])ans++;
	}
	ans=max((int)(0),ans-k*2);
	cout<<n-ans-1<<endl;
}


Measured memory_bytes: 512
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned int  ull;
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define int ll
#define pll pair<ll, ll> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 998244353
using namespace std;

ll power(ll x, ll y){  
	if(x == 1 || y == 0)
		return 1;
    ll res = 1;   
    x = x % mod; 
    if (x == 0) 
		return 0;  
    while (y > 0){  
        if (y & 1)  
	        res = (res * x) % mod;  
        y = y >> 1; 
        x = (x * x) % mod;  
    }  
    return res;  
} 
int dp[200005];
int solve(int st, int n, pii p[], int k){
	if(st == n)
		return 1;
	if(dp[st] != -1)
		return dp[st];
	int so = 0;
	rep(i, 0, k){
		
	}
	return dp[st] = so;
}

signed main(){
	FASTIO
	int n, k;
	cin >> n >> k;
	pii p[k];
	rep(i, 0, k){
		cin >> p[i].first >> p[i].second;
	}
	sort(p, p + k);
	int suff[n+2];
	suff[n+1] = 0;
	dp[n] = 1;
	suff[n] = 1;
	for(int i = n - 1; i > 0; i--){
		dp[i] = 0;
		int L = n+1, R = 0;
		rep(j, 0, k){
			int l = p[j].first + i, r = min(p[j].second, n - i) + i;
			if(l > n || l > r)
				break;
			dp[i] = (dp[i] + (suff[l] - suff[r+1] + mod) % mod) % mod;
			if(l == n)
				break;
		}
		// cout << i << " " << dp[i] << endl;
		suff[i] = (suff[i+1] + dp[i]) % mod;
	}
	cout << dp[1];
    return 0;
}


Measured memory_bytes: 6792
d,n = map(int,input().split())

if d == 0:
    if n == 100:
        ans = 101
    else:
        ans = n
elif d == 1:
    if n == 100:
        ans = 10100
    else:
        ans = 100 * n
elif d == 2:
    if n == 100:
        ans = 1010000
    else:    
        ans = 10000 * n

print(ans)


Measured memory_bytes: 38384