akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

bool isPrime(int n){
    for(int i=2; i<n; i++){
        if((n%i)==0) return false;
    }
    return true;
}

int main() {
    int n; cin>>n;
    while(n != 0){
        //素数列挙
        vector<int> prime;
        for(int i=2; i<=n; i++){
            if(isPrime(i)) prime.push_back(i);
        }

        //累積和
        vector<int> c(prime.size()+1);
        for(int i=1; i<c.size(); i++){
            c[i] = c[i-1] + prime[i-1];
        }

        int count = 0;

        //二分探索
        for(int i=0; i<c.size(); i++){
            int left = i, right = c.size();
            while(left < right){
                int mid = (left+right)/2;
                int sum = c[mid]-c[i];
                if(sum > n) right = mid;
                else left = mid+1;
                if(sum == n){
                    count++;
                }
            }
        }
        cout << count << endl;
        cin>>n;
    }
}



Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    void calc()
    {
        int N = cin.nextInt();
        int[] A = cin.ArrayInt(N + 1);
        int[] B = cin.ArrayInt(N);

        //Aそれぞれが10^9までなので
        //これのsumはintに収まらないことに注意！
        long ans = 0;
        for (int i = 0; i < N; i++)
        {
            //まずは左を全力で倒す
            int left = Math.Min(A[i], B[i]);
            ans += left;
            A[i] -= left;
            B[i] -= left;

            //残った戦力で右を全力で倒す
            int right = Math.Min(A[i + 1], B[i]);
            ans += right;
            A[i + 1] -= right;
            B[i] -= right;
        }

        Console.WriteLine(ans);
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 30180
import Data.Char
import Control.Applicative

toggleString :: String -> String
toggleString s = map toggleChar s
    where
        toggleChar :: Char -> Char
        toggleChar c
            | elem c ['a' .. 'z'] = toUpper c
            | elem c ['A' .. 'Z'] = toLower c
            | otherwise           = c

main :: IO ()
main = putStrLn =<< toggleString <$> getLine

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

int main(){
  int n,b[200],bb[200][200],a,c,min;
  cin>>n;
  for(int i=1;i<n;i++){
    cin>>a>>c;
    b[i]=a;
  }
  cin>>a>>c;
  b[n]=a;
  b[n+1]=c;
  for(int i=1;i<=n;i++){
    bb[i][i]=0;
    if(i<n)bb[i+1][i]=b[i]*b[i+1]*b[i+2];
  }
  for(int i=2;i<=n-1;i++){
    for(int j=1;j<=n-i;j++){
      min=1000000000;
      for(int l=j;l<j+i;l++){
	if(min>bb[l][j]+bb[j+i][l+1]+b[j]*b[l+1]*b[j+i+1])
	  min=bb[l][j]+bb[j+i][l+1]+b[j]*b[l+1]*b[j+i+1];
      }
      bb[j+i][j]=min;
    }
  }

  cout<<bb[n][1]<<endl;
  return 0;
}

/*
for(int i=0;i<=n;i++){
for(int j=0;j<=n;j++){
cout<<bb[i][j]<<" ";
}
}

*/

Measured memory_bytes: 3092
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<string,int> P;


int main(){
  bool flag=false;
  int N,ans=0,count=0;
  string s;
  cin>>N>>s;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++,count=0){
      //cout<<j<<endl;
      if(flag==false){
        if(s[i]==s[j]){
          while(j+count<N && i+count<j && s[i+count]==s[j+count]){
            count++;
          }
        }
      }else{
        if(i+ans>=j){
          j=i+ans; continue;
        }else{
          if(j+ans>=N) break;
          if(s.substr(i,ans)!=s.substr(j,ans)) continue;
          while(j+ans+count<N && i+count+ans<j && s[i+ans+count]==s[j+ans+count]){
            count++;
          }
        }
      }

      if(flag==false) ans=max(ans,count);
      else ans+=count;
      //j+=count;
      //cout<<i<<" "<<j<<endl;
      if(ans>0) flag=true;
    }
  }
  cout<<ans<<endl;
}


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

int main(){
  using ll = long long int ;
  ll n ; cin >> n ; 
  vector<ll> c(n-1) ;
  vector<ll> s(n-1) ;
  vector<ll> f(n-1) ;
  vector<ll> a(n-1) ;
  for(int i=0;i<n-1;i++){
    cin >> c.at(i) >> s.at(i) >> f.at(i) ;
  }
  for(int i=0;i<n-1;i++){
    a.at(n-2-i) = 0 ;
    for(int j=0;j<i+1;j++){
      a.at(n-2-i) = max(a.at(n-2-i),s.at(n-2-i+j)) ;
      a.at(n-2-i) += (f.at(n-2-i+j)-a.at(n-2-i)%f.at(n-2-i+j))%f.at(n-2-i+j) ;
      a.at(n-2-i) += c.at(n-2-i+j) ;
    }
  }
  for(auto i:a){
    cout << i << endl ;
  }
  cout << 0 << endl ;
}

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

