akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	//input
	ll N, X, M;
	cin >> N >> X >> M;
	//calculate
	vector<ll> memo(M,-1);
	vector<ll> A;
	ll len = 0;
	ll total = 0;
	while(memo[X]==-1){
		A.pb(X);
		memo[X] = len;
		len++;
		total += X;
		X = (X*X)%M;
	}

	//calculate one circulation total
	ll c = len - memo[X];
	ll c_total = 0;
	for(int i = memo[X]; i < len; i++){
		c_total += A[i];
	}

	ll ans = 0;
	if(len > N){
		rep(i,N) ans += A[i];
	}else{
		// brefore circulaton total
		ans = total;
		// circulation total
		N -= len;
		ans += c_total*(N/c);
		// after circulation total
		N %= c;
		rep(i,N) ans += A[memo[X]+i];
	}

	cout << ans << endl;
}	

Measured memory_bytes: 4584
import java.util.*;

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

    private void solveB() {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	String s = sc.next();
	int ans = 0;

	for(int i=0; i<n; i++){
	    int cnt = 0;
	    
	    for(char c='a'; c<='z'; c++){
		boolean left = false;
		boolean right = false;
		
		for(int j=0; j<i;j++){
		    if(s.charAt(j) == c) left = true;	    
		}
		for(int k=i; k<n;k++){
		    if(s.charAt(k) == c) right = true;	    
		}
		if(left && right) cnt ++;
	    }
	    ans = Math.max(ans,cnt);
	}
	System.out.println(ans);
    }
}


Measured memory_bytes: 22996
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 read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let v = read_vec::<i64>();
    let (a,b,c) = (v[0],v[1],v[2]);
    let ans = if b - a == c - b{
        "YES"
    } else {
        "NO"
    };
    println!("{}",ans );
}

Measured memory_bytes: 4352
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>


using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SRTVG(v) sort(v.begin(),v.end(),greater<>())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef map<string,int> si;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
#define int long long


string s;
string ss[]={"resare","remaerd","maerd","esare"};
bool ans=false,check=true;;


int atcoder() {
    cin >> s;
    reverse(s.begin(),s.end());
    while(check){
        check=false;
        REP(i,0,4) if(s.substr(0,ss[i].size())==ss[i]){s.erase(s.begin(), s.begin() + ss[i].size());check=true;}
        if(s=="") ans=true;
    }

    YESNO(ans);
    return 0;
}

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


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

using namespace std;
using i64 = int64_t;

i64 dp[3005][3005];
i64 N, S;
const i64 MOD = 998244353LL;

i64 rot(int n){
  for(i64 i=1;;i++){
    n -= i;
    if(i >= n) return i;
  }
}

