akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main()
{
    int tasks[3];
    int maxNumber = 0, maxIndex = 0;
    for (int i = 0; i<3; i++) {
        cin >> tasks[i];
        if (tasks[i] > maxNumber) {
            maxNumber = tasks[i];
            maxIndex = i;
        }
    }
    swap(tasks[0], tasks[maxIndex]);

    if (tasks[2] > tasks[1])
        swap(tasks[2], tasks[1]);

    cout << (tasks[0]-tasks[1]) + (tasks[1] - tasks[2]);

    return 0;
}

Measured memory_bytes: 256
import itertools

n, m = map(int, input().split(" "))
path_city = [[] for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split(" "))
  path_city[a - 1].append(b - 1)
  path_city[b - 1].append(a - 1)
list_city = [i for i in range(1, n)]
list_order_city = itertools.permutations(list_city)

result = 0
for one_order in list_order_city:
  pre_city = 0
  flag_con = True
  for one_city in one_order:
    if pre_city not in path_city[one_city]:
      flag_con = False
      break
    pre_city = one_city
  if flag_con:
    result += 1
print(result)

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

using namespace std;

using ll = long long;

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

    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
        cout << "Possible\n";
    else
        cout << "Impossible\n";

    return 0;
}


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
        k:i64,
    }
    let mut ans = 0;
    for a in 1..=k {
        for b in 1..=k {
            for c in 1..=k {
                ans += gcd_list(&vec![a, b, c]);
            }
        }
    }
    println!("{}", ans);
}
pub fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
pub fn gcd_list(list: &[i64]) -> i64 {
    list.iter().fold(list[0], |a, &b| gcd(a, b))
}


Measured memory_bytes: 2168
#include <algorithm>
#include <cstdio>
#include <cstring>

const int Maxv = 200010; 

int Head[Maxv], cnt; 

struct Node {
    int v, next; 
} N[Maxv << 1]; 

inline void addEdge(int u, int v) {
    N[++cnt].v = v; 
    N[cnt].next = Head[u]; 
    Head[u] = cnt; 
}

int deg[Maxv][2], q[Maxv], head, tail, n, m; 
char col[Maxv]; 
bool vis[Maxv]; 

int main() {
    scanf("%d%d", &n, &m); 
    scanf("%s", col + 1); 

    for (int i = 1; i <= m; i++) {
        int u, v; 
        scanf("%d%d", &u, &v); 
        addEdge(u, v); 
        addEdge(v, u); 
        deg[u][col[v] == 'B']++; 
        deg[v][col[u] == 'B']++; 
    }

    for (int i = 1; i <= n; i++) {
        if (deg[i][0] == 0 || deg[i][1] == 0) {
            vis[q[tail++] = i] = true; 
        }
    }
    
    while (head != tail) {
        int x = q[head++]; 

        for (int i = Head[x]; i; i = N[i].next) {
            if (!vis[ N[i].v ]) {
                if (--deg[ N[i].v ][col[x] == 'B'] == 0) {
                    vis[ N[i].v ] = true; 
                    q[tail++] = N[i].v; 
                }
            }
        }
    }

    if (tail == n) puts("No"); 
    else puts("Yes"); 

    return 0; 
}

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

using namespace std;

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;

#define rep(i,a,b) for(int i =a;i<b;i++)


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

    int n;
    cin>>n;

    vector<int> v(n);
    for(auto &x: v){
        cin>>x;
    }

    vector<int> cost(n);//dp array

    cost[0] = 0;
    cost[1] = cost[0]+ abs(v[1] - v[0]);

    rep(i, 2, n){
        cost[i] = min(cost[i-1]+ abs(v[i]- v[i-1]), cost[i-2]+ abs(v[i]-v[i-2]));
    }

    cout<<cost[n-1]<<endl;



    return 0 ;
}



Measured memory_bytes: 3968
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int N,K;
	cin >> N >> K;
	vector<int> fruits(N);
	for (int i = 0; i < fruits.size(); i++) {
		cin >> fruits.at(i);
	}

	sort(fruits.begin(), fruits.end());

	int sum = 0;
	for (int i = 0; i < K; i++) {
		sum += fruits.at(i);
	}

	cout << sum << endl;

}

Measured memory_bytes: 3628
import java.util.Scanner;

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

		String a="abcdefghijklmnopqrstuvwxyz";
		int num=a.indexOf(C);
		char b=a.charAt(num+1);

		System.out.println(b);
	}
}


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

