akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        do {
            int c = a % b;
            a = b;
            b = c;
        } while (b != 0);
        sc.close();
        System.out.println(a);
    }
}


Measured memory_bytes: 26216
#include <bits/stdc++.h>
using namespace std;
int main(){
	
	vector<char> vec(4);
  for(int i=0; i<4; i++){
    cin>>vec.at(i);
  }
  if(vec[0]==vec[1] || vec[1]==vec[2] || vec[2]==vec[3]){
    cout<<"Bad"<<endl;
  }
  else{
    cout<<"Good"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
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;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

struct UnionFind {
    vector< int > data;

    UnionFind(int sz) {
        data.assign(sz, -1);
    }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return false;
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int find(int k) {
        if(data[k] < 0) return k;
        return data[k] = find(data[k]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int k) {
        return -data[find(k)];
    }
};

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int>> out(n);
    UnionFind fri(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        out[a].push_back(b);
        out[b].push_back(a);
        fri.unite(a, b);
    }
    rep(i, k) {
        int c, d;
        cin >> c >> d;
        c--, d--;
        if(fri.same(c, d)) out[c].push_back(d), out[d].push_back(c);
    }
    rep(i, n) cout << fri.size(i) - out[i].size() - 1 << endl;
}

Measured memory_bytes: 7936
import math
K = int(input())
if K==2: print(K)
else:
        if K%2 ==0:
                K+=1
        while True:
                flg =0
                N = int(math.sqrt(K))
        
                for i in range(2,N):
                        if K%i == 0:
                        
                                flg = 1
                                break
                if flg == 0:
                        print(K)
                        break
                K+=2

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

int main(){
	int w,n,a,b;
	char c;
	cin >> w >> n;
	vector<int> v;
	for(int i = 0; i < w+1; i++){
		v.push_back(i);
	} 
	
	for(int j = 0; j < n; j++){
		cin >> a >> c >> b;
		swap(v[a],v[b]);
	}
	
	for(int k = 1; k < w+1; k++){
		cout << v[k] << "\n";
	}
}

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

class Cube{
public:
    int s[6];
    Cube(){}
    void roll_z(){roll(1,2,4,3);}//横回転、時計回り
    void roll_y(){roll(0,2,5,3);}//W
    void roll_x(){roll(0,1,5,4);}//N
    void roll(int i,int j,int k,int l){
        int t=s[i];s[i]=s[j];s[j]=s[k];s[k]=s[l];s[l]=t;
    }

};
int getRight(Cube cube,int f1,int f2){
    for(int i=0;i<6;i++){
        for(int j=0;j<4;j++){
            if(cube.s[0]==f1 && cube.s[1]==f2){
                return cube.s[2];
            }
            cube.roll_z();
        }
        if(i%2==0) cube.roll_y();
        else cube.roll_x();
      /*  if(i==1) cube.roll_x();
        if(i==2) cube.roll_y();
        if(i==3) {
            cube.roll_y();cube.roll_y();cube.roll_y();
        }
        if(i==4){
            cube.roll_x();cube.roll_x();cube.roll_x();
        }
        if(i==5){
            cube.roll_y();cube.roll_y();
        }*/
    }
    return -1;
}

int main() {
    Cube dice;

    int f1,f2;
    for(int i=0;i<6;i++){
        cin>>dice.s[i];
    }
    int q;cin>>q;
    for(int i=0;i<q;i++){
        cin>>f1>>f2;
        cout<<getRight(dice,f1,f2)<<endl;
    }
    return 0;

}


Measured memory_bytes: 3096
#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 10000007
#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*b/gcd(a,b);}

int main(){
    int n;
    cin>>n;
    vi a(n);rep(i,n)cin>>a[i];
    int ans=1,sum=1;
    rep(i,n){
        int c=0;
        if((a[i]-1)%2==1)c++;
        if(a[i]%2==1)c++;
        if((a[i]+1)%2==1)c++;
        sum*=c;ans*=3;
    }
    cout<<ans-sum;
}

Measured memory_bytes: 256
import bisect
import sys

input = sys.stdin.readline


def read_i():
    return list(map(int, input().split()))


n = int(input())
ls = sorted(read_i())
ls2 = ls[::-1]
res = 0
for i, x in enumerate(ls2):
    for j, y in enumerate(ls2[i + 1:], i + 1):
        if 2 * y < x:
            break
        res += n - j - 1 - bisect.bisect(ls[:-(j + 1)], x - y)
print(res)

Measured memory_bytes: 59868
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
void solve(){
    int n,m;
    cin>>n>>m;
    vector<int>h(n+1);
    int a,b;
    for(int i=1;i<=n;i++) cin>>h[i];
    vector<int>good(n+1,1);
    for(int i=0;i<m;i++){
        cin>>a>>b;
        if(h[a]<=h[b]) good[a]=-1;
        if(h[b]<=h[a]) good[b]=-1;
    }
    int count=0;
    for(auto x:good){
        if(x==1) count++;
    }
    cout<<count-1;
}
int  main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
    //cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  if(n%2 == 0) {
    int start = 1, end = n;
    bool flg = false;
    for(int i = 0; i < m; ++i) {
      cout << start << " " << end << endl;
      start++;
      end--;
      if(!flg && end-start <= n/2) {
        flg = true;
        end--;
      }
    }
  } else {
    int start = 1, end = n;
    for(int i = 0; i < m; ++i) {
      cout << start << " " << end << endl;
      start++;
      end--;
    }
  }
  return 0;
}

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