using namespace std;

#define forn(i,n) for(int i = 0;i<int(n);i++)



int main(){
    string a;
    cin>>a;
    if( a[2] == a[3] && a[4] == a[5] )
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long int lli;
const long long int MaxN=200005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	double arr[MaxN];
	void solve(){
		lli N,K,i,j;
		double p,q;
		double s=0,res=0;
		cin>>N>>K;
		for(i=0;i<N;i++){
			cin>>p;
			arr[i]=(p+1)/2;
		}
		for(i=0;i<K;i++){
			s+=arr[i];
		}
		res=s;
		for(i=K;i<N;i++){
			s+=arr[i];	
			s-=arr[i-K];	
			res=max(res,s);
		}
		printf("%.7f",res);
	}
int main(){
	cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}

Measured memory_bytes: 1792
h,w=map(int,input().split())
if h==1 or w==1:
    print(1)
    exit()
    
if w%2==0:
    print(w//2*h)
    exit()
if w%2==1:
    if h%2==0:
        print(w*h//2)
    elif h%2==1:
        ans=0
        ans+=w*(int(h/2))
        ans+=w//2+1
        print(ans)

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

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

// union find
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

long long MOD = 10000000000 + 7;
int main(){
  cout << setprecision(10);
  int N,M; cin >> N >> M;
  UnionFind tree(N);
  for(int i = 0; i < M; i++){
    int x,y; cin >> x >> y;
    x--; y--;
    tree.unionSet(x,y);
  }

  int max_size = 0;
  for(int i = 0; i < N; i++){
    max_size = max(max_size, tree.size(i)); 
  }
  cout << max_size << endl;


}


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

int main(){
  long long K;
  cin >> K;
  queue<long long> q1;
  for(int i=1; i<=9; i++){
    q1.push(i);
  }
  long long x;
  for(int i=0; i<K; i++){
    x = q1.front();
    q1.pop();
    if(x%10!=0)q1.push(10*x+(x%10)-1);
    q1.push(10*x+(x%10));
    if(x%10!=9)q1.push(10*x+(x%10)+1);
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
    int a[1000000]={0};
    int s;
    cin >> s;
    int n=s;
    a[n]=1;
    int i=2;
    do{
        if(n%2==0) n/=2;
        else n=3*n+1;
        if(a[n]==1) break;
        a[n]=1;
        i++;

    }while(n!=0);
    cout << i <<endl;
}

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

#define int long long

signed main(){
	string s;
	cin >> s;
	int n = s.size();

	if(n % 2 != 0){
		cout << "No" << endl;
		return 0;
	}

	for(int i = 0;i < n;i+=2){
		if(!(s[i] == 'h' && s[i+1] == 'i')){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = m; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
inline int popcount(const int x) { return __builtin_popcount(x);}
template<class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b;}
template<class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b;}
template<class T> void drop(const T &x) { std::cout<<x<<endl; exit(0);}
void debug_out() { std::cout << "\n";}
template<class T, class... Args> void debug_out(const T &x, const Args &... args) { std::cout<<x<< " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

struct InitIO{
  InitIO() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
  }
}init_io;

int main() {
  int x;
  cin >> x;
  if (x >= 30) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <set>
using namespace std;
using ll = long long;
using ld = long double;

const ll MOD = 1000000000 + 7;
const ll INF = 1e+9;
const ld PI = acos((long double)(-1));

#define no "no"
#define No "No"
#define NO "NO"
#define yes "yes"
#define Yes "Yes"
#define YES "YES"
#define next '\n'
#define sp " "
#define print(x) cout << (x) << endl;
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for(auto& (elem) : (_list))
#define view(_list) foreach(e, _list){ cout << e << sp; } cout << next
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e)
#define EPS 0.00000001

// 最大公約数
ll gcd(ll a, ll b){
    if(a < b) std::swap(a, b);

    ll result = b;
    while(a % result != 0){
        result = a % b;
        a = b;
        b = result;
    }

    return result;
}

vector<pair<ll, int>> factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i){
            continue;
        }

        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }

    if(n != 1){
        res.emplace_back(n, 1);
    }

    return res;
}

int main() {
    FAST;

    ll a, b;
    cin >> a >> b;

    ll x = gcd(a, b);

    auto f = factorize(x);

    ll ans = size(f) + 1;
    print(ans);
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  
  if (m != 0) {
  vector<int> ac(n);
  vector<int> isac(n);
  for (int i = 0; i < n; i++) {
    ac.at(i) = 0;
    isac.at(i) = 0;
    }
  
  int numac, pe;
  numac = pe = 0;
  
  for (int i = 0; i < m; i++) {
    int p; string s;
    cin >> p >> s;
    p--;
    
    if (isac.at(p) == 0) {
      ac.at(p)++;
      if (s == "AC") {
        isac.at(p) = 1;
        numac++;
      }
    }
  }
  
  for (int i = 0; i < n; i++)
    pe += (ac.at(i) - 1) * isac.at(i);
  cout << numac << " " << pe << endl;
  }
  
  else
    cout << "0 0" << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;
#define INF 1LL<<60
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
ld lginf = -1;
ll lcm(ll a, ll b) {
    if(lginf < 0) lginf = log10l(INF);

    if (a == INF) return INF;
    if (b == INF) return INF;
    a /= gcd(a, b);

    ld aa = log10l(a);
    ld bb = log10l(b);

    if (lginf <= aa + bb) return INF;

    return a * b;
}
/*---------------------------------------------------------------------------------------------------
????????????????????????????????? ??§?????§  
??????????????? ??§?????§ ???????´<_??? ?????? Welcome to My Coding Space!
???????????? ??? ?´_???`??????/??? ???i     
?????????????????????????????? ???  |???|     
????????? /?????? /??£??£??£??£/??????|  
??? ???_(__??????/???    ???/ .| .|????????????  
??? ????????????/????????????/??????u??????  
---------------------------------------------------------------------------------------------------*/




typedef long double ld;
#define INF 1LL<<60
int N; ll M; ll A[20]; ld P[20];
ll f[1 << 20];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) {
        int x; cin >> x;
        P[i] = x / 100.0;
    }

    // f[mask] := ??¨?????????mask??¨?????§????????????????????°
    rep(mask, 1, 1 << N) {
        ll lc = 1;
        rep(i, 0, N) if(mask & (1 << i)) lc = lcm(lc, A[i]);
        f[mask] = M / lc;
    }

    // ????????????????????????????????\??????????????????????????????
    // f[mask] := ??¨?????????mask?????????????????§????????????????????°
    rep(i, 0, N) rep(j, 0, 1 << N) if (j & (1 << i)) f[j] -= f[j ^ (1 << i)];

    ld ans = 0;
    rep(mask, 0, 1 << N) {
        ld p = 1;
        rep(i, 0, N) {
            if (mask & (1 << i)) p *= P[i];
            else p *= 1 - P[i];
        }

        ans += (ld)abs(f[mask]) * p;
    }
    printf("%.10llf\n", ans);
}

Measured memory_bytes: 11548
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    string s;
    cin >> s;
    if (s[1] == 'B') s[1] = 'R';
    else s[1] = 'B';

    print(s);

    return 0;
}



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