int main(){
    int n, m; cin >> n >> m;
    vector<int> a(m), b(m), c(n);
    rep(i,n) c[i] = 0;
    rep(i,m){
        cin >> a[i] >> b[i];
        c[a[i]-1]++; c[b[i]-1]++;
    }
    rep(i,n) cout << c[i] << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 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) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
  COMinit();
  ll N,P,sum=0,g=0,k=0,ans=0,G=0,K=0;
  cin>>N>>P;
  vector<ll> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
    sum+=A[i];
    if(A[i]%2==0) g++;
    else k++;
  }
  G=pow(2,g);
  if(sum%2==P){
    for(int i=2;i<=k;i+=2){
      K+=COM(k,i);
    }
    ans+=K+G+K*(G-1);
  }else{
    for(int i=1;i<=k;i+=2){
      K+=COM(k,i);
    }
    ans+=K*G;
  }
  cout<<ans<<endl;
}


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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    // x = By + z
    // x/B = y
    // Ax = ABy + Az
    // Ax/B = Ay + (Az/B)
    // Ay - Ay + floor(Az/B)
    // floor(Az/B)

    ll a, b, n;
    cin >> a >> b >> n;
    ll hoge = min(b - 1, n);
    cout << a * hoge / b << newl;

    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

using namespace std;

