akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int a, b;
        cin >> a >> b;
        if (a<=b)
        {
                cout << a << endl;
        } else{
                cout << a - 1 << endl;
        }

      

        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define me memset
const int N=1e6+10;
const int mod=1e9+7;
using namespace std;
int k;
long long q[N],hh=1,tt=0;
int main(){
	scanf("%d",&k);
	if(k<=12){
		printf("%d\n",k);
		return 0;
	}
	for(int i=1;i<=9;++i) q[++tt]=i;
	int cnt=0;
	long long ans;
	while(cnt!=k){
		long long now=q[hh];
		hh++;
		long long res=now%10;
		if(res!=0)q[++tt]=now*10+res-1,cnt++;
		if(cnt==k-10+1){
		   ans=q[tt];
		   break;
		}
		q[++tt]=now*10+res,cnt++;
		if(cnt==k-10+1){
			ans=q[tt];
			break;
		}
		if(res!=9)q[++tt]=now*10+res+1,cnt++;
		if(cnt==k-10+1){
			ans=q[tt];
			break;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

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

int main() {
	ll A, B;
	cin >> A >> B;
	cout << A*B/gcd(A, B) << endl;
	return 0;
}

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

int main()
{
    std::vector<int> num(3);
    for (int i = 0; i < 3; i++) {
        std::cin >> num[i];
    }

    int num_5 = 0, num_7 = 0;
    for (int i = 0; i < 3; i++) {
        if (num[i] == 5) {
            num_5++;
        } else if (num[i] == 7) {
            num_7++;
        }
    }

    if (num_5 == 2 && num_7 == 1) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}


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

int main(void){
  int A[3][3] = {};
  bool isA[3][3] = {};
  //std::cin >> a;
  //std::cin >> b;
  for(int i = 0;i < 3;i++){
    for(int j = 0;j < 3;j++){
      std::cin >> A[i][j];
    }
  }
  int N = 1;
  std::cin >> N;
  
  int b[N] = {}; 
  for(int k = 0;k < N;k++){
    std::cin >> b[k];
    for(int i = 0;i < 3;i++){
      for(int j = 0;j < 3;j++){
        if(A[i][j] == b[k]){
          isA[i][j] = true;
        }
      }
    }
  }
  
  std::string ans = "No";
  if((isA[0][0] && isA[0][1] && isA[0][2]) ||
     (isA[0][0] && isA[1][1] && isA[2][2]) ||
     (isA[0][0] && isA[1][0] && isA[2][0]) ||
     (isA[0][1] && isA[1][1] && isA[2][1]) ||
     (isA[0][2] && isA[1][2] && isA[2][2]) ||
     (isA[1][0] && isA[1][1] && isA[1][2]) ||
     (isA[2][0] && isA[2][1] && isA[2][2]) ||
     (isA[2][0] && isA[1][1] && isA[0][2])){
    ans = "Yes";
  }       
  
  std::cout << ans << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif m + f >= 80:
        print('A')
    elif m + f >= 65:
        print('B')
    elif m + f >= 50:
        print('C')
    elif m + f >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')



Measured memory_bytes: 5596
using System;

namespace AOJ_Progran
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            for(int i=0;i<n;i++)
            {
                double[] triangle = new double[3];
                string[] s = Console.ReadLine().Split(' ');
                for (int j = 0; j < 3;j++ )
                {
                    triangle[j] = double.Parse(s[j]);
                }
                Array.Sort(triangle);

                    if (Math.Pow(triangle[2], 2) == (Math.Pow(triangle[0], 2) + Math.Pow(triangle[1], 2)))
                        Console.WriteLine("YES");
                    else
                        Console.WriteLine("NO");
            }
        }
    }
}

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

{
  int a[5];
  int x;
  for(int i=0;i<5;++i)
  {
    cin>>a[i];
    if(a[i]==0)
    {
     x=i+1;
     }
  }
  cout<<x;
  return 0;
  
}

Measured memory_bytes: 3592
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define rall(n) std::rbegin(n), std::rend(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void init() {
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
}

void calc() {

	Int X; std::cin >> X;

	for (Int A = -1000; A <= 1000; ++A)for (Int B = -1000; B <= 1000; ++B) {
		if (pow(A, 5) - pow(B, 5) == X) {
			std::cout << A << " " << B;
			return;
		}
	}

}


int main() {

	init();
	calc();

	return 0;
}

Measured memory_bytes: 4116
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int n,m,x,y,ans;
vector<int> g[100005];
int h[100005];
int32_t main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    for(int i=0;i<m;i++){
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    for(int i=1;i<=n;i++){
        int f = 1;
        for(int j=0;j<g[i].size();j++){
            if(h[g[i][j]]>=h[i]){f=0;break;}
        }
        if(f==1){
            ans++;
        }
    }
    cout<<ans;
    
}

Measured memory_bytes: 9104
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n;
    bool flag=false;
    scanf("%d",&n);
    while(n--){
        if(flag)puts("");
        else flag=true;
        int fld[9][9];
        for(int i=0;i<9;i++)for(int j=0;j<9;j++)scanf("%d",&fld[i][j]);

        for(int i=0;i<9;i++){
            for(int j=0;j<9;j++){
                bool flag=true;
                for(int k=0;k<9;k++){
                    if(i!=k)flag&=(fld[k][j]!=fld[i][j]);
                    if(j!=k)flag&=(fld[i][k]!=fld[i][j]);
                }
                int y=i/3*3,x=j/3*3;
                for(int k=0;k<9;k++){
                    if(y+k/3!=i||x+k%3!=j)
                        flag&=(fld[y+k/3][x+k%3]!=fld[i][j]);
                }
                if(flag)printf(" ");
                else printf("*");
                printf("%d",fld[i][j]);
            }
            puts("");
        }
    }
}

Measured memory_bytes: 1040
#
# File    : A.rb
# Author  : Kazune Takahashi
# Created : 2018-7-7 21:38:18
# Powered by Visual Studio Code
#

a, b = gets.chomp.split(" ").map{|i| i.to_i}
if a + b == 15
  puts "+"
elsif a * b == 15
  puts "*"
else
  puts "x"
end

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			//2???????????¶??°???????????????
			int numX = sc.nextInt();
			int numY = sc.nextInt();

			//0??????????????§??????????±???????
			int output = 0;
			int checkNum = 0;
			do {
				//??°????????????
				if (numX >= numY) {
					checkNum = numX % numY;
					numX = checkNum;
				}else{
					checkNum = numY % numX;
					numY = checkNum;
				}
			} while (checkNum != 0);
			//???????????????
			output = Math.max(numX, numY);
			System.out.println(output);
		}catch (Exception e) {
			System.out.println(e);
		} finally {
			if (sc != null) {
				sc.close();
			}
		}
	}

}