#define mp make_pair
#define pb push_back
#define fst first
#define snd second
#define int long long
#define fast_io() ios::sync_with_stdio(false)
#define FOR(i, l, r) for(int i = (l); i < (r); i++)
#define H(x) cout << #x << " " << x << endl;

typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef set<int> si;
typedef double ld;
typedef pair<ld, ld> dd;

const ll INF = 1000000000000000000LL;
const int NMAX = 1e6+4;
const int mod = 1e9+7;
const ld eps = 1e-10;
const ld PI = acos(-1);

int H, W, N;
int sr, sc;
string S, T;

signed main (){
    cin >> H >> W >> N;
    cin >> sr >> sc;
    cin >> S >> T;
    sr --; sc--;
    int x = sc, y = sr;
    // Try to move up
    FOR(i, 0, N) {
        if(S[i] == 'U') y -= 1;
        if(y < 0) {
            cout << "NO" << endl;
            return 0;
        }
        if(T[i] == 'D' && y + 1 < H) y += 1;
    }

    //Try to move left
    FOR(i, 0, N) {
        if(S[i] == 'L') x -= 1;
        if(x < 0) {
            cout << "NO" << endl;
            return 0;
        }
        if(T[i] == 'R' && x+1 < W) x += 1;
    }

    x = sc; y = sr;
    
    // Try to move down
    FOR(i, 0, N) {
        if(S[i] == 'D') y += 1;
        if(y >= H) {
            cout << "NO" << endl;
            return 0;
        }
        if(T[i] == 'U' && y - 1 >= 0) y -= 1;
    }

    // Try to move right
    FOR(i, 0, N) {
        if(S[i] == 'R') x += 1;
        if(x >= W) {
            cout << "NO" << endl;
            return 0;
        }
        if(T[i] == 'L' && x - 1 >= 0) x -= 1;
    }

    cout << "YES" << endl;

}

Measured memory_bytes: 776
object Main extends App {

  import scala.io.StdIn._

  val Array(n, m, k) = readLine.trim.split(' ').map(_.toInt)
  val hatake = readLine.trim.split(' ').map(_.toInt).zip(readLine.trim.split(' ').map(_.toInt)).toList
  println(
    takeRand(hatake, k).map{ l ⇒
      var potato = m
      var sum = 0
      for ((a, b) <- l.sortBy(_._1).reverse) {
        val ue = math.max(0, math.min(potato, b))
        potato -= ue
        sum += ue * a
      }
      sum + potato
    }.max
  )
  def takeRand(target: List[(Int, Int)], count: Int): List[List[(Int, Int)]] = {
    val memo = Array.tabulate(target.length + 1){_ ⇒ Array.tabulate(count){_ ⇒ None: Option[List[List[(Int, Int)]]]}}
    def rand(target: List[(Int, Int)], count: Int): List[List[(Int, Int)]] = {
      if (count == 0) Nil :: Nil
      else {
        memo(target.length)(count - 1) match {
          case None ⇒
            val res = target match {
              case Nil ⇒ Nil
              case h :: t ⇒ rand (t, count - 1).map (h :: _) ++ rand (t, count)
            }
            memo(target.length)(count - 1) = Some(res)
            res
          case Some(r) ⇒ r
        }
      }
    }
    rand(target, count)
  }
}


Measured memory_bytes: 44472
n,m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

ans = "No"
flag = False

for i in range(n-m+1):
    for j in range(n-m+1):
        if b[0][0] == a[i][j]:
            atmp = []
            atmp.extend([a[s][j:j+m] for s in range(i,i+m)])
            if b == atmp:
                ans = "Yes"
                flag = True
        if flag:
            break
    if flag:
        break

print(ans)

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

using namespace std;

int main() {
	constexpr int INF = 1e9;
	int N, M, X;
	cin >> N >> M >> X;
	vector<int> C(N);
	vector<vector<int>> A(N, vector<int>(M));
	for (int i = 0; i < N; ++i) {
		cin >> C[i];
		for (int j = 0; j < M; ++j) { cin >> A[i][j]; }
	}

	int ans = INF;
	for (int i = 0; i < (1<<N); ++i) {
		int tmp = 0;
		vector<int> b(M, 0);
		for (int j = 0; j < N; ++j) {
			if ((i>>j) & 1) { continue; }
			tmp += C[j];
			for (int k = 0; k < M; ++k) {
				b[k] += A[j][k];
			}
		}
		bool ok = true;
		for (int j = 0; j < M; ++j) {
			if (b[j] < X) { ok = false; }
		}
		if (ok) { ans = min(ans, tmp); }
	}
	cout << (ans == INF ? -1 : ans) << endl;

	return 0;
}


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

using namespace std;

const int MOD=1000000007;

