akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i].first >> a[i].second;
    }
    std::sort(a.begin(), a.end(),
              [](const pair<int, int> &x, const pair<int, int> &y){return x.second < y.second;});
    int res = 0;
    int last = -1;
    for (auto p : a) {
        if (p.first <= last) {
            continue;
        }
        last = p.second - 1;
        res++;
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
bool ok[801][801];
vector<int> G[801];
int cnt[2];
int col[801];
bool dp[2][801];

bool dfs(int v,int c){
	col[v]=c;
	if(c==1)cnt[0]++;
	else cnt[1]++;
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i];
		if(col[nv]==0){
			if(!dfs(G[v][i],-c))return false;
		}else{
			if(col[nv]==c)return false;
		}
	}
	return true;
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		ok[a][b]=true;
		ok[b][a]=true;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<i;j++){
			if(!ok[i][j]){
				G[i].push_back(j);
				G[j].push_back(i);
			}
		}
	}
	int cur=0,nxt=1;
	dp[0][0]=true;
	for(int i=0;i<n;i++){
		if(col[i]==0){
			memset(cnt,0,sizeof(cnt));
			if(!dfs(i,1)){
				printf("-1\n");
				return 0;
			}else{
				for(int j=0;j<n;j++){
					if(dp[cur][j]){
						dp[nxt][j+cnt[0]]=true;
						dp[nxt][j+cnt[1]]=true;
					}
				}
				swap(nxt,cur);
				memset(dp[nxt],false,sizeof(dp[nxt]));
			}
		}
	}
	int ans=m;
	for(int i=0;i<=n;i++){
		if(dp[cur][i]){
			int da=i*(i-1)/2;
			da+=(n-i)*(n-1-i)/2;
			ans=min(ans,da);
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){

	char str[21];
	char r_str[21];
	int i,j;

	scanf("%s",&str);
	i=0;
	j=strlen(str)-1;
	while(str[i] != '\0'){
		r_str[j-i]=str[i];
		i++;
	}
	r_str[j+1]='\0';
	printf("%s\n",r_str);
	return 0;
}

Measured memory_bytes: 524
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;

#define MP make_pair
#define F first
#define S second

int main(){
	int a,b,c;
    cin >> a >> b >> c;
    cout << c <<" "<< a <<" " << b;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long double ans = 0;
  long double pie = 3.141592653589793238;
  int a;
  cin >> a;
  
  ans = a * 2;
  ans = ans * pie;
  
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > bellman_ford(Edges< T > &edges, int V, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(V, INF);
  dist[s] = 0;
  for(int i = 0; i < V - 1; i++) {
    for(auto &e : edges) {
      if(dist[e.src] == INF) continue;
      dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
    }
  }
  for(auto &e : edges) {
    if(dist[e.src] == INF) continue;
    if(dist[e.src] + e.cost < dist[e.to]) return vector< T >();
  }
  return dist;
}

int V,E,r;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>V>>E>>r;

    Edges<int> g;
    REP(i,E){
        int s,t,d;
        cin>>s>>t>>d;
        g.emplace_back(s,t,d);
    }

    vi dist = bellman_ford<int>(g,V,r);
    //DEBUG_VEC(dist);

    if(dist.empty()){
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    REP(i,dist.size()){
        if(dist[i]==INT_MAX) cout << "INF" << endl;
        else cout << dist[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3236
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 0, b = 0, c, d, n, k = 0, ans = 0;
string s, t;


int main()
{
	cin >> s;
	string ans;
	rep(i, sz(s))
	{
		if (s[i] == 'B')
		{
			if (!ans.empty())
				ans.erase(sz(ans) - 1);
		}
		else
			ans += s[i];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

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

  int n, k;
  cin >> n >> k;
  double dn = 0.0;
  dn += n;
  double ans = 0.0;
  cout << fixed;
  cout << setprecision(14);
  /*
  cerr << fixed;
  cerr << setprecision(14);
  */
  
  FOR(i,1,n+1){
    if(i >= k) ans += (double)(1/dn);
    else{
      double times = 0.0;
      int val = i;
      while(val<k){
	val *= 2;
	times++;
      }
      //cerr << times << endl;
      //cerr << (double)(1/dn) << endl;
      ans += (double)(1/dn) * (double)pow(0.5,times);
    }
  }
  cout << ans << endl;
  
  return 0;
}


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

int main(void)
{
  double x1, y1, x2, y2;
  scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);

  printf("%lf\n", sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));

  return 0;
}

Measured memory_bytes: 2688
#include<cstdio>
#include<iostream>
#include<cstring>
#define ll long long
using namespace std;
ll ans;
int len;
char ch[202020];
int doe[33];
int main()
{
	scanf("%s",ch+1);
	len=strlen(ch+1);
	for (int i=1;i<=len;++i)
	{
		++doe[ch[i]-'a'];
		ans+=(i-doe[ch[i]-'a']);
	}
	printf("%lld\n",ans+1);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;

int main(){
     
    char a,b;
    
    cin>>a>>b;
    if((a=='H'&&b=='H')||(a=='D'&&b=='D'))cout<<"H"<<endl;
    else cout<<"D"<<endl;
     
    return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define LL long long
int n;

int main() {
    #ifdef LOCAL
        freopen("test.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif // LOCAL
    ios::sync_with_stdio(false);

    while(scanf("%d", &n) != EOF) {
        printf("%d\n", n / 3);
    }

    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main(){
    string str1,str2,str3;
    int n,a,b,j,k;
    cin>>str1>>n;
    for(int i=0;i<n;i++){
        cin>>str3;
        if(str3=="print"){
            cin>>a>>b;
            cout<<str1.substr(a,b-a+1)<<endl;
        }
        else if(str3=="replace"){
            cin>>a>>b>>str2;
            str1.replace(a,b-a+1,str2);
        }
        else if(str3=="reverse"){
            cin>>a>>b;
            str2=str1.substr(a,b-a+1);
            for(j=0,k=b;k>=a;k--){
                str1[k]=str2[j++];
            }
        }
    }
return 0;
}


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

namespace CS_AtCoder {
	class Program {
		static void Main(string[] args) {
			new Calc().Solve();
		}
	}
	public class Calc {
		Scan cin = new Scan();
		public void Solve() {
			var NM = cin.ReadInt(' ');
			int[] bridge = new int[NM[0]];
			for (int i = 0; i < NM[1]; i++) {
				var aibi = cin.ReadInt(' ');
				bridge[aibi[0]-1]++;
				bridge[aibi[1]-1]++;
			}
			foreach (var item in bridge) {
				item.WL();
			}
			return;
		}
	}

	public class Scan {
		public Scan() { }
		public int ReadInt() => int.Parse(Console.ReadLine());
		public int[] ReadInt(char separator) => Console.ReadLine().Split(separator).Select(int.Parse).ToArray();
		public double ReadDouble() => double.Parse(Console.ReadLine());
		public double[] ReadDouble(char separator) => Console.ReadLine().Split(separator).Select(double.Parse).ToArray();
		public long ReadLong() => long.Parse(Console.ReadLine());
		public long[] ReadLong(char separator) => Console.ReadLine().Split(separator).Select(long.Parse).ToArray();
		public string ReadLine() => Console.ReadLine();
		public string[] ReadLine(char separator) => Console.ReadLine().Split(separator).ToArray();
	}
	public static class Utils {
		public static string Docking<T>(this IEnumerable<T> collection,Func<T,string> filter = null) {
			StringBuilder sb = new StringBuilder();
			foreach (var item in collection) {
				sb.Append(filter != null ? filter(item) : item.ToString());
			}
			return sb.ToString();
		}
		public static void WL(this object obj) => Console.WriteLine(obj);
		public static int IntParse(this string s) => int.Parse(s);
		public static int IntParse(this char c) => c - '0';
	}
}


Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000 * 1000 * 1000 + 7;
const int N = 5e5 + 7;
const int C = 1 << 20;
int mod(int n) {
    return (n % MOD + MOD) % MOD;
}   
void add(int &a, int b) {
    a = mod(a + b);
}   
int a[N];
int p0[N], pr[N];
int dp[N][2];

int sp[C], s[C];
int dp1[N];

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];        
    for (int i = 1; i <= n; ++i) pr[i] = pr[i - 1] ^ a[i];
    for (int i = 1; i <= n; ++i) p0[i] = p0[i - 1] + !pr[i];
    if (pr[n]) {
        dp[0][0] = 1;
        for (int i = 1; i < n; ++i) {
            if (pr[i] == pr[n]) {
                dp[i][0] = dp[i - 1][0];
                dp[i][1] = mod(dp[i - 1][0] + dp[i - 1][1]);
            }
            else if (pr[i] == 0) {
                dp[i][1] = dp[i - 1][1];
                dp[i][0] = mod(dp[i - 1][0] + dp[i - 1][1]);
            }
            else {
                dp[i][0] = dp[i - 1][0];
                dp[i][1] = dp[i - 1][1];
            }   
        }   
        cout << dp[n - 1][0] << '\n';
    }
    else {

        #ifdef HOME
        for (int i = 1; i <= n; ++i) {
            cout << pr[i] << ' ';
        }   
        cout << '\n';
        #endif

        int ans = 0;
        for (int i = n; i >= 1; --i) {
            if (pr[i] == 0) continue;
            dp1[i] = mod(sp[pr[i]] - s[pr[i]] * p0[i] + 1);
            add(sp[pr[i]], dp1[i] * p0[i]);
            add(s[pr[i]], dp1[i]);
            add(ans, dp1[i]);
        }   
        
        #ifdef HOME
        for (int i = 1; i <= n; ++i) cout << dp1[i] << ' ';
        cout << '\n';
        #endif

        int cnt = 0;
        for (int i = 1; i < n; ++i) cnt += pr[i] == 0;
        int t = 1;
        for (int i = 0; i < cnt; ++i) t = mod(t << 1);
        add(ans, t);
        cout << ans << '\n';
    }   
}


Measured memory_bytes: 33920
s=input()
t=input()
if s==t:
    print('No')
    exit(0)
alp="abcdefghijklmnopqrstuvwxyz"
d={}
e={}
for i in range(len(alp)):
    d[alp[i]]=i
    e[i]=alp[i]

s_array = []
for i in range(len(s)):
    s_array.append(d[s[i]])

s_array=sorted(s_array)

t_array=[]
for j in range(len(t)):
    t_array.append(d[t[j]])

t_array=sorted(t_array,reverse=True)

s=''
for i in range(len(s_array)):
    s+=e[s_array[i]]

t=''
for j in range(len(t_array)):
    t+=e[t_array[j]]

dictionary={}
dictionary[s]=1
dictionary[t]=1

dictionary=sorted(dictionary.items(),key=lambda x: x[0])

if dictionary[0][0]==s:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9052
import java.util.Scanner;


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

		int a = sc.nextInt();
		if(a>=1200){
			System.out.println("ARC");
		}else if(a<1200){
			System.out.println("ABC");
		}

}
}

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

using ll=long long;
const ll z=0;

int main() {
  int N,a=0;
  cin >> N;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >> H[i];
  }
  int MAX=H[0];
  for(int i=1;i<N;i++){
    if(MAX-H[i]>1)
      a=1;
    MAX=max(MAX,H[i]);
  }
  
  if(a==0){
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
  
}

Measured memory_bytes: 640
gets.to_i
as = gets.split(' ').map(&:to_i)
bs = gets.split(' ').map(&:to_i)
cs = gets.split(' ').map(&:to_i)

sum = 0
as.each_with_index do |a, i|
  sum += bs[i]
  if i != 0 && a == as[i-1] + 1
    sum += cs[a-2]
  end
end
puts sum

Measured memory_bytes: 1788
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, K;
  cin>>N>>K;
  cout<<N-K+1<<endl;
}


Measured memory_bytes: 3544
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

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

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

		int N = sc.nextInt();

		int max = 0;
		int ans = 0;

		for(int i=0;i<N;i++) {
			int p = sc.nextInt();
			ans += p;
			max = Math.max(max, p);
		}

		ans = (ans - max) + (max / 2);

		out.println(ans);

		sc.close();

	}

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

}


Measured memory_bytes: 21716
//300
fun ac096(args: Array<String>) {
    val (a, b, c, x, y) = args[0].split(" ").map { it.toInt() }
    val onlyC = Math.max(x, y) * 2 * c
    val cAndAOrB =
            if (x < y) {
                x * 2 * c + (y - x) * b
            } else {
                y * 2 * c + (x - y) * a
            }
    val onlyAAndB = a * x + y * b
    println(listOf(onlyC, cAndAOrB, onlyAAndB).min())
}

fun main(args: Array<String>) {
    ac096(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

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

int main() {
  int n;
  cin>>n;
  long long a[n];
  for(int i=0;i<n;i++){
    long long k;
    cin>>k;
    a[i]=k-i;
  }
  sort(a,a+n);
  long long t=a[n/2],ans=0;
  for(int i=0;i<n;i++){
    a[i]-=t;
    ans+=abs(a[i]);
  }
  cout<<ans<<endl;
}


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

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

  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }

  int ans=0;

  for(int i=0; i<n; i++){
    if(a[a[i]-1]-1 == i){
      ans++;
    }
  }

  cout << ans/2 << endl;
  
  return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, p = LI()
    def fact(x):
        res = 1
        for i in range(2, int(sqrt(x)) + 3):
            t = 0
            while x % i == 0:
                t += 1
                x //= i
            while t >= n:
                res *= i
                t -= n
        return res
    if n == 1:
        print(p)
        return
    print(fact(p))

    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39792
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;
typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int x,y;
	cin>>x>>y;
	int tv = 0;
	if((x == 1) && (y == 1))
	tv += (2*300000) + 400000;
	else if(x == 1)
	{
		tv += 300000;
		if(y == 2)
		tv += 200000;
		else if(y == 3)
		tv += 100000;
	}
	else if(x == 2)
	{
		tv += 200000;
		if(y == 1)
		tv += 300000;	
		else if(y == 2)
		tv += 200000;
		else if(y == 3)
		tv += 100000;	
	}	
	else if(x == 3)
	{
		tv += 100000;
		if(y == 1)
		tv += 300000;	
		else if(y == 2)
		tv += 200000;
		else if(y == 3)
		tv += 100000;	
	}
	else
	{
		if(y == 1)
		tv += 300000;	
		else if(y == 2)
		tv += 200000;
		else if(y == 3)
		tv += 100000;
	}	
	cout<<tv<<"\n";
	return;	
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

/*#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif*/

	while(T--)
	solve(T);

/*#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif*/

	return 0;
}

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

int main(void){
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int count = 0;
    for (int i = 0; i <= a; i++){
        for (int j = 0; j <= b; j++){
            for (int k = 0; k <= c; k++){
                if(500*i+100*j+50*k == x){
                    count++;
                }
            }
            
        }
        
    }
    cout << count << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  ll cur = 0;
  rep(i, n) {
    if (a[i] == cur + 1) cur++;
  }
  if (cur == 0) {
    cout << -1 << endl;
  } else {
    cout << n - cur << endl;
  }
  return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;
const int mod    = 998244353;
struct mint {
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    mint operator()(int n) { return fact[n]; }
};

int main() {
    lint N, M, K;
    cin >> N >> M >> K;
    combination comb(10000000);
    mint ans = 0;
    for (int k = 0; k <= K; k++) {
        int l = (N - 1) - k;
        // dd(k, l);
        // d(comb(M, l + 1).x);
        ans += comb(N - 1, l) * comb(M, 1) * comb(M - 1, 1).pow(l);
        // cout << ans.x << endl;
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 159548
// Problem : E - Sequence Sum
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define int long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define mod 998244353
#define bug cout<<"HY"<<endl
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define numize(A) A.numize(unique(A.begin(), A.end()) - A.begin())
typedef pair<int,int> P;
int power(int a,int b)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return (power((a*a)%mod,b/2))%mod;
    return (a*(power((a*a)%mod,b/2))%mod)%mod;
}
int modInv(int n)
{
    return power(n, MOD-2);
}
int nCr(int n, int r, int p=MOD)
{
   if (r==0)
      return 1;
    int Fact[n+1];
    Fact[0] = 1;
    for (int i=1 ; i<=n; i++)
    {
        Fact[i] = (Fact[i-1]*i)%p;
    }
    return (((Fact[n]* modInv(Fact[r])) % MOD) *(modInv(Fact[n-r]) % MOD)) % MOD;
}
double PI=3.14159265359;
void solve()
{
	int n,x,m,i;
	cin>>n>>x>>m;
	int Cnt[m];
	int V[m];
	memset(Cnt,0,sizeof(Cnt));
	memset(V,0,sizeof(V));
	while(n && x)
	{
		if(Cnt[x]>0)
			break;
		V[x]=(x*x)%m;
		Cnt[x]++;
		x=(x*x)%m;
		n--;
	}
	if(n!=0 && x!=0)
	{
		int num=1;
		int s=x;
		int cycle=1;
		while(V[s]!=x)
		{
			cycle++;
			s=V[s];
		}
		int time=n/cycle;
		int extra=n%cycle;
		// cout<<x<<" "<<time<<" "<<extra<<" "<<<n<<" "<<cycle<<endl;
		// return;
		while(n>0)
		{
			Cnt[x]+=time+(extra?1:0);
			n-=(time+(extra?1:0));
			x=(x*x)%m;
			if(extra>0)
				extra--;
		}
	}
	int ans=0;
	for(i=0;i<m;i++)
	{
		ans+=i*Cnt[i];
	}
	cout<<ans<<endl;
}
int32_t main()
{
    boost;
    int  t=1;
    // cin>>t;
    while(t--)
    {
    	solve();
    }
}


Measured memory_bytes: 5216
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int N,M;
vector<int> g[50];
int check[50];
int A[50],B[50];
bool dfs(int v,int i){
	bool flag=true;
    check[v]=1;
	for(int u:g[v]){
        if(check[u]==1) continue;
        else if(v==A[i]&&u==B[i]) continue;
		else if(u==B[i]) flag=false;
		else flag&=dfs(u,i);
	}return flag;
}
int main(){
	cin>>N>>M;
	int a,b;
	rep(i,0,M){
		cin>>a>>b; a--; b--;
		A[i]=a; B[i]=b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int cnt=0;
	rep(i,0,M){
        rep(j,0,N) check[j]=0;
		if(dfs(A[i],i)) cnt++;
	}cout<<cnt<<endl;
}

Measured memory_bytes: 256
def p_d():
    L, R = map(int, input().split())

    def f(x):
        tmp = 0
        if not (x & 1):
            tmp = x
            x -= 1
        x = 0 if (x - 3) % 4 == 0 else 1
        return x + tmp

    print(f(L - 1) ^ f(R))


if __name__ == '__main__':
    p_d()

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

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



int main(){
  char a,b;
  cin >> a >> b;
  char c = min(a,b);
  int n = int(max(a,b)) - 48;
  rep(i,n) cout << c;
  return 0;
}




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

using namespace std;

int main() {
	string s,check,sx;
	int i, sum_w = 0, sum_b = 0;

	cin >> s;

	check = s[0];
	sx = s;
	
	while (1) {
		if (check == "B") {
			sum_w+=2;
			i = s.find("W", 0);
			if (i == EOF)
				break;
			s.erase(0, i);
			check = "W";
		}
		else {
			sum_b+=2;
			i = s.find("B", 0);
			if (i == EOF)
				break;
			s.erase(0, i);
			check = "B";
		}
	}

	if (sum_w*sum_b == 0)
		cout << 0;
	else {
		if (sx[0]==sx[sx.size()-1]) {
			if (sum_b < sum_w)
				cout << sum_w - 2;
			else
				cout << sum_b - 2;
		}
		else {
			if (sum_b > sum_w)
				cout << sum_w - 1;
			else
				cout << sum_b - 1;
		}
	}
	
	return 0;
}

Measured memory_bytes: 512
## ABC105C - Base -2 Number
def main():
    N = int(input())
    ans = ""
    while N != 0:
        r = N % 2
        r += 2 if r < 0 else 0
        N = (N - r) // -2
        ans += str(r)
    print(ans[::-1] if ans else 0)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
n, m = map(int, input().split())
graph = [[10 ** 9 for _ in range(n)] for _ in range(n)]
edge = []
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    graph[a][b] = c
    graph[b][a] = c
    edge.append((a, b))
for i in range(n):
    graph[i][i] = 0

from copy import deepcopy
distance = deepcopy(graph)    
for k in range(n):
    for i in range(n):
        for j in range(n):
            distance[i][j] = min(distance[i][j], distance[i][k] + distance[k][j])
ans = 0
for i, j  in edge:
    if distance[i][j] < graph[i][j]:
        ans += 1
print(ans)

Measured memory_bytes: 9688
x1, y1, x2, y2 = map(int, input().split())
x3, y3 = x2 + (y1 - y2), y2 - (x1 - x2)
x4, y4 = x3 + (y2 - y3), y3 - (x2 - x3)
print(x3, y3, x4, y4)


Measured memory_bytes: 2940
#include <stdio.h>
int main(){
   long int a, b, k;
   scanf("%ld %ld %ld", &a, &b, &k);

   if(a-k < 0){
      if((a+b)-k < 0){
         a=0;
         b=0;
      }else{
         b-=(k-a);
         a=0;
      }
   }else{
      a-=k;
   }
   printf("%ld %ld\n", a, b);
   return 0;
}


Measured memory_bytes: 1708
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <functional>
#include <utility>
#include <vector>
using namespace std;
typedef pair<int,int> pii;
priority_queue<int,vector<int>,greater<int> > pq;
vector<pii> v;
int main(){
	int N,M;
	scanf("%d %d",&N,&M);
	for(int i=0;i<N;i++){
		int tmp;
		scanf("%d",&tmp);
		pq.push(tmp);
	}
	for(int i=0;i<M;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		v.push_back(make_pair(-b,-a));
	}
	sort(v.begin(),v.end());
	for(auto it : v){
		int b=-it.first, a=-it.second;
		for(int i=0;i<a;i++){
			if(pq.top()<b){
				pq.pop();
				pq.push(b);
			}
			else break;
		}
	}
	long long sum=0;
	while(!pq.empty()){
		sum+=pq.top();
		pq.pop();
	}
	printf("%lld",sum);
}

Measured memory_bytes: 1784
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int X[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << X[K-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)


ll modpow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        ll h = modpow(x, n / 2);
        return h * h % MOD;
    } else {
        return x * modpow(x, n - 1) % MOD;
    }
}

int gcd(int a,int b)  {
	if (a%b==0)  return(b);
	else return(gcd(b,a%b));
}

int main() {
    int A, B, X; cin >> A >> B >> X;
    string ans = "NO";
    if((A<=X)&&(X<=(A+B))) ans = "YES";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return
    if self.parents[x] > self.parents[y]:
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x
  def size(self, x):
    return -self.parents[self.find(x)]
  def same(self, x, y):
    return self.find(x) == self.find(y)
  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]
  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]
  def group_count(self):
    return len(self.roots())
  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}
  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M=map(int,input().split())

u=UnionFind(N)
for m in range(M):
  a,b=map(int,input().split())
  u.union(a-1,b-1)
print(u.group_count()-1)

Measured memory_bytes: 12760
import sys
n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))