Measured memory_bytes: 26328
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>a>>b>>c;
    if(min(a,b)<=c&&c<=max(a,b))Cout("Yes");
    else Cout("No");
    return 0;
}


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

#define all(v) begin(v), end(v)
#define endl   '\n';
#define int    long long
#define pii    pair<int, int>

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

    int n; cin >> n;
    vector<int> a(n);
    int res = 1;
    bool overflow = false, hasZero = false;
    for (int& x : a) {
        cin >> x;
        if (x == 0) {
            hasZero = true;
            break;
        }
        if (res <= (long double)(1e18) / x) {
            res *= x;
        } else {
            overflow = true;
        }
    }
    if (hasZero) {
        cout << 0 << endl;
        return 0;
    }
    if (overflow) {
        cout << -1 << endl;
        return 0;
    }
    cout << res << endl;

}

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

int main() {
  long int N,K,i,j,x,ans=1;
  cin>>N>>K;
  vector<int> A(N+1),B(N+1,-1);
  for(i=1;i<=N;i++)cin>>A[i];
  for(i=1;i<=K;i++){
    B[ans]=i-1;
    ans=A[ans];
    if(B[ans]!=-1){
      x=i-B[ans];
      break;
    }
    //for(j=1;j<=N;j++)if(B[j]>0||j==ans)B[j]++;
  }
  int a;
  if(x)a=(K-i)%x;
  //cout<<a<<","<<ans<<","<<(727202214173249351-2)%3<<","<<B[ans]<<","<<i<<endl;
  for(i=0;i<a;i++){
    ans=A[ans];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4844
#include <iostream>
#include <algorithm>
using namespace std;
int a[200];
int main()
{
	int n,m,x;
	cin>>n>>m>>x;
	for(int i=1;i<=m;i++)
	 {
	 	int  t;
	 	cin>>t;
	 	a[t]=1;
	 }
	 int maxx=0,minn=0;
	 for(int i=x+1;i<=n;i++)
	 {
	 	if(a[i])
	 	{
	 		maxx++;
	 	}
	 }
	for(int i=x-1;i>=1;i--)
	 {
	 	if(a[i])
	 	{
	 		minn++;
	 	}
	 }
	 cout<<min(maxx,minn);
	 return 0;
}


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

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

  int v[3];
  cin >> v[0] >> v[1] >> v[2];
  swap(v[0], v[1]);
  swap(v[0], v[2]);
  cout << v[0] << " " << v[1] << " " << v[2] << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<set>
#include<bitset>
int main()
{
	const int N=300010;
	int n,i,j,k,l,a[]={6,8};
	std::bitset<N>p;
	p.set();
	for(i=0;i<2;++i)for(j=a[i];j<=N/6;j+=7)if(p[j])for(k=0;k<2;++k)for(l=a[k]*j;l<N;l+=7*j)p[l]=0;
	
	while(scanf("%d",&n),n-1)
	{
		typedef std::set<int>S;
		S s;
		printf("%d:",n);
		for(i=6;i<=n+2;i+=7)
		{
			if(n%i==0&&p[i])s.insert(i);
			if(n%(i+2)==0&&p[i+2])s.insert(i+2);
		}
		for(S::iterator t=s.begin();t!=s.end();++t)printf(" %d",*t);
		puts("");
	}
	return 0;
}

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

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using ml = map<ll,ll>;

#define ff first
#define ss second
#define endl '\n'
#define ins insert
#define eb emplace_back
#define sz(c) (ll) c.size()
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define itr(x,c) for(auto &x : c)
#define tc ll t; cin >> t; while(t--)
#define rep(i,a,n) for(ll i = a ; i < n ; ++i)
#define per(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) itr(x,c) cout << x << " "; cout << endl;
#define dm(m) itr(x,m) cout << x.ff << " -> " << x.ss << endl;
#define godspeed cin.tie(0) -> sync_with_stdio(0);


int main() {
    godspeed;
    
    ll sev = 7;
    ll k; cin >> k;

    ll ans = 1;

    if(k % 2 == 0 || k % 5 == 0) {cout << -1; return 0;}

    for(ll i = 0 ; i < 1000000 ; ++i) {
    	if(sev % k == 0) {cout << ans; return 0;}
    	ans++;
    	sev = (sev * 10 + 7) % k;
    }

    cout << -1;
}

Measured memory_bytes: 3628
#pragma warning(disable:4996)

#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <complex>
#include <iterator>
#include <random>
#include <time.h>
#include <tuple>
#include <functional>
#include <list>
#include <limits.h>
#define mp make_pair
#define ni(x) scanf("%d", &(x))
#define nii(x,y) scanf("%d%d",&(x),&(y))
#define mul(x,y) ((ll)(x)*(y)%mod)
#define mtp make_tuple
#define F(i,n) for(int i = 0; i < (n); i++)
#define FF(i,n) for(int i = 1; i <= (n); i++)
#define FE(i,n) for(int i = 0; i <= (n); i++)

#ifndef __GNUG__
int __builtin_popcount(int n) {
	int x = 0;
	while (n)n -= n&(-n), x++;
	return x;
}
#endif

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int mod = 998244353;
const int inf = 2012345678;
const ll infl = 9012345678901234567;
const double pi = 3.1415926535897932384626433832795;
//----------------------------------------------------------------------------//

int chk[101010];
pii L[101010], R[101010];

ll Do(int n,int icr) {
	for (int i = 0; i < n; i++)chk[i] = 0;
	int li = n, ri = 0;
	int cr = icr; int cur = 0;
	ll ans = 0;

	while (1) {
		if (!cr) {
			while (li && chk[L[li - 1].second])li--;
			if (li == 0 || L[li-1].first <=cur) return ans + abs(cur);
			chk[L[li-1].second] = 1;
			ans += abs(cur - L[li-1].first);
			cur = L[li - 1].first;
		}
		else {
			while (ri < n && chk[R[ri].second])ri++;
			if (ri == n || R[ri].first >= cur)return ans + abs(cur);
			chk[R[ri].second] = 1;
			ans += abs(cur - R[ri].first);
			cur = R[ri].first;
		}
		cr ^= 1;
	}
	return ans + abs(cur);
}

int main() {
//	freopen("input.txt", "r", stdin);
	int n; ni(n);
	F(i, n) {
		int l, r; nii(l, r);
		L[i] = { l,i };
		R[i] = { r,i };
	}
	sort(L, L + n); sort(R, R + n);
	ll ans = Do(n,0);
	ans = max(ans, Do(n,1));
	printf("%lld\n", ans);

}

Measured memory_bytes: 2176
#![allow(dead_code)]
fn solve(src: &str) -> String {
    use std::fmt::Write;
    let mut sc = Scanner::from_str(src);
    let mut buf = String::new();

    let n: usize = sc.read();
    let m: usize = sc.read();
    let l: i64 = sc.read();
    let neighbor = {
        let mut neighbor = vec![vec![]; n];
        for _ in 0..m {
            let v: usize = sc.read();
            let w: usize = sc.read();
            let c: i64 = sc.read();
            neighbor[v - 1].push((w - 1, c));
            neighbor[w - 1].push((v - 1, c));
        }
        neighbor
    };
    let d = shortest_paths(n, &neighbor);
    let mut near = vec![vec![]; n];
    for i in 0..n {
        for j in 0..n {
            if d[i][j] <= l {
                near[i].push((j, 1));
            }
        }
    }
    let d = shortest_paths(n, &near);

    let q: usize = sc.read();
    for _ in 0..q {
        let s: usize = sc.read();
        let t: usize = sc.read();
        if d[s-1][t-1] > 10i64.pow(15) {
            writeln!(&mut buf, "-1");
        } else {
            writeln!(&mut buf, "{}", d[s-1][t-1]-1);
        }
    }

    buf
}
#[test]
fn test_solve() {
   assert_eq!(solve("3 2 5\n1 2 3\n2 3 3\n2\n3 2\n1 3\n"), "0\n1\n");
   assert_eq!(solve("4 0 1\n1\n2 1\n"), "-1\n");
   assert_eq!(solve("5 4 4\n1 2 2\n2 3 2\n3 4 3\n4 5 2\n20\n2 1\n3 1\n4 1\n5 1\n1 2\n3 2\n4 2\n5 2\n1 3\n2 3\n4 3\n5 3\n1 4\n2 4\n3 4\n5 4\n1 5\n2 5\n3 5\n4 5\n"), "0\n0\n1\n2\n0\n0\n1\n2\n0\n0\n0\n1\n1\n1\n0\n0\n2\n2\n1\n0\n");
}
fn shortest_paths(n: usize, neighbor: &Vec<Vec<(usize, i64)>>) -> Vec<Vec<i64>> {
    let mut d = vec![vec![i64::max_value() >> 1; n]; n];
    for v in 0..n {
        for &(w, c) in &neighbor[v] {
            d[v][w] = c;
        }
    }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                d[i][j] = std::cmp::min(d[i][j], d[i][k] + d[k][j])
            }
        }
    }
    d
}
fn main() {
    let mut buf = String::new();
    use std::io::Read;
    std::io::stdin().read_to_string(&mut buf).unwrap();
    use std::io::Write;
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<I> {
    src: I,
}
impl<'a> Scanner<std::str::SplitWhitespace<'a>> {
    fn from_str(src: &'a str) -> Self {
        Scanner {
            src: src.split_whitespace(),
        }
    }
}
impl<'a, I> Scanner<I>
where
    I: std::iter::Iterator<Item = &'a str>,
{
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.src.next().unwrap().parse().ok().expect("Parse error")
    }
    fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    fn chars(&mut self) -> Vec<char> {
        self.src.next().unwrap().chars().collect()
    }
}