int main(){
    int n;
    cin >> n;
    long long int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    long long int ans=0;
    long long int sum=0;
    for(int i=n-1;i>0;i--){
        sum += a[i];
        sum %= MOD;
        ans+=a[i-1]*sum%MOD;
        ans%=MOD;
    }

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


Measured memory_bytes: 5176
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func primeFactor(n int) map[int]int {
	m := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			m[i]++
			n /= i
		}
	}
	if n != 1 {
		m[n] = 1
	}
	return m
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()

	pfs := map[int]int{}
	for i := 2; i <= n; i++ {
		pf := primeFactor(i)
		for k, v := range pf {
			pfs[k] += v
		}
	}

	num := func(m int) int {
		res := 0
		for _, v := range pfs {
			if v >= m-1 {
				res++
			}
		}
		return res
	}

	ans := num(75) + num(25)*(num(3)-1) + num(15)*(num(5)-1) + num(5)*(num(5)-1)*(num(3)-2)/2
	puts(ans)
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    cout << N * N * N << endl;
    return 0;
}


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

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if(A == B && A == C){
        cout << "No" << endl;
    }
    else if(A == B || A == C || B == C){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long int
#define fr(i,n) for(ll i=0; i<n; i++)
#define fre(i,n) for(ll i=1; i<=n; i++)
#define pb push_back
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define pii pair<ll,ll>
#define ve vector
#define piii pair<pii, ll>
#define FAST ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;

ll power(ll x, ll n, ll m)
{
    if(n==0)
        return 1;
    if(n==1)
        return x;
    x%=m;
    if(n%2)
        return (x*(power((x*x)%m, n/2, m)%m))%m;
    return power((x*x)%m, n/2, m)%m;
}

int main(){
  
    FAST;
    ll n,W;
    cin>>n>>W;

    ll v[n+1],w[n+1];
    for(int i=1; i<=n; i++) 
      cin>>w[i]>>v[i];

    ll dp[n+1][W+1];

    for(int i=0; i<=n; i++){
      for(int j=0 ; j<=W; j++){
        if( i==0 || j==0 )
          dp[i][j] = 0;
        else if( w[i] <= j )
          dp[i][j] = max( dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
        else
          dp[i][j] = dp[i-1][j];
      }
    }

    cout<<dp[n][W];

}

Measured memory_bytes: 82368
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	string s1, s2; cin >> s1 >> s2;
	if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

int dp[100005];
//dp[i] 足場[i]にいくときの最小コスト

int main(){
  int n, k;
  int h[100001];
  cin >> n >> k;
  for(int i=1;i<=n;i++)cin >> h[i];

  dp[1]=0;
  for(int i=2;i<=n;i++){
    int mn = 1001001001;
    for(int j=1;j<=k&&0<i-j;j++){
      int tmp = dp[i-j]+abs(h[i]-h[i-j]);
      mn = min(mn,tmp);
      // cout << "[" << mn << "]";
    }
    dp[i]=mn;
    // cout << endl;
  }

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

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

int main()
{
	char s[5];

	cin >> s;

	int a1 = (s[0] - '0') * 10 + s[1] - '0';
	int a2 = (s[2] - '0') * 10 + s[3] - '0';

	bool mmyy, yymm;

	mmyy = (1 <= a1) && (a1 <= 12);
	yymm = (1 <= a2) && (a2 <= 12);

	if (mmyy && !yymm)
	{
		cout << "MMYY" << endl;
		return 0;
	}
	if (!mmyy && yymm)
	{
		cout << "YYMM" << endl;
		return 0;
	}
	if (mmyy && yymm)
	{
		cout << "AMBIGUOUS" << endl;
		return 0;
	}
	if (!mmyy && !yymm)
	{
		cout << "NA" << endl;
		return 0;
	}

	return 0;
}


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

const int N = 2e5 + 5;
typedef long long ll;

map <int, int> cnt;
int n, a[N];
ll ans;

int main() {
	cin>>n;
	for(int i = 1; i <= n; i++) {
		cin>>a[i];
		ans += cnt[a[i] - i];
		cnt[-(a[i] + i)]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 21264
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int *)b - *(int *)a;
}

int main()
{

    int n;
    int num;
    long long A[200001];

    scanf("%d", &n);
    scanf("%d", &num);
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &A[i]);
    }

    qsort(A, n, sizeof(long long), compare_int);
    long long sum = 1;
    if (num % 2 == 1)
    { //奇数の時
        if (A[0] < 0)
        {
            sum = A[0];
            //最大値が負　全部ふ
            for (int i = 0; i < num-1; i++)
            {
                sum = sum * A[1+i]%1000000007;
            }
        }
        else if (A[0] >= 0)
        {
            sum = A[0];
            int front=1;
            int last = n;
            for (int i = 0; i < num - 1; i = i + 2)
            {
                if(A[front] * A[front + 1]>A[last - 1] * A[last - 2]){
                    sum = (sum * A[front] % 1000000007 )* A[front + 1] % 1000000007;
                    front += 2;
                }
                else
                {
                    sum = (sum * A[last - 1] % 1000000007) * A[last - 2] % 1000000007;
                    last -= 2;
                }
            }
        }
    }
    else
    {
        int front = 0;
        int last = n;
        for (int i = 0; i < num - 1; i = i + 2)
        {
            if (A[front] * A[front + 1] > A[last - 1] * A[last - 2])
            {
                sum = (sum * A[front] % 1000000007)* A[front + 1] % 1000000007;
                front += 2;
            }
            else
            {
                sum = (sum * A[last - 1] % 1000000007) * A[last - 2] % 1000000007;
                last -= 2;
            }
        }
    }
    if(sum<0){
        sum += 1000000007;
    }
    printf("%lld", sum);
    printf("\n");
}

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

// # DEFINES # //
#define ll long long
#define M (ll)1e9+7
#define EPS 1e-9

using namespace std;

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

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

    ll k;

    cin >> k;


    ll sum = 0;
    for(ll i = 1; i <= k; i++) {
        for(ll j = 1; j <= k; j++) {
            for(ll l = 1; l <= k; l++) {
                sum += gcd(i, gcd(j, l));
            }
        }
    }
    cout << sum << endl;


    return 0;
}

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