string cmp[4] = {"dream","dreamer","erase","eraser"};
int main(){
	string s;
	cin >> s;
	
	for(int i = 0;i < s.size();){
		if(s[i]=='d'){
			for(int j = 0;j < cmp[0].size();j++){
				if(s[i]!=cmp[0][j]){
					cout << "NO";
					return 0;
				}
				if(i<s.size()) i++;
			}
			if(s[i]=='e'&&s[i+1]=='r'&&s[i+2]!='a') i+=2;
		}
		else if(s[i]=='e'){
			for(int j = 0;j < cmp[2].size();j++){
				if(s[i]!=cmp[2][j]){
					cout << "NO";
					return 0;
				}
				if(i<s.size()) i++;
			}
			if(s[i]=='r') i++;
		}
		else{
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
}

Measured memory_bytes: 512
def someone_ans():
    n=int(input())
    a=input()
    b=input()
    c=[]
    i=0
    while i<n:
        if i == n-1:
            c.append(1)
            i+=1
        elif a[i] == a[i+1]:
            c.append(0)
            i +=2
        else:
            c.append(1)
            i+=1

    if c[0] ==0: count=6
    else: count=3
    for i in range(len(c)-1):
        if c[i]==1:count*=2
        elif c[i]==0 and c[i+1]==0: count*=3
    return count % 1000000007

# print(m())
print(someone_ans())

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

int main(void){
    int k, i;
    char s[100];

    scanf("%d%s", &k, s);
    if(strlen(s) <= k){
        printf("%s\n", s);
    }else{
        for(i=0; i<k; i++){
            printf("%c", s[i]);
        }
        printf("...\n");
    }
    return 0;
}

Measured memory_bytes: 1660
#include<cstdio>
#include<cmath>
#include<queue>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=2e5,MAXM=2e5;
int head[MAXN+5],nxt[MAXM+5],Cnt;
bool vis[MAXN+5],v[MAXN+5];
int ind[MAXN+5],id[MAXN+5];
int n,m,root;
struct Edge
{
	int u,v;
	Edge(int _u=0,int _v=0){u=_u,v=_v;}
}E[MAXM+5];
struct node
{
	int id,num;
}f[MAXN+5];
bool cmp(node a,node b)
{
	return a.id>b.id;
}
void Addedge(int u,int v)
{
    E[++Cnt]=Edge(u,v);
    nxt[Cnt]=head[u];
    head[u]=Cnt;
}
void bfs(int root)
{
	int tot=0;
	queue<int> que;
	que.push(root);
	vis[root]=1;
	while(!que.empty())
	{
		int u=que.front();que.pop();
		f[++tot].id=tot,f[tot].num=u;
		id[u]=tot;
		for(int i=head[u];i;i=nxt[i])
			if(!vis[E[i].v])
			{
				vis[E[i].v]=1;
				que.push(E[i].v);
			}
	}
	//for(int i=1;i<=n;i++)
	//	printf("点%d:%d\n",i,id[i]);
	//printf("----------\n");
}
void Solve()
{
	sort(f+1,f+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		int u=f[i].num;
		//printf("u:%d\n",u);
		for(int j=head[u];j;j=nxt[j])
			if(id[E[j].v]<f[i].id)
			{
				if(ind[u]%2)
				{
					ind[u]++;
					printf("%d %d\n",u,E[j].v);					
				}
				else
				{
					ind[E[j].v]++;
					printf("%d %d\n",E[j].v,u);
				}	
			}
	}
}
int main()
{
	//freopen("degree.in","r",stdin);
	//freopen("degree.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		root=u;
		Addedge(u,v);
		Addedge(v,u); 
	}
	//printf("---------\n");
	if(m%2)
	{
		printf("-1\n");
		return 0;
	}
	bfs(root);
	Solve();
	return 0;
}
/*
5 6
1 2
1 3
2 3
2 5
3 4
4 5

4 6
1 2
2 3
3 4
1 4
1 3
2 4
*/


Measured memory_bytes: 6912
#include <cstdio>
#include <stdlib.h>
using namespace std;
int main() {
	int N;
	scanf("%d", &N);
    if (N/100 == 7 || N%100/10 == 7 || N%10 == 7) {
        printf("%s\n", "Yes");
    } else {
        printf("%s\n", "No");
    }
}

Measured memory_bytes: 1648
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
var arr = (0...100000).map{_ in 0}
for _ in 0..<input[0] {
  let input = readLine()!.characters.split(" ").map{Int(String($0))!}
  arr[input[0]] += input[1]
}
var tmp = input[1]
for i in 1...100000 {
  tmp -= arr[i]
  if tmp <= 0 {
    print(i)
    break
  }
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

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

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

int N;
ll A[int(1e5+5)], B[int(1e5+5)];

int main(){
  cin >> N;
  for (int i = 0; i <= N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];

  ll ans = 0;
  for (int i = 0; i < N; i++){
    if (B[i] < A[i]){
      ans += B[i]; continue;
    }
    ans += A[i]; B[i] -= A[i];

    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: 5160
import java.util.*;
import java.io.*;

class Main {
	public static void main(String... args) {
		int N = IN.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = IN.nextInt() - (i + 1);
		}

		Arrays.sort(A);
		int m = A[N / 2];
		long ans = 0;
		for (int a: A) {
			ans += Math.abs(a - m);
		}
		puts(ans);
		flush();
	}
	static final Scanner IN = new Scanner(System.in);
	static final PrintWriter OUT = new PrintWriter(System.out);
	static <T> void puts(T arg) { OUT.println(arg); }
	static void flush() { OUT.flush(); }
}


Measured memory_bytes: 64076
#include <iostream>
#include <algorithm>
using namespace std;
int S[100005];
int main() {
  ios::sync_with_stdio(false);
  int N, M, L, R;
  cin >> N >> M;
  for (int i=0; i<M; i++) {
    cin >> L >> R;
    S[L]++;
    S[R+1]--;
  }
  int ret = 0;
  for (int i=1; i<=N; i++) {
    S[i] += S[i-1];
    if (S[i] == M) ret++;
  }
  cout << ret << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

//選ばれたらtrue
//一個点を選んで端っこまで見ていく
//最初の点から二方向

int N, M;
vector<int> G[100001];
bool isUsed[100001];
vector<int> v;
vector<int> ans1, ans2;

void dfs(int x){
    isUsed[x] = true;
    FOR(i, 0, G[x].size()){
        if(isUsed[G[x][i]]) continue;
        dfs(G[x][i]);
        break;
    }
    v.push_back(x);
    return;
}

int main(){
    cin >> N >> M;
    int a, b;
    FOR(i, 0, M){
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    FOR(i, 0, N) isUsed[i] = false;
    dfs(a);
    int len = v.size();
    ans1 = v;
    if(G[a].size()==1){
        cout << len << endl;
        FOR(i, 0, ans1.size()){
            if(i) cout << " ";
            cout << ans1[i];
        }
        cout << endl;
        return 0;
    }
    v.clear();v.shrink_to_fit();
    dfs(a);
    if(v.size()<=1){
        cout << len << endl;
        FOR(i, 0, ans1.size()){
            if(i) cout << " ";
            cout << ans1[i];
        }
        cout << endl;
        return 0;
    }
    reverse(v.begin(), v.end());
    len += v.size() -1;
    ans2 = v;
    cout << len << endl;
    FOR(i, 0, ans1.size()){
        if(i) cout << " ";
        cout << ans1[i];
    }
    cout << " ";
    FOR(i, 1, ans2.size()){
        if(i>1) cout << " ";
        cout << ans2[i];
    }
    cout << endl;
}


Measured memory_bytes: 9644
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');

  (function(S) {
    // ????????????????????????
    var h = parseInt(S / 3600);
    var m = parseInt((S / 60) % 60);
    var s = S % 60;
    console.log(h+':'+m+':'+s);

  })(parseInt(inputs[0], 10)); // ??°?????????

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15524
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++) // for loop
#define RREP(x,l,u) for(ll x = l;x>=u;x--) // reverse for loop

/**
 *  debugging stuff
 */
string to_string(string s) {return s;}
string to_string(char c) {return string(1,c);}
template <typename A, typename B> string to_string(pair<A,B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(vector<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }
template <typename A> string to_string(set<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }

/**
 *  more debugging stuff
 */
void debug_out() {cerr << endl;}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifndef ONLINE_JUDGE
#define debug(...) do { cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__); } while (false)
#else
#define debug(...) do { } while (false)
#endif

typedef long long ll;
typedef double db;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL; 
typedef pair<ll,ll> PLL;
typedef vector<string> VS;

template <typename A, typename B> void in(A & a, B & b) { in(a); in(b); }
template <typename A, typename B, typename C> void in(A & a, B & b, C & c) { in(a); in(b); in(c); }

const ll inf = (ll)1e18 + 5;

ll V;

VLL bfs(ll source, VVLL & adj_list) {

    VLL distance((V+2), inf);
    queue<ll> Q;

    Q.push(source);
    distance[source] = 0;

    while (Q.size()) {
        // pop front of queue
        ll at = Q.front();
        Q.pop();

        for (ll to : adj_list[at]) {

            if (distance[to] == inf) {
                Q.push(to);
                distance[to] = distance[at] + 1;
            }

        }
    }

    return distance;
}

namespace SOLVE {	
	void main() {
    

        cin >> V;
        ll vertex;

        VVLL adj_list(V+1);

        // create adjacency list
        REP (i,1,V+1) {
            cin >> vertex;

            ll adj_vertices;

            cin >> adj_vertices;

            REP (j,0,adj_vertices) {

                ll add_vertex;
                cin >> add_vertex;
                adj_list[vertex].push_back(add_vertex);
            }
        }

        VLL distance = bfs(1, adj_list);

        REP(i,1,V+1) {
            if (distance[i] == inf) {
                distance[i] = -1;
            }
            cout << i << " " << distance[i] << endl;
        }
	}
}

signed main() {
	ll t;
	t = 1;
    // cin >> t;
	REP(i,0,t) {
		SOLVE::main();
	}

	return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }


// youtube editorial
// ゾロ目を列挙

void solve() {
    int s;
    cin >> s;
    
    cout << (s + 110) / 111 * 111 << endl;
}



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}




Measured memory_bytes: 256
Public Class Program
  Shared Sub Main()
    Dim a As Integer = Cin.Int()
    Dim b As Integer = Cin.Int()
    Dim ans As Integer = 0
    Select Case a
      Case 1
        If b = 2 Then ans = 3
        If b = 3 Then ans = 2
      Case 2
        If b = 3 Then ans = 1
        If b = 1 Then ans = 3
      Case 3
        If b = 1 Then ans = 2
        If b = 2 Then ans = 1
    End Select
    Console.WriteLine(ans.ToString())
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    for(int i=0;i<N+1;++i){
        if(N == i*108/100){
            cout<<i<<endl;
            return 0;
        }
    
    }
    cout<<":("<<endl;
    }


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 100010;
const double eps = 1e-6;

int n;
int s[5];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        string t;
        cin >> t;
        if(t[0] == 'A') s[0]++;
        else if(t[0] == 'C') s[1]++;
        else if(t[0] == 'H') s[2]++;
        else if(t[0] == 'M') s[3]++;
        else if(t[0] == 'R') s[4]++;
    }

    LL res = 0;
    for(int i = 0; i < 5; i++)
        for(int j = i + 1; j < 5; j++)
            for(int k = j + 1; k < 5; k++)
                res += 1LL * s[i] * s[j] * s[k];

    cout << res << endl;
    return 0;
}


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

map<string,string> m;

void make() {
  const static string d = "TLURD";
  const static string p = "w kstnhmyr";
  const static string c = "aiueo";
  for(int i = 0; i <= 9; ++i) {
    if(i == 0) {
      m["0T"]  = "wa";
      m["0D"]  = "wo";
      m["0U"]  = "nn";
    } else {
      for(int j = 0; j < 5; ++j) {
        string key = string(1, '0'+i) + d[j];
        string s = "";
        if(i != 1) s += p[i];
        s += c[j];
        m[key] = s;
      }
    }
  }
}

int main() {
  make();
  string str;
  while(cin >> str) {
    for(int i = 0; i < str.size(); i += 2) {
      cout << m[str.substr(i,2)];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    S=readline().strip()
    now=len(S)
    while now>0:
        if S[now-6:now]=="eraser":
            now-=6
        elif S[now-7:now]=="dreamer":
            now-=7
        elif S[now-5:now]=="erase":
            now-=5
        elif S[now-5:now]=="dream":
            now-=5
        else:
            print("NO")
            break
    else:
        print("YES")
        
if __name__=="__main__":
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n;
  string s,t;
  cin>>n>>s>>t;
  int ans=2*n;
  for(int i=1;i<=n;i++){
    if(s.substr(s.size()-i,i)==t.substr(0,i)) ans=2*n-i;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
	if (a > 0) return a % MOD;
	if (a % MOD == 0) return 0;
	ll x = -a / MOD + 1;
	a += x * MOD;
	return a % MOD;
}

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(double x, ll t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
// ll dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

int main() {
	IOS();
	ll L, n;
	cin >> L >> n;
	vector<ll> x(n + 1), y(n + 1); // 正負の向き
	vector<ll> sx(n + 1), sy(n + 2);
	sx[0] = sy[n + 1] = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> x[i];
		y[i] = L - x[i];
	}
	for (int i = 1; i <= n; ++i) { sx[i] = sx[i - 1] + 2 * x[i]; }
	for (int i = n; i >= 1; --i) { sy[i] = sy[i + 1] + 2 * y[i]; }

	// for (int i = 1; i <= n; ++i) { cout << sx[i] << " " << sy[i] << endl; }

	ll ans = 0;

	for (int i = 1; i <= n; ++i) { //正の向きにi地点まで行って往復
		ll tmp = 2 * x[i];
		ll pos = (n - i) / 2, neg = n - i - pos;
		tmp += sx[i + pos] - sx[i];
		tmp += sy[n - neg + 1];
		if ((n - i) % 2 == 0)
			tmp -= x[pos + i];
		else
			tmp -= y[n - neg + 1];
		ans = max(tmp, ans);
	}
	for (int i = n; i >= 1; --i) {
		ll tmp = 2 * y[i];
		ll neg = (i - 1) / 2, pos = i - neg - 1;
		tmp += sx[pos];
		tmp += sy[i - neg] - sy[i];
		if (i % 2 == 1)
			tmp -= y[i - neg];
		else
			tmp -= x[pos];
		ans = max(tmp, ans);
	}
	dump(ans);
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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;}

int main(){
    int n;cin>>n;
    vi a(n);
    map<int,int>c;
    rep(i,n){
        cin>>a[i];
        c[a[i]]++;
    }
    sort(all(a));
    if(c[1]==1){cout<<1<<endl;return 0;}
    else if(c[1]>1){cout<<0<<endl;return 0;}
    else{
    int ans=0;
    rep(i,n){
        bool d=true;
        int m=a[i];
        if(c[m]>1)d=false;
        else{
        for(int j=2;j*j<=m;++j){
            if(m%j==0){
                if(j!=m&&c[j]>0){d=false;break;}
                if((m/j)!=m&&c[m/j]>0){d=false;break;}
            }
        }
        }
        if(d)ans++;
    }
    cout<<ans<<endl;}
}


Measured memory_bytes: 32732
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, n) for (int i = 1; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 3000000000000000000;

int main() {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    rep(i, SZ(S)) {
        if (S[i] != T[i]) ++ans;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3920
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  int H, W; cin >> H >> W;
  char s[50][50];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> s[i][j];
    }
  }
  queue<pair<pair<int, int>,int>> Q;
  Q.push(make_pair(make_pair(0, 0), 0));
  bool visit[50][50];
  for (int i = 0; i < 50; i++) {
    for (int j = 0; j < 50; j++) {
      visit[i][j] = false;
    }
  }
  while (Q.front().first != make_pair(H-1, W-1) && !Q.empty()) {
    int y = Q.front().first.first; int x = Q.front().first.second;
    int depth = Q.front().second;
    /*cout << Q.front().first.first << " "
      << Q.front().first.second << " "
        << Q.front().second << endl;*/
    if (y > 0 && s[y-1][x] != '#' && !visit[y-1][x]) {
      Q.push(make_pair(make_pair(y-1, x), depth+1));
      visit[y-1][x] = true;
    }

    if (y < H-1 && s[y+1][x] != '#' && !visit[y+1][x]) {
      Q.push(make_pair(make_pair(y+1, x), depth+1));
      visit[y+1][x] = true;
    }
    if (x > 0 && s[y][x-1] != '#' && !visit[y][x-1]) {
      Q.push(make_pair(make_pair(y, x-1), depth+1));
      visit[y][x-1] = true;
    }
    if (x < W-1 && s[y][x+1] != '#' && !visit[y][x+1]) {
      Q.push(make_pair(make_pair(y, x+1), depth+1));
      visit[y][x+1] = true;
    }
    Q.pop();
  }
  if (Q.empty())
    cout << -1 << endl;
  else {
    int dotCount = 0;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        dotCount += (s[i][j] == '.');
      }
    }
    cout << dotCount - Q.front().second - 1 << endl;
  }
}


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

using namespace std;

int main()
{
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        constexpr char ANONYMOUS = '@';
        unordered_map<char, int> m;
        m[ANONYMOUS] = 0;
        bool isTie{true};
        vector<char> v;
        for(int i = 0; i < n; ++i) {
            char c;
            cin >> c;
            v.push_back(c);
        }
        for (int i = 0; i < n; ++i) {
            auto remain = n - (i + 1);
            m[v[i]] += 1;
            int count{0};
            char win{'\0'};
            for (auto&& j : m) {
                auto sum_ = j.second + remain;
                bool user_ok{true};
                for (auto&& k : m) {
                    if (k.first == j.first) {
                        continue;
                    }
                    if (k.second > sum_) {
                        user_ok = false;
                    }
                }
                if (user_ok) {
                    ++count;
                    win = j.first;
                }
            }
            if (count == 1) {
                cout << win << ' ' << (i + 1) << endl;
                isTie = false;
                break;
            }
        }
        if(isTie) {
            cout << "TIE" << endl;
        }
    }
}

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