int main(){
  vector<bool> isprime(1000005, true);
  isprime[0] = isprime[1] = false;
  for(int i=2;i<=1000005;i++){
    if(!isprime[i])continue;
    for(int j=2;i*j<=1000005;j++){
      isprime[i*j] = false;
    }
  }
  i64 N, T;
  cin >> N;
  T = N;
  map<i64, i64> factors;
  for(i64 i=2;i<=T&&i*i<=N;i++){
    if(!isprime[i])continue;
    while(T % i == 0){
      factors[i]++;
      T /= i;
    }
  }
  if(T != 1)factors[T]++;
  i64 ret = 0;
  for(auto&& p:factors){
    cerr << p.first << " " << p.second << endl;
    ret += rot(p.second);
  }
  cout << ret << endl;
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    int ans = 0;
    for(int i=0;i<n;i++) cin >> l[i];
    sort(l.begin(),l.end());
    for(int j=n-1;j>=n-k;j--){
        ans += l[j];
    }
    cout << ans << endl;
    return 0;

}

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int V, E;
	int tmp;
	cin >> V >> E;
	for (int i = 0; i < E; i++)
	{
		cin >> tmp;
		cin >> tmp;
		cin >> tmp;
	}

	int T;
	cin >> T;
	for (int i = 0; i < T; i++)
	{
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*************************************
 * problem:      ABC127 problem A.
 * user name:    hkxadpall.
 * time:         2019-05-25.
 * language:     C++.
 * upload place: AtCoder.
*************************************/ 

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

template <typename Int>
inline Int read()       
{
    Int flag = 1;
    char c = getchar();
    while ((!isdigit(c)) && c != '-') c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
	return init * flag;
}

template <typename Int>
inline void write(Int x)
{
    if (x < 0) putchar('-'), x = ~x + 1;
    if (x > 9) write(x / 10);
    putchar((x % 10) | 48);
}  

template <typename Int>
inline void write(Int x, char nextch)
{
    write(x);
    putchar(nextch);
}  

int n, m;

int main()
{
    n = read<int>();
    m = read<int>();
    if (n < 6) puts("0");
    else if (n <= 12) write(m / 2);
    else write(m);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)

#define scan1(a) scanf("%d", &a)
#define scan2(a,b) scanf("%d%d", &a,&b)
#define scan3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scan4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define print1(a) printf("%d\n", a)
#define print2(a,b) printf("%d %d\n", a,b)
#define print3(a,b,c) printf("%d %d %d\n", a,b,c)
#define print4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

int main(void){
    int N, east[300009]={}, west[300009]={};
    string S;
    
    cin >> N >> S;
    
    rep(i,N) {
        if(S[i]=='W') west[i] = 1;
        if(i) west[i] += west[i-1];
    }
    rrep(i,N-1) {
        if(S[i]=='E') east[i] = 1;
        if(i<N-1) east[i] += east[i+1];
    }
    
    int minv = min(east[1],west[N-2]);
    rep(i,N-1) {
        minv = min( minv, west[i]+east[i]-1);
    }
    cout << minv << endl;
}


Measured memory_bytes: 3136
k = int(input())
import math
k1 = 0
k2 = 0
k3 = 0
count = 0
for i in range(0,k):
  k1 = k1 + 1
  k2 = 0
  for j in range(0,k1):
    k3=0
    k2 = k2 + 1
    for k in range(0, k2):
      k3 = k3 + 1
      if k1==k2==k3:
        count = count + k1
      elif k1==k2:
        count = count + 3*math.gcd(k1,k3)
      elif k2==k3:
        count = count + 3*math.gcd(k1,k2)
      elif k3==k1:
        count = count + 3*math.gcd(k1,k2)
      else:
        k4 = math.gcd(k1,k2)
        count = count + 6*math.gcd(k3,k4)
print(count)


Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define X first
#define Y second
const int maxn = 500 + 5;
int n;
pii a[maxn];
int vis[maxn];

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i].X,&a[i].Y);
	sort(&a[1],&a[n+1]);

	int ans = n;

	for(int x=1;x<=n;x++) {
		for(int y=1;y<=n;y++) {
			int p = a[x].X-a[y].X, q = a[x].Y-a[y].Y;
			int cnt = 0;
			for(int i=1;i<=n;i++) vis[i] = 0;
			for(int i=1;i<=n;i++) {
				if(!vis[i]) cnt++;
				for(int j=1;j<=n;j++) {
					if(a[i].X+p == a[j].X && a[i].Y+q == a[j].Y) vis[j] = 1;
				}
			}
			ans = min(ans, cnt);
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

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


int main(){fastio
    ll n,k,c;cin>>n>>k>>c;
    string s;cin>>s;
    ll a[n][2];memset(a,0,sizeof(a));
    ll cnt=1;
    rep(i,0,n-1){
        if(s[i]=='o'){
            a[i][0]=cnt;
            cnt++;
            i+=c;
        }
    }
    cnt=1;
    for(ll i=n-1;i>=0;i--){
        if(s[i]=='o'){
            a[i][1]=cnt;
            cnt++;
            i-=c;
        }
    }
    rep(i,0,n-1){
        if(a[i][0]!=0&&a[i][1]!=0){
            if(a[i][0]+a[i][1]==k+1){
                cout<<i+1<<endl;
            }
        }
    }
    
    return 0;
}



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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

// 最大公約数
LL gcd(LL x, LL y) {
    return y ? gcd(y, x%y) : x;
}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    int b;cin >> b;
    inc(i, 0, n-1){
        int a;cin >> a;
        b = gcd(a, b);
    }
    cout << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int a, b, c; cin >> a >> b >> c;
    cout << max(0, c - (a-b)) << endl;
}

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

using namespace std;

int main() {
  int H, W, A, ans{};
  cin >> H >> W;

  vector<vector<int>> c(10, vector<int>(10));
  for (int i = 0; i != 10; i++) {
    for (int j = 0; j != 10; j++) {
      cin >> c[i][j];
    }
  }

  vector<int> dist(10, -1);
  priority_queue<int> q;
  dist[1] = 0;
  q.push(1);
  while (!q.empty()) {
    int j = q.top();
    q.pop();
    for (int i = 0; i != 10; ++i) {
      if (i == j) continue;
      if (dist[i] == -1 || dist[i] > dist[j] + c[i][j]) {
        dist[i] = dist[j] + c[i][j];
        q.push(i);
      }
    }
  }
  
  for (int i = 0; i != H * W; i++) {
    cin >> A;
    if (A != -1) ans += dist[A];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <math.h>

int main()
{
long long N;
long long A;
long long even;
long long odd;
long long i;
  scanf("%d",&N);
  even=0;
  for(i=0; i<N; i++)
  {
    scanf("%d",&A);
    if ( (A%2)==0 ) even++;
  }
  odd=N-even;
  if( ((((even%2))==1)&((odd%2)==0)) || ((((even%2))==0)&((odd%2)==0)) )
  {
       printf("YES");
  }else{
       printf("NO");
  }
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var o, e string
	fmt.Scan(&o, &e)

	var ans string
	for i := 0; i < len(e); i++ {
		ans += string(o[i])
		ans += string(e[i])
	}
	if len(o)-len(e) == 1 {
		ans += string(o[len(o)-1])
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <typeinfo>
#include <list>
#include <queue>
#include <stack>
#include <limits.h>
#include <set>
#include <map>
#include <cstring>

using namespace std;

vector<int> ACNum(string S, vector<pair<int, int> > Q) {
    int n = S.size(), n_q = Q.size();
    vector<int> record(n, 0);
    vector<int> res(n_q);
    for (int i = 1; i < n; i++) {
        if (S.substr(i - 1, 2) == "AC") {
            record[i] = record[i - 1] + 1;
        }
        else {
            record[i] = record[i - 1];
        }
    }
    for (int i = 0; i < n_q; i++) {
        res[i] = record[Q[i].second - 1] - record[Q[i].first - 1];
    }
    return res;
}


int main() {
    ios::sync_with_stdio(false);
    int N, Q;
    string S;
    cin >> N >> Q;
    cin >> S;
    vector<pair<int, int> > q;
    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        q.push_back({l, r});
    }
    vector<int> res = ACNum(S, q);
    for (int i = 0; i < Q; i++) {
        cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 2756
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(1, n -1):
    if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i - 1] > p[i] and p[i] > p[i + 1]):
        count += 1
print(count)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
	long int min=100000000;
	long int max=-100000000;
	long int x,n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(max<x) max=x;
		if(min>x) min=x;
		sum+=x;
	}
	cout<<min<<" "<<max<<" "<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3068
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Arrays;

public class Main {
	public static int[][] warshall(int n, int[][]matrix) {
		int[][] ans = matrix;
		for(int i=0; i<n; i++) {
			ans[i][i] = 0;
		}
		for(int i=0; i<n; i++) {
			for(int j=0; j<n; j++) {
				for(int k=0; k<n; k++) {
					if(ans[j][i] == Integer.MAX_VALUE || ans[i][k] == Integer.MAX_VALUE) continue;
					ans[j][k] = Math.min(ans[j][k], ans[j][i]+ans[i][k]);
				}
			}
		}
		return ans;
	}

	public static void main(String[] args) {
		FS r = new FS();
		int v = r.nextInt();
		int e = r.nextInt();
		int[][] matrix = new int[v][v];
		for(int i=0; i<v; i++) {
			Arrays.fill(matrix[i], Integer.MAX_VALUE);
		}
		for(int i=0; i<e; i++) {
			int s = r.nextInt();
			int t = r.nextInt();
			int d = r.nextInt();
			matrix[s][t] = d;
		}
		int[][] ans = warshall(v, matrix);
		for(int i=0; i<v; i++) {
			if(ans[i][i] < 0) {
				System.out.println("NEGATIVE CYCLE");
				return;
			}
		}
		for(int i=0; i<v; i++) {
			String[] print = new String[v];
			for(int j=0; j<v; j++) {
				if(matrix[i][j] == Integer.MAX_VALUE) print[j] = "INF";
				else print[j] = Integer.toString(matrix[i][j]);
			}
			System.out.println(String.join(" ", print));
		}
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}

Measured memory_bytes: 28032
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int n, a, b;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  if(n==1){
    cout << "Hello World" << endl;
  }else{
    cin >> a >> b;
    cout << a+b << endl;
  }
  return 0;
}

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

int main(){
    int n;
    string a,b,c;
    cin >> n >> a >> b >> c;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == b[i] && b[i] != c[i]){
            cnt++;
        }else if(a[i] == c[i] && b[i] != c[i]){
            cnt++;
        }else if(c[i] == b[i] && a[i] != c[i]){
            cnt++;
        }else if(a[i] != b[i] && b[i] != c[i] && c[i] != a[i]){
            cnt += 2;
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();

    let mut m = n;
    while m > 9 {
        m /= 10;
    }

    let mut ans = 0;
    for i in m - 1..=m {
        if i > n {
            break;
        }

        let mut j = i;
        let mut k = i;
        while j * 10 + 9 <= n {
            j = j * 10 + 9;
            k += 9;
        }
        ans = max(ans, k);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2080
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

struct edge{int to, cost; };

int main(void){
	int m;
	while(cin >> m && m){
	int tx[200], ty[200];
	int n;
	map<int, vector<int> > S;
	REP(i, m){
		cin >> tx[i] >> ty[i];
	}
	cin >> n;
	REP(i, n){
		int x, y;
		cin >> x >> y;
		S[x].push_back(y);
	}
	REP(i, 1000000){
		REP(j, S[i].size()){
			bool flag;
			int diff_x, diff_y;
			diff_x = i-tx[0];
			diff_y = S[i][j]-ty[0];
			FOR(k, 1, m){
				flag = false;
				REP(l, S[tx[k]+diff_x].size()){
					if(S[tx[k]+diff_x][l] == ty[k]+diff_y){
						flag = true;
					}
				}
				if(!flag){
					break;
				}
			}
			if(flag){
				cout << diff_x << " " << diff_y << endl;
				j = S[i].size();
				i = 1000000;
			}
		}
	}
	}

}

Measured memory_bytes: 57728
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
int k,t;
int sum=0;
int a[150];
signed main(){
    cin>>k>>t;
    rep(i,t)cin>>a[i];
    sort(a,a+t);
    rep(i,t-1){
        sum+=a[i];
    }
    int ans=a[t-1]-sum-1;
    if(ans<0)ans=0;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
S, C = [], []
for _ in range(M):
    s, c = map(int, input().split())
    S.append(s)
    C.append(c)

for i in range(1000):
    str_i = str(i)
    if len(str_i) != N:
        continue

    flag = True
    for s, c in zip(S, C):
        if int(str_i[s-1]) != c:
            flag = False
            break

    if flag:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 3064
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
// #define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 100005
#define BLOCK 555
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 200005;
const long double epsilon = 1e-9;
inline ll myceil(ll a, ll b) { if (a % b == 0)	return (a / b);	return (a / b + 1);}
inline ll binlen(ll n) {
	ll c = 0;
	while (n > 0)
		++c , n /= 2;
	return c;
}
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	fast
	ll n, x, t;
	cin >> n >> x >> t;
	cout << myceil(n, x)*t << END;



// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}

Measured memory_bytes: 3620
import java.util.*;

class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    double c = X/100;
    int C = (int)c;
    
    
       if(100*C <= X && X<=105*C){
         System.out.println(1);
       }
       else{
         System.out.println(0);
       }
    
  }
}

Measured memory_bytes: 23636
/*
Author:Jenil Mehta
Not yet serious but trying to be serious :)
Coding is lub
*/
 
#include <iostream>
#include <sstream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
typedef long long int ll;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
using namespace std;
ll a[1002];
ll b[1002];
int dp[3000 + 5][3000 + 5];
int main()
{
    ll n;
    //cin>>n;
    ll w;
    //cin>>w;
    string s,t;
    cin>>s>>t;
    n=s.length();
    w=t.length();
    ll i,j;
    ll ans=0;
    ll index=0;
    //cout<<"hello1"<<endl;
    for(i=1;i<=n;i++)
    {
        //cout<<"hello2"<<endl;
        for(j=1;j<=w;j++)
        {
           if(i==0||j==0)
           dp[i][j]=0;
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    ll len=dp[n][w];
    i=n;
    j=w;
    string r;
    while(i>0&&j>0)
    {
        if(s[i-1]==t[j-1])
        {
            //lcs[len-1]=s[i-1];
            r+=s[i-1];
            i--;
            j--;
            //len--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        i--;
        else 
        {
            j--;
        }
    }
    reverse(r.begin(),r.end());
    cout<<r<<endl;
}

Measured memory_bytes: 35456
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N;
int pos[50], fall_time[50];
int dp[50][5];

#define fprintf(...) void(0)
 
signed main() {
    while(cin >> N, N) {
        for(int i=0; i<N; i++) {
            cin >> pos[i+1] >> fall_time[i+1];
        }

        fill(dp[0], dp[N+2], INF);
        dp[0][0] = 0;

        int first_ng = -1;
        for(int i=0; i<N; i++) {
            bool ok = false;

            // come directly
            for(int k=0; k<3; k++) {
                if(dp[i][k] == INF) continue;
                int cand = fall_time[i] + abs(pos[i+1] - pos[i]) * (k+1);
                if(cand > fall_time[i+1]) continue;
                ok = true;
                chmin(dp[i+1][k+1], dp[i][k] + abs(pos[i+1] - pos[i]));
            }

            // come after going home
            for(int k=1; k<4; k++) {
                if(dp[i][k] == INF) continue;
                int cand = fall_time[i] + pos[i] * (k+1) + pos[i+1];
                if(cand > fall_time[i+1]) continue;
                ok = true;
                chmin(dp[i+1][1], dp[i][k] + pos[i] + pos[i+1]);
            }

            if(ok == false && first_ng < 0) {
                first_ng = i+1;
            }
        }

        int ans = INF;
        for(int k=1; k<4; k++) {
            fprintf(stderr, "k = %lld, dp = %lld\n", k, dp[N][k]);
            chmin(ans, dp[N][k] + pos[N]);
        }

        if(ans == INF) cout << "NG " << first_ng << endl;
        else cout << "OK " << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main(void)
{
  char ch;

  while(1){
    scanf("%c", &ch);
    if(islower(ch)) 
      ch=toupper(ch);
    else if(isupper(ch)) 
      ch=tolower(ch);
    printf("%c",ch);
    if ( ch == '\n' ) break;
  }
  
  return 0;
}

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

int main() 
{
    int A, B;
    cin >> A >> B;
    int r=0; 
    for (int i = A; i <= B; i++) {
      int s = i%10, t = i/10000%10, u = i/10%10, v = i/1000%10;
      if (s == t && u == v) r++; 
    }
  
    cout << r << endl; 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int a, b, m;
  cin >> a >> b >> m;
  vector<int> p(a);
  vector<int> q(b);
  int minA = 1e9, minB = 1e9;
  for (int i = 0; i < a; i++) {
    cin >> p[i];
    minA = min(minA, p[i]);
  }
  for (int i = 0; i < b; i++) {
    cin >> q[i];
    minB = min(minB, q[i]);
  }
  vector<vector<int>> w(m, vector<int>(3));
  for (int i = 0; i < m; i++) {
    cin >> w[i][0] >> w[i][1] >> w[i][2];
  }
  int ans = minA + minB;
  for (int i = 0; i < m; i++) {
    ans = min(ans, p[w[i][0] - 1] + q[w[i][1] - 1] - w[i][2]);
  }
  cout << ans << endl;
  return 0;
}

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

const int mod = 1e9 + 7;

int dp[1002][1002];

int main() {
  int H, W;
  scanf("%d%d", &W, &H);
  for (int i = 1; i <= W; ++i) {
    for (int j = 1; j <= H; ++j) {
      char c;
      scanf(" %c", &c);
      if (c == '#') {
        dp[i][j] = 0;
        continue;
      }
      dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
      if (i == 1 && j == 1) {
        ++dp[i][j];
      }
    }
  }

  printf("%d\n", dp[W][H]);
}

Measured memory_bytes: 4224
n,m = map(int,input().split())

a = list(map(int,input().split()))

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

for i in range(n):
	b[i+1] = (b[i]+a[i])%m

c = {}
for i in b:
	if i in c:
		c[i] += 1
	else:
		c[i] = 1

ans = 0

for i in c:
	ans += (c[i]*(c[i]-1)//2)
print(ans)

Measured memory_bytes: 16956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    --a;
    A[i] = a;
  }
  for (int i = 0; i < N; i++) cin >> B[i];
  for (int i = 0; i < N-1; i++) cin >> C[i];
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += B[A[i]];
    if (i != N-1 && (A[i] +1 == A[i+1])) {
      ans += C[A[i]];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrep1(i, s, n) for (int i = (s); i >= (n); i--)
#define print_array(ary, size) cout << ary[0]; rep1(i, 1, size - 1) cout << ' ' << ary[i]; cout << endl;
typedef long long ll;
typedef unsigned long long ull;

int A[251];

int main()
{
	int H;

	cin >> H;
	rep1(i, 1, H) cin >> A[i];

	rep1(i, 1, H) {
		printf("node %d: key = %d, ", i, A[i]);
		if (i >= 2) printf("parent key = %d, ", A[i / 2]);
		if (i * 2 <= H) printf("left key = %d, ", A[i * 2]);
		if (i * 2 + 1 <= H) printf("right key = %d, ", A[i * 2 + 1]);
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
ll dp[N][2];//到了第i个位子第i个位子按不按?
//其实可以一维,只是为了方便理解.
int a[N],b[N];

int main()
{
    int n;cin>>n;
    for(int i=1;i<=n;i++)  {cin>>a[i];b[i]=a[i];}
    int pos=n;
    for(int i=1;i<=n;i++)
    {
        a[pos]=b[i];pos--;
    }
   // for(int i=1;i<=n;i++)
   //     for(int j=0;j<2;j++)
   //     dp[i][j]=-2e14;
    dp[2][0]=a[1]+a[2];
    dp[2][1]=-a[1]-a[2];
    for(int i=3;i<=n;i++)
    {
        dp[i][1]=max(dp[i-1][0]-a[i]-2*a[i-1],dp[i-1][1]-a[i]+2*a[i-1]);//这个地方用.
        dp[i][0]=max(dp[i-1][0]+a[i],dp[i-1][1]+a[i]);//这个地方不用.
    }
    //cout<<dp[i][1]<<' '<<dp[i][0]<<endl;
    //cout<<dp[1][0]<<endl;
   // cout<<dp[3][0]<<endl;
    cout<<max(dp[n][0],dp[n][1])<<endl;
    return 0;
}


Measured memory_bytes: 5860
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
map<int,ll> mp;
set<int> s;
int a[200010];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		s.insert(a[i]);
		mp[a[i]]++;
	}
	ll cnt=0;
	for(set<int>::iterator it=s.begin();it!=s.end();it++){
		ll k=mp[*it];
		cnt+=k*(k-1)/2;
	}
	for(int i=0;i<n;i++){
		cout<<cnt-mp[a[i]]+1<<endl;
	}
	return 0;
}

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

using namespace::std;

int main() {
	int a, b, c, d, e;
	vector<int> userinput(5);
	
	cin >> a >> b >> c >> d >> e;

	userinput[0] = a;
	userinput[1] = b;
	userinput[2] = c;
	userinput[3] = d;
	userinput[4] = e;
	
	int index = 0;
	
	for (int i = 0; i <= 4; i++) {
		if (userinput[i] == 0) {
			index = i+1;
		}
	}
	
	cout << index << endl;
}


Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

constexpr lint INF=1e18;

int main()
{
	int N,M,L;
	int A[310]={};
	int B[310]={};
	lint C[310]={};
	int Q;
	int s[100010]={};
	int t[100010]={};

	lint dist[310][310]={};
	for(int i=0;i<310;i++)
		for(int j=0;j<310;j++)
			if(i!=j)dist[i][j]=INF;

	cin >> N >> M >> L;
	for(int i=0;i<M;i++)
	{
		cin >> A[i];
		cin >> B[i];
		cin >> C[i];
		A[i]--;
		B[i]--;
		dist[A[i]][B[i]]=C[i];
		dist[B[i]][A[i]]=C[i];
	}
	cin >> Q;
	for(int i=0;i<Q;i++)
	{
		cin >> s[i];
		cin >> t[i];
		s[i]--;
		t[i]--;
	}

	for(int k=0;k<N;k++)
		for(int i=0;i<N;i++)
			for(int j=0;j<N;j++)
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);

	lint cnt[310][310]={};
	for(int i=0;i<310;i++)
		for(int j=0;j<310;j++)
			if(i!=j && dist[i][j]>L)cnt[i][j]=INF;
	
	for(int k=0;k<N;k++)
	{
		for(int i=0;i<N;i++)
		{
			for(int j=0;j<N;j++)
			{
				lint ncnt=cnt[i][k]+cnt[k][j];
				if(dist[i][k]+dist[k][j]>L)
					ncnt++;

				cnt[i][j]=min(cnt[i][j],ncnt);
			}
		}
	}

	for(int i=0;i<Q;i++)
	{
		lint ans=cnt[s[i]][t[i]];
		if(ans==INF)ans=-1;
		cout << ans << endl;

	}
	return 0;
}


Measured memory_bytes: 2816
from collections import deque
import math
    
def dfs(edges, s):
    stack = deque([s])
    used  = {s}
    while stack:
        x = stack.pop()
        for y in edges[x]:
            if y not in used:
                used.add(y)
                stack.append(y)
    return used


def bfs(edges, s):
    queue = deque([s])
    used  = {s}
    while queue:
        x = queue.popleft()
        for y in edges[x]:
            if y in used:
                continue
            used.add(y)
            queue.append(y)
    return used
    

def bellman(dist):  #負辺があるケースでの、スタートからゴールへの最短路を求めるアルゴ。
    cost = [float("inf")] * n
    cost[0] = 0
    for _ in range(n): #頂点の個数の分だけ回る
        updated = False
        for u,v,c in dist: #辺の個数の分だけ回る
            if cost[u] + c < cost[v]:
                cost[v] = cost[u] + c
                updated = True                
    #収束しない場合は負閉路があるため無限に小さくできる。
    if updated==True:
        return -1
    else:
        return max(0, cost[n-1]*-1)    
        

n,m,p = map(int, input().split())
dist  = []
edge1 = [[] for _ in range(n)]
edge2 = [[] for _ in range(n)]  # rev_edge
for _ in range(m):
    u,v,c = map(int, input().split())
    u -= 1
    v -= 1
    dist.append((u,v,(c-p)*-1))
    edge1[u].append(v)
    edge2[v].append(u)    
    
use = dfs(edge1, 0) & dfs(edge2, n-1)
dist2 = [(a,b,c) for a,b,c in dist if a in use and b in use]
print(bellman(dist2))

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    int n, sum = 0;; cin >> n;
    int array[n]; REPI(i, n){ cin >> array[i]; sum += array[i]; }

    int m; cin >> m;
    int p[m], x[m]; REPI(i, m) cin >> p[i] >> x[i];

    REPI(i, m)
        cout << sum + (x[i] - array[p[i] - 1]) << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
         
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
const int N = 100001; 

// bool sortbysec(const pair<int,int> &a, const pair<int,int> &b){ 
//     return (a.second < b.second);}
 
// int fexp(int a, int b,int m){int ans = 1;while(b){if(b&1)ans=ans*a%m; b/=2;a=a*a%m;}return ans;}
// int inverse(int a, int p){return fexp(a, p-2,mod);} 

// int fac[2000001];

// int nCrModPFermat(int n, int r,int p) { 
//     if (r==0) return 1; 
//     return (fac[n]*inverse(fac[r],p)%p*inverse(fac[n-r],p)%p)%p; 
// }
 
void solve(){
	int n;cin>>n;
	int a=0,w=0,t=0,r=0;
	rep(i,0,n){
		string s;cin>>s;
		if(s=="AC")a++;
		if(s=="TLE")t++;
		if(s=="WA")w++;
		if(s=="RE")r++;
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<w<<endl;
	cout<<"TLE x "<<t<<endl;
	cout<<"RE x "<<r<<endl;
    return ;
}
         
signed main(){
        IOS;    
  
        int t=1;
        // cin>>t;
        // fac[0] = 1; 
        // for (int i=1 ; i<=2000001; i++) fac[i] = fac[i-1]*i%mod; 
        rep(i,0,t){
            solve();
            cout<<"\n";
        //   cout<<" * "<<t<<"\n";
        }
    //    return 0;
}

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

#define mod 1000000007
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repx(i,x,n) for(int i=x;i<n;i++)

// int ans(vector<int>& a,int k){
    
// }

int main(void) {
    int k, i, r;
 
    scanf("%d", &k);
 
    r = 0;
    for (i = 0; i < k; i++) {
        r = (r * 10 + 7) % k;
        if (r == 0) {
            printf("%d\n", i + 1);
            return 0;
        }
    }
 
    printf("-1\n");
 
    return 0;
}


Measured memory_bytes: 3804
#include <stdio.h>
int x,y,z;
int main(void){
  scanf("%d\n",&x);
  scanf("%d\n",&y);
  scanf("%d\n",&z);
  if((x==y&&x!=z)||(x==z&&x!=y)||(y==z&&y!=x)){
    printf("Yes");
  }else printf("No");
  return 0;
}

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

int main() {
	int a,b;
	cin >> a >> b;
	int ans = a;
	if (b<a) ans--;
	cout << ans << endl;
	return 0;
}


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

void hyouji(vector<int> v, int n) {
  for (int k = 0; k < n; k++) {
    if (k == n - 1) {
      cout << v.at(k) << endl;
    } else {
      cout << v.at(k) << " ";
    }
  }
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  hyouji(a, n);

  for (int i = 1; i < n; i++) {
    int v = a.at(i);
    int j = i - 1;
    while (j >= 0 && a.at(j) > v) {
      a.at(j + 1) = a.at(j);
      j--;
    }
    a.at(j + 1) = v;
    hyouji(a, n);
  }
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,ans,f=1,x=5;
int main()
{
	cin>>n;
	if(n<=1||n%2)
	{
		cout<<0;
		return 0;
	}
	while(1)
	{
		ll ret=x*2;
		if(ret>n) break;
		ans+=f*(n/ret);
		x*=5;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
//Author: 23forever
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <bitset>
const int MAXN = 1000;
const int INF = 0x3f3f3f3f;
using namespace std;

inline int read() {
  int x = 0, w = 1;
  char c = ' ';

  while (c < '0' || c > '9') {
    c = getchar();
    if (c == '-') w = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }

  return x * w;
}

int n, m, ga[MAXN + 5][MAXN + 5], belong[MAXN + 5], vis[MAXN + 5], sum[2];
bool f;

void dfs(int u, int col) {
  if (f) return;

  belong[u] = col;
  vis[u] = true;
  ++sum[col];

  for (int i = 1; i <= n; ++i) {
    if (i != u && !ga[u][i]) {
      int v = i;

      if (!vis[v]) {
        dfs(v, col ^ 1);
      } else if (col == belong[v]) {
        f = true;
        return;
      }
    }
  }
}

void init() {
  n = read();
  m = read();

  for (int i = 1; i <= m; ++i) {
    int u = read(), v = read();
    ga[u][v] = true;
    ga[v][u] = true;
  }
}

bitset<705>S;

int main() {
  init();
  
  S[0] = 1;

  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) {
      memset(sum, 0, sizeof(sum));
      dfs(i, 0);

      S = (S << sum[0]) | (S << sum[1]);
    }
  }

  if (f) {
    puts("-1");
    return 0;
  }
  
  int ans = INF;

  for (int i = 0; i < n; ++i) if (S[i]) ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
  
  printf("%d\n", ans);

  return 0;
}

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

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

	int a;
	while(n>0){
		a=sqrt(n);
		if(pow(a,2)==n){
			cout<<n<<endl;
			break;
		}else n--;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int N;
    cin >> N;
    int* A = new int[N];
    rep (i, N)
    {
        cin >> A[i];
    }

    int sw = 0;
    int i, j, minj;
    for (i = 0; i < N -1; ++i)
    {
        minj = i;
        for (j = i; j < N; ++j)
        {
            if (A[j] < A[minj]) minj = j;
        }
        swap(A[i], A[minj]);
        if (i != minj) ++sw;

        if (sw > 2)
        {
            break;
        }
    }

    if (sw <= 1)
    {
        cout << "YES\n";
    }
    else
    {
        cout << "NO\n";
    }

    return 0;
}



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

int main() {
    int A,B,K;
    cin >> A >> B >> K;

    rep(i,K)
        if(i%2) {
            if(B%2)
                --B;
            B /= 2;
            A += B;
        } else {
            if(A%2)
                --A;
            A /= 2;
            B += A;
        }
    
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

lin n;
lin s[200002];
lin d[5];

lin calc_sum(int i, int j)
{
    return s[j] - s[i];    
}

lin calc_result()
{
    lin ss[4];
    rep(i, 4)
    {
        ss[i] = calc_sum(d[i], d[i+1]);
    }

    lin mx = max(ss[0], max(ss[1], max(ss[2], ss[3])));
    lin mn = min(ss[0], min(ss[1], min(ss[2], ss[3])));
    return mx - mn;
}

int main(void)
{
    cin >> n;
    s[0] = 0;
    rep(i, n)
    {
        lin a;
        cin >> a;
        s[i+1] = s[i] + a;
        //cout << s[i] << endl;
    }

    d[0] = 0;
    d[1] = 1;
    d[2] = 2;
    d[3] = 3;
    d[4] = n;
    lin res = -1;

    loop(i, 2, n - 1)
    {
        d[2] = i;

        lin s01 = calc_sum(d[0], d[2]);
        lin t01 = -1;
        loop(j, d[1], i)
        {
            lin s0 = calc_sum(d[0], j);
            lin s1 = calc_sum(j, d[2]);
            lin t = abs(s1 - s0);

            if(t01 < 0 || t < t01)
                t01 = t;
            else 
                break;

            d[1] = j;
        }

        lin s23 = calc_sum(d[2], d[4]);
        lin t23 = -1;
        if(d[2] == d[3])
            d[3]++;
        loop(j, d[3], n)
        {
            lin s2 = calc_sum(d[2], j);
            lin s3 = calc_sum(j, d[4]);
            lin t = abs(s3 - s2);

            if(t23 < 0 || t < t23)
                t23 = t;
            else 
                break;

            d[3] = j;
        }

        lin tt = calc_result();
        if(res < 0)
            res = tt;
        else
            res = min(tt, res);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1792