Measured memory_bytes: 12540
#include <iostream>
#include <sstream>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a-1)*(b-1);
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define nn 1000008
#define lg 21
int n;
int pos[nn];
struct afd{
	int bel[nn];
	int l[nn],r[nn];
	void init(int v)
	{
		for(int i=1;i<=n;i++)
		{
			if(i==1 or pos[i]-pos[i-1]>v) bel[i]=i,l[i]=r[i]=i;
			else bel[i]=bel[i-1],r[bel[i]]=i; 
		}
	}
}v2[lg];
int l=0;
int v;

void fuckoff()
{
	while(n--) puts("Impossible");
	exit(0);
}
int fl[nn],fr[nn];
void chkmin(int &x,int y) {x=min(x,y);}
void chkmax(int &x,int y) {x=max(x,y);}


int main()
{
	scanf("%d%d",&n,&v);
	for(int i=1;i<=n;i++) scanf("%d",&pos[i]);
	while(v) v2[l++].init(v),v/=2;
	v2[l++].init(v),v/=2;
	
	int cnt=0;
	for(int i=1;i<=n;i++)
		if(v2[0].bel[i]==i)
			cnt++;
	if(cnt>1+l) fuckoff();
	
	for(int ii=1;ii<=n;ii++)
	{
		if(v2[0].bel[ii]==ii)
		{
			int el=v2[0].l[ii],er=v2[0].r[ii];
			
			memset(fl,0x3f,sizeof fl);
			memset(fr,0,sizeof fr);
			
			fl[1]=el;fr[1]=er;
			
			for(int mask=1;mask<(1<<l);mask++)
			{
				if(!(mask&1) or fl[mask]>n) continue;
				for(int i=1;i<l;i++)
				{
					if(mask&(1<<i)) continue;
					int x=v2[i].bel[fl[mask]-1];

					if(!x) chkmin(fl[mask|(1<<i)],fl[mask]);
					else chkmin(fl[mask|(1<<i)],v2[i].l[x]);
				}
			}

			for(int mask=1;mask<(1<<l);mask++)
			{
				if(!(mask&1) or !fr[mask]) continue;
				for(int i=1;i<l;i++)
				{
					if(mask&(1<<i)) continue;
					int x=v2[i].bel[fr[mask]+1];
					
					if(!x) chkmax(fr[mask|(1<<i)],fr[mask]);
					else chkmax(fr[mask|(1<<i)],v2[i].r[x]);
				}
			}
		
			int flag=0;
			for(int mask=0;mask<(1<<l);mask++)
			if(mask&1)
				if(fl[mask]<=1 and fr[(((1<<l)-1)^mask)|1]>=n)
					flag=1;
						
			if(flag)
				for(int i=el;i<=er;i++) puts("Possible");
			else
				for(int i=el;i<=er;i++) puts("Impossible");
		}
	}
	
	return 0;
}