typedef long long ll;
#define mod 1000000007

// debug fn.
template<typename T>
void deb(initializer_list<T> l)
{
    for (auto &e : l)
        cout << e << ' ';
    cout << endl;
}

void solve(){
    int n;
    cin>>n;
    vector<ll> dp(n+1, 1);
    for(int i = 2; i <= n; i++){
        ll j = i;
        while (j <= n){
            dp[j] += 1;
            j += i;
        }
        dp[i] *= i;
    }
    ll ans = 0;
//    for(int j = 1; j <= n; j++){
//        cout<<dp[j]<<" ";
//    }
//    cout<<endl;
    for(int j = 1; j <= n; j++){
        ans += dp[j];
    }
    cout<<ans;
}

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

    int t = 1;
    // cin >> t;
    while (t--)
        solve();

    return 0;
}

Measured memory_bytes: 81344
n = int(input())
s1 = str(input())
s2 = str(input())

L = []

for i in range(n):
    if s1[i] == s2[i]:
        L.append(0)
    else:
        if i == n-1:
            continue
        if s1[i] == s1[i+1]:
            L.append(1)

m = len(L)
ans = 1
mod = 10**9+7
for i in range(m):
    if i == 0:
        if L[i] == 0:
            ans *= 3
        else:
            ans *= 6
        ans %= mod
    else:
        if L[i-1] == 0 and L[i]== 0:
            ans *= 2
        elif L[i-1] == 0 and L[i] == 1:
            ans *= 2
        elif L[i-1] == 1 and L[i] == 0:
            ans *= 1
        else:
            ans *= 3
        ans %= mod
