akhauriyash/Code-Regression huggingface dataset:
struct DFS {
    diff: Vec<u32>,
    g: Vec<Vec<(usize, usize)>>,
    c: Vec<bool>,
    ans: Vec<usize>,
}

impl DFS {
    fn new(n: usize) -> DFS {
        DFS {
            diff: Vec::with_capacity(n + 1),
            g: vec![vec![]; n],
            c: vec![false; n],
            ans: vec![],
        }
    }

    fn search(&mut self, u: usize) {
        for (v, i) in self.g[u].clone() {
            if self.c[v] { continue; }
            self.c[v] = true;
            self.search(v);
            if self.diff[v] == 1 {
                self.diff[u] ^= 1;
                self.diff[v] ^= 1;
                self.ans.push(i);
            }
        }
    }
}

fn main() {
    let (n, m): (usize, usize) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let mut bombs = Vec::with_capacity(n + 2);
    bombs.push((0, 0));
    for _ in 0..n {
        let bomb: (u32, u32) = {
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            let mut iter = buf.split_whitespace();
            (
                iter.next().unwrap().parse().unwrap(),
                iter.next().unwrap().parse().unwrap(),
            )
        };
        bombs.push(bomb);
    }
    bombs.push((std::u32::MAX, 0));
    bombs.sort();

    let mut dfs = DFS::new(n + 2);
    for i in 0..(n + 1) {
        dfs.diff.push(bombs[i].1 ^ bombs[i + 1].1);
    }

    for i in 1..=m {
        let (l, r): (u32, u32) = {
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            let mut iter = buf.split_whitespace();
            (
                iter.next().unwrap().parse().unwrap(),
                iter.next().unwrap().parse().unwrap(),
            )
        };

        let f = |x: u32| -> usize {
            let (mut left, mut right) = (0, n + 2);
            while right - left > 1 {
                let mid = (left + right) / 2;
                if bombs[mid].0 < x {
                    left = mid;
                } else {
                    right = mid;
                }
            }
            left
        };    
        
        let (u, v) = (f(l), f(r + 1));
        if u != v {
            dfs.g[u].push((v, i));
            dfs.g[v].push((u, i));
        }
    }

    for i in 0..(n + 1) {
        if dfs.c[i] { continue; }
        dfs.search(i);
        if dfs.diff[i] == 1 {
            println!("-1");
            return;
        }
    }

    dfs.ans.sort();
    println!("{}", dfs.ans.len());
    println!(
        "{}",
        dfs.ans.iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}

Measured memory_bytes: 29008
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    ll n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    for(ll i = 0;i <= n-1;i++){
        if(c*(n-1-i)-d*i <= b-a && b-a <= d*(n-1-i)-c*i){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int par[100010],dep[100010];
void init(int N){
    for(int i = 0; i < N; i++){
        par[i] = i;
        dep[i] = 0;
    }
}

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

void merge(int a,int b){
    a = find(a);
    b = find(b);
    if (dep[a] > dep[b]){
        par[b] = a;
        dep[a] += b;
    } else {
        par[a] = b;
        dep[b] += a;
    }
}


int main(){
    int N; cin >> N;
    int a[N+1];
    for(int i = 1; i <= N; i++){
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 1; i <= N; i++){
        if (i < a[i]){
            if (a[a[i]] == i) ans++;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

int main() {
	string S;
	while (cin >> S)
	{
		if (S == "0")
		{
			break;
		}
		long long int ans = 0;
		vector<vector<long long int>>dp(S.length(), vector < long long int >(2));
		for (size_t i = 0; i < S.length(); i++)
		{
			if (i)
			{
				dp[i] = dp[i - 1];
			}
			if (i % 2)
			{
				dp[i][0] += S[i] - '0';
			}
			else {
				dp[i][1] -= S[i] - '0';
			}
		}
		for (size_t i = 0; i < S.length(); i++)
		{
			dp[i][0] += dp[i][1];
			while (dp[i][0] < 0)
			{
				dp[i][0] += 11;
			}
			dp[i][0] %= 11;
		}
		map<long long int, long long int>X;
		X[0]++;
		for (size_t i = 0; i < S.length(); i++)
		{
			ans += X[dp[i][0]];
			if (!(i < S.length() - 1 && S[i + 1] == '0'))
			{
				X[dp[i][0]]++;
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 7384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	string s;
	while(cin>>s,s!="#"){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		int n=1;
		rep(i,s.size())if(s[i]=='/')n++;
		vvi in(n);
		int t=0;
		rep(i,s.size()){
			if(s[i]=='/')t++;
			else{
				if(s[i]=='b')in[t].pb(1);
				else{
					rep(j,s[i]-'0')in[t].pb(0);
				}
			}
		}
		in[a-1][b-1]--;
		in[c-1][d-1]++;
		rep(i,n){
			int co=0;
			rep(j,in[i].size()){
				if(in[i][j]){
					if(co)cout<<co;
					cout<<"b";
					co=0;
				}else co++;
			}
			if(co)cout<<co;
			if(i!=n-1)cout<<"/";
		}
		cout<<endl;
	}
}

Measured memory_bytes: 3160
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX=100001;
typedef long long ll;
int main()
{
  ll n,x,m,a,t,i,res;
  ll d[N_MAX],s[N_MAX];
  cin >> n >> x >> m;
  fill(d,d+m,0);
  s[0]=0;
  a=x;
  s[1]=x;
  d[x]=1;
  for(i=2;i<=n;i++){
    a=(a*a)%m;
    s[i]=s[i-1]+a;
    if(d[a]>0)
      break;
    d[a]=i;
  }
  if(i>n){
    res=s[n];
  }else{
    t=(n-d[a])/(i-d[a]);
    res=t*(s[i]-s[d[a]])+s[n-t*(i-d[a])];
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mod 1000000007
using namespace std;
int n,m;
int cnt;
int vis[200005];
vector<int> g[200005];
void dfs(int ind){
	cnt++;
	for(int i=0;i<g[ind].size();i++){
		if(vis[g[ind][i]]) continue;
		vis[g[ind][i]]=1;
		dfs(g[ind][i]);
	}
}
int main() {
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		g[a].pb(b);
		g[b].pb(a);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		cnt=0;
		if(!vis[i]){
			vis[i]=1;
			dfs(i);
			ans=max(ans,cnt);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 21680
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main() {
  int n, m;
  cin >> n >> m;
  Graph G(n);
  for (int i = 0; i < n; i++) seen.push_back(false);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int ans = -1;
  for (int i = 0; i < n; i++) {
    if (!seen[i]) {
      dfs(G, i);
      ans++;
    }
  }
  cout << (max(ans, 0)) << endl;
}



Measured memory_bytes: 9592
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func scanStringToken() (word string) {
	scanner.Scan()
	word = scanner.Text()
	return
}

func scanNumberToken() (num int) {
	scanner.Scan()
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return
}

func main() {
	n := scanNumberToken()
	// c := int(n / 1000)
	mod := n % 1000

	if mod == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(1000 - mod)
	}

}


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

int main() {
    int a, b;
    cin >> a >> b;

    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        cout << "Possible" << endl;
    }
    else {
        cout << "Impossible" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

W, a, b = MAP()
if a <= b <= a+W or a <= b+W <= a+W:
	print(0)
else:
	print(min(abs(a+W-b), abs(a-b-W)))


Measured memory_bytes: 5392
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
	int n;
	string astr, bstr, cstr;
	cin >> n;
	cin >> astr >> bstr >> cstr;
	vector<string> a, b, c;
	for (int i = 0; i < n; i++) {
		a.push_back(astr.substr(i, 1));
		b.push_back(bstr.substr(i, 1));
		c.push_back(cstr.substr(i, 1));
	}
	int diff = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == b[i] && a[i] == c[i]) {
			diff += 0;
		}
		else if (a[i] == b[i] || a[i] == c[i] || b[i] == c[i]) {
			diff += 1;
		}
		else {
			diff += 2;
		}
	}
	cout << diff;
    return 0;
}

Measured memory_bytes: 256
// buy a lot of 0s
// or simply return 0 ?
// nope, it's buy one 0
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

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

  int n;
  cin >> n;
  map<string, int> cnt;
  cnt.clear();
  for(int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    cnt[s]++;
  }
  cout << "AC x " << cnt["AC"] << '\n';
  cout << "WA x " << cnt["WA"] << '\n';
  cout << "TLE x " << cnt["TLE"] << '\n';
  cout << "RE x " << cnt["RE"] << '\n';
  return 0;
}


Measured memory_bytes: 3636
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
int n , m , r;
ll ans;
map<int , int> rem;
int main()
{
	abdelrahman010
	cin >> n >> m;
	for(int i = 0 , x;i < n;i++)
	{
		cin >> x;
		r = (r + x) % m;
		ans += 1ll * rem[r] + !r;
		rem[r]++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3200
h, w = [int(_) for _ in input().split(' ')]
a = []
for _ in range(h):
    a.append([int(_) for _ in input().split(' ')])

if h * w > 1:
    m = False
    ops = []
    for j in range(h):
        for k in range(w):
            if j < h - 1 or k < w - 1:
                if j % 2 == 0:
                    i = k
                else:
                    i = w - 1 - k

                if a[j][i] % 2 == 1:
                    m = m ^ True
                if m:
                    if k < w - 1:
                        if j % 2 == 0:
                            op = '{0} {1} {2} {3}'.format(j + 1, i + 1, j + 1, i + 2)
                        else:
                            op = '{0} {1} {2} {3}'.format(j + 1, i + 1, j + 1, i)
                    else:
                        op = '{0} {1} {2} {3}'.format(j + 1, i + 1, j + 2, i + 1)
                    ops.append(op)

    print(len(ops))
    for op in ops:
        print(op)
else:
    print(0)


Measured memory_bytes: 16280
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<set>
#include<vector>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
set<int>s;
vector<int>ans;
typedef set<int>::iterator It;
int n,a[100010],cnt[100010];
inline bool dfs(int limit)
{
	if(ans.size()==n){for(int i=0;i<n;i++)pr1(ans[i]);return true;}
	if(n-ans.size()-1==cnt[limit] && s.find(limit)!=s.end())return false;
	for(It i=s.begin();i!=s.end();i++)
	{
		int p=*i;
		if(p==limit)continue;
		ans.push_back(p),cnt[a[p]]--;s.erase(p);
		if(dfs(a[p])==true)return true;
		ans.pop_back(),cnt[a[p]]++;s.insert(p);
	}return false;
}
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++)a[i]=read(),cnt[a[i]]++,s.insert(i);
	if(dfs(0)==false)puts("-1");
	return 0;
}


Measured memory_bytes: 11008
N,T = map(int,input().split())
lst = list(map(int,input().split()))
ma = lst[-1] + T
for i in range(len(lst)-1):
  sub = lst[i+1] - lst[i]
  if (sub > T):
    ma -= lst[i+1] - T - lst[i]
print(ma)

Measured memory_bytes: 85328
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
string s[20],si[20];
bool forb[20][20][20][20];
bool ok[2][5000],bad[20][20];
vector<PII> v;
bool dfs(int x,int y,bool fl)
{
	if (x & (1<<y)) return dfs(x,y+1,fl);
	if (x==(1<<n)-1)
	{
		memset(ok,0,sizeof(ok));
		memset(bad,0,sizeof(bad));
		for (int i=0;i<m;i++)
			for (int j=0;j<m;j++)
				for (int k=0;k<v.size();k++)
					bad[i][j]|=forb[v[k].Fst][v[k].Snd][i][j]; 
		ok[0][0]=1;
		for (int i=0;i<(1<<m)-1;i++)
		{
			for (int j=0;j<m;j++)
			{
				if (i & (1<<j)) continue;
				for (int k=j;k<m;k++)
				{
					if ((i & (1<<k)) || (m%2==0 && j==k) || bad[j][k]) continue;
					if (j!=k)
					{
						ok[0][i|(1<<j)|(1<<k)]|=ok[0][i];
						if (m%2!=0) ok[1][i|(1<<j)|(1<<k)]|=ok[1][i];
					}
					else ok[1][i|(1<<j)]|=ok[0][i];
				}
				break;
			}
		}
		return ok[m%2!=0][(1<<m)-1];
	}
	for (int i=y;i<n;i++)
	{
		if (si[i]!=si[y] || (x & (1<<i)) || (!fl && i==y)) continue;
		v.push_back(MP(i,y));
		if (dfs(x|(1<<i)|(1<<y),y+1,fl&(i!=y))) return 1;
		v.pop_back();
	}
	return 0;
}
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++) cin >>s[i];
	for (int i=0;i<n;i++) si[i]=s[i],sort(si[i].begin(),si[i].end());
	for (int i=0;i<n;i++)
		for (int j=0;j<n;j++)
			for (int x=0;x<m;x++)
				for (int y=0;y<m;y++)
					if (s[i][x]!=s[j][y] || s[i][y]!=s[j][x])
						forb[i][j][x][y]=1;
	cout <<(dfs(0,0,n%2!=0) ? "YES" : "NO");
	return 0;
} 

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

int main() {
    int K, N, max_A = 0, sum_A = 0;
    vector<int> A, diff;

    cin >> K >> N;
    for(int i = 0; i < N; i++){
        int t;
        cin >> t;
        A.push_back(t);
    }

    max_A = A[0] + K - A[N-1];
    for(int i = 0; i < N-1; i++){
        max_A = max(max_A, A[i+1] - A[i]);
    }

    cout << K - max_A << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (long long i = (a); i <= (b); i++)
#define FORD(i,a,b) for (long long i = (a); i >= (b); i--)
#define REP(i,a) FOR(i,0,(long long)(a)-1)
#define reset(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(), x.end()
#define uni(x) x.erase(unique(all(x)), x.end());
#define BUG(x) cout << #x << " = " << x << endl
#define BUGP(x) cout << #x << " = " << x._1 << ", " << x._2 << endl
#define PR(x,a,b) {cout << #x << " = "; FOR (_,a,b) cout << x[_] << ' '; cout << endl;}
#define CON(x) {cout << #x << " = "; for(auto _i:x) cout << _i << ' '; cout << endl;}
#define mod 1000000007
#define pi acos(-1)
#define eps 1e-8
#define pb push_back
#define sqr(x) (x) * (x)
#define _1 first
#define _2 second

int a, b;

int main() {
  ios::sync_with_stdio(false);
  cin >> a >> b;
  if (max(a, b) > 8) cout << ":(";
  else cout << "Yay!";
}


Measured memory_bytes: 256
import sys
from itertools import permutations
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    P=tuple(map(int,input().split()))
    Q=tuple(map(int,input().split()))
    p_list=list(permutations(range(1,n+1)))
    print(abs(p_list.index(Q)-p_list.index(P)))

if __name__=='__main__':
    main()

Measured memory_bytes: 44656
import java.util.Scanner;
class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		Main app = new Main();
		while(scan.hasNext()){
			int second = app.input(scan);
			int minute = app.getMinute(second);
			System.out.println(minute);
			System.out.println(second - minute*60);
		}
	}
	
	public int input(Scanner scan){
		int time = 0;
		for(int i=0;i<4;i++){
			time += scan.nextInt();
		}
		
		return time;
	}
	
	public int getMinute(int second){
		int minute = 0;
		
		while(second >= 60){
			minute ++;
			second -= 60;
		}
		
		return minute;
	}
}

Measured memory_bytes: 17168
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string a,b;
    double ans;
    cin>>a>>b;
    a=a+b;
    ans=stoi(a);
    if(sqrt(ans)==(int)sqrt(ans))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const ll N=3e5;
using namespace std;
map<string,int> a;
string words[N];
int main()
{
    int n;
    string last, word;
    cin>>n;
    for (int i=0; i<n; i++)
        cin>>words[i];
    last=words[0];
    a[last]++;
    for (int i=1; i<n; i++)
    {
        word=words[i];
        a[word]++;
        if (word[0] != last[last.length()-1] || a[word]>1)
        {
            cout<<"No";
            return 0;
        }
        last=word;
    }
    cout<<"Yes";
}

Measured memory_bytes: 2560
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Map<Integer, Integer> map = new HashMap<>();
    for (int i = 0; i < N; i++) {
      int a = sc.nextInt();
      map.put(a, map.getOrDefault(a, 0) + 1);
      map.put(a+1, map.getOrDefault(a+1, 0) + 1);
      map.put(a-1, map.getOrDefault(a-1, 0) + 1);
    }

    int max = 0;
    for (int value : map.values()) {
      max = Math.max(value, max);
    }

    System.out.println(max);
  }
}

Measured memory_bytes: 63708
use std::cmp;

const INF: i64 = 1 << 50;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let n = sc.read();
    let a: Vec<i64> = sc.vec(n);
    let mut graph = vec![vec![]; n];
    for _ in 1..n {
        let u = sc.read::<usize>() - 1;
        let v = sc.read::<usize>() - 1;
        graph[u].push(v);
        graph[v].push(u);
    }

    let mut power_dp = vec![vec![]; n];
    let mut min_dp = vec![vec![]; n];
    dfs(0, 0, &a, &graph, &mut min_dp, &mut power_dp);
    for i in 0..n {
        if power_dp[0][i] < INF || min_dp[0][i] < 0 {
            println!("{}", i);
            return;
        }
    }
}

fn dfs(
    v: usize,
    p: usize,
    a: &Vec<i64>,
    graph: &Vec<Vec<usize>>,
    min_dp: &mut Vec<Vec<i64>>,
    power_dp: &mut Vec<Vec<i64>>,
) {
    power_dp[v].push(if a[v] > 0 { a[v] } else { INF });
    min_dp[v].push(a[v]);
    for &child in graph[v].iter() {
        if child == p {
            continue;
        }
        dfs(child, v, a, graph, min_dp, power_dp);
        power_dp[v] = connect(&power_dp[v], &power_dp[child], &min_dp[child], true);
        min_dp[v] = connect(&min_dp[v], &power_dp[child], &min_dp[child], false);
    }
}

fn connect(dp: &Vec<i64>, power: &Vec<i64>, min: &Vec<i64>, is_power: bool) -> Vec<i64> {
    let mut next = vec![INF; dp.len() + power.len() + 1];
    for parent_cut in 0..dp.len() {
        for child_cut in 0..power.len() {
            let total_cut = parent_cut + child_cut;
            if power[child_cut] < INF {
                chmin(&mut next[total_cut], dp[parent_cut] + power[child_cut]);
            }
            if min[child_cut] < INF && !is_power {
                chmin(&mut next[total_cut], dp[parent_cut] + min[child_cut]);
            }
            if power[child_cut] < INF || min[child_cut] < 0 {
                chmin(&mut next[total_cut + 1], dp[parent_cut]);
            }
        }
    }
    next
}

fn chmin<T: Ord>(a: &mut T, b: T) {
    if *a > b {
        *a = b;
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 408444
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	ll A,B,C;
	int K;
	cin >> A >> B >> C >> K;
	
	ll ma = max(A, max(B, C));
	ll rest = A + B + C - ma;
	for(int i=0;i<K;i++) ma *= 2;
	cout << ma + rest << endl;
	
	
	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

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

    int N;
    cin >> N;
    vector<int> A(N + 1), B(N);
    REP(i, N + 1) { cin >> A.at(i); }
    REP(i, N) { cin >> B.at(i); }
    ll ans = 0;
    REP(i, N) {
        if (A[i] >= B[i]) {
            ans += B[i];
            A[i] -= B[i];
        } else {
            B[i] -= A[i];
            ans += A[i];
            A[i] = 0;
            if (A[i + 1] >= B[i]) {
                ans += B[i];
                A[i + 1] -= B[i];
            } else {
                ans += A[i + 1];
                A[i + 1] = 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

namespace ITP1
{
    class ITP1_5_D
    {
        static void Main(string[] args)
        {
            int n;

            n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
            {
                int x = i;
                if (x % 3 == 0)
                {
                    Console.Write(" " + i);
                }
                else
                {
                    while (x > 10)
                    {
                        if (x % 10 == 3)
                        {
                            Console.Write(" " + i);
                            break;
                        }
                        x /= 10;
                        if (x == 3)
                        {
                            Console.Write(" " + i);
                            break;
                        }
                    }
                    
                }
            }
            Console.WriteLine();
        }
    }
}



Measured memory_bytes: 15948
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
ll wt[N], v[N], a[N][105];
ll f(ll w, ll i)
{
    if (a[w][i] != -1)
        return a[w][i];
    else if (!w || !i)
        a[w][i] = 0;
    else if (wt[i - 1] > w)
        a[w][i] = f(w, i - 1);
    else
        a[w][i] = max(f(w, i - 1), f(w - wt[i - 1], i - 1) + v[i - 1]);
    return a[w][i];
}
int main()
{
    ll n, w;
    cin >> n >> w;
    for (ll i = 0; i < n; i++)
        cin >> wt[i] >> v[i];
    for (ll i = 0; i <= w; i++)
        for (ll j = 0; j <= n; j++)
            a[i][j] = -1;
    cout << f(w, n);
}

Measured memory_bytes: 82304
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl

typedef long long ll;
typedef pair<ll, ll> P;
#define X first
#define Y second

const int MAX = 1<<17;
const ll INF = 1e18;

ll val[2][MAX];
vector <P> V[2][MAX];
pair <P, int> p[MAX];

void Nope()
{
  printf("No\n");
  exit(0);
}

P Dfs(P poz)
{
  P ret = P(INF, INF);
  if (poz.X == 0)
    ret.X = val[poz.X][poz.Y];
  else
    ret.Y = val[poz.X][poz.Y];

  for (auto it : V[poz.X][poz.Y]) {
    ll nval = it.Y - val[poz.X][poz.Y];
    if (val[poz.X^1][it.X] == INF) {
      val[poz.X^1][it.X] = nval;
      P tmp = Dfs(P(poz.X^1, it.X));
      ret.X = min(ret.X, tmp.X);
      ret.Y = min(ret.Y, tmp.Y);
    }
    else if (val[poz.X^1][it.X] != nval)
      Nope();
  }

  return ret;
}

int main()
{
  int n;

  scanf("%*d%*d%d", &n);

  for (int i=0; i<n; i++) {
    scanf("%lld%lld%d", &p[i].X.X, &p[i].X.Y, &p[i].Y);
    V[0][p[i].X.X].push_back(P(p[i].X.Y, p[i].Y));
    V[1][p[i].X.Y].push_back(P(p[i].X.X, p[i].Y));
  }
  
  for (int i=0; i<2; i++)
    for (int j=0; j<MAX; j++)
      val[i][j] = INF;
 
  for (int i=0; i<MAX; i++) {
    if (val[0][i] == INF) {
      val[0][i] = 0;
      P tmp = Dfs(P(0, i));
      if (tmp.X + tmp.Y < 0)
        Nope();
    }
  }

  printf("Yes\n");

  return 0;
}


Measured memory_bytes: 23808
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
string str;
set<char> s;
bool has[26];
int main()
{
    cin>>str;
    int n=str.size();
    if(str=="zyxwvutsrqponmlkjihgfedcba")
    {
        puts("-1");
        return 0;
    }
    if(n<26)
    {
        memset(has,false,sizeof(has));
        for(int i=0;i<n;i++) has[str[i]-'a']=true;
        for(int i=0;i<26;i++)
        {
            if(!has[i])
            {
                str+=(char)('a'+i);
                break;
            }
        }
        cout<<str<<endl;
        return 0;
    }
    for(int i=25;i>=0;i--)
    {
        bool f=false;
        for(int j=i+1;j<26;j++)
        {
            if(str[j]>str[i])
            {
                f=true;
                break;
            }
        }
        if(f)
        {
            int now=INF;
            for(int j=i+1;j<26;j++) if(str[j]>str[i]) now=min(now,str[j]-'a');
            str=str.substr(0,i);
            str+=(char)('a'+now);
            cout<<str<<endl;
            return 0;
        }
    }
    return 0;
}



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

vector<int> dp(200000);

int main(){
    int N;
    int h[200000];
    cin>>N;
    for(int i=1;i<=N;i++){
        cin>>h[i];
    }
    dp[1]=0;
    dp[2]=abs(h[1]-h[2]);
    for(int i=3;i<=N;i++){
        dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]));
    }

    cout<<dp[N]<<endl;

}

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;


ll gcd(ll a, ll b) {
    if (a % b == 0) return b;
   return gcd(b, a % b);
}
int main() {
    ll n, k; cin >> n >> k;
    cout << min(n % k, k - (n % k)) << endl;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  string s;cin>>s;
  string ans=s.substr(0,1)+to_string(s.size()-2)+s.substr(s.size()-1,1);
  cout(ans);
  return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int C[6]={1,5,10,50,100,500};
int P;
int N[6];

const int T=5000;
int dp[2][T];

int calc(int v){
    int ans=0;
    for(int i=5;i>=0;i--){
        ans+=v/C[i];
        v%=C[i];
    }
    return ans;
}

signed main(){
    while(cin>>P){
        rep(i,6)cin>>N[i];
        if(P==0)break;
        fill_n(*dp,2*T,1001001001);
        int cnt=0;

        for(int i=5;i>=0;i--){
            while(P-C[i]>=T/4&&N[i]){
                cnt++;
                N[i]--;
                P-=C[i];
            }
            if(N[i])break;
        }

        dp[0][0]=0;
        rep(i,6){
            rep(j,C[i]){
                deque<pint>deq;
                for(int k=j;k<T;k+=C[i]){
                    int w=T-k/C[i];
                    chmin(dp[(i+1)&1][k],dp[i&1][k]);
                    while(deq.size()&&deq.front().se+C[i]*N[i]<k)deq.pop_front();
                    if(deq.size())chmin(dp[(i+1)&1][k],deq.front().fi-w);
                    if(deq.size()&&deq.front().se+N[i]*C[i]<=k)deq.pop_front();
                    deq.pb(pint(dp[i&1][k]+w,k));
                }
            }
        }
        int mi=1001001001;
        for(int i=P;i<T;i++){
            chmin(mi,dp[0][i]+calc(i-P));
        }
        cout<<mi+cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 1312
#include <stdio.h>

int is_prime(int n)
{
    int i;

    if (n % 2 == 0){
        return (0);
    }
    for (i = 3; i * i <= n; i += 2){
        if (n % i == 0){
            return (0);
        }
    }

    return (1);
}

int main(void)
{
    int n;
    int i;

    while (scanf("%d", &n) * n != 0){
        i = n;
        while (is_prime(i) != 1 || is_prime(i - 2) != 1){
            i--;
        }
        printf("%d %d\n", i - 2, i);
    }

    return (0);
}

Measured memory_bytes: 600
n = int(input())
l=[]
for i in range(n-1):
    tmp = list(map(int,input().split()))
    l.append(tmp)
l.sort()

link = [[] for _ in range(n)]

for tmp in l:
    link[tmp[0]-1].append([tmp[1]-1,tmp[2]])
    link[tmp[1]-1].append([tmp[0]-1,tmp[2]])

from collections import deque
Q = deque()
Q.append(0)

dis = [-1]*n
dis[0]=0

while Q:
    num=Q.popleft()
    for tmp in link[num]:
        if dis[tmp[0]] == -1:
            dis[tmp[0]] = dis[num]+tmp[1]
            Q.append(tmp[0])

for a in dis:
    print(a%2)

Measured memory_bytes: 99288
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
int main()
{
   long N;
   std::cin >> N;
   for(long i=1; i<=N; i++){
       double temp = (double)i*(double)1.08;
       long temp2=std::floor(temp);
       if(temp2==N){
           std::cout << i << std::endl;
           break;
       }
       if(i==N){
           std::cout << ":(" << std::endl;
       }
   }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



int main() {


	int A, B;
	scanf("%d%d", &A, &B);

	int ans = A - 2 * B;

	if (ans >= 0) {
		printf("%d", ans);
	}
	else {
		printf("0");
	}

}






Measured memory_bytes: 128
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        G[a].append((b, c))
        G[b].append((a, c))
    Q, K = map(int, input().split())
    K -= 1
    X = []
    Y = []
    for _ in range(Q):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        X.append(x)
        Y.append(y)

    que = queue.Queue()
    INF = 10 ** (25)
    dist = [INF for _ in range(N)]
    dist[K] = 0
    que.put(K)
    while not que.empty():
        cn = que.get()
        for nn, c in G[cn]:
            if dist[nn] > dist[cn] + c:
                dist[nn] = dist[cn] + c
                que.put(nn)

    for x, y in zip(X, Y):
        print(dist[x] + dist[y])


if __name__ == '__main__':
    main()


Measured memory_bytes: 86188
/*  ex6_2
    potter0723sw  */

#include <stdio.h>
#include <string.h>

int main(void){
    int num, last;
    char string[101];//ヌル文字分含め確保
    scanf("%s", &string);
    num = (int)strlen(string) - 2;//省略する文字数は最初と最後以外の数（ヌル文字はカウントされてない）
    last = (int)strlen(string) - 1;//配列は0から始まることに注意
    printf("%c%d%c\n", string[0], num, string[last]);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        String N = scanner.nextLine();
        int n = Integer.parseInt(N);
        String line = scanner.nextLine();
        String[] strs = line.split(" ");
        int[] values = new int[strs.length];

        for (int i = 0; i < strs.length; i++) {
            values[i] = Integer.parseInt(strs[i]);
        }

        boolean[] changed = new boolean[n];
        boolean can = true;
        while (true) {
            boolean hasChanged = false;
            int i;
            for (i = 1; i < values.length; i++) {
                if (values[i] < values[i - 1]) {
                    if (!changed[i - 1]) {
                        values[i - 1] = values[i - 1] - 1;
                        changed[i - 1] = true;
                        hasChanged = true;
                    } else {
                        can = false;
                        break;
                    }
                }
            }
            if (hasChanged) {
                continue;
            }
            if (i >= values.length || !can) {
                break;
            }
        }
        if(can) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 47460
from sys import stdin
input = stdin.readline
import bisect

N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

A.sort()
B.sort()
C.sort()

## 各B[i]に対してそれより上(下)に積むことができる数を計算
n_upper_lst = []
n_lower_lst = []
ans = 0
for i in range(N):
  n_upper = bisect.bisect_left(A, B[i])
  n_upper_lst.append(n_upper)
  n_lower = N - bisect.bisect_right(C, B[i])
  n_lower_lst.append(n_lower)
  ans += n_upper * n_lower

print(ans)
  

Measured memory_bytes: 24128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX 256

unsigned long euclid(unsigned long m, unsigned long n);

int main(){
    unsigned long a[1000],b[1000],gcd[1000],lcm[1000];
    int i,j,num;
    char str[MAX], *tp;

    /* input */
    while (fgets(str,MAX,stdin) != NULL)
    {
        tp = strtok(str, " ");
        a[i] = atoi(tp);
        tp = strtok(NULL, "\n");
        b[i] = atoi(tp);
        i++;
    }

    /* gcd */
    for(j = 0; j < i; j++)
    {
        if (a[j] >= b[j])
        {
            gcd[j] = euclid(a[j],b[j]);
        }
        else
        {
            gcd[j] = euclid(b[j],a[j]);
        }
    }


    /* lcm */
    for(j = 0; j < i; j++)
    {
        lcm[j] = (a[j] * b[j]) / gcd[j];
    }

    /* output */
    for(j = 0; j < i; j++)
    {
        printf("%ld %ld\n",gcd[j],lcm[j]);
    }

    return 0;
}


unsigned long euclid(unsigned long m, unsigned long n)
{
    unsigned long tmp;

    while (n != 0)
    {
        tmp = n;
        n = m % n;
        m = tmp;
    }

    return m;
}

Measured memory_bytes: 544
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
int mod=1000000007;
typedef long long ll;
using namespace std;

ll a[12][12];
string s;
ll sum=0;

void DFS(int pnt,ll cnt){
	if(pnt==s.size()){
		sum+=cnt;
		return;
	}
	for(int i=pnt+1;i<=s.size();i++){
		DFS(i,cnt+a[pnt][i]);
	}
}
int main(){
	cin>>s;
	for(int i=0;i<s.size();i++){
		for(int j=i+1;j<=s.size();j++){
			ll tmp=0;
			for(int k=0;k+i<j;k++){
				tmp*=10;
				tmp+=s[k+i]-'0';
			}
			a[i][j]=tmp;
		}
	}
	sum=0;
	DFS(0,0);
	cout<<sum<<endl;
	return 0;
}


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

int main() {
  int A, B, C, D;
  string op;
  cin >> A >> B >> C >> D;

  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
   else if ((A + B) < (C + D)) {
    cout << "Right" << endl;
  }
   else {
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;

int main(){
    int N,L ; cin >> N >> L;
    int sum = N * (L-1) + N * (N+1)/2;
    int tmp;
    int res;
    rep(i,N){
        if(i == 0){
            res = L+i; //n
            continue;
        }
        tmp = L+i; //n+1
        if(abs(tmp) > abs(res)){
            continue;
        }
        else{
            res = tmp;
            continue;
        }
    }
    cout << sum - res << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll count4 = 0, count2 = 0;
    for(int i = 0; i < n; ++i){
        ll ai;
        cin >> ai;
        count4 += (ai % 4 == 0);
        if(ai % 4 != 0 && ai % 2 == 0){
            count2++;
        }
    }
    const ll rest = (n - count2 - count4) + count2 % 2;
    if(count4 >= rest - 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

Measured memory_bytes: 2656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cout << a[i] << " "; cout << "\n"; }
ll dbgt = 1; void err() { cout << "passed " << dbgt++ << "\n"; }
template<class H, class... T> void err(H&& h,T&&... t){ cout<< h << (sizeof...(t)?" ":"\n"); if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-20;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ld dp[305][305][305], PP[305][305][305];
ll A[4];
int main() {
    init();
    ll N;
    cin >> N;
    rep(i,N){
        ll a;
        cin >> a;
        A[a]++;
    }

    PP[A[1]][A[2]][A[3]] = 1.0L;

    repr(t3,N+1){
        repr(t2,N+1){
            repr(t1,N+1){
                ld T = t1 + t2 + t3, D = dp[t1][t2][t3], P = PP[t1][t2][t3];
                ld R = 1.0L * N / T, K = D / P;
                if (T == 0 or P < EPS) continue;
                if(t1>0){
                    PP[t1 - 1][t2][t3] += P * t1 / T;
                    dp[t1 - 1][t2][t3] += (K + R) * P * t1 / T;
                }
                if(t2>0){
                    PP[t1 + 1][t2 - 1][t3] += P * t2 / T;
                    dp[t1 + 1][t2 - 1][t3] += (K + R) * P * t2 / T;
                }
                if(t3>0){
                    PP[t1][t2 + 1][t3 - 1] += P * t3 / T;
                    dp[t1][t2 + 1][t3 - 1] += (K + R) * P * t3 / T;
                }
            }
        }
    }

    cout << dp[0][0][0] << endl;
}


Measured memory_bytes: 870656
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
	// writer  = bufio.NewWriterSize(os.Stdout, 1000000)
)

func main() {
	scanner.Split(bufio.ScanWords)
	// scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	// defer writer.Flush()
	s, w := scanInt(), scanInt()
	if w >= s {
		fmt.Println("unsafe")
	} else {
		fmt.Println("safe")
	}
}

func scanInt() int {
	i, _ := strconv.Atoi(scanString())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanString(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanString() string {
	scanner.Scan()
	return scanner.Text()
}

func scanStrings(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanString()
	}
	return s
}


Measured memory_bytes: 1760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int n,k;
    cin >> n >> k;
    map<int,int> a;
    vector<int> b;
    rep(i,n){
        int b;
        cin >> b;
        a[b]++;
    }
    for(auto i:a) b.push_back(i.second);
    sort(b.begin(),b.end());
    int j = 0,ans = 0;
    rep(i,(int)b.size()-k) ans += b[i];
    cout << ans << endl;
}

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

 using namespace std;
 int main() {
   string s;
   int i, j;
   bool Yes = false;

   cin >> s;

   for (i = 0; i < s.length() - 1; i++) {
     if (s.at(i) == 'C') {
       for (j = i + 1; j < s.length(); j++) {
         if (s.at(j) == 'F') {
           cout << "Yes" << endl;
           Yes = true;
           break;
         }
       }
     }
     if (Yes == true) break;
   }
   if (Yes == false) cout << "No" << endl;
 }


Measured memory_bytes: 256