Measured memory_bytes: 151936
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

#if __has_include("debug.hpp")
#include "debug.hpp"
#else
template<typename T>
void debug(T& obj) {}
#endif

//----------------------------------------------------------------------
void solve() {

	ll N;
	string S,T;
	cin >> N >> S >> T;
	rep(i,N) {
		cout << S[i] << T[i];
	}

}
//----------------------------------------------------------------------

int main(int argc, char* argv[]) {
	solve();
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll a,b;
  cin >>a >> b;

  cout << max({a+b,a-b,a*b}) << endl;
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 3620
//============================================================================
// Name        : JOI.cpp
// Author      : 
// Version     : 20min
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
using namespace std;

int main() {

	int N;
	cin>>N;
	int m;
	int t=1;
	int p=1;
	for(int i=0;i<N;++i){
		cin>>m;
		if(m%2==0)t*=2;
		p*=3;
	}
	cout<<p-t<<endl;
	return 0;

}


Measured memory_bytes: 256
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    S = input().strip()
    n = int(input().strip()) - 1
    m=0
    for i in range(len(S)):
        if S[i] != '1':
            m = i
            break
    if n < m:
        print("1")
        return
    else:
        print(S[m])
        return


if __name__ == '__main__':
    main()


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

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INF =1LL << 60;
ll N;
ll h[101000];
//DP テーブル
ll dp[101000];

int main() {
   ll N,K; 
   cin >> N>>K;
   rep(i,N){
       cin>>h[i];
   }

// DP テーブル全体を初期化 (最小化問題なので INF に初期化)
for (int i = 0; i < 101000; ++i) {
    dp[i] = INF;
    }

// 初期条件
dp[0] = 0;

// ループ
for (ll i = 0; i < N; ++i) {

        for(ll j=1;j<=K;j++){
         chmin(dp[i+j], dp[i] + abs(h[i]-h[i+j]));
    
}}
    
// 解を得て出力
cout << dp[N-1] << endl;
return 0 ;

}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i,N)cin >> A[i];
    vector<ll> light(N);
    bool end = 0;
    REP(i,K){
        light.assign(N,0);
        REP(l,N){
            light[max((ll)0,l-A[l])]++;
            if(l + A[l] +1< N)light[l+A[l]+1]--;
        }
        end = 1;
        ll sum = 0;
        REP(l,N){
            sum += light[l];
            A[l] = sum;
            if(A[l] != N)end = 0;
        }
        if(end)break;
    }
    REP(i,N)cout << A[i] << "\n";
}

Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;