ans %= mod
print(ans)

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

const long long INF = -10000000000;

int main() {
  long long a, b, n;
  cin >> a >> b >> n;
  
  if (b == 1)
    cout << 0 << endl;
  else {
    long long res = INF;
    for (long long i = 0; i <= n / b; i++) {
      if (((i + 1) * b - 1) <= n) {
        long long x = (a * ((i + 1) * b - 1)) / b - a * i;
        res = max(res, x);
      }
      else if (i == n / b) {
        long long y = (a * n) / b - a * (n / b);
        res = max(res, y);
      }
    }
  
    cout << res << endl;
  }
  
  return 0;
}
    

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

int main()
{
    vector<int> amount, price;
    vector<int>::iterator pt;
    vector<int>::iterator at;
    char ch;
    int abuff, pbuff;
    int sum = 0;
    double avg;
    int c=0;
    while(cin >> pbuff >> ch >> abuff)
    {
        amount.push_back(abuff);
        price.push_back(pbuff);
    }
    for(pt = price.begin(), at = amount.begin(); pt != price.end(); pt++,at++ )
    {
        sum += *pt * *at;
        avg += *at;
    }
    avg = avg /amount.size();
    avg = floor(avg + 0.5f);
    cout << sum << endl;
    cout << (int) avg << endl;
    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll,ll> pll;

vector< pll> solve(vector<ll> v)
{
        vector<pll> t; t.clear();
        if(v.size() == 2) return t;
        vector< ll > X; X.clear();
        for(ll i=1;i<v.size()-1;i++) X.pb(v[i]);
        vector< pll > ret = solve(X);
        for(ll i=1;i<v.size()-1;i++){
                ret.pb(make_pair(v[0],v[i]));
                ret.pb(make_pair(v.back(), v[i]));
        }
        return ret;
}
ll n;
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL); cout.tie(NULL);
        cin >> n;
        vector<ll> v;
        for(ll i=1;i<n;i++) v.pb(i);
        if(n%2 == 0) v.pb(n);
        vector< pll > X = solve(v);
        if(n%2 == 1) {
                for(ll i=1;i<n;i++) X.pb(make_pair(i,n));
        }
        cout << X.size() << "\n";
        for(auto i : X) cout << i.first << " " << i.second << "\n";
        return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define EM 1000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