int main(void){
  int A,B;
  cin>>A;
  cin>>B;
  cout << max({A+B,A-B,A*B}) << endl;
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  double x;
  double count = 0;
  string s;
  for(int i=0;i<n;i++){
    cin >> x >> s;
    if(s=="BTC"){
      x*=380000;
      count += x;
    }else{
      count += x;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
/*
    author: Salam_35
    Created at :

*/

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() int t;cin >> t;while(t--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

int main()
{
    int n,m,h;
    string s;
    cin>> n>>m;
    int arr[n+10];
    int sum=0;
    for (int i = 0; i < m; ++i)
    {
    	cin >> arr[i];
    	sum+=arr[i];
    }
    cout<<(sum>n?-1:abs(sum-n))<<endl;
}


Measured memory_bytes: 3668
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  n = readline() |> parseInt
  a = readline() |> split |> parseArray
  b = readline() |> split |> parseArray
  c = readline() |> split |> parseArray

  ans=sum(b)
  for i in 1:n-1
    a[i+1]==a[i]+1 && a[i]!=n && (ans+=c[a[i]])
  end
  println(ans)
end

main()


Measured memory_bytes: 111632
#include<iostream>
using namespace std;
int main(void){
  int a, b, c, d, e;
  cin >> a >> b >> c;
  d = abs(a-b);
  e = abs(a-c);
  if(d <= e) cout<<"A"<<endl;
  else cout<<"B"<<endl;
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i ++) {
    if (s[i] == 'C') {
      for (int j = i + 1; j < s.size(); j ++) {
        if (s[j] == 'F') {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }

  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
 
 
int main()
{
    int n;
    scanf("%d",&n);
    REP(i,n+1)
    {
        if(i%4==0 &&(n-i)%7==0)
        {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int N = cin.ReadInt;
            int[] arr = cin.ReadIntArray(N);
            string answer = "APPROVED";
            for(int i = 0; i < N; i++)
            { 
                if (arr[i] % 2 != 0)
                {
                    continue;
                }
                else if (arr[i] % 3 != 0 && arr[i] % 5 != 0)
                {
                    answer = "DENIED";
                }
                else
                {
                    continue;
                }
            }
            Console.WriteLine(answer);
            
            
            
        }


    }
            


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}


Measured memory_bytes: 13268
import java.util.*;class Main{public static void main(String[]a){for(Scanner s=new Scanner(System.in);s.hasNext();){Integer[]i=new Integer[5];for(int t=5;t-->0;i[t]=s.nextInt());Arrays.sort(i,Collections.reverseOrder());System.out.println(Arrays.toString(i).replaceAll("[\\[\\],]",""));}}}

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

bool is_prime(int x)
{
    if (x == 1)
    {
        return false;
    }

    for (int i = 2; i * i <= x; i++)
    {
        if (x % i == 0)
        {
            return false;
        }
    }

    return true;
}

int main()
{
    int Q;
    cin >> Q;
    bool prime[100000 + 1] = {};
    int like[100000 + 1] = {};
    prime[2] = true;
    for (int i = 2; i <= 100000; i++)
    {
        if (i % 2 == 1)
        {
            prime[i] = is_prime(i);
        }

        if (prime[i] && prime[(i + 1) / 2])
        {
            like[i] = like[i - 1] + 1;
        }
        else
        {
            like[i] = like[i - 1];
        }
    }

    for (int i = 0; i < Q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << like[r] - like[l - 1] << endl;
    }
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

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

//dp table
ll dp[3005][3005];

//input
string S,T;
int N,M;

int main() {
	//input
	cin>>S>>T;
	N = S.size();
	M = T.size();

	//dp
	//初期状態
	dp[0][0] = 0;

	rep(i,N)rep(j,M){
		if(S[i]==T[j]){
			dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+1);
		}
		dp[i+1][j+1] = max(dp[i+1][j+1],dp[i+1][j]);
		dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j+1]);	
	}

	string ans = "";


	while(N>0 && M>0){
		if(dp[N][M] == dp[N-1][M]){
			N--;
		}
		else if(dp[N][M] == dp[N][M-1]){
			M--;
		}
		else{
			ans = S[N-1] + ans;
			N--; M--;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 70656
#include <iostream>
#include <cstdio>
using namespace std;
int a;
string s;
int main()
{
	cin >> s;
	int i, j;
	for(i = 0; i < s.size(); i++) {
		if(s[i] == 'A'){
			break;
		}
	}
	for(j = 0; j < s.size(); j++) {
		if(s[j] == 'Z'){
			a = j;
		}
	}
	cout << a - i + 1;
    return 0;
}


Measured memory_bytes: 640
S = list(input())
n = (len(S)-1)//2
m = 0
for i in range(n):
  if S[i] == S[-(i+1)] and S[i] == S[i+n+1]:
    continue
  else:
    print('No')
    m = 1
    break
if m < 1:
  print('Yes')

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;

namespace _20200322
{
    class Program
    {
        static void Main()
        {
            var n = Console.ReadLine();
            var aStrList = Console.ReadLine().Split(' ');
            var aList = new List<int>();
            var counts = new Dictionary<int, long>();
            long all = 0;
            foreach (var aStr in aStrList)
            {
                var a = int.Parse(aStr);
                aList.Add(a);
                if (counts.ContainsKey(a))
                {
                    ++counts[a];
                }
                else
                {
                    counts[a] = 1;
                }
            }
            foreach (var a in counts.Keys)
            {
                all += counts[a] * (counts[a] - 1) / 2;
            }
            foreach (var a in aList)
            {
                Console.WriteLine(all - counts[a] + 1);
            }
        }
    }
}


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

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

typedef int type;
const type INIT = 0;

class segment_tree {
private:
	int n;
	vector<type> dat;

	inline type function(type a, type b) const {
		return max(a, b);
	}

	type query(int a, int b, int k, int l, int r) const {
		if(r <= a || b <= l)
			return INIT;

		if(a <= l && r <= b) {
			return dat[k];
		}
		else {
			const type vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			const type vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return function(vl, vr);
		}
	}

public:
	segment_tree(int n_) {
		n = 1;
		while(n < n_) n *= 2;
		dat.resize(2 * n - 1, INIT);
	}

	inline void update(int k, type a) {
		k += n - 1;
		dat[k] = a;

		while(k > 0) {
			k = (k - 1) / 2;
			dat[k] = function(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}

	inline type query(int a, int b) const {
		return query(a, b, 0, 0, n);
	}
};

inline int next(int idx, int mod) {
	return (idx + 1) % mod;
}

inline int mod_sub(int a, int b, int mod) {
	return (a - b + mod) % mod;
}

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

	int n, k;
	cin >> n >> k;

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

	const int number_of_edges = n / 2;
	int lds = 0;
	vector<bool> used(n, false);

	for(int i = 0; i < n; ++i) {
		if(used[i]) continue;

		used[i] = true;
		used[a[i]] = true;

		vector<int> sequence;
		sequence.reserve(number_of_edges);
		const int pos = a[i] - i;

		for(int j = i + 1; j != a[i]; j = next(j, n)) {
			const int pos_a = mod_sub(a[j], i, n);
			if(pos_a > pos) { // intersect
				sequence.emplace_back(n - pos_a - 1);
			}
		}

		if(static_cast<int>(sequence.size()) < lds) continue;

		segment_tree seg(n);

		for(int i = 0; i < static_cast<int>(sequence.size()); ++i) {
			const int value = seg.query(sequence[i] + 1, n) + 1;
			chmax(lds, value);
			seg.update(sequence[i], value);
		}
	}

	int ans = min(lds + 1 + k, number_of_edges);
	cout << ans << endl;
	return EXIT_SUCCESS;
}

Measured memory_bytes: 1320
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            var result = 0;

            for (int d1 = 0; d1 <= 9; d1++)
            {
                for (int d2 = 0; d2 <= 9; d2++)
                {
                    for (int d3 = 0; d3 <= 9; d3++)
                    {
                        var i1 = S.IndexOf(d1.ToString(), 0);
                        var i2 = S.IndexOf(d2.ToString(), i1 + 1);
                        var i3 = S.IndexOf(d3.ToString(), i2 + 1);

                        if (i1 >= 0 && i2 >= 0 && i3 >= 0) result++;
                    }
                }
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13408
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string S,T;
    cin>>S>>T;
    
    if(S.size()+1!=T.size()){
        cout<<"No"<<endl;
        return 0;
    }
    for(ll i=0;i<S.size();i++){
        if(S[i]!=T[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    
    return 0;
}


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

int a, b;

void solve() {
    cin >> a >> b;
    cout << (a > 9 || b > 9 ? -1 : a * b) << "\n";
}

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

Measured memory_bytes: 3648
#include <stdio.h>
#define BLACK 1
#define WHITE 0
#define GRAY 2
#define inf 1000000
int n;
int M[100][100];

void dijkstra()
{
  int minv,i,u,v;
  int d[100],color[100];
  for(i=0;i<n;i++){
    d[i]=inf;
    color[i]=WHITE;
  }
  d[0]=0;
  color[0]=GRAY;
  while(1){
    minv=inf;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
        u=i;
        minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=inf){
        if(d[v]>d[u]+M[u][v]){
          d[v]=d[u]+M[u][v];
          color[v]=GRAY;
        }
      }
    }
  }
    for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }
}
int main()
{
  int i,j,u,k,v,c;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=inf;
    }
  }

  for(i=0;i<n;i++)
    {
      scanf("%d",&u);
      scanf("%d",&k);
      for(j=0;j<k;j++)
        {
          scanf("%d",&v);
          scanf("%d",&c);
          M[u][v]=c;
        }
    }

  dijkstra();

  return 0;
}


Measured memory_bytes: 1996
using System;
namespace ABC087B_Coins
{
    public class MainClass
    {
        public static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int x = int.Parse(Console.ReadLine());
            int cnt  = 0;
            for (int i = 0; i <= a; i++)
            {
                for (int j = 0; j <= b; j++)
                {
                    for (int k = 0; k <= c; k++)
                    {
                        if(500*(a-i) + 100*(b-j) + 50*(c-k) == x)
                        {
                            cnt++;
                        }
                    }
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 
 
int main() {
    int n, mp = int(1E6), cnt = 0;
    cin >> n;
    rep(i, n) {
        int p;
        cin >> p;
        if (mp >= p) {
            ++cnt;
            mp = p;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
int main(){
FASTIO;
int auxi[3],i;
memset(auxi,0,sizeof(auxi));
int x;
for(i=0;i<2;i++){
    cin>>x;
    auxi[x-1]++;
}
for(i=0;i<3;i++){
    if(!auxi[i])
        cout<<i+1<<endl;
}
}


Measured memory_bytes: 256
int n, k, ans, i;
int main(){
  scanf("%d%d", &n, &k);
  ans=1;
  for(i=0; i<n; i++){
    if(ans>=k){
      break;
    }else{
      ans<<=1;
    }
  }
  for(; i<n; i++){
    ans+=k;
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 128
//??????????????¨??¨??????. ??????????????????, ????????????????????????????¬?????±???????.
#include <iostream>
using namespace std;

int c;
int maisu[4];
int tanka[4] = {10, 50, 100, 500};
int ans[4];

int getCount(int x) {
	int ret = 0;
	for (int i = 3; i >= 0; i--) {
		int cnt = x / tanka[i];
		x -= tanka[i] * cnt;
		ret += cnt;
	}
	return ret;
}

int main() {
	int i, j, k, l;
	bool first = true;
	while (cin >> c) {
		if (!c) break;
		if (first) { first = false; }
		else { cout << endl; }
		
		for (i = 0; i < 4; i++) cin >> maisu[i];
		
		int minCount = 114514;
		for (i = 0; i <= maisu[0]; i++) {
			for (j = 0; j <= maisu[1]; j++) {
				for (k = 0; k <= maisu[2]; k++) {
					for(l = 0; l <= maisu[3]; l++) {
						int otsuri = tanka[0] * i + tanka[1] * j + tanka[2] * k + tanka[3] * l - c;
						if (otsuri < 0) continue;
						if (minCount > -i - j - k - l + getCount(otsuri)) {
							minCount = -i - j - k - l + getCount(otsuri);
							ans[0] = i;
							ans[1] = j;
							ans[2] = k;
							ans[3] = l;
						}
					}
				}
			}
		}
		
		for (i = 0; i < 4; i++) {
			if (ans[i] == 0) continue;
			cout << tanka[i] << " " << ans[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3004
#include<bits/stdc++.h>
using namespace std;
int last[200200];
struct node{
	int x,v;
}r[200200];
int cmp(node m,node n){
	return m.x>n.x;
}
int main(){
	int n,k;
	scanf("%d%d",&n,&k); 
	//for(int i=1;i<=n;i++)last[i]=i;
	for(int i=1;i<=k;i++){
		int a;
		scanf("%d",&a);
		last[a]=i;
	}
	int tot=0;
	for(int i=1;i<=n;i++)
		if(last[i])
			r[++tot]={last[i],i};
	sort(r+1,r+1+tot,cmp);
	for(int i=1;i<=tot;i++)
		printf("%d\n",r[i].v);
	for(int i=1;i<=n;i++) 
		if(!last[i])
			printf("%d\n",i);
}

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

long long lcm(long long x,long long y){
    long long x1 = x;
    long long y1 = y;
    for(;y != 1;){
        double c=x%y;
      	if(c == 0){
            x = y;
            break;
        }
        x = c;
        if(y>x){
            swap(x,y);
        }
    }
    if(y == 1){
        x = 1;
    }
    long long A =  x1*y1/x;
	return A;
}

int main(){
    int a,b;
    cin >> a >>b;
    cout << lcm(a,b) <<endl;
}


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

int main() {
    int h, w;
    cin >> h >> w;
    
    for (int i = 0; i < w + 2; i++) cout << '#';
    cout << endl;
    
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        cout << '#' << s << '#' << endl;
    }
    
    for (int i = 0; i < w + 2; i++) cout << '#';
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
inline int getint(){
  char c; int res = 0;
  for(c = getchar();c < '0' || c > '9';c = getchar());
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res;
}
int main(){
  int a = getint(), b = getint(), k = getint();
  for(int i = 100;i >= 1;i--){
    if(a % i == 0 && b % i == 0) k--;
    if(k == 0){
      printf("%d\n",i);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 998244353;
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}

vector<P>vec;
int n;
int main(){
ios::sync_with_stdio(false);
	cin>>n;
	rep(i, n){
		string s; cin >> s;
		int sum = 0, mn = 0;
		rep(j, s.size()){
			sum += (s[j]=='('?1:-1);
			chmin(mn, sum);
		}
		vec.pb(mp(sum, mn));
	}
	sort(all(vec), [&](const P &a, const P &b){
		if(a.fi >= 0 && b.fi < 0) return true;
		if(a.fi < 0 && b.fi >= 0) return false;
		if(a.fi >= 0 && b.fi >= 0){
			return a.sc > b.sc;
		}
		if(a.fi < 0 && b.fi < 0){
			return a.fi-a.sc > b.fi-b.sc;
		}
	});
	int cur = 0;
	rep(i, vec.size()){
		if(cur+vec[i].sc < 0){
			puts("No"); return 0;
		}
		cur += vec[i].fi;
	}
	if(cur != 0){
		puts("No"); return 0;
	}
	puts("Yes");}



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

ll modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = (res*a)%mod;
        a = (a*a)%mod;
        n >>= 1;
    }
    return res;
}

int main() {
  ll n,MOD = 1e9+7;
  cin >> n;
  ll ten = modpow(10,n,MOD),nine = modpow(9,n,MOD),eight = modpow(8,n,MOD);
  ll ans = ten+eight;
  nine = (2*nine)%MOD;
  ans -= nine;
  ans = (ans+MOD)%MOD;
  cout << ans << endl;
}

Measured memory_bytes: 3628
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// #define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);++i)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()

int main(){
	int N,K; cin>>N>>K;
	int c = 0;
	rp(i,N){
		int h;
		cin>>h;
		if(h>=K){
			c++;
		}
	}
	ote(c);
}


Measured memory_bytes: 256
n = input()
if len(n) == 1:
  print(int(n))
elif len(n) == 2:
  print(9)
elif len(n) == 3:
  print(int(n)-99 + 9)
elif len(n) == 4:
  print(999-99+9)
elif len(n) == 5:
  print(int(n) - 9999 + 999 -99 + 9)
else:
  print(99999-9999+999-99+9)

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

int gcd(int X, int Y) {
	int a = min(X, Y), b = max(X, Y);
	while (a != 0) {
		int c = b % a;
		b = a;
		a = c;
	}
	return b;
}

int main() {
	int N, G, A;
	cin >> N >> A;
	G = A;
	for (int i = 1; i < N; i++) {
		cin >> A;
		G = gcd(G, A);
	}
	int count = 0;
	while (G % 2 == 0) {
		G /= 2;
		count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;
#define endl "\n"

long long modpow(long long a, long long n, long long mod) {//a^n(mod)を求める
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;//次の準備
        n >>= 1;
    }
    return res;
}

//二分累乗法 modを設定すること

ll dp[100010]={};

signed main(){
    ll ans=0,size;
    string l;
    dp[0] = 1;
    cin>>l;
    size=(ll)l.size()-1;

    for(int i=0;i<=size;i++)//iは桁数,上からi桁目ではじめて不一致
    {
        if('1'==l.at(i)){ //i桁目が１
            dp[i+1]=dp[i]*2;
            ans+=modpow(3,size-i,mod)*dp[i];
            ans%=mod;
        }else{
            dp[i+1]=dp[i];
            
            
        }
        if(i==size){
            ans+=dp[i+1];
            ans%=mod;
        }
        dp[i+1]%=mod;
    }

    cout << ans%mod << endl;
}
//longlojgで収まらないときはstringで

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  int x = A + B;
  int y = C + D;
  
  if (x > y) {
    cout << "Left" << endl;
  }
  
  else if (x == y) {
    cout << "Balanced" << endl;
  }
  
  else {
    cout << "Right" << endl;
  }
}

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

long long calc(vector<int>& A, int N, long long ans, bool up) {
  if (N == 1) return ans + A[0];
  int num = A[N - 1];
  if (up) {
    if (num >= 5) num++;
  }
  if (num <= 5) {
    ans += num;
    if (num == 5) return calc(A, N - 1, ans, true);
    else return calc(A, N - 1, ans, false);
  } else {
    ans += 10 - num;
    A[N - 2]++;
    return calc(A, N - 1, ans, false);
  }
}

int main(){
  string S; cin >> S;
  int N = S.size();
  vector<int> A(N + 1, 0);
  rep(i, N) A[i + 1] = S[i] - '0';

  cout << calc(A, N + 1, 0, false) << endl;
  
}


Measured memory_bytes: 5252
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    char[] s;
    scan(s);

    int ans = 100000;

    foreach (ch ; 'a' .. 'z' + 1) {
        ans = min(ans, solve(s, ch.to!char));
    }

    writeln(ans);
}

int solve(char[] s, char ch) {
    int n = s.length.to!int;
    char[] cur = s.dup;

    foreach (i ; 0 .. n - 1) {
        bool ok = true;

        foreach (j ; 0 .. cur.length) {
            if (cur[j] != cur[0]) {
                ok = false;
                break;
            }
        }

        if (ok) {
            return i;
        }

        auto nex = new char[](n - 1 - i);
        foreach (j ; 0 .. n - 1 - i) {
            if (cur[j] == ch || cur[j + 1] == ch) {
                nex[j] = ch;
            }
            else {
                nex[j] = cur[j];
            }
        }
        cur = nex;

        debug {
            writeln(cur);
        }
    }

    return n - 1;
}





















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 380
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

n,a,b,c,d=map(int,input().split())

# iterate through number of +'s and -'s
for i in range(n):
    j=n-1-i
    # i +'s, j -'s
    x=a+c*i-d*j
    y=a+d*i-c*j
    if x<=b<=y:
        print("YES")
        break
else:
    print("NO")


Measured memory_bytes: 2940
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define mod 1000000000+7
#define rep(i,n) for(int i=0;i<(int) (n);i++)
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
int main(){
ll a,b,k;
cin>>a>>b>>k;

ll n=a-k;
if(n<0){
  b=b+a-k;
  a=0;
}else a=n;

if(b<0)b=0;

cout<<a<<" "<<b;
}

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

double mnk(double a,double b,double c){
  double s = (a + b + c) / 2;
  double S = sqrt(s*(s - a)*(s - b)*(s - c)); //テ」ツδ佚」ツδュテ」ツδウテ」ツ?ョテ・ツ?ャテ・ツシツ?
  return S;
}

int main(){
  double x1,y1,x2,y2,x3,y3,xp,yp;
  
  while( cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp ){
    double a = sqrt(pow(x1-x2,2) + pow(y1-y2,2));
    double b = sqrt(pow(x1-x3,2) + pow(y1-y3,2));
    double c = sqrt(pow(x3-x2,2) + pow(y3-y2,2));
    double S1 = mnk(a,b,c);
    
    double x = sqrt(pow(x1-xp,2) + pow(y1-yp,2));
    double y = sqrt(pow(x2-xp,2) + pow(y2-yp,2));
    double z = sqrt(pow(x3-xp,2) + pow(y3-yp,2));
    double S2 = mnk(x,y,a) + mnk(x,z,b) + mnk(y,z,c);
    
    if ((float)S1 == (float)S2){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
    
    
  }
  return 0;
}

Measured memory_bytes: 1216
fn main() {
  let s: String = read();
  
  let pre = s.chars().take(4).collect::<String>();
  
  println!("{}", if pre.as_str() == "YAKI" {"Yes"} else {"No"});
}

fn read<T: std::str::FromStr>() -> T {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().parse::<T>().ok().unwrap()
}

Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAXN 2010
using namespace std;

int n;
int a[MAXN],b[MAXN],s[MAXN];
int p1[MAXN],p2[MAXN];
int g[MAXN];

void input(){
	static char str[MAXN];
	scanf("%s",str+1);
	n=strlen(str+1);
	for(int i=1;i<=n;i++) s[i]=str[i]-'0';
	scanf("%s",str+1);
	for(int i=1;i<=n;i++) b[i]=str[i]-'0';
}

int getDis(int x){
	x=((x-1)%n+n)%n+1;
	return min(x-1,n+1-x);
}

int gao(int x){
	int cnt=0;
	for(int i=1,j=x;i<=n;i++,j++){
		if(j>n) j-=n;
		a[j]=s[j]^b[i];
		if(a[j]) cnt++;
	}
	int temp=-n;
	for(int i=1;i<=n;i++)
		if(b[i]) temp=-n+i;
	for(int i=1;i<=n;i++){
		if(b[i]) temp=i;
		if(a[i]) p1[i]=i-temp;
	}
	temp=2*n;
	for(int i=n;i>=1;i--)
		if(b[i]) temp=n+i;
	for(int i=n;i>=1;i--){
		if(b[i]) temp=i;
		if(a[i]) p2[i]=temp-i;
	}
	for(int i=1;i<=n;i++) g[i]=0;
	for(int i=1;i<=n;i++) 
		if(a[i])
			g[p1[i]]=max(g[p1[i]],p2[i]);
	for(int i=n;i>=1;i--) g[i]=max(g[i],g[i+1]);
	int res=1<<30;
	for(int i=0;i<=n;i++){
		int j=g[i+1];
		int res1=getDis(x-i)+2*j+i+cnt;
		int res2=getDis(x+j)+2*i+j+cnt;
		res=min(res,res1);
		res=min(res,res2);
	}
	return res;
}

int main(){
#ifdef DEBUG
	freopen("D.in","r",stdin);
#endif
	input();
	bool flag1=0,flag2=0;
	for(int i=1;i<=n;i++){
		if(s[i]) flag1=1;
		if(b[i]) flag2=1;
	}
	if(!flag1 && !flag2){
		puts("0");
		return 0;
	}
	if(!flag2){
		puts("-1");
		return 0;
	}
	int ans=1<<30;
	for(int i=1;i<=n;i++) 
		ans=min(ans,gao(i));
	printf("%d\n",ans);
}


Measured memory_bytes: 384
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e5 + 5;
const int mod = (int) 1e9 + 7;

int n, a[N];

inline void solve () {
        scanf ("%d", &n);
        for (int i = 1; i <= n; i++) {
                scanf ("%d", &a[i]);
        }
        sort (a + 1, a + n + 1, greater<int> ());
        int f = n, x = 0;
        for (int i = 1; i <= n; i++) {
                if (a[i] < i) {
                        f = i - 1;
                        break;
                }
        }
        for (int i = 1; i <= n; i++) {
                if (a[i] >= f) {
                        x++;
                }
        }
        puts (((x - f) | (a[f] - f)) % 2 ? "First" : "Second");
}

int tests = 1;

int main () {
//        freopen (".in", "r", stdin);
//        freopen (".out", "w", stdout);
//        scanf ("%d", &tests);
        while (tests--) {
                solve ();
        }
        return 0;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<class a, int N, class T>
void fillArray(a(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }


int n, m;
vector<int> g[100005];
bool visited[100005];
int deg[100005];
void dfs(int pos, int par) {
    visited[pos] = true;
    rep(i, sz(g[pos])) {
        auto nv = g[pos][i];
        if (nv == par) continue;
        if (visited[nv]) {
            if (pos < nv) {
                cout << pos + 1 << " " << nv + 1 << endl;
                ++deg[pos];
            }
        }
        else dfs(nv, pos);
    }

    if (pos == 0) return;
    if (deg[pos] % 2 == 1) {
        cout << pos + 1 << " " << par + 1 << endl;
        ++deg[pos];
    }
    else {
        cout << par + 1 << " " << pos + 1 << endl;
        ++deg[par];
    }
}

void solve() {
    cin >> n >> m;
    rep(i, m) {
        int a, b; cin >> a >> b; --a; --b;
        g[a].emplace_back(b); g[b].emplace_back(a);
    }

    if (m % 2 != 0) { cout << -1 << endl; return; }
    dfs(0, -1);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 15232
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0), cin.tie(0) 
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const int inf = ~0u >> 1;
int main() {
    IO;
    int n;
    cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; ++i) {
        if (!(i % 3 == 0 || i % 5 == 0))
            ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define P pair<int, int>
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    ll a, b, n;
    cin >> a >> b >> n;
    ll memo;
    memo = min(b - 1, n);
    memo = floor(a * memo / b) - a * floor(memo / b);
    cout << memo << endl;
    solve();
    return 0;
}




Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int n,m;
    cin>>n>>m;
    string p;
    cin>>p;
    if(p==s)
        cout<<n-1<<" "<<m<<endl;
    else
        cout<<n<<" "<<m-1<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    N, M = in_nn()
    p = in_nl()

    uni = UnionFind(N)
    for i in range(M):
        x, y = in_nn()
        x, y = x - 1, y - 1
        uni.union(x, y)

    edge = [[] for i in range(N)]
    for i in range(N):
        x = uni.find(i)
        edge[x].append(i)

    ans = 0
    for i in range(N):
        if edge[i]:
            s = set(edge[i])
            for e in edge[i]:
                if p[e] - 1 in s:
                    ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 102908
#include<iostream>
#include<stdio.h>

int main(){
  int H,W,i,j;
  while(true){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0)break;
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){

        if((i+j)%2==0){
          printf("#");
        }else{
          printf(".");
        }

      }
      printf("\n");
    }
    printf("\n");

  }
  return 0;
}


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

const int MAX = 100000;
int main() {
	int N, M, a, b;
	cin >> N >> M;
	static pair<pair<int, int>, int> bridge[MAX], bridge2[MAX];
	static bool ignore[MAX];
	for (int i = 0;i < MAX;++ i) ignore[i] = false;
	for (int i = 0;i < M;++ i) {
		cin >> a >> b;
		bridge[i] = make_pair(make_pair(a, b), i);
		bridge2[i] = make_pair(make_pair(b, a), i);
	}
	sort(bridge, bridge + M);
	sort(bridge2, bridge2 + M);
	
	int ans = 0, check = 0;
	for (int i = 0;i < M;++ i) {
		if (!ignore[bridge2[i].second]) { // まだその要望が叶えられていない
			++ ans;
			for (;check < M && bridge[check].first.first < bridge2[i].first.first;++ check) {
				ignore[bridge[check].second] = true; // この要望は叶えられた
			}
		}
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、全部取っ払えば問題ないから答えは最大でもN-1
次に、bの小さい順にソートしたとする
この時、b_1より手前の全ての橋は放置しても問題ない
b_1とb_1の1個前の島の橋を撤去する
その時、aがb_1より小さい要望は全て消去できる
これを繰り返せば、答えが求まる
*/

Measured memory_bytes: 2688