const int N = 1e5 + 10;
int a[N], n, q;
LL sum[N], oddS[N];

void init() {
    for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
    oddS[1] = a[1];
    for (int i = 2; i <= n; i++) oddS[i] = oddS[i - 2] + a[i];
}

bool check(int x, int mid) {
    if (a[mid] <= x) return 1;
    int left = lower_bound(a + 1, a + n + 1, 2 * x - a[mid]) - a;
    return mid - left + 1 < n - mid + 1;
}

LL solve(int x) {
    if (x >= a[n]) return oddS[n];
    int l = 1, r = n;
    while (l + 1 < r) {
        int mid = (l + r) >> 1;
        if (check(x, mid)) l = mid;
        else r = mid;
    }
    int p = n - (n - l) * 2;
    return sum[n] - sum[l] + oddS[p];
}

int main() {
    scanf("%d%d", &n, &q);
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    init();
    while (q--) {
        int x;
        scanf("%d", &x);
        printf("%lld\n", solve(x));
    }
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

class SegmentTree {
    using F = function<ll(ll, ll)>;
    const F f;
    int n, init;
    vector<int> node;

public:
    SegmentTree(int sz, const F f, ll init) : f(f), init(init) {
        n = 1;
        while (n < sz) n <<= 1;
        node.assign(2 * n, init);
    }

    void update(int x, ll val) {
        x += n;
        node[x] = val;
        while (x >>= 1) {
            node[x] = f(node[2 * x + 0], node[2 * x + 1]);
        }
    }

    // [a:b)
    ll query(int a, int b) {
        ll l = init, r = init;
        for (a += n, b += n; a < b; a >>= 1, b >>= 1) {
            if (a & 1) l = f(l, node[a++]);
            if (b & 1) r = f(node[--b], r);
        }
        return f(l, r);
    }
};


// verified
//   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A&lang=jp
void AOJ_DSL_2_A() {
    ll n, q, c, x, y;
    cin >> n >> q;
    SegmentTree seg(n, [](ll a, ll b) { return min(a, b); }, 2147483647LL);
    while (q--) {
        cin >> c >> x >> y;
        if (c) cout << seg.query(x, y + 1) << "\n";
        else seg.update(x, y);
    }
}


// verified
//   https://atcoder.jp/contests/abc125/tasks/abc125_c
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); }
void AtCoder_2019_4_27_C() {
    int n, a;
    cin >> n;
    SegmentTree seg(n, gcd, 0);
    for (int i = 0; i < n; i++) { cin >> a; seg.update(i, a); }
    int ans = 1;
    for (int i = 0; i < n; i++) ans = max(ans, gcd(seg.query(0, i), seg.query(i + 1, n)));
    cout << ans << "\n";
}

int main() {
    // AOJ_DSL_2_A();
    AtCoder_2019_4_27_C();
    return 0;
}

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

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


Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <iostream>
#include <string.h>

using namespace std;
#define debug(x) cout << #x << ": " << x << endl
typedef long long ll;

void solve() {
    int h, w, k;
    cin >> h >> w >> k;
    char arr[h][w];
    for (int i = 0; i < h; i++) {
        string row;
        cin >> row;
        for (int j = 0; j < w; j++) {
            arr[i][j] = row[j];
        }
    }
    int combinations = 0;
    for (int hmask = 0; hmask < (1 << h); hmask++) {
        for (int wmask = 0; wmask < (1 << w); wmask++) {
            int numBlack = 0;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (arr[i][j] == '#' && (hmask >> i & 1) && (wmask >> j & 1)) {
                        numBlack++;
                    }
                }
            }
            if (numBlack == k) {
                combinations++;
            }
        }
    }
    cout << combinations << endl;
}

int main() {
    // int t;
    // cin >> t;
    // while (t--)
    solve();
}

Measured memory_bytes: 3588
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  double fa=a,fb=b;
  //cout << (a/b) <<" "<<(a%b)<<" "<<(fa/fb)<<endl;
  printf("%d %d %.5f\n",(a/b),(a%b),(fa/fb));
  return 0;
}



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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) ( (int)(x).size() )
using LL = long long;