using namespace std;

int main()
{
    int n, d, x;
    cin >> n;
    cin >> d >> x;
    int ans = x + n;
    vector<int> a(n);
    vector<int> b(n, 1);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        b[i] += a[i];
    }
    for (int i = 2; i <= d; ++i) {
        for (int j = 0; j < n; ++j) {
            if (b[j] == i) {
                ++ans;
                b[j] += a[j];
            }
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        //static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var S = ReadLine();
            var pos = new List<long>[10];
            for (var i = 0; i < 10; ++i)
                pos[i] = new List<long>();
            for (var i = 0; i < N; ++i) 
                pos[S[i] - '0'].Add(i);
            var ans = 0L;
            for (var i = 0; i < 1000; ++i)
            {
                var s = $"{i:D3}".ToCharArray().Select(a => a - '0').ToArray();
                if (0 == pos[s[0]].Count)
                    continue;
                var one = pos[s[0]][0];
                var two = pos[s[1]].FirstOrDefault(c => c > one);
                if (two == 0) continue;
                if (!pos[s[2]].Any(c => c > two))
                    continue;
                ++ans;
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13920
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
k=1
for i in range(61):
    count0=0
    count1=0
    for j in a:
        if not (j>>i & 1):
            count0+=1
        if j>>i & 1:
            count1+=1
    ans+=((count0*count1)*(k))%mod
    k=(2*k)%mod
    
    
print(ans%mod)

Measured memory_bytes: 124468
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define ull unsigned long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FOR(i,start,stop)  for(int i=(start); i < (stop); i++)
#define FORD(i,start,stop) for(int i=(start); i >= (stop); i--)
#define RIP(i,stop) FOR(i,0,stop)
#define PI 3.141592653589793
#define PRECISION(c,f) fixed << setprecision(c) << f
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a,b,c; cin >> a >> b >> c;

  int ans5 = 0;
  int ans7 = 0;

  if(a == 5) ans5++;
  if(b == 5) ans5++;
  if(c == 5) ans5++;

  if(a == 7) ans7++;
  if(b == 7) ans7++;
  if(c == 7) ans7++;

  if(ans5 == 2 and ans7 == 1) YES;
  else NO;

  return 0;
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 999999999999

using namespace std;

#define int long long

int n;
vector<int> a, b, c;

int32_t main(){
	cin >> n;
	REP(i, n){
		int x, y;
		cin >> x >> y;
		a.pb(x);
		b.pb(y);
	}
	
	REP(i, n){
		c.pb(a[i]%b[i]);
	}

	int ans=0;
	for(int i=n-1; i>=0; i--){
		c[i]=(ans+c[i])%b[i];
		if(c[i]!=0) ans+=(b[i]-c[i]);
		//cout << b[i] << " " << c[i] << " " << ans << endl;
	}
	
	cout << ans << endl;
}



Measured memory_bytes: 3308
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#define ll long long
using namespace std;

const int N=200005;

int n,ans,w,last,sum;
int a[N],b[N],c[N],d[N];

int calc(int w,ll s){
	int l,r,mid;
	if (1ll*w+1ll*d[n]<1ll*s) return 0;
	l=1; r=n;
	while (l<r){
		mid=l+(r-l)/2;
		if (1ll*w+1ll*d[mid]>=1ll*s) r=mid;
		else l=mid+1;
	}
	return n-r+1;
}

int main(){
	int i,j,k,l,t;
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	for (i=1;i<=n;i++) scanf("%d",&b[i]);
	for (i=0;i<=29;i++){
		for (j=1;j<=n;j++) c[j]=a[j]&((1<<i+1)-1);
		for (j=1;j<=n;j++) d[j]=b[j]&((1<<i+1)-1);
		sort(c+1,c+1+n);
		sort(d+1,d+1+n);
		sum=0;
		for (j=1;j<=n;j++){
			sum+=max(calc(c[j],1ll<<i)-calc(c[j],1ll<<i+1),0);
			sum+=max(calc(c[j],3ll*(1ll<<i))-calc(c[j],1ll<<i+2),0);
			sum=sum&1;
		}
		if (sum&1) ans+=1<<i; 
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define sd second
#define ft first
#define pr pair
#define vl vector<ll>
#define vs vector<string>
#define vmp vector<pair<ll,ll>>
#define en "\n"
#define lb lower_bound
#define ub upper_bound
#define vll vector<vector<ll>>
#define vmpl vector<vector<pair<ll,ll>>>
#define st size()
#define al(v) v.begin(),v.end()
#define cast static_cast<char>
#define ins insert
#define fata_fat ios_base::sync_with_stdio(false); cin.tie(NULL);
ll M=1e9+7,MAX=1e18,MIN=-1e18;
void bhaag()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
int main()
{   
     bhaag(); fata_fat;
     string s; cin>>s;
     if(s[s.size()-1]=='s')cout<<s<<"es";
     else cout<<s<<"s";
}


Measured memory_bytes: 3612
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word
// also tink all answers possible for a question
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
#define sz 100005
ll inf = 1e9;
ll power(ll x, ll n, ll mod)
{
  ll res = 1;
  x %= mod;
  while (n)
  {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res%mod;
}
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  ll n;
  cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++)
    cin>>a[i];
  bool f=0;
  for(ll i=0;i<n;i++)
  {
    if(a[i]%2==0)
    {
      if(a[i]%3!=0 && a[i]%5!=0)
      {
        f=1;
        break;
      }
    }
  }
  if(f)
    cout<<"DENIED";
  else
    cout<<"APPROVED";
  return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <cctype>
#include <cmath>
#include <cstring>
#include <climits>
#include <complex>
#include <set>
#include <deque>
#define DEBUG(x) cerr<<"line:"<<__LINE__<<", "<<#x" == "<<(x)<<endl;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(it,s) for(__typeof(s.begin()) it=s.begin();it!=s.end();it++)
#define fst first
#define snd second
#define ALL(a) a.begin(),a.end()
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define DRI(x) int (x);scanf("%d",&(x))
#define DRII(x,y) int (x),(y);scanf("%d%d",&(x),&(y))
#define DRIII(x,y,z) int (x),(y),(z);scanf("%d%d%d",&(x),&(y),&(z))
#define MS0(a) memset((a),0,sizeof((a)))
#define MS1(a) memset((a),-1,sizeof((a)))
#define MS(a,b) memset((a),(b),sizeof((a)))
using namespace std;

typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

LL pow(LL a, LL b, LL MOD) {
    LL ans = 1;
    while (b) {
        if (b & 1) ans = ans * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return ans;
}

#define INF (int)1e9
#define EPS (1.0e-8)
// ------------------
const int maxn = 200;
// int dp[200][10];
int K, __count = 0;
LL cur = 0;
void dfs(LL pre, int remain) {

    // cout << "dfs " << pre << " " << remain <<  " cout = " << __count << endl;
    if (__count >= K) return;
    
    if (remain == 0) {
        __count++;

    }

    if (__count == K) {
        cur = pre;
        cout << pre << endl;
        // goto out;
        exit;
    }

    if (remain == 0) {
        return;
    }

    int last = pre % 10;
    if (last == 0) {
        dfs(pre * 10 + 0, remain - 1);
        dfs(pre * 10 + 1, remain - 1);
    } else if (last == 9) {
        dfs(pre * 10 + 8, remain - 1);
        dfs(pre * 10 + 9, remain - 1);
    } else {
        dfs(pre * 10 + last-1, remain - 1);
        dfs(pre * 10 + last, remain - 1);
        dfs(pre * 10 + last + 1, remain - 1);
    }
}

int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);
#endif
    cin >> K;


    int pre = 1;
    

    int count = 0;
    for (int remain = 0; remain <= 10; remain++) {
    for (int i = 1; i <= 9; i++) {
        dfs(i, remain);
    }
    }


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

using namespace std;

int main(void) {
  int n, k, q;
  cin >> n >> k >> q;

  if (k > q) {
    for (int i = 0; i < n; i++) {
      cout << "Yes" << endl;
    }
    return 0;
  }
  
  int cor[n];
  memset(cor, 0, sizeof(cor));
  for (int i = 0; i < q; i++) {
    int j; cin >> j;
    cor[j-1]++;
  }

  for (int i = 0; i < n; i++) {
    cout << (cor[i]+k > q ? "Yes" : "No") << endl;
  } 

  return 0;
}

Measured memory_bytes: 896
/*
P135
AOJ 0558 Cheese
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0558
*/
 
 
#include <iostream>
#include <map>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <functional>
#include <string.h>
using namespace std;
 
 
int dx[] = {0, 1, 0, -1, 0};
int dy[] = {1, 0, -1, 0, 0};
 
int num;
int pos0;
typedef pair<int,int> PAIR;
map<int, int> mp;
 
int pow10[8] = {1,10,100,1000,10000,100000,1000000,10000000};
 
bool check(int x, int y)
{
    return (x>=0&&x<2 && y>=0 && y<4);
}
 
 
 
bool read()
{
    num = 0;
    int x;
    for(int i=0; i<8; ++i){
        if(scanf("%d", &x) == EOF) return false;
        num *= 10;
        num += x;
    }
    return true;
}
 
 
int swapPos(int n, const int& p0, const int& p2){
    int d = n / pow10[7-p2] % 10;
    n -= d * pow10[7-p2];
    n += d * pow10[7-p0];
    return n;
}
 
 
void bfs(){
    queue<PAIR> q;
    mp[1234567] = 0;
    q.push(make_pair(1234567, 0));
 
    while(!q.empty()){
        PAIR cur = q.front(); q.pop();
        int curNum = cur.first;
        int p0 = cur.second;
        int step = mp[curNum];
        int x = p0>>2, y = p0&3;
 
        for(int d=0; d<4; ++d){
            int cx = x + dx[d], cy = y + dy[d];
            if(check(cx, cy)){
                int cn = (cx*4 + cy);
                int v = swapPos(curNum, p0, cn);
                if(!mp.count(v)) {
                    mp[v] = step+1;
                    q.push(make_pair(v, cn));
                }
            }
        }
    }
}
 
 
void solve()
{
    printf("%d\n", mp[num]);
}
 
int main()
{
    bfs();
    while(read())
        solve();
 
}
 
 
 
 
/*
int W, H;
char board[110][110];
int a[10];
bool read()
{
    for(int i=0; i<10; ++i)
        scanf("%d", a+i);
}
 
bool isVisited[110][110];
int step;
 
void dfs(int x, int y, char c){
    if(x<0 || x>=H || y<0 || y>=W) return;
    if(board[x][y]!=c) return;
    if(isVisited[x][y]) return;
    isVisited[x][y] = true;
    dfs(x+1, y, c);
    dfs(x-1, y, c);
    dfs(x, y+1, c);
    dfs(x, y-1, c);
}
 
 
 
void solve1()
{
    int x1=0, x2=0;
    bool ans = true;
    for(int i=0; i<10; ++i)
    {
        if(x1 < x2) swap(x1, x2);
        if(x1 < a[i]) x1 = a[i];
        else if(x2 < a[i]) x2 = a[i];
        else {ans = false; break;}
    }
    if(ans) printf("YES\n");
    else printf("NO");
}
 
 
 
vector<int> L_bucket;
vector<int> R_bucket;
 
bool dfs2(int d){
    if(d == 10) return true;
    bool flag;
    if(L_bucket.size() == 0 || L_bucket.back() < a[d]){
        L_bucket.push_back(a[d]);
        flag = dfs2(d+1);
        L_bucket.pop_back();
    }
    if(flag) return true;
    if(R_bucket.size() == 0 || R_bucket.back() < a[d]){
        R_bucket.push_back((a[d]));
        flag = dfs2(d+1);
        R_bucket.pop_back();
    }
    if(flag) return true;
    return false;
 
}
 
void solve2()
{
    if(dfs2(0))
        printf("YES\n");
    else printf("NO\n");
}
 
int main()
{
    int T;
    scanf("%d", &T);
    while(T--){
        read();
        solve2();
    }
}
*/

Measured memory_bytes: 4172
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    sc.nextInt();
    List<String> inputs = new ArrayList<>();

    while (sc.hasNext()) {
      inputs.add(sc.next());
    }
    sc.close();

    long ac = inputs.stream()
    .filter(s -> s.equals("AC"))
    .count();

    long wa = inputs.stream()
    .filter(s -> s.equals("WA"))
    .count();

    long tle = inputs.stream()
    .filter(s -> s.equals("TLE"))
    .count();
    
    long re = inputs.stream()
    .filter(s -> s.equals("RE"))
    .count();

    System.out.print("AC x ");
    System.out.println(ac);

    System.out.print("WA x ");
    System.out.println(wa);

    System.out.print("TLE x ");
    System.out.println(tle);

    System.out.print("RE x ");
    System.out.println(re);
  }
}

Measured memory_bytes: 64520
using System;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var input = Array.ConvertAll(ReadLine().Split(' '), ulong.Parse);
        var min = input[0];
        var max = input[1];
        var num = input[2];
        ulong result = 0;
        if (min != 0) result = max / num - (min-1) / num;
        else result = max / num + 1;
        WriteLine(result);

    }
}



Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)