h = [min(t[i],a[i]) for i in range(n)]
fixed = [False] * n
fixed[0] = True; fixed[n-1] = True

if a[n-1] > t[n-1] or t[0] > a[0]:
    print(0)
    sys.exit(0)
# takahashi check
for i in range(1,n):
    if t[i] > t[i-1]: 
        fixed[i] = True
        if t[i] > a[i]:
            print(0)
            sys.exit(0)
# aoki check
for i in range(n-2, -1, -1):
    if a[i] > a[i+1]:
        fixed[i] = True
        if a[i] > t[i]:
            print(0)
            sys.exit(0)

# calc ans
ans = 1
for i in range(n):
    if not fixed[i]:
        ans = ans * h[i] % (10**9+7)
print(ans)

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

int main(){
    int N; cin >> N;
    vector<int> X(N);
    int maximum = 101;
    int minimum = 0;
        for(int i=0;i<N;i++){
        cin >> X[i];
        maximum = max(maximum,X[i]);
        minimum = min(minimum,X[i]);
    }
    int t = 0;
    int ans = 100000000;
    for(int i=1;i<=100;i++){
        t=0;
        for(int j=0;j<N;j++){
            int x = abs(X[j]-i);
            t += x*x;
        }
        if(t<ans){
            ans = t;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

struct WarshallFloyd {
  vector<int> a,b,c;
  int V,E; // 辺の数
  int INF;
  vector<vector<int> > dist;
  WarshallFloyd(int V, int E):V(V),E(E){
    INF = 2e9;
    a.resize(E,INF);
    b.resize(E,INF);
    c.resize(E,INF);
    dist.resize(V, vector<int>(V, INF));
  }
  void calc(){
    for(int i=0;i<V;i++){
      dist[i][i]=0;
    }
    for(int i=0;i<E;i++){
      dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
    }
    for(int k=0;k<V;k++){
      for(int i=0;i<V;i++){
        for(int j=0;j<V;j++){
          if(dist[i][k]==INF||dist[k][j]==INF) continue;
          dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        }
      }
    }
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int V,E;
  cin>>V>>E;
  WarshallFloyd WF(V, E);
  FOR(i,0,E){
    cin>>WF.a[i]>>WF.b[i]>>WF.c[i];
  }
  WF.calc();
  FOR(i,0,V){
    if(WF.dist[i][i]<0){
      cout<<"NEGATIVE CYCLE"<<endl;
      return 0;
    }
  }
  FOR(i,0,V) {
    FOR(j,0,V) {
      if(j) cout<<" ";
      if(WF.dist[i][j]==2e9) cout<<"INF";
      else cout<<WF.dist[i][j];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 3304
#include<iostream>

using namespace std;

const int N = 100005, INF = 1e9;
struct card
{
    char suit;
    int value;
};
void swap(card *x, card *y){
    card z;
    z = *y;
    *y = *x;
    *x = z;
}
void merge(card A[], int p, int q, int r){
    int n1, n2;
    n1 = q - p + 1;
    n2 = r - q;
    card L[N], R[N];
    for (int i = 0; i < n1; i++)
        L[i] = A[p + i];
    for (int i = 0; i < n2; i++)
        R[i] = A[q + i + 1];
    L[n1].value = INF;
    R[n2].value = INF;
    int i = 0, j = 0;
    for (int k = p; k <= r; k++)
    {
        if (L[i].value <= R[j].value)
        {
            A[k] = L[i];
            i++;
        }
        else 
        {
            A[k] = R[j];
            j++;
        }
    }    
}

void merge_sort(card A[], int p,int r){
    int q;
    if (p < r)
    {
        q = (p + r) / 2;
        merge_sort(A, p, q);
        merge_sort(A, q+1, r);
        merge(A, p, q, r);
    }
}
int partition(card A[], int p, int r){
    int  i, j;
    card x;
    x = A[r];
    i = p - 1;
    for (j = p; j < r; j++)
    {
        if (A[j].value <= x.value)
        {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i+1], A[j]);
    return i+1;
}

void quick_sort(card A[], int p, int r){
    int q;
    if(p < r){
        q = partition(A, p, r);
        quick_sort(A, p, q-1);
        quick_sort(A, q+1, r);
    }
}


int main(){
    int n; cin >> n;
    card A[100005], B[100005];
    for (int i = 0; i < n; i++)
    {
        cin >> A[i].suit >> A[i].value;
        B[i].suit = A[i].suit;
        B[i].value = A[i].value;
    }
    quick_sort(A, 0, n-1);
    merge_sort(B, 0, n-1);
    bool stable = true;
    for (int i = 0; i < n; i++)
    {
        if(A[i].suit != B[i].suit){
            stable = false;
            break;
        }
    }
    cout << (stable ? "Stable" : "Not stable") << endl;
    for (int i = 0; i < n; i++)
    {
        cout << A[i].suit << " " << A[i].value << endl;
    }
}


Measured memory_bytes: 5448
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    string str;
    if(a<=b) rep(i,b) str+=to_string(a);
    else     rep(i,a) str+=to_string(b);
    cout<<str<<endl;

    return 0;
}

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

int main() {
    int a, b;
    char op;
    cin >> a >> op >> b;
    int res = 0;
    if (op == '+') {
        res = a + b;
    } else if (op == '-') {
        res = a - b;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
//#include <stdio.h>
#include <bits/stdc++.h>
#include <climits>
using namespace std;
int main()
{   
    int n;
    cin >> n;
    int a[22];
    int b[22];
    int c[22];
    int last=-4;
    int ans=0;
    bool flag[22]={false};
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(last+1==a[i]){
            flag[last]=true;
         //   cout << last<<endl;
        }
        last=a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
        ans+=b[i];
    }
    for (int i = 0; i < n-1; i++)
    {
        cin >> c[i];
        if(flag[i+1]==true){
            ans+=c[i];
        //    cout << i<<endl;
        }
    }
    cout << ans<<endl;
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

bool isprime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//#define int ll

int q;
int l,r,cnt=0;
int f[100010],c[100010];

signed main(){
    cin>>q;
    for(int i=2;i<=100000;i++)if(!f[i])for(int j=i+i;j<=100000;j+=i) f[j]=true; 
    for(int i=3;i<=100000;i+=2)if(!f[i]&&!f[(i+1)/2])c[i]++; 
    for(int i=3;i<=100000;i++)c[i]+=c[i-1]; 
    
    while(q--){
        cin>>l>>r;
        cout<<c[r]-c[l-1]<<endl;
    }
    return 0;
}

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

int n;
vector<int> c(1000),s(1000),f(1000);

void solve(int pla){
    int time=0;
    while(1){
        if(time<s[pla]){
            time=s[pla];
        }
        if(time%f[pla]){
            time+=f[pla]-time%f[pla];
        }
        time+=c[pla];
        pla++;
        if(pla==n-1) break;
    }
    cout<<time<<endl;
}

int main(){
    cin>>n;
    rep(i,n-1) cin>>c[i]>>s[i]>>f[i];
    rep(i,n-1) solve(i);
    cout<<"0"<<endl;
}

Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

double x, h, S;

int main(){
	while (cin >> x >> h&&x + h){
		printf("%.8lf\n", x*x + 2 * (sqrt(pow(x / 2, 2) + pow(h, 2)))*x);
	}
}

Measured memory_bytes: 1236
// kadai 3

#include <stdio.h>
#include <stdlib.h>

void printA(int a[], int n){
    int i;
    for(i=0;i<n;i++){
        printf("%d ",a[i]);
    }
    printf("\n");
}

void swap(int* a, int* b){
    int  tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void QuickSort(int a[], int n, int lef, int rig){
    int nxl,nxr,piv,t;
    if(lef >= rig) return;
    piv = a[(lef+rig)/2];
    nxl = lef;
    nxr = rig;
    while(nxl <= nxr){
        while(a[nxl] < piv) nxl++;
        while(a[nxr] > piv) nxr--;
        if(nxl <= nxr){
        	swap(&a[nxl],&a[nxr]);
        	nxl++;
        	nxr--;
        }
    }
    QuickSort(a,n,lef,nxr);
    QuickSort(a,n,nxl,rig);
}

void solve(int a[], int n){
    int i,ans1 = 0, ans2 = 0;
    QuickSort(a, n, 0, n-1);
    for(i=0;i<n/2;i++) swap(&a[i],&a[n-i-1]);
    for(i=0;i<n;i+=2) ans1 += a[i];
    for(i=1;i<n;i+=2) ans2 += a[i];
    printf("%d\n",ans1-ans2);
}

int main(void){
    int n,i;
    int *v;
    scanf("%d",&n);
    v = (int*)malloc(sizeof(int)*n);
    if(v==NULL){
        printf("ERROR\n");
        return -1;
    }
    for(i=0;i<n;i++){
        scanf("%d",&v[i]);
    }
    solve(v,n);
    return 0;
}


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

#define int long long
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define vint vector<int>
#define vchar vector<char>
#define vstr vector<string>
#define pb(n) push_back(n)

signed main(){
  int A,B,N,M,count=0,count2=0,count3=0,stack=0;
  str S,T;
  int C='A'-'a';
  cin>>N;
  vint V(N);
  rep(0,N)cin>>V.at(i);
  sort(all(V));
  cout<<abs(V.at(N-1)-V.at(0))<<endl;
}


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


int main(){
    ll n;
    cin >> n;
    string ans;
    while(n){
        n--;
        ans += 'a' + n%26;
        n /= 26;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
    return 0;
}

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

int main() {
	int a, b;
	char s;

	cin >> a >> s >> b;

	while (s != '?') {
		if (s == '+') cout << a + b << endl;
		else if (s == '-') cout << a - b << endl;
		else if (s == '*') cout << a * b << endl;
		else if (s == '/') cout << a / b << endl;
		cin >> a >> s >> b;
	}

	return 0;
}



Measured memory_bytes: 3088