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

public class Main {
	public static void main(String[] args) {
		// Config 
		Scanner sc = new Scanner(System.in);
		
		// Input
		int N = Integer.parseInt(sc.nextLine());
		String[] inList = sc.nextLine().split(" ");
		int[] numList = new int[N];
		for(int i=0; i<N; i++) {
			numList[i] = Integer.parseInt(inList[i]);
		}
		
		// Sort
		Main prob1 = new Main();
		prob1.insertionSort(numList, N);
		
	}
	
	// insertion sort implement
	private void insertionSort(int[] A, int N) {
		for(int i=0; i<A.length; i++) {
			int v = A[i];
			int j = i - 1;
			while(j>=0 && A[j]>v) {
				A[j+1] = A[j];
				j--;
			}
			A[j+1] = v;
			Output(A);
		}
	}
	
	// Output
	private void Output(int[] A) {
		String ans = "";
		for(int i=0; i<A.length-1; i++) {
			ans += A[i] + " "; 
		}
		ans += A[A.length-1];
		System.out.println(ans);
	}
}



Measured memory_bytes: 45296
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;

using Graph = vector<vector<int> >;

vector<int> seen;

int main()
{
	string S;
	int K;

	cin >> S >> K;

	map<string,int> map_s;

	string ss;
	for(int si = 0; si < S.length(); si++){
		for (int len = 1; len <= 5 && si + len <= S.length(); len++){
			ss = S.substr(si,len);
			map_s[ss]++;
		}
	}

	int cnt = 0;
	for (auto p : map_s){
		ss = p.first;
		cnt++;
		if (cnt == K) break;
	}

	//printf("%.9f", ans);
	std::cout << ss;

	return 0;
}



Measured memory_bytes: 1920
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first.first
#define yy first.second
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace __gnu_pbds;
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifdef LOCALc
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
template<typename T, typename l>
void getv(T& a, int n, l f) {
	a.resize(n);
	for (auto& i : a)
		cin >> i, f(i);
}
template<typename T>
void getv(T& a, int n) {
	a.resize(n);
	for (auto& i : a)
		cin >> i;
}
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct wrk {
	int x, s, t;
	void get() {
		cin >> s >> t >> x;
	}
};
struct cmpS {
	bool operator()(const wrk &a, const wrk &b) { //<
		return (a.s-a.x) < (b.s-b.x);
	}
};
struct cmpT {
	bool operator()(const wrk &a, const wrk &b) { //<
		return (a.t-a.x) < (b.t-b.x);
	}
};
struct cmpX {
	bool operator()(const wrk &a, const wrk &b) { //<
		return a.x < b.x;
	}
};
ll n, q, ans[400100];
vpi ppl;
__V<wrk> w;
multiset<wrk, cmpT> wT;
multiset<wrk, cmpX> wX;
int main() {
	doin();
	cin >> n >> q;
	w.resize(n);
	for (auto& i : w)
		i.get();
	sort(all(w), cmpS());

	ppl.resize(q);
	for (int i = 0; i < q; i++)
		ppl[i].second = i, cin >> ppl[i].first;
	sort(all(ppl));
	int l = 0, r = 0;
	for (int i = 0; i < q; i++) {
		while (r < n && w[r].s <= (w[r].x + ppl[i].first)) {
			wT.insert(w[r]);
			wX.insert(w[r]);
			r++;
		}
		while (!wT.empty() && wT.begin()->t <= (wT.begin()->x + ppl[i].first)) {
			wX.erase(wX.find(*wT.begin()));
			wT.erase(wT.begin());
		}
		ans[ppl[i].second] = wX.empty() ? -1 : wX.begin()->x;
	}
	for (int i = 0; i < q; i++)
		cout << ans[i] << "\n";
}


Measured memory_bytes: 33280
import itertools

N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

ans = -10 ** 10
for f in list(itertools.product([0, 1], repeat=10))[1:]:
    p = sum([P[i][sum([F[i][j] * f[j] for j in range(10)])] for i in range(N)])
    ans = max(ans, p)

print(ans)


Measured memory_bytes: 3188
import numpy as np
s = input()
ans = 0
reg = 0
for i in range(len(s)):
    if(s[i] == 'A' or s[i] == 'G' or s[i] == 'C' or s[i] == 'T'):
        reg += 1
    else:
        reg = 0
        continue
    if(ans<reg):
        ans = reg
print(ans)

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

using namespace std;
#define int long long
#define double long double
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second
typedef pair<int, int> pii;
#define l_b lower_bound
#define u_b upper_bound

struct T {
    int f, s, t;

    T(int f, int s, int t) : f(f), s(s), t(t) {}

    bool operator<(const T &other) {
        if (f != other.f)return f < other.f;
        if (s != other.s)return s < other.s;
        return t < other.t;
    }
};

int N;
int A[330][330];
vector<T> edge;
int d[330][330];

void updateD(int a, int b, int l) {
    d[a][b] = l;
    rep(i, N) {
        rep(j, N) {
            d[i][j] = min(d[i][j], d[i][a] + d[a][b] + d[b][j]);
            d[i][j] = min(d[i][j], d[i][b] + d[a][b] + d[a][j]);
        }
    }
}