template<class T>
inline bool asMn(T &a, const T &b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T &a, const T &b) { return a < b ? a = b, true : false; }

const LL infLL = 1e18;
const int inf = 1e9;
mt19937 rng( (int)chrono::steady_clock::now().time_since_epoch().count() );

vector<int> a;
vector<vector<int> > gr;
vector<vector<array<LL, 2> > > f;
void dfs(int u, int pr) {
  f[u].assign(1, array<LL, 2>{ infLL, infLL } );
  f[u][0][ a[u] < 0 ] = a[u];

  for (int v : gr[u]) if (v ^ pr) {
    dfs(v, u);

    vector<array<LL, 2> > nF(sz(f[u]) + sz(f[v]), array<LL, 2>{ infLL, infLL });
    for (int i = 0; i < sz(f[u]); ++i) {
      for (int flagI = 0; flagI < 2; ++flagI) if (f[u][i][flagI] ^ infLL) {
        for (int j = 0; j < sz(f[v]); ++j) {
          for (int flagJ = 0; flagJ < 2; ++flagJ) if (f[v][j][flagJ] ^ infLL) {
            asMn(nF[i + j][flagI | flagJ], f[u][i][flagI] + f[v][j][flagJ]);
            if (!flagJ || f[v][j][flagJ] < 0) asMn(nF[i + j + 1][flagI], f[u][i][flagI]);
          }
        }
      }
    }

    f[u].swap(nF);
  }

//  cerr << "u = " << u + 1 << '\n';
//  for (int i = 0; i < sz(f[u]); ++i) {
//    for (int j = 0; j < 2; ++j) if (f[u][i][j] ^ infLL) cerr << i << ' ' << j << ' ' << f[u][i][j] << '\n';
//  }
}

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

  #ifdef FourLeafClover
  freopen("input", "r", stdin);
  #endif // FourLeafClover

  int n; cin >> n;
  a.assign(n, 0);
  for (auto &i : a) cin >> i;
  gr.assign(n, {} );
  for (int i = 1; i < n; ++i) {
    int u, v; cin >> u >> v; --u; --v;
    gr[u].emplace_back(v);
    gr[v].emplace_back(u);
  }

  f.assign(n, {} );
  dfs(0, -1);
  int ans = inf;
  for (int i = 0; i < sz(f[0]); ++i) {
    for (int j = 0; j < 2; ++j) if (f[0][i][j] ^ infLL && (!j || f[0][i][j] < 0) ) asMn(ans, i);
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 164096
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define All(A) A.begin(),A.end()
#define RAll(A) A.rbegin(),A.rend()
typedef long long LL;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<30;
 
 
 
template< typename G >
struct StronglyConnectedComponents {
    const G &g;
    G gg, rg;
    vector< int > comp, order, used;
 
    StronglyConnectedComponents(G &g) : g(g), gg(g.size()), rg(g.size()), comp(g.size(), -1), used(g.size()) {
        for(int i = 0; i < g.size(); i++) {
            for(auto e : g[i]) {
                gg[i].emplace_back((int) e);
                rg[(int) e].emplace_back(i);
            }
        }
    }
 
    int operator[](int k) {
        return (comp[k]);
    }
 
    void dfs(int idx) {
        if(used[idx]) return;
        used[idx] = true;
        for(int to : gg[idx]) dfs(to);
        order.push_back(idx);
    }
 
    void rdfs(int idx, int cnt) {
        if(comp[idx] != -1) return;
        comp[idx] = cnt;
        for(int to : rg[idx]) rdfs(to, cnt);
    }
 
    void build(G &t) {
        for(int i = 0; i < gg.size(); i++) dfs(i);
        reverse(begin(order), end(order));
        int ptr = 0;
        for(int i : order) if(comp[i] == -1) rdfs(i, ptr), ptr++;
        t.resize(ptr);
        for(int i = 0; i < g.size(); i++) {
            for(auto &to : g[i]) {
                int x = comp[i], y = comp[to];
                if(x == y) continue;
                t[x].push_back(y);
            }
        }
    }
};
 
int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    for(int i=0;i<M;i++){
        int u,v;
        cin >> u >> v;
        u--;v--;
        G[u].pb(v);
    }
    StronglyConnectedComponents<vector<vector<int>>> scc(G);
    vector<vector<int>> h;
    scc.build(h);
    vector<LL> dp(h.size(),0);
    LL ans=1;
    for(int i=0;i<h.size();i++){
        if(!dp[i]) dp[i]=1;
        if(h[i].size()){
            if(dp[h[i][0]]) dp[h[i][0]]=(dp[h[i][0]]*(dp[i]+1))%mod;
            else dp[h[i][0]]=(dp[h[i][0]]+dp[i]+1)%mod;
        }
        else{
            ans=(ans*(dp[i]+1))%mod;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3384
#include<stdio.h>
int a,b,i,x;
int main(){
for(i=0;i<4;i++){
scanf("%d",&x);
a+=x;
}
for(i=0;i<4;i++){
scanf("%d",&x);
b+=x;
}
if(a>b) printf("%d\n",a);
else printf("%d\n",b);
return 0;
}

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

int main()
{
	int N,n;
	std::vector<int> A,B,C;
	long total=0;
    std::cin>>N;

	A.resize(N);
	B.resize(N);
	C.resize(N);

	for (int i = 0; i < N; i++)
	{
		std::cin >> n;

		A.at(i) = n;
	}

	for (int i = 0; i < N; i++)
	{
		std::cin >> n;

		B.at(i) = n;
	}
	
	for (int i = 0; i < N-1; i++)
	{
		std::cin >> n;

		C.at(i) = n;
	}

	for (int i = 0; i < N; i++)
	{		
		total += B.at(i);

		if (i < N - 1)
		{
			if (A.at(i) + 1 == A.at(i + 1))
			{
				total += C.at(A.at(i)-1);
			}
		}
	}

	std::cout << total << std::endl;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include <stdio.h>
#include<unordered_map>
#define Amr_Abdelazim ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll int
#define ld long double
#define pll pair<ll,ll>
#define vll vector<ll>
#define vvll vector<vector<ll> >
#define vpll vector<pair<ll,ll> >
#define P complex<ld>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define rep(i,n)   for(int i=0;i<n;i++)
#define repp(i,s,n)   for(int i=s;i<=n;i++)
#define print(v) {for(auto i:v)cout<<i<<" ";cout<<"\n";}
#define mkp make_pair
#define clr(ar,v) memset(ar,v,sizeof(ar));
#define TC ll amr_abdelazim;cin>>amr_abdelazim;while(amr_abdelazim--)
#define popcnt(x) __builtin_popcount(x)
#define EPS 1e-9

using namespace std;
const int mod = 1000000007;

const double pi = acos(-1);
class cmp {
public:
	bool operator() (ll &A, ll &B) {
		return A > B;
	}
};
bool by_sec(const pll &a, const pll &b) {
	if ((abs(a.first) == abs(b.first)))
		return (abs(a.second) < abs(b.second));
	return (abs(a.first) < abs(b.first));
}
bool byth(const tuple<ll, ll, ld>& a, const tuple<ll, ll, ld>& b) {
	return (get<2>(a) < get<2>(b));
}
ld dist(P a, P b) {
	return (ld)abs(a - b);
}

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll min(ll a, ll b) {
	if (a <= b)return a;
	else return b;
}
const int N = 1005 + 9;
const ll INF = 1000000009;

int main()
{
	Amr_Abdelazim
		string a, b;
	cin >> a >> b;
	reverse(all(b));
	if (a == b)cout << "YES\n";
	else cout << "NO\n";
	return 0;
}

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

int main() {
	int takahasi, aoki, times, counta;
	cin >> takahasi >> aoki >> times;

	while(1){
		if (takahasi % 2 == 1) takahasi--;
		takahasi /= 2;
		aoki += takahasi;
		counta++;
		if (counta == times)break;
		if (aoki % 2 == 1)aoki--;
		aoki /= 2;
		takahasi += aoki;
		counta++;
		if (counta == times)break;
	}
	cout << takahasi << " " << aoki << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int result = 0;
  for(int i=1;i<=n;++i){
    string s = to_string(i);
    if(s.length()%2==1){
      result++;
    }
  }
  cout<<result<<endl;
  return 0;
}

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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, M, ans=0, tmp=0;
vector<vector<ll>> d;
vector<ll> A, B, C;

void warshall_floyd() { // nは頂点数
  for (int i = 0; i < N; i++)      // 経由する頂点
    for (int j = 0; j < N; j++)    // 開始頂点
      for (int k = 0; k < N; k++)  // 終端
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

signed main(){
    cin >> N >> M;
    d.resize(N);
    for(int i=0;i<N;i++) {
        d[i].resize(N, INF);
        d[i][i] = 0;
    }
    for(int i=0;i<M;i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        d[a][b] = c;
        d[b][a] = c;
        A.push_back(a);
        B.push_back(b);
        C.push_back(c);
    }
    warshall_floyd();
    for(int i=0;i<M;i++) {
        if(d[A[i]][B[i]]!=C[i]||d[B[i]][A[i]]!=C[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define INF 1e9

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

    while(1){
        long long n,m;
        cin>>n>>m;

        if(n==0)break;

        vector<long long> a(n);

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

        long long ans=-1;

        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                long long sum=a[i]+a[j];

                if(sum<=m && sum>ans)ans=sum;
            }
        }

        if(ans==-1)cout<<"NONE"<<endl;
        else cout<<ans<<endl;

    }

}


Measured memory_bytes: 3140
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483648
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

int n;

vi sortc(vi c) {
	vi ret = c;
	Loop1(i, 3) {
		c = { c[(0 + i) % 4], c[(1 + i) % 4],c[(2 + i) % 4],c[(3 + i) % 4] };
		ret = min(ret, c);
	}
	return ret;
}

int cnt_rout(vi c) {
	int ret = 1;
	Loop1(i, 3) {
		vi ccopy = { c[(0 + i) % 4], c[(1 + i) % 4], c[(2 + i) % 4], c[(3 + i) % 4] };
		if (c == ccopy) ret++;
	}
	return ret;
}

void solve(vvi c) {
	ll ans = 0;
	Loop(i, n - 5) {
		for (int j = i + 1;j < n;j++) {
			Loop(k, 4) {
				vi cs = { c[i][0],c[i][1],c[i][2],c[i][3],
					c[j][(0 + k) % 4], c[j][(3 + k) % 4],c[j][(2 + k) % 4],c[j][(1 + k) % 4] };
				vvi findlist = {
					sortc({cs[4],cs[0],cs[3],cs[7]}),
					sortc({cs[1],cs[5],cs[6],cs[2]}),
					sortc({cs[4],cs[5],cs[1],cs[0]}),
					sortc({cs[6],cs[7],cs[3],cs[2]}) };
				sort(findlist.begin(), findlist.end());
				vi buf(4), buf2(4);
				ll _ans = 1;
				Loop(m, 4) {
					if (m > 0 && findlist[m] == findlist[m - 1]) {
						buf[m] = buf[m - 1] - 1;
					}
					else {
						auto ub = upper_bound(c.begin() + i + 1, c.end(), findlist[m]);
						auto lb = lower_bound(c.begin() + i + 1, c.end(), findlist[m]);
						buf[m] = ub - lb;
						if (lb - c.begin() <= j&&j < ub - c.begin()) buf[m]--;
					}
					buf2[m] = cnt_rout(findlist[m]);
					_ans *= buf[m] * buf2[m];
					if (buf[m] == 0) break;
				}
				ans += _ans;
			}
		}
	}
	cout << ans << endl;
}

int main() {
	cin >> n;
	vvi c(n, vi(4));
	Loop(i, n) {
		Loop(j, 4) {
			cin >> c[i][j];
		}
		c[i] = sortc(c[i]);
	}
	sort(c.begin(), c.end());
	solve(c);
	return 0;
}

Measured memory_bytes: 256
//C
//#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>


#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Hang in there!

using namespace std;


int main() {
	vector<int>data(3);
	for (int i = 0; i < 3; i++) {
		cin >> data[i];
	}
	sort(data.begin(), data.end());
	cout << 10 * data[2] + data[1]  + data[0] << endl;
}



Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

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

  printf("%.10lf %.10lf\n", R*R*PI, 2*R*PI);

  return 0;
}



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


int n,a[200200];

int main(){
	cin >> n;
	for (int i=1;i<=n;i++) cin >> a[i];
	if (n%2==0){
		for (int i=n;i>0;i-=2) cout << a[i] << " ";
		for (int i=1;i<=n;i+=2) cout << a[i] << " ";
	}
	else{
		for (int i=n;i>0;i-=2) cout << a[i] << " ";
		for (int i=2;i<=n;i+=2) cout << a[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <map>

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

using namespace std;

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

    map<string,int> group;
    rep(i, n)
    {
        string s;
        cin >> s;

        if (group.count(s) == 0)
        {
            group[s] = 1;
        }
        else
        {
            group[s]++;
        }
    }

    int max = 0;
    for (auto entry : group)
    {
        if (entry.second > max)
        {
            max = entry.second;
        }
    }
    
    for (auto entry: group)
    {
        if (max == entry.second)
        {
            cout << entry.first << endl;
        }
    }
    return 0;
}


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

int main(){
    long N,K;
    cin>>N>>K;
    vector<long long > vec(N);
    for(long i=0;i<N;++i){
        cin>>vec[i];
    }

    

    long long ans=1e9;
    for(long i=0;i<=N-K;++i){
        if(vec[i+K-1]<=0){
            ans=min(ans,abs(vec[i]));
        }else if(0<=vec[i]){
            ans=min(ans,abs(vec[i+K-1]));            
        }else{
            ans = min({ans, abs(vec[i]) * 2 + vec[i + K - 1], abs(vec[i]) + vec[i + K - 1] * 2});
        }
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 1024
#include <iostream>
#define int long long
using namespace std;

int a, b, c;

signed main() {
	cin >> a >> b >> c;
	
	int res = c - a - b;
	if (res < 0) { cout << "No" << endl; return 0; }
	
	if (4 * a * b < res * res) { cout << "Yes" << endl; return 0; }
	else { cout << "No" << endl; return 0; }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define for_tests(t, tt) int t; scanf("%d", &t); for(int tt = 1; tt <= t; tt++)
#ifndef ONLINE_JUDGE
#define debug(args...) fprintf(stderr,args)
#else
#define debug(args...)
#endif //ONLINE_JUDGE
template<typename T> inline T abs(T t) { return t < 0? -t : t; }
const ll modn = 1000000007;
inline ll mod(ll x) { return x % modn; }
#define IOS() ios::sync_with_stdio(0),cin.tie(0)

const int MAXN = 212345;

int n, m, k;
int s[MAXN];

vector<int> adj[MAXN];
int mrk[MAXN];

void go(int u){
    mrk[u] = 1;
    for(int nxt: adj[u]){
        if(mrk[nxt]) continue;
        go(nxt);
    }
}

int main (){
	scanf("%d%d", &n, &m);
	for(int a=0;a<m;a++){
        int i, j;
        scanf("%d%d", &i, &j);
        adj[i].pb(j);
        adj[j].pb(i);
	}
    int ans = 0;
    for(int a=1;a<=n;a++){
        if(!mrk[a]){
            ans++;
            go(a);
        }
    }
    printf("%d\n", ans-1);
}



Measured memory_bytes: 12804