LL mod = 1e9+7;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<vector<int>> G(100010);
vector<int> used(100010, 0);

void dfs(int u){
    used[u] = 1;
    for(auto g : G[u]){
        if(used[g] == 0)    dfs(g);
    }
}
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> x(M), y(M), z(M);
    for(int i = 0;i < M;i++){
        cin >> x[i] >> y[i] >> z[i];
        G[x[i]-1].push_back((y[i]-1));
        G[y[i]-1].push_back((x[i]-1));
    }
    int ans = 0;
    for(int i = 0;i < N;i++){
        if(used[i] == 0){
            dfs(i);
            ans++;
        }
    }

    cout << ans << endl;
}

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

int main()
{
    int n,m;

    cin >> n >> m;
    vector<int> swptn(n);
    rep(i,m) {
        int k;
        cin >> k;
        rep(j, k) {
            int x;
            cin >> x;
            swptn[x-1] |= 1 << i;
        }
    }

    int p = 0;
    rep(i, m) {
        int x;
        cin >> x;
        if (x)
            p |= 1 << i;
    }

    int ans = 0;
    rep(bit,(1 << n)) {
        int t = 0;
        rep(i, n) {
            if (bit >> i & 1) {
                t ^= swptn[i];
            }
        }
        if (t == p) {
            ++ans;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3544
// 素数

#include<stdio.h>
#include<math.h>

int pri(int);
int print(int);

int main()
{
 
  int a,b,c,i,j;
  int A[10000];
 
  scanf("%d",&a);
 
  for(i=0; i < a; i++){
    scanf("%d",&A[i]);
  }
  
  c = a;
 
  for (i = 0; i < a; i++){
    if (A[i] == 2) {
    }
    
    else if(A[i] % 2 == 0){
      c--; 
    }
    
    else{
      b = sqrt(A[i]);
      for(j=3; j<=b; j=j+2){
        if(A[i] % j == 0){
          c--;  
          break;  
        }
      }  
    }
  }
 
  printf("%d\n",c);
 
  return 0;
}



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

int main(){
	int n;
	cin>>n;
	
	vector<int>v;
	string s;
	for(int i=0;i<n;i++){
		char a;
		cin>>a;
		s.push_back(a);
		}
	s.push_back(s[n-1]);
	
	char now=s[0];
	int rs=1;
	for(int i=1;i<s.size();i++){
		if(now==s[i]){
			v.push_back(rs);
			rs=1;
			now=s[i];
			}
		else{
			rs++;
			now=s[i];
			}	
		}
	for(int i=0;i<=3;i++)v.push_back(0);
	
	int ans=0;
	ans=v[0]+v[1]+v[2];
	for(int i=0;i<v.size()-2;i++)ans=max(ans,v[i]+v[i+1]+v[i+2]);
	cout<<ans<<endl;
	return 0;		
	}

Measured memory_bytes: 3372
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
count = 0
for i in itertools.permutations([i + 1 for i in range(n)], n):
    if i == p:
        a = count
    if i == q:
        b = count
    count += 1
print(abs(a - b))

Measured memory_bytes: 9096