signed main() {
    cin >> N;
    rep(i, N) {
        rep(j, N) {
            cin >> A[i][j];
            d[i][j] = INF;
            if (i == j)d[i][j] = 0;
            if (i < j)edge.emplace_back(A[i][j], i, j);
        }
    }

    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                if (A[i][k] + A[k][j] < A[i][j]) {
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }

    sort(edge.begin(), edge.end());
    int ans = 0;
    rep(i, edge.size()) {
        int a = edge[i].s;
        int b = edge[i].t;
        int l = edge[i].f;
        if (d[a][b] != l) {
            updateD(a, b, l);
            ans += l;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

#define maxn l005
#define ll long long

int main() {
	ll a, b, c;
	scanf("%lld%lld%lld", &a, &b, &c);
	if (b - a == c - b) {
		printf("YES\n");
	}
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n;
	int m;
	int c,c1,c2;
	int i;
	int flg;
	int max;
	scanf("%d",&n);
	scanf("%d",&m);
	max=m;
	flg=0;
	c=0;
	for(i=0;i<n;i++){
		scanf("%d %d",&c1,&c2);
		max=max+c1;
		max=max-c2;
		if(c<max){
			c=max;
		}
		if(max<0){
			flg=1;
		}		
	}
	if(flg==1){
		printf("0\n");
		return 0;
	}
	else if(flg==0){
		if(m<=c){
			printf("%d\n",c);
			return 0;
		}
		else {
			printf("%d\n",m);
			return 0;
		}
	}
	return 0;
}

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

int main(){
  int N, M, X;
  cin >> N >> M >> X;
  int W=0;
  int E=0;
  for(int i=0; i<M; i++){
    int A;
    cin >> A;
    if(A<X) W++;
    else E++;
  }
  cout << min(W, E) << endl;
}

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

using namespace std;

#define ll long long
const int N = 1050;

ll n,m,dp[N],a[N][5],ans,maxn;

int main(){
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		for(int j = 0; j < 3; j++)
			cin >> a[i][j];
	
	for(int i = 0; i < 8; i++){
		vector <ll> v;
		for(int j = 1; j <= n; j++){
			ll tot = 0;
			for(int l = 0; l < 3; l++)
				if(i / (1 << l) % 2 == 0) tot -= a[j][l];
				else tot += a[j][l];
				v.push_back(tot);
		}
		sort(v.begin(),v.end());
		reverse(v.begin(),v.end());
		maxn = 0;
		for(int j = 0; j < m; j++)
			maxn += v[j];
		ans = max(maxn,ans);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;

ll kaijo(ll n){
    ll ret = n;
    while(n > 1){
        ret *= --n;
        ret %= mod;
    }
    return ret;
}

int main() {

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

    if(abs(a-b) > 1){
        cout << 0 << endl;
        return 0;
    }

    ll n = kaijo(a);
    ll m = kaijo(b);
    ll ans = (n * m) % mod;
    if(a == b){
        ans *= 2;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
i = 0
flag = 0
while(True):
    if(s[i:i+5]) == "dream":
        if(i+5==n):
            break
        elif(s[i+5:i+10] =="dream"):
            i += 5
        elif(s[i+5:i+10] == "erase"):
            i += 5
        elif(s[i+5:i+7] == "er"):
            i += 7
            if(i==n):
                break
        else:
            flag = 1
            break

    elif(s[i:i+5]) == "erase":
        if(i+5==n):
            break
        elif(s[i+5:i+10] =="dream"):
            i += 5
        elif(s[i+5:i+10] == "erase"):
            i += 5
        elif(s[i+4:i+6] == "er"):
            i += 6
            if(i==n):
                break
        else:
            flag = 1
            break
    else:
        flag = 1
        break
print("YES" if flag == 0 else "NO")

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

int main(){
  string S;
  cin >> S;
  map<string, string> mp;
  mp["Sunny"] = "Cloudy";
  mp["Cloudy"] = "Rainy";
  mp["Rainy"] = "Sunny";
  cout << mp[S] << endl;
  return 0;
}

Measured memory_bytes: 3544
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long a, b, c;
  cin >> a >> b >> c;
  map<long, long> mp;
  mp[a]++;
  mp[b]++;
  mp[c]++;
  if (mp[5] == 2 and mp[7] == 1) puts("YES"); else puts("NO");
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

#define all(c) (c).begin(),(c).end()

using namespace std;

vector<int>p,v;
bool fg[101000];

int main(void){

  for(int i=2;i*i<101000;i++){
    if(!fg[i]){
      for(int j=i*i;j<101000;j+=i){
	fg[j]=true;
      }
    }
  }
  for(int i=2;i<101000;i++)
    if(!fg[i])p.push_back(i);

  int N,P;
  while(cin >> N >> P,0<=N && 0<=P){
    int b = upper_bound(all(p),N) - p.begin();
    int psize = p.size();
    v.clear();
    for(int i=b;i-b<P && i<psize;i++){
      for(int j=i;j-i<P && j<psize;j++){
	v.push_back(p[i]+p[j]);
      }
    }
    sort(all(v));
    cout << v[P-1] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3244
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << setprecision(16);
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;

    rep(i,1000){
        string t;
        int x = i;
        rep(j,3){
            t += '0'+ x%10;
            x /= 10;
        }
        int cur = 0;
        rep(j,n){
            if(s[j] == t[cur]){
                cur++;
                if(cur == 3)break;
            }
        }
        if(cur == 3) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

bool isPrime[100100];
vector<int> primes;

void sieve() {
    isPrime[2] = true;
    primes.push_back(2);
    for (int i = 3; i <= 100000; ++i) {
        bool isP = true;
        for (int prime:primes) {
            if (i % prime == 0) {
                isP = false;
                break;
            }
        }
        if (isP) {
            isPrime[i] = true;
            primes.push_back(i);
        }
    }
}

int S[100100];

signed main() {
    sieve();
    for (int i = 3; i <= 99999; i += 2) {
        if (isPrime[i] && isPrime[(i + 1) / 2]) {
            S[i] = 1;
        }
    }
    rep(i, 100000) {
        S[i + 1] += S[i];
    }
    int Q;
    cin >> Q;
    rep(i, Q) {
        int l, r;
        cin >> l >> r;
        cout << S[r + 1] - S[l - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
//ll const INF=1001001001;
//ll const INF=1001001001001001001;
ll const MOD=1000000007;

int H,W,D;
int A[301][301];
int Q;
int L[100001];
int R[100001];
P idx[90001];
int sum[90001];

int main(){
    cin>>H>>W>>D;
    repn(i,H) repn(j,W) cin>>A[i][j];
    cin>>Q;
    repn(i,Q) cin>>L[i]>>R[i];

    repn(i,H) repn(j,W) idx[A[i][j]]=P(i,j);

    repn(i,D){
        for(int j=i+D;j<=H*W;j+=D){
            int x=abs(idx[j].first-idx[j-D].first);
            int y=abs(idx[j].second-idx[j-D].second);
            sum[j]=sum[j-D]+x+y;
        }
    }

    repn(i,Q){
        int ans=sum[R[i]]-sum[L[i]];
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 5740
module Main where
    import Data.List
    import Control.Monad

    main = do
        input<-getInputs
        if length (filter isTri [x+y|x<-[0,input!!0],y<-[0,input!!1]])>0 then
            putStrLn "Possible"
        else 
            putStrLn "Impossible"

    isTri  x =and [x>0,mod x 3 == 0]

    read' s = read s ::Integer

    getInputs = do
        line <- getLine
        let inputs = map read' (words line)
        return inputs

    getLines n = do
        lines <- (replicateM n getLine)
        return lines


Measured memory_bytes: 508
N = int(input())

prime = []

for i in range(10,1145148101919+1):
    a = True
    for g in range(2, i-1):
        if i%g == 0:
            a = False
            break
    if a:
        if i%5==1:
            prime.append(i)
    if len(prime)==55:
        break
    
print(*prime[:N])

Measured memory_bytes: 3060
/**
  *  Worg
  */
#include <map>
#include <cstdio>
#include <vector>
#include <algorithm>

//FILE *fin = freopen("main.in", "r", stdin); FILE *fout = freopen("main.out", "w", stdout);

const int kMaxInf = 2e9;

std::map<int, int > map, revmap;
int n, z, w, cursor;
int a[2005];
int dp[2][2005][2005];

void Add(int value) {
  if(!map[value]) {
    cursor ++;
    map[value] = cursor;
    revmap[cursor] = value;
  }
}

void Get(int turn, int card, int idx) {
  if(dp[turn][card][idx] != kMaxInf && dp[turn][card][idx] != -kMaxInf) return;

  dp[turn][card][idx] = std::abs(revmap[card] - a[n]);

  if(turn == 0) {
    for(int i = idx + 1; i <= n; i++) {
      Get(1 - turn, map[a[i - 1]], i);
      dp[turn][card][idx] = std::max(dp[turn][card][idx], dp[1 - turn][map[a[i - 1]]][i]);
    }
  } else {
    for(int i = idx + 1; i <= n; i++) {
      Get(1 - turn, map[a[i - 1]], i);
      dp[turn][card][idx] = std::min(dp[turn][card][idx], dp[1 - turn][map[a[i - 1]]][i]);
    }
  }
}

int main() {
  scanf("%d%d%d", &n, &z, &w);
  Add(z); Add(w);

  for(int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    Add(a[i]);
  }

  for(int i = 0; i < 2005; i++) {
    for(int j = 0; j < 2005; j++) {
      dp[0][i][j] = -kMaxInf; dp[1][i][j] = kMaxInf;
    }
  }

  Get(0, map[w], 1);
  printf("%d\n", dp[0][map[w]][1]);
	return 0;
}


Measured memory_bytes: 32128
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a == 1)a = 14;
	if (b == 1)b = 14;
	//cout << min(n*a,b) << endl;
	printf((a>b) ? "Alice\n" :(a==b)?"Draw\n": "Bob\n");
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  string s,t; cin>>s>>t;
  s=s+s;
  auto i = s.find(t);
  if (i!=std::string::npos) out("Yes");
  cout<<"No"<<endl;
  

  return 0;
}


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



int func(int n) {
    if (n == 0)return 0;
    return n + func(n-1);

}

int main(){
    int n,x;
    cin>>n;
    x =n;
    for (int n =0; n <= x ;++n){
        
    }
     cout<<func(n)<<endl;
}

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


int main(){
  int n,i,a,j,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(a==2) count+=1;
    if(a%2!=0){
      j=3;
      while(1){
        if(a%j==0) break;
        if((j*j)>a) break;
        j+=1;
      }
      if((j*j)>a) count+=1;
    }
  }
  printf("%d\n",count);
  return 0;
}
   
  

Measured memory_bytes: 596
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
#define endl "\n"
const int mod=1e9+7;
const double pi=acos(-1.0);

int main(int argc, char const *argv[])
{
    /*#ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int n;
    cin>>n;
    vll v(n);
    map<ll,ll>mp;
    for(int i=0;i<n;i++)
    {
    	ll x;
    	cin>>x;
    	v[i]=x;
    	++mp[x];
    }
    ll ans=0;
    for(auto x:mp)
    {
    	ll y=x.second;
    	ans+=(y*(y-1))/2;
    }
    //cout<<ans<<endl;
    for(int i=0;i<n;i++)
    {
    	ll x=v[i];
    	//cout<<x<<" "<<x<<endl;
    	ll y=mp[x];
    	//cout<<y<<" "<<y<<endl;
    	ll m=(y*(y-1))/2;
    	//cout<<"m "<<m<<endl;
    	ll n=((y-1)*(y-2))/2;
    	ll res=ans-m+n;
    	cout<<res<<endl;
    }

}

Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#define mem0(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,0x3f,sizeof(a))
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef double db;
const int maxn = 2e5 + 10;
const int maxn2 = 1e9 + 1;
int n;
ll a[maxn];
ll b[maxn];
int main()
{
	ll mx = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &a[i]);
		b[i] = a[i];
	}
	sort(b, b + n);
	ll m1 = b[n / 2];
	ll m2 = b[n / 2 - 1];
	for (int i = 0; i < n; i++)
	{
		if (a[i] > m2)
			cout << m2 << endl;
		else
			cout << m1 << endl;
	}
	return 0;
}

Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str_scan = scan.nextLine();
    // スペース区切りで分ける
    var str = str_scan.split(" ");
    // int型へ変換
    int num1 = Integer.parseInt(str[0]);
    int num2 = Integer.parseInt(str[1]);
    var ans = "hoge";

    if ( ((num1 * num2) % 2 ) == 1) {
      ans = "Odd";
    }else{
      ans = "Even";
    }

    System.out.println(ans);
    scan.close();
  }
}

Measured memory_bytes: 35500
#include<iostream>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;


const int END_OF_INPUT = 0;


int main() {
	int a_n;
	
	while (cin >> a_n && a_n != 0){
		vector<int> m_list;
		m_list.push_back(a_n);

		for (int i = 0; i < 4; ++i){
			cin >> a_n;
			m_list.push_back(a_n);
		}

		int is_even = 0;
		bool rps[3];
		for (int i = 1; i <= 3; ++i){
			vector<int>::iterator cIter = find(m_list.begin(), m_list.end(), i);
			rps[i - 1] = false;
			if (cIter != m_list.end()){
				++is_even;
				rps[i - 1] = true;
			}
		}
		if (is_even == 3 || is_even == 1){
			// even 
			for (int i = 1; i <= 5; ++i){
				cout << "3" << endl;
			}
		}
		else{
			int winner = 0;
			if (rps[0] && rps[1]){
				// グー
				winner = 1;
			}
			else if (rps[1] && rps[2]){
				// ちょき
				winner = 2;
			}
			else if (rps[2] && rps[0]){
				// パー
				winner = 3;
			}

			for (int i = 0; i < 5; ++i){
				if (m_list[i] == winner){
					cout << "1" << endl;
				}
				else{
					cout << "2" << endl;
				}
			}
		}


		

	}
	


}

Measured memory_bytes: 1208
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>

using namespace std;

int main() {
	double r;
	double s, l;
	cin >> r;
	s = r*r*3.141592653589;
	l = 2 * r*3.141592653589;
	printf("%.8f %.8f", s,l);
	cin >> r;
}

Measured memory_bytes: 3168
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	unsigned size_; 
	std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	//unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	unsigned root(unsigned x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

struct tupe
{
	ll a;
	ll b;
};

int compare(tupe &a, tupe &b)
{
	return a.a < b.a;
}

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

	ll N, M;
	
	cin >> N >> M;

	tupe k[N];

	rep(i, N)
	{
		//ll a, b;
		cin >> k[i].a >> k[i].b;

	}

	sort(k, k+N, compare);

	ll sum = 0;

	ll remaining = M;

	ll idx = 0;
	
	rep(i, N)
	{
		if (remaining <= k[i].b)
		{
			sum += remaining * k[i].a;
			break;
		}
		else
		{
			sum += k[i].b * k[i].a;
			remaining -= k[i].b;
		}
	}
	
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

int func(int x) {
	if (x % 2 != 0)return 0;
	return 1 + func(x / 2);
}
int gcd(int x, int y) {
	if (x > y)return gcd(y, x);
	return x ? gcd(y%x, x) : y;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S, T;
	cin >> S >> T;
	vector<int> start(26, -1);
	vector<int> goal(26, -1);
	REP(i, S.size()) {
		int a = S[i] - 'a';
		int b = T[i] - 'a';
		if (start[a] != -1 || goal[b] != -1) {
			if (start[a] != b || goal[b] != a) {
				cout << "No" << endl;
				return 0;
			}
		}
		start[a] = b;
		goal[b] = a;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1020
using System;
using System.Linq;

namespace abc046A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);
            if (a == b && b == c)
                Console.WriteLine(1);
            else if (a == b)
                Console.WriteLine(2);
            else if (a == c)
                Console.WriteLine(2);
            else if (b == c)
                Console.WriteLine(2);
            else
                Console.WriteLine(3);
        }
    }
}


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

struct node{
  struct node *r;
  struct node *l;
  struct node *parent;
  int key;
}node;

typedef struct node *Node;

#define NIL NULL

Node root;

Node treeMinimum(Node x){

  while(x -> l != NIL)
    x = x -> l;
  return x;

}

Node treeMaximum(Node x){

  while(x -> r != NIL)
    x = x -> r;
  return x;

}

Node treeSearch(Node x, int k){

  if(x == NIL && k == x ->key) return x;
  if(k < x -> key) return treeSearch(x -> l, k);
  if(k > x -> key) return treeSearch(x -> r, k);

}

Node treeSuccessor(Node x){

  Node y;
  if(x -> r != NIL)return treeMinimum(x -> r);

  y = x -> parent;

  while(y != NIL && x == y -> r){
    x = y;
    y = y -> parent;
  }
  return y;

}

void treeDelete(Node z){

  Node x;
  Node y;

  if(z -> l == NIL || z -> r == NIL) y = z;
  else y = treeSuccessor(z);

  if(y -> l != NIL) x = y -> l;
  else x = y -> r;

  if(x != NIL) x -> parent = y -> parent;

  if(y -> parent == NIL) root = x;
  else if(y == y -> parent -> l) y -> parent -> l = x;
  else y -> parent -> r = x;

  if(y != z) z -> key = y -> key;

}

void insert(int k){

  Node x = root;
  Node y = NIL;
  Node z;

  z = malloc(sizeof(node));

  z -> key = k;
  z -> l = NIL;
  z -> r = NIL;

  while( x != NIL){
    y = x;
    if(z -> key < x -> key) x = x -> l;

    else x = x -> r;
  }
  z -> parent = y;

  if(y == NIL) root = z;

  else if(z -> key < y -> key) y -> l = z;

  else y -> r = z;

}

void inorder(Node x){

  if(x != NIL){
    inorder(x -> l);
    printf(" %d", x -> key);
    inorder(x -> r);
  }

}

void preorder(Node x){

  if(x != NIL){
    printf(" %d", x -> key);
    preorder(x -> l);
    preorder(x -> r);
  }

}

int main(){

  int n, i, x;
  char com[20];

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s",com);

    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    
    else if ( com[0] == 'i' ){
      scanf("%d",&x);
      insert(x);
    }
    
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    
    else if ( com[0] == 'd' ){
      scanf("%d",&x);
      treeDelete(treeSearch(root,x));
    }
  }

  return 0;
  
}



Measured memory_bytes: 25140
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

template<class Ty>
using passive_queue = priority_queue<Ty, vector<Ty>, greater<Ty>>;

struct Problem {

	UL N;
	vector<UL> A;

	bool Solve2(UL K) {
		UL l, r; l = r = N - 1;
		while (l != 0) {
			l--; r++;
			if ((A[l] >= K) == (A[l + 1] >= K)) return A[l] >= K;
			if ((A[r] >= K) == (A[r - 1] >= K)) return A[r] >= K;
		}
		return A[0] >= K;
	}

	void Solve() {
		cin >> N;
		A.resize(N * 2 - 1);
		rep(i, N * 2 - 1) cin >> A[i];
		UL l = 0, r = 2 * N + 1;
		while (l + 1 < r) {
			UL m = (l + r) / 2;
			if (Solve2(m)) l = m; else r = m;
		}
		cout << l << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>

using ll = long long;

//vector
template <class T>
using vec = std::vector<T>;

void solve()
{
    using namespace std;
    
    char a, b;
    cin >> a >> b;

    if ((a == 'D') ^ (b == 'D'))
        cout << "D" << endl;
    else
        cout << "H" << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
void func(int);
int main(void)
{
    int a,b,c,i,cnt;
    scanf("%d %d %d",&a,&b,&c);
    cnt=0;
    i=0;
    while(cnt<c) {
        i++;
        cnt+=a;
        if(i%7==0)  cnt+=b;
    }
    printf("%d\n",i);
    return 0;
}


Measured memory_bytes: 2704
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;

const double EPS=1e-12,PI=3.1415926535897932384626;

void solve(long long N, std::vector<long long> x, std::vector<long long> y){
  const ll t_num = ll(3e5);
  double ans = 0.0;
  rep(t,t_num){
    double si = sin(2*PI*double(t)/double(t_num));
    double co = sqrt(1-si*si-EPS);
    ll ax1, ax2, ay1, ay2;
    ax1 = ax2 = ay1 = ay2 = 0;
    rep(i,N){
      double dx = double(x[i]);
      double dy = double(y[i]);
      if(dx*co+dy*si>=0) ax1 += x[i], ay1 += y[i];
      else ax2 += x[i], ay2 += y[i];
    }
    chmax(ans, sqrt(double(ax1*ax1+ay1*ay1)));
    chmax(ans, sqrt(double(ax2*ax2+ay2*ay2)));
  }
  cout << ans << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  std::vector<long long> x(N);
  std::vector<long long> y(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&x[i]);
    scanf("%lld",&y[i]);
  }
  solve(N, std::move(x), std::move(y));
  return 0;
}


Measured memory_bytes: 640
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	long long n, k;
	cin >> n >> k;

	n %= k;
	long long r = abs(n - k);
	n = min(r, n);
	cout << n << '\n';
}

Measured memory_bytes: 256
use std::cmp::min;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize,
    }
    println!("{}", min(n * a, b));
}


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

//橋と関節点の判定:  O(V + E)
class Lowlink{
public:
  int V;
  vector<vector<int> > G;
  vector<int> ord;           //ord[i] := ノードiに訪れた順番
  vector<int> low;           //low[i] := ノードiから訪れることができる最小のord[j]の値。
  vector<int> articulation;
  int ok;
  
  Lowlink():V(-1),ok(false){};
  Lowlink(int V):V(V),G(V),ok(false){};
  
  void add_edge(int a,int b){
    ok = false;
    assert(a < V && b < V);
    assert(a >=0 && b >= 0);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  void build(int root = 0){
    ok = true;
    ord.clear(); ord.resize(V,-1);
    low.clear(); low.resize(V,-1);
    articulation.clear(); articulation.resize(V,0); /*関節点用*/
    
    int cnt = 0;
    function<int(int,int)> dfs=[&](int pos,int pre){
      ord[pos] = low[pos] = cnt++;
      for(int to:G[pos]) {
        if(to == pre) continue; 
        if(ord[to] != -1) low[pos] = min(low[pos], ord[to]);
        else {
          low[pos] = min(low[pos], dfs(to, pos));
	  
	  /*関節点用*/
	  if(pos == root) articulation[pos]++;
	  else articulation[pos] |= ord[pos] <= low[to];
	  
	}
      }
      return low[pos];
    };
    
    dfs(root , -1);
    articulation[root] = articulation[root] >= 2; /*関節点用*/
  }

  int isBridge(int a,int b){
    assert(ok);
    assert(a < V && b < V);
    assert(a >= 0 && b >= 0);
    if(ord[a] > ord[b]) swap(a, b);
    return ord[a] < low[b];
  }
  
  int isArticulation(int a){
    assert(ok);
    assert(a >= 0 && a < V);
    return articulation[a];
  }
};


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  auto verifyBridge=[&]{
    int V, E;
    cin>>V>>E;
  
    Lowlink A(V);
    for(int i=0;i<E;i++){
      int a,b;
      cin>>a>>b;
      A.add_edge(a,b);
    }
    
    A.build();
    
    typedef pair<int,int> P;
    vector<P> ans;
    for(int i=0;i<V;i++)
      for(int to:A.G[i]) if(i < to && A.isBridge(i, to)) ans.push_back(P(i, to));
    
    sort(ans.begin(),ans.end());
    for(auto a:ans) cout<<a.first<<" "<<a.second<<endl;
  };

  auto verifyArticulationPoint=[&]{
    int V, E;
    cin>>V>>E;
  
    Lowlink A(V);
    for(int i=0;i<E;i++){
      int a,b;
      cin>>a>>b;
      A.add_edge(a,b);
    }
    A.build();
    for(int i=0;i<V;i++) if(A.isArticulation(i)) cout<<i<<endl;

  };
  
  //verifyBridge();
  verifyArticulationPoint();
  return 0;
}



Measured memory_bytes: 4912
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
 

signed main(){
	
	int n,m;
	pair<int,int> s[111111];
	
	cin>>n>>m;
	rep(i,n){
		cin>>s[i].second>>s[i].first;
	}
	sort(s,s+n,greater<>());
	
	priority_queue<int,vector<int>,greater<int>> pque;
	
	int net[111111]={0};
	int co=0;
	int sans=0;//カンストしたおいしさポイント
	int ans;
	
	for(int i=0;i<m;i++){
		sans+=s[i].first;
		if(net[s[i].second]==0)co++;
		else pque.push(s[i].first);//同じ種類が2つ目以降をプッシュ(取り換えるかも)
		net[s[i].second]++;
	}
	ans=sans+co*co;
	for(int i=m;i<n;i++){
	    if(pque.empty())break;
		if(net[s[i].second]==0){
			sans-=pque.top();
			pque.pop();
			sans+=s[i].first;
			int ke=ans;
			ans=max(ans,sans+(co+1)*(co+1));
			//int a=sans+(co+1)*(co+1);
			//DEB(a)END
			if(ke<=ans){
			    net[s[i].second]++;
			    co++;
			}
			//DEB(ans)END
		}
	}
	//cout<<co<<endl;
	cout<<ans<<endl;
	
}

Measured memory_bytes: 3452
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)

struct cmp
{
    template <typename T, typename U>
    bool operator()(T const &left, U const &right)
    {
        if (left.second < right.second)
            return true;
        return false;
    }
};

int edgeTo[100000 + 5];
int distTo[100000 + 5];
set<pair<int, int>> pq;
void relax(int from, int to, int weight)
{
    if (distTo[to] > distTo[from] + weight)
    {
        pair<int, int> backup = {to, distTo[to]};
        distTo[to] = distTo[from] + weight;
        edgeTo[to] = from;
        if (pq.find(backup) != pq.end())
        {
            pq.erase(backup);
            pq.insert({to, distTo[to]});
        }
        else
        {
            pq.insert({to, distTo[to]});
        }
    }
}

void dijsktra(vector<vector<pair<int, int>>> g, int s)
{
    int n = g.size();
    for (int i = 0; i < n + 1; i++)
    {
        distTo[i] = 2147483647;
    }

    distTo[s] = 0;
    pq.insert({s, 0});
    while (!pq.empty())
    {
        auto it = pq.end();
        it--;
        pair<int, int> top = *it;
        pq.erase(*it);
        for (pair<int, int> e : g[top.first])
        {
            relax(top.first, e.first, e.second);
        }
    }
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> graph(n + 1);
    rep(i, 1, m + 1)
    {
        int a, b;
        cin >> a >> b;
        graph[a].push_back({b, 1});
        graph[b].push_back({a, 1});
    }
    dijsktra(graph, 1);

    cout << "Yes" << endl;
    rep(i, 2, n + 1)
    {
        cout << edgeTo[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 23248
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

int main() {
  long long N;
  cin >> N;
  long long key;
  for(long long i = 1; i * i <= N; i++) {
    if(N % i == 0) {
      key = i;
    }
  }
  long long ans = key + N / key - 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			int a = sc.nextInt();
			int t = 0;
			int h = 0;

			for (int i = 0; i < a; i++) {
				String taro = sc.next();
				String hana = sc.next();

				if (taro.compareTo(hana) > 0) {
					t += 3;
				} else if (hana.compareTo(taro) > 0) {
					h += 3;
				} else {
					t += 1;
					h += 1;
				}
			}
			System.out.println(t + " " + h);
		}
	}
}


Measured memory_bytes: 29996
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# n^p(mod m) -- START --
def powMod(n,p,m):
  if p==0:
    return 1
  if p%2==0:
    t=powMod(n,p//2,m)
    return t*t%m
  return n*powMod(n,p-1,m)%m
# n^p(mod m) --- END ---

def main():
  n,a,b=LI()

  ans=powMod(2,n,mod)
  ans-=1
  ans%=mod

  pattern_a1=1
  for i in range(a):
    pattern_a1*=n-i
    pattern_a1%=mod
  pattern_a2=1
  for i in range(1,a+1):
    pattern_a2*=i
    pattern_a2%=mod
  pattern_a=pattern_a1*pow(pattern_a2,mod-2,mod)

  pattern_b1=1
  for i in range(b):
    pattern_b1*=n-i
    pattern_b1%=mod
  pattern_b2=1
  for i in range(1,b+1):
    pattern_b2*=i
    pattern_b2%=mod
  pattern_b=pattern_b1*pow(pattern_b2,mod-2,mod)

  ans-=pattern_a
  ans%=mod
  if ans<0:
    ans+=mod
  ans-=pattern_b
  ans%=mod
  if ans<0:
    ans+=mod

  return ans

# main()
print(main())


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

int main(void){
  int a[12] = {1,3,1,2,1,2,1,1,2,1,2,1};

  int x,y;
  scanf("%d", &x);
  scanf("%d", &y);

  if (a[x-1]==a[y-1]) {
    printf("Yes");
  }else{
    printf("No");
  }

  return 0;
}


Measured memory_bytes: 256
/*
** Author: MAC45
*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.tie(0);
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt","wt",stdout);
    int K, A, B;
    cin >> K >> A >> B;
    int rem = A % K;
    if (rem != 0 && K - rem + A > B)
        cout << "NG" << endl;
    else
        cout << "OK" << endl;
    return 0;
}


Measured memory_bytes: 3648
<?php
    fscanf(STDIN, "%d %d", $n, $l);
    $str_list = [];
    for ($i = 0; $i < $n; $i++) {
        fscanf(STDIN, "%s", $str_list[]);
    }
    
    sort($str_list);
    
    $result = "";
    
    foreach ($str_list as $str) {
        $result .= $str;
    }
    
    echo $result;
?>

Measured memory_bytes: 3576
//https://qiita.com/tanakh/
#[allow(unused_macros)]
macro_rules! input {
	(source = $s:expr, $($r:tt)*) => {
		let mut iter = $s.split_whitespace();
		let mut next = || { iter.next().unwrap() }; 
		input_inner!{next, $($r)*}
	};
	($($r:tt)*) => {

		let stdin = std::io::stdin();
		let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); 
		let mut next = move || -> String{
			bytes
				.by_ref()
				.map(|r|r.unwrap() as char) 
				.skip_while(|c|c.is_whitespace()) 
				.take_while(|c|!c.is_whitespace()) 
				.collect()
			};
	input_inner!{next, $($r)*} 
	};
}

#[allow(unused_macros)]
macro_rules! input_inner { 
	($next:expr) => {}; 
	($next:expr, ) => {};

	($next:expr, $var:ident : $t:tt $($r:tt)*) => { 
		let $var = read_value!($next, $t); 
		input_inner!{$next $($r)*}
	}; 
}
#[allow(unused_macros)]
macro_rules! read_value { 
	($next:expr, ( $($t:tt),* )) => {
		( $(read_value!($next, $t)),* ) 
	};
	
	($next:expr, [ $t:tt ; $len:expr ]) => {
		(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
	};

	($next:expr, chars) => {
		read_value!($next, String).chars().collect::<Vec<char>>()
	};
	
	($next:expr, bytes) => {
		read_value!($next, String).into_bytes()
	};
	
	($next:expr, usize1) => { 
		read_value!($next, usize) - 1
	};

	($next:expr, $t:ty) => {
		$next().parse::<$t>().expect("Parse error")
	};
}

fn main(){
    input!{
        a : i64,
        b : i64,
        t : i64,
    }
    let mut tmp : i64 = 0;
    let mut ans : i64 = 0;
    tmp = t / a;
    ans = tmp * b;
    println!("{}",ans);
}

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

#define INF 9999999999999

int main(){
  long long x;
  int limit;
  int i;
  int min = INF;
  long long a,b;
  int flag = 0;

  scanf("%lld", &x);

  limit = sqrt(x);
  a = INF;
  b = INF;

  for(i = 2;i <= limit;i++){
    if(x % i == 0){
      a = i;
      b = x/i;
      flag = 1;
    }

    if(a + b < min){
      min = a + b;
    }
  }

  if(flag == 1) printf("%lld\n", a + b - 2);

  else printf("%lld\n", x - 1);

  return 0;
}


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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    int a,b,c;
    cin>>a>>b>>c;
    int ans = max(0,c-(a-b));
    cout<<ans<<endl;

}


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

int s[MAX];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		s[temp - 1] = i;
	}

	for (int i = 0; i < n; i++) {
		cout << (s[i] + 1);
		if (i != n - 1) {
			cout << " ";
		}
		else
		{
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1152
#include <vector>
#include <string.h>
#include<iostream>
#include<set>
#include<map>
#include<unordered_map>
#include<string.h>
#include<algorithm>
#include <stdlib.h>
using namespace std;

const int mod=1e9+7;
typedef long long ll;

#define out_vector(v) for(auto a:v)cout<<a<<" "; cout<<endl;



int main()
{
    int n,m;
    cin>>n>>m;
    ll X=0,Y=0;
    vector<ll>x(n),y(m);
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    for(int i=0;i<m;i++){
        cin>>y[i];
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    for(int i=0;i<n;i++){
        X+=i*x[i]-(n-1-i)*x[i];
        X%=mod;
    }
    for(int i=0;i<m;i++){
        Y+=i*y[i]-(m-1-i)*y[i];
        Y%=mod;
    }
    ll ans=(X*Y)%mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(int argc, char *argv[]){  
	int n,i,j;
	cin >> n;
	int c[n],s[n],f[n];
	for(i=0;i<n-1;i++)
		cin >> c[i] >> s[i] >> f[i];
	for(i=0;i<n-1;i++){
		int t=s[i];
		for(j=i;j<n-1;j++){
			if(t<s[j]) t=s[j];
			if(t%f[j]!=0) t+=f[j]-t%f[j];
			t+=c[j];
		}
		cout << t << endl;
	}
	cout << 0 << endl;
	return 0;
}

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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  s += '.';
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == s[i + 1]) {
      cout << i + 1 << ' ' << i + 2 << '\n';
      return 0;
    }
    if (s[i] == s[i + 2]) {
      cout << i + 1 << ' ' << i + 3 << '\n';
      return 0;
    }
  }
  cout << "-1 -1" << '\n';
  return 0;
}

Measured memory_bytes: 512