int main() {
  int X, Y, Z;cin >> X >> Y >> Z;
  cout << Z << " "<< X << " " << Y;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 2e18
using namespace std;
typedef long long ll;
typedef pair<ll,ll>p;
int main()
{
    //freopen("in.txt", "r", stdin);
    ll a,b;
    cin>>a>>b;
    if(a>=10 || b>=10){
        cout<<"-1"<<endl;
    }
    else{
        cout<<a*b<<endl;
    }
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    int z =0;
    if((a+d-1)/d>=(c+b-1)/b){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35792
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

int main(){
  int k;cin >> k;
  vector<int> a(k);
  rep(i,k) cin >> a[i];
  if(a[k-1]!= 2){
    cout << -1 << endl;
    return 0;
  }
  //cout << k << endl;
  ll mx = 1e16;
  ll mi = 1;
  ll mid = (mx+mi)/2;
  ll temp;
  while(mx-mi>1){
    temp = (mx+mi)/2;
    //cout << temp << endl;
    rep(i,k){
      temp = temp/a[i]*a[i];
      if(temp == 0) {
        mi = (mx+mi)/2; 
        break;
      }
    }
    //cout << " " << temp << endl;
    if(temp > 2) mx = (mx+mi)/2;
    if(temp == 2) {
      mid = (mx+mi)/2;
      break;
    }
  }
  if(mid > 1e15) {
    cout << -1 << endl;
    return 0;
  }
  //cout << mid << endl;
  //cout << temp << endl;
  mx = mid;
  mi = 1;
  while(mx-mi>1){
    temp = (mx+mi)/2;
    rep(i,k){
      temp = temp/a[i]*a[i];
      if(temp == 0) {
        mi = (mx+mi)/2; 
        break;
      }
    }
    if(temp == 2) mx = (mx+mi)/2;
  }

  ll mians = mx;

  mx = 1e16;
  mi = mid;
  while(mx-mi>1){
    temp = (mx+mi)/2;
    rep(i,k) temp = temp/a[i]*a[i];
    if(temp > 2) mx = (mx+mi)/2;
    if(temp == 2) mi = (mx+mi)/2;
  }

  ll mxans = mi;
  printf("%lld %lld\n",mians,mxans);
}

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

int main(){
	string s;
	cin >> s;
	int res = 0;
	rep(i,16) if(s[i] != "CODEFESTIVAL2016"[i]) res++;
	cout << res << endl;
}


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

int main(){
  char M='O';
  cin >> M;
  switch(M){
    case 'A':
      cout << 'T' << endl;
      break;
    case 'T':
      cout << 'A' << endl;
      break;
    case 'C':
      cout << 'G' << endl;
      break;
    case 'G':
      cout << 'C' << endl;
      break;
  }
  return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for x in [0]*n]
cd = [list(map(int,input().split())) for x in [0]*m]
for a,b in ab:
    l = [abs(a-c)+abs(b-d) for c,d in cd]
    print(l.index(min(l))+1)


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static llong MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


int main (int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  llong l, r;
  cin >> l >> r;

  if (r - l >= 2019) {
    cout << 0 << endl;
  } else {
    llong ans = INF;
    for (llong i = l; i <= r; ++i) {
      for (llong j = i + 1; j <= r; ++j) {
        ans = min(ans, ((i % 2019) * (j % 2019)) % 2019);
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import re

s = input()

candidates = ["dream", "dreamer", "erase", "eraser"]
ok = False
t = ""

pattern = r"^(dream|dreamer|erase|eraser)*$"
repatter = re.compile(pattern)
match_obj = repatter.match(s)

if match_obj:
    print("YES")
else:
    print("NO")

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

int n,l;
vector<string> str;
vector<int> G[1001];
int aim[1001];
bool used[1001];


bool check(int a,int b){
	for(int i=0;i<l;i++){
		if(str[a][i]!=str[b][l-1-i])return false;
	}
	return true;
}

bool checkme(int a){
	for(int i=0;i<l/2;i++){
		if(str[a][i]!=str[a][l-1-i])return false;
	}
	return true;
}

int main(void){
	scanf("%d%d",&n,&l);
	for(int i=0;i<n;i++){
		string si;
		cin >> si;
		str.push_back(si);
	}
	sort(str.begin(),str.end());
	for(int i=0;i<n;i++){
		if(checkme(i))aim[i]=1;
		for(int j=i+1;j<n;j++){
			if(check(i,j)){
				G[i].push_back(j);
			}
		}
	}
	vector<string> resf;
	vector<string> rest;
	string resm="";
	for(int i=0;i<n;i++){
		if(used[i])continue;
		for(int j=0;j<G[i].size();j++){
			if(!used[G[i][j]]){
				used[i]=true;
				used[G[i][j]]=true;
				resf.push_back(str[i]);
				rest.push_back(str[G[i][j]]);
				break;
			}
		}
		if(!used[i] && aim[i]==1 && resm.size()==0){
			used[i]=true;
			resm+=str[i];
		}
	}
	string res="";
	for(int i=0;i<resf.size();i++){
		res+=resf[i];
	}
	res+=resm;
	for(int i=0;i<rest.size();i++){
		res+=rest[rest.size()-i-1];
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3536
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
int dfs(int node, vector<vector<int>>& g, vector<int>& vis){
    if(vis[node])
        return 0;
    vis[node] = 1;
    int cnt = 1;
    for(int idx : g[node]){
        cnt += dfs(idx, g, vis);
    }
    return cnt;
}
void solve(){
    int n, m;
    cin>>n>>m;
    vector<vector<int>> g(n+1);
    for(int i = 0; i < m; i++){
        int f, s;
        cin>>f>>s;
        g[f].push_back(s);
        g[s].push_back(f);
    }
    int ans = 0;
    vector<int> vis(n+1, 0);
    // cout<<dfs(1, g, vis);
    for(int i = 1; i <= n; i++){
        ans = max(ans, dfs(i, g, vis));
    }
    cout<<ans<<" ";
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 24296
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPP(i, n) for(int i = 1; i <= n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;

int main() {
    string s; cin >> s;
    bool ans = true;
    REP(i,3) {
        if(s[i]==s[i+1]) ans = false;
    }
    cout << (ans ? "Good" : "Bad") << endl;
    return 0;
}

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

	int N;
	cin >> N;
	int D[N];
	map<int,int> mpd,mpt;
	for(int i=0;i<N;i++){
		cin >> D[i];
		mpd[D[i]]++;
	}

	int M;
	cin >> M;
	int T[M];
	for(int i=0;i<M;i++){
		cin >> T[i];
		mpt[T[i]]++;
	}

	for(int i=0;i<M;i++){
		if(mpt[T[i]] > mpd[T[i]]){
			cout << "NO" << endl;
			return 0;
		}
	}
	
	cout << "YES" << endl;
}






Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define el(a) (a).end()-(a).begin()
#define mod 1000000007
#define inf 2147483647
#define range(x,a,b) (a)<=x&&x<=(b)
int main(){
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a;
	return 0;
}

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

void solveA(){
  int n,k;
  cin >> n >> k;

  if (k <= (n+1)/2){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}
void solveB(){
}
void solveC(){
}
void solveD(){
}

int main(){
  solveA();
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char str[110];
char A[10];
char B[10];
int main(){
	scanf("%s%s",A,B);
	sprintf(str,"%s%s",A,B);
	int c;sscanf(str,"%d",&c);
	for(int i=0;i<1100;i++){
		if(i*i==c){
			printf("Yes\n");return 0;
		}
	}
	printf("No\n");
}

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

using namespace std;

class UnionFind {
 public:
  // parentの番号を格納する。親だった場合は-(その集合のサイズ)
  vector<int> Parent;

  //作成時は全て-1なので木が全て独立している状態
  UnionFind(int N) { Parent = vector<int>(N, -1); }

  // Aがどのグループに属しているか調べる
  int root(int A) {
    if (Parent[A] < 0)
      return A;
    else {
      return Parent[A] = root(Parent[A]);
    }
  }

  //自分のいるグループの頂点数を調べる //rootで親を取ってくる
  int size(int A) { return -Parent[root(A)]; }

  // AとBをくっつける
  bool merge(int A, int B) {
    // AとBを繋げるのではなくroot(A)とroot(B)を繋げる
    A = root(A);
    B = root(B);
    if (A == B) {
      //すでに繋がれているので繋がない
      return false;
    }

    //大きい方（A）に小さい方（B）をくっつけたい
    if (size(A) < size(B)) swap(A, B);

    // Aのサイズを変更する
    Parent[A] += Parent[B];
    // Bの親をAに変更する
    Parent[B] = A;


    return true;
  }
    bool initialize(){
        for(int i = 0 ;i<Parent.size();i++){
            Parent[i]=-1;
        }
        return true;
    }

};

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

  int N, M;
    cin >> N >> M;

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

    int ans = 0;

    for(int i=0;i<M;i++){
            UnionFind Uf(N);

        for(int j = 0 ; j<M;j++){
            if(j!=i) Uf.merge(a[j],b[j]);
        }

        if(Uf.root(a[i])!=Uf.root(b[i])){
            ans++;
        }

    }

    cout << ans <<'\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int i,j,n,c=0;
	cin>>n;
	for(i=9;i<=n;i=i+2)
	{
		int d=0;
		for(j=1;j*j<=i;j++)
		{
			if(j*j==i)
			d+=1;
			else if(i%j==0)
			d+=2;
		}
		if(d==8)
		{
			c++;
		}
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
class Mint:
    
    MOD = 10**9+7
    
    def __init__(self, x=0):
        self.x = (x%self.MOD + self.MOD) % self.MOD
    
    def __iadd__(self, other):
        self.x += other.x
        if self.x >= self.MOD:
            self.x -= self.MOD
        return self
    
    def __isub__(self, other):
        self.x += self.MOD - other.x
        if (self.x >= self.MOD):
            self.x -= self.MOD
        return self
    
    def __imul__(self, other):
        self.x *= other.x
        self.x %= self.MOD;
        return self;
    
    def __add__(self, other):
        ans = Mint(self.x)
        ans += other
        return ans
        
    def __sub__(self, other):
        ans = Mint(self.x)
        ans -= other
        return ans
    
    def __mul__(self, other):
        ans = Mint(self.x)
        ans *= other
        return ans
    
    def __pow__(self, n):
        if n == 0:
            return Mint(1)
        a = self.__pow__(n >> 1)
        a *= a
        if n&1:
            a *= self
        return a
    
    def inv(self):
        return self**(self.MOD-2)
    
    def __ifloordiv__(self, other):
        self *= other.inv()
        return self
    
    def __floordiv__(self, other):
        ans = Mint(self.x)
        ans //= other
        return ans
        
class Comb:
    
    def __init__(self):
        pass
    
    def comb(self, n, k):
        assert n < Mint.MOD
        if k < 0 or k > n:
            return 0
        numerator = Mint(n-k+1)
        for i in range(n-k+2, n+1):
            numerator *= Mint(i)
        d = Mint(1)
        for i in range(2, k+1):
            d *= Mint(i)
        denominator = d.inv()
        return numerator*denominator            
        

def Main(N, A, B):
    ans = Mint(2)**N-Mint(1)-Comb().comb(N, A)-Comb().comb(N, B)
    return ans.x

def main():
    N, A, B = list(map(int, input().split()))
    print(Main(N, A, B))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3192