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

int main() {
  int N;
  cin >> N;
  tuple<int, string, int> SP[N];
  for (int i = 0; i < N; i++) {
    get<0>(SP[i]) = i + 1;
    cin >> get<1>(SP[i]) >> get<2>(SP[i]);
  }
  sort(SP, SP + N, [](tuple<int, string, int> A, tuple<int, string, int> B) {
    if (get<1>(A) == get<1>(B))
      return get<2>(A) > get<2>(B);
    else
      return get<1>(A) < get<1>(B);
  });

  for (int i = 0; i < N; i++) cout << get<0>(SP[i]) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(b==1) return a;else if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n);
    vector<pair<int,int>> vec(n);
    int d=0,ans=0;
    rep(i,n){
        in(vec[i].first,vec[i].second);
        if(vec[i].first==vec[i].second){
            d++;
            ans=max(ans,d);
        }else{
            d=0;
        }
    }
    yn(ans>=3);
}

Measured memory_bytes: 3676
from collections import defaultdict
N = int(input())
S = defaultdict(int)
S2 = []
max = 0
for _ in range(N):
    s = input()
    S[s] += 1
    if max < S[s]:
        max = S[s]
for k, v in sorted(S.items(), key=lambda x: -x[1]):
    if max == v:
        S2.append(k)
    else:
        break
for s in sorted(S2):
    print(s)

Measured memory_bytes: 43484
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var w = Console.ReadLine();
        var dic = new Dictionary<char, int>();
        foreach (var item in w)
        {
            if (dic.ContainsKey(item))
                dic[item]++;
            else
                dic.Add(item, 1);
        }
        var isok = true;

        foreach (var item in dic)
        {
            if (item.Value % 2 == 1)
                isok = false;
        }
        Console.WriteLine(isok ? "Yes" : "No");
    }

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<long> SplittedStringToInt64List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;

  
  

    public static void PrintArray(int[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            var sb = new StringBuilder();
            for (int j = 0; j < array.GetLength(1); j++)
            {
                sb.Append(array[i, j]).Append(" ");
            }
            Console.WriteLine(sb.ToString());
        }
    }

    #endregion
}



Measured memory_bytes: 13152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string s;
    cin>>s;
    if(s=="ABC"){
        cout<<"ARC";
    }else{
        cout<<"ABC";
    }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101010];
ll S[101010];
ll mo=1000000007;

const int NUM_=400001;
static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	inv[1]=fact[0]=factr[0]=1;
	for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
	for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	
	cin>>N;
	FOR(i,N) {
		cin>>A[i];
		S[i+1]=(S[i]+A[i])%mo;
	}
	
	// all
	ll ret=S[N];
	
	for(i=1;i<N;i++) {
		// left;
		(ret+=S[i]*inv[i+1])%=mo;
		// right
		(ret+=(mo+S[N]-S[N-i])%mo*inv[i+1])%=mo;
	}
	
	
	ll add=0;
	for(i=1;i<N-1;i++) {
		(add += 2*inv[i+2]*inv[i+1])%=mo;
	}
	for(i=1;i<N-1;i++) {
		(ret += mo-add*S[i]%mo)%=mo;
		(add +=mo- 2*inv[N-i+1]*inv[N-i]%mo)%=mo;
	}
	for(i=1;i<N-1;i++) {
		(add += 2*inv[i+2]*inv[i+1])%=mo;
	}
	for(i=1;i<N-1;i++) {
		(ret += add*S[N-i]%mo)%=mo;
		(add +=mo- 2*inv[N-i+1]*inv[N-i]%mo)%=mo;
	}
	
	cout<<(ret*fact[N]%mo)<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 10880
X, N = map(int, input().split())
p = list(map(int, input().split()))


if N == 0:
    print(X)
    exit()

for i in range(102):
    if X - i not in p:
        print(X - i)
        exit()
    
    if X + i not in p:
        print(X + i)
        exit()


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using lP = pair<ll, ll>;
const int inf{int(1e9)};
int main(void){
  int N;
  cin >> N;
  vector <ll> a(N), b(N), x(N), y(N);
  rep(i,N){
    cin >> a[i] >> b[i];
    x[i] = a[i] + b[i];
    y[i] = a[i] - b[i];
  }
  ll x_ = *max_element(all(x)) - *min_element(all(x));
  ll y_ = *max_element(all(y)) - *min_element(all(y));
  ll ans = max(x_, y_);
  cout << ans << endl;

  // 誤り
  // vector <ll> sum(N);
  // rep(i,N) sum[i] = p[i].first + p[i].second;
  // // cのmaxとminが同じ場合
  // if (*max_element(all(sum)) == *min_element(all(sum))){
  //   sort(all(p));
  //   cout << (p[N-1].first - p[0].first) * 2 << endl;
  //   return 0;
  // }else{
  //   int mn = min_element(all(sum)) - sum.begin();
  //   int mx = max_element(all(sum)) - sum.begin();
  //   ll ans = abs(p[mx].first - p[mn].first) + abs(p[mx].second - p[mn].second);
  //   cout << ans << endl;
  // }
  return 0;
}


Measured memory_bytes: 9600
N = input()
o = []
for i in range(int(N)):
    o.append(input())
total  = 0
for i in range(int(N)):
    x = o[i].split(" ")[0]
    v = o[i].split(" ")[1]
    if v == "JPY":
        total += float(x)
    else:
        total +=  float(x) * 380000.0
print(total)

Measured memory_bytes: 3060
abm = [int(n) for n in input().split()]

a = abm[0]
b = abm[1]
m = abm[2]
am, bm = 1000000, 1000000
al = [int(n) for n in input().split()]
bl = [int(n) for n in input().split()]
for i in al:
    if am > i:
        am = i
for i in bl:
    if bm > i:
        bm = i
ans = am + bm

for i in range(m):
    x, y, c = map(int, input().split())
    x = x - 1
    y = y - 1
    cur = al[x] + bl[y] - c
    if cur < ans:
        ans = cur

print(ans)

Measured memory_bytes: 18572
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct UnionFind {
  std::vector<int> parent;
  int __size;
  UnionFind(int n) : parent(n, -1), __size(n) {}
  void unite(int x, int y) {
    if ((x = root(x)) != (y = root(y))) {
      if (parent[y] < parent[x]) { std::swap(x, y); }
      parent[x] += parent[y];
      parent[y] = x;
      __size--;
    }
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
  int size(int x) { return -parent[root(x)]; }
  int size() { return __size; }
};

int main() {
  int N, M; cin >> N >> M;
  UnionFind uf_tree(N);

  while (M--) {
    int X, Y, Z; cin >> X >> Y >> Z;
    X--; Y--;
    uf_tree.unite(X, Y);
  }
  cout << uf_tree.size() << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextLong();
		// 最大公約数求める
		long l = a[0];
		for(int i = 1 ; i < n ; i++) {
			l = lcm(l, a[i]);
		}
		System.out.println(l);
	}

	public static long gcd(long a, long b) {
		if(b == 0) return a;
		if(a < b) {
			long temp = a;
			a = b;
			b = temp;
		}
		return gcd(b, a % b);
	}

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}


}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, max1 = INT_MIN, max2 = INT_MIN;
    cin>>n;
    int arr[n];
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
        if(arr[i] >= max1)
            max2 = max1, max1 = arr[i];
        else if(arr[i] >= max2 && arr[i] < max1)
            max2 = arr[i];
    
        // cout<<max1<<" "<<max2<<"\n";
    }    
        
    for(int i=0; i<n; i++)
    {
        if(max1 == arr[i])
            cout<<max2;
        else
            cout<<max1;
        cout<<"\n";
    }
    
}

Measured memory_bytes: 2432
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <climits>
#include <complex>
using namespace std;

typedef long long ll;
typedef complex<double> P;

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
const double INF = 99999;

double cross(P a,P b){
  return imag(conj(a) * b);
}

double dot(P a,P b){
  return real(conj(a) * b);
}

int ccw(P a,P b,P c){
  b -= a;
  c -= a;
  if(cross(b,c) > 0) return 1;
  if(cross(b,c) < 0) return -1;
  if(dot(b,c) < 0) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

bool intersectSS(P a,P b,P c,P d){
  return
    ccw(a,b,c) * ccw(a,b,d) <= 0 &&
    ccw(c,d,a) * ccw(c,d,b) <= 0;
}

bool intersectSP(P a,P b,P p){
  return abs(a-p) + abs(b-p) - abs(b-a) < EPS;
}

P crosspoint(P a,P b,P c,P d){
  double A = cross(b-a,d-c);
  double B = cross(b-a,b-c);
  return c + B / A * (d - c);
}

int n;
char dch[150];
P from[150],to[150];

void getNext(P &now,P &dp,P p,int mirror){
  dp = now;

  if(dch[mirror] == 'y'){
    double dist = abs(now.imag() - p.imag());
    if(now.imag() > p.imag()){
      dp.imag() -= dist * 2;
    }
    else{
      dp.imag() += dist * 2;
    }
  }
  else{
    double dist = abs(now.real() - p.real());
    if(now.real() > p.real()){
      dp.real() -= dist * 2;
    }
    else{
      dp.real() += dist * 2;
    }
  }
  now = p;
  dp = now + INF * (dp - now);
}

int main(){
  while(cin>>n,n>=0){
    rep(i,n){
      double x,y;
      cin>>dch[i]>>x>>y;
      from[i] = P(x,y);
      to[i] = (dch[i] == 'x' ? P(x+1,y) : P(x,y+1));
    }

    from[n] = to[n+3] = P(0,0);
    from[n+1] = to[n] = P(8,0);
    from[n+2] = to[n+1] = P(8,8);
    from[n+3] = to[n+2] = P(0,8);

    P now(0.75,0.25);
    P dp = now + INF * (P(1,0.5) - now);
    bool himself = false;

    while(1){
      int minIdx = -1;
      P minP;
      double minDist = INF;

      rep(i,n){
        if(intersectSS(from[i],to[i],now,dp)){
          P p = crosspoint(from[i],to[i],now,dp);
          double dist = abs(p - now);
          if(dist > EPS && dist < minDist){
            minIdx = i;
            minDist = dist;
            minP = p;
          }
        }
      }
      if(intersectSP(now,dp,P(0.75,0.25))){
        double dist = abs(P(0.75,0.25) - now);
        if(dist > EPS && dist < minDist){
          himself = true;
          break;
        }
      }
      if(minIdx == -1) break;

      getNext(now,dp,minP,minIdx);
    }

    if(himself){
      printf("75 25\n");
      continue;
    }

    rep(i,4){
      if(intersectSS(from[n+i],to[n+i],now,dp)){
        P p = crosspoint(from[n+i],to[n+i],now,dp);
        if(abs(p - now) < EPS) continue;
        printf("%d %d\n",(int)(p.real()*100),(int)(p.imag()*100));
      }
    }
  }
}

Measured memory_bytes: 0
import sys

import numpy as np

readline = sys.stdin.buffer.readline


def main():
    H, W = map(int, readline().split())
    A = np.array([
        list(map(lambda x: int(x) % 2,
                 readline().split())) for _ in range(H)
    ])

    aa = []
    for h in range(H):
        for w in range(W - 1):
            if A[h, w] == 1:
                A[h, w + 1] += 1
                aa.append([h + 1, w + 1, h + 1, w + 2])

    for h in range(H - 1):
        w = W - 1
        if A[h, w] % 2 != 0:
            A[h + 1, w] += 1
            aa.append([h + 1, w + 1, h + 2, w + 1])

    print(len(aa))

    for a in aa:
        print(*a)


main()


Measured memory_bytes: 38964
#include<iostream>
#include<string>
using namespace std;
int n,c;string S;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>S;if(S=="A")c++;else c--;
        if(c<0){cout<<"NO"<<endl;return 0;}
    }
    if(c==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>

int main() {
	int n, a, b;
	std::cin >> n >> a >> b;
	int nSum = 0;
	for (int i =1 ;i <= n;i++) {
		if (i<10) {
			if (i >= a&&i <= b) {
				nSum += i;
			}
		}
		else if (i >= 10 && i < 100) {
			if (i / 10 + i % 10 >= a&&i / 10 + i % 10 <= b) {
				nSum += i;
			}
		}
		else if (i >= 100 && i < 1000) {
			int c = i % 100;
			if (i / 100 + c / 10 + c % 10 >= a&&i / 100 + c / 10 + c % 10<= b) {
				nSum += i;
			}
		}
		else if(i>=1000&&i<10000) {
			int d = i % 1000;
			int e = d % 100;
			if (i / 1000 + d / 100 + e / 10 + e % 10 >= a&&i / 1000 + d / 100 + e / 10 + e % 10 <= b) {
				nSum += i;
			}
		}
		if (i == 10000) {
			if (1 >= a&&b <= b) {
				nSum += i;
			}
		}
	}
	std::cout << nSum << std::endl;

	return 0;
}

Measured memory_bytes: 256
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}



const ll N=2e5+5;


int main()
{ 

IOS;

ll n;cin>>n;

string s;cin>>s;

ll cr=0;

for(int i=0;i<n;i++){
if(s[i]=='R')cr++;
}

ll ir=0;

for(int i=0;i<cr;i++){
  if(s[i]!='R')ir++;
}

cout<<ir;


//end_routine();

return 0;
 
 }


Measured memory_bytes: 3800
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    H, W, A, B = LI()

    ans = [['0'] * W for _ in range(H)]
    for i in range(H):
        for j in range(W):
            if i < B and j < A or i >= B and j >= A:
                ans[i][j] = '1'

    for i in ans:
        print(''.join(i))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 17772
n = int(input())
s = input()
count = [0 for _ in range(n)]

west, east = 0, 0
for i, j in enumerate(s):
    count[i] += west
    if j == 'W':
        west += 1

for i, j in enumerate(s[::-1]):
    count[-i-1] += east
    if j == 'E':
        east += 1

print(min(count)        )


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

using namespace std;

typedef long long LL;
typedef pair<LL , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 100010;
const LL mod = 1e9 + 7;
const LL INF = 20123456789012345;
int N,M,S,T;
LL z[MC];
vector<P2> V[MC];
priority_queue<P2 , vector<P2> , greater<P2> > Q;
LL ans_s[MC] , ans_t[MC];
int r[MC];

int main(){
	cin >> N >> M;
	cin >> S >> T;
	repp(i,0,M){
		int x,y;
		LL d;
		cin >> x >> y >> d;
		d *= 2;
		V[x].PB(MP(d,y));
		V[y].PB(MP(d,x));
	}
	fill(z,z+MC,INF);
	z[S] = 0;
	Q.push(MP(0,S));
	while(!Q.empty()){
		int x = Q.top().second; Q.pop();
		for(auto u : V[x]){
			if(z[u.second] > z[x] + u.first){
				z[u.second] = z[x] + u.first;
				Q.push(MP(z[u.second],u.second));
			}
		}
	}
	LL c = z[T] / 2;
	ans_s[S] = 1;
	ans_t[T] = 1;
	repp(i,0,N) r[i] = i+1;
	sort(r,r+N,[&](const int &x , const int &y){return z[x] < z[y];});
	repp(i,0,N){
		for(auto u : V[r[i]]){
			if(z[u.second] == z[r[i]] + u.first){
				(ans_s[u.second] += ans_s[r[i]]) %= mod;
			}
		}
	}
	repm(i,N-1,-1){
		for(auto u : V[r[i]]){
			if(z[u.second] + u.first == z[r[i]]){
				(ans_t[u.second] += ans_t[r[i]]) %= mod;
			}
		}
	}
	LL ans0 = 0 , ans1 = 0;
	repp(i,1,N+1){
		if(z[i] == c){
			LL w = ans_s[i] * ans_t[i] % mod;
			(ans0 += w) %= mod;
			(ans1 += w * w) %= mod;
		} else if(z[i] < c){
			for(auto u : V[i]) if(z[u.second] == z[i] + u.first && z[u.second] > c){
				LL w = ans_s[i] * ans_t[u.second] % mod;
				(ans0 += w) %= mod;
				(ans1 += w * w) %= mod;
			}
		}
	}
	cout << (ans0 * ans0 % mod - ans1 + mod) % mod << endl;
	return 0;
}


Measured memory_bytes: 16504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=103,INF=1<<30;

int BFS(string s,string t,vector<string> &from,vector<string> &to){
    map<string,int> MA;
    queue<string> Q;
    Q.push(s);
    MA[s]=1;
    
    while(!Q.empty()){
        string a=Q.front();Q.pop();
        
        for(int i=0;i<from.size();i++){
            string b;
            for(int j=0;j<a.size();){
                if(j+from[i].size()-1<a.size()&&string(a.substr(j,from[i].size()))==from[i]){
                    b+=to[i];
                    j+=from[i].size();
                }else{
                    b+=a[j];
                    j++;
                }
            }
            
            if(a==b) continue;
            if(b.size()>t.size()) continue;
            
            if(MA[b]==0||MA[a]+1<MA[b]){
                MA[b]=MA[a]+1;
                Q.push(b);
            }
        }
    }
    
    return MA[t]-1;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        vector<string> from(N),to(N);
        for(int i=0;i<N;i++) cin>>from[i]>>to[i];
        string S,T;cin>>S>>T;
        cout<<BFS(S,T,from,to)<<endl;
    }
}






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

int main( void )
{
    int r;
    cin >> r;
    if ( r < 1200 )
    {
        cout << "ABC" << endl;
    }
    else if ( r < 2800 )
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "AGC" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;



int main() {
	string s, t;
	cin >> s >> t;
	vector<int> rs(26, -1);
	vector<int> rt(26, -1);

	bool canTrans = true;
	for (int i = 0; i < s.length(); i++) {
		

		if (rs[s[i] - 'a'] >= 0) {

			if (rs[s[i] - 'a'] != t[i]) {
				canTrans = false;
				break;
			}
		}

		if (rt[t[i] - 'a'] >= 0) {
			if (rt[t[i] - 'a'] != s[i]) {
				canTrans = false;
				break;
			}
		}
		if (rs[s[i] - 'a'] < 0) {
			rs[s[i] - 'a'] = t[i];
		}
		if (rt[t[i] - 'a'] < 0) {
			rt[t[i] - 'a'] = s[i];

		}


	}
	cout << (canTrans ? "Yes" : "No") << endl;

}

Measured memory_bytes: 776
#include<iostream>
using namespace std;
int main()
{
	int A, B;
	cin>>A>>B;
	int ans = -1;
	for(int i=1;i<11000;i++)
	{
		int x = i*0.08;
		int y = i*0.1;
		if(x==A && y==B)
		{
			ans = i;
			break;	
		} 
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())

dp = [[h*w for i in range(w+1)] for j in range(h+1)]

dp[0][1] = 0
dp[1][0] = 0

for i in range(h):
    for j in range(w):
        # print("i", i, "j", j, "s[i][j]", s[i][j])
        # print(s[i][j] == '#' and (i == 0 or s[i-1][j] == '.'))
        
        #前の道が（"."またはグリッド外）かつ現在地が#の場合に1を加える
        #前の道が"#"であればまとめて変換できるので何も加えない
        dp[i+1][j+1] = min(
            dp[i][j+1] + (s[i][j] == '#' and (i == 0 or s[i-1][j] == '.')),
            dp[i+1][j] + (s[i][j] == '#' and (j == 0 or s[i][j-1] == '.'))
        )

print(dp[-1][-1])


Measured memory_bytes: 3444
/*
Hokudai Practice Contest 2014
A - King's Inspection

ティツァツ」テヲツウツ陛ッツシツ堙」ツつキテ」ツδ淌」ツδ・テ」ツδャテ」ツδシテ」ツつキテ」ツδァテ」ツδウ
テヲツ崢クテ」ツ?凝」ツつ古」ツ?ヲテ」ツ??」ツつ凝」ツδォテ」ツδシテ」ツδォテ」ツ?ォテ・ツセツ禿」ツ?」テ」ツ?ヲテ・ツセツゥテ・ツ?ε」ツ?凖」ツつ凝」ツ??」ツ?妥」ツ??
テ」ツδォテ」ツδシテ」ツδォテ」ツつ津・ツ?催ァツ渉セテ」ツ?凖」ツつ凝」ツ?淌」ツつ?」ツ?ォテ」ツ?ッテ」ツδェテ」ツつケテ」ツδ暗」ツ?ョテ・ツセツェテァツ陳ーテ」ツつ?ヲツ鳴?・ツュツ療」ツ?ョテ・ツセツェテァツ陳ーテ」ツつ津・ツ?催ァツ渉セテ」ツ?凖」ツつ凝・ツソツ?ィツヲツ?」ツ?古」ツ?づ」ツつ凝」ツ??
(M-1)+1 -> 0, 0-1 -> (M-1)テ」ツ??」ツ?ィテ」ツ?ェテ」ツつ凝」ツつ暗」ツ??」ツ?ォテ」ツ?凖」ツつ凝」ツ?ォテ」ツ?ッテ」ツ??・ツ可ーテ、ツスツ?%)テ」ツつ津ァツ板ィテ」ツ??」ツつ古」ツ?ーテ」ツつ暗」ツ??」ツ??

テヲツ卍づゥツ鳴禿ィツィツ暗ァツョツ療ゥツ?湘ッツシツ唹(|s|)
テァツゥツコテゥツ鳴禿ィツィツ暗ァツョツ療ゥツ?湘ッツシツ唹(n + |s|)
*/

#include<iostream>
#include<cctype>
using namespace std;

//a-zA-z -> テゥツ??ァツ閉ェ
int toInt(char a){
  if(islower(a))return a-'a';
  return a-'A'+26;
}

//テゥツ??ァツ閉ェ -> a-zA-Z
char toChar(int a){
  if(a<26)return 'a'+a;
  return 'A'+a-26;
}

//テゥツァツ?ヲツ閉ー
const int M = 52;

int main(){
  int n,k[100];
  string s;

  while(cin >> n,n){
    for(int i=0;i<n;i++)cin >> k[i];
    cin >> s;

    for(int i=0;i<(int)s.size();i++){
      //テ・ツセツェテァツ陳ーテ」ツつ津」ツつキテ」ツδ淌」ツδ・テ」ツδャテ」ツδシテ」ツつキテ」ツδァテ」ツδウテ」ツ?凖」ツつ凝」ツ?ォテ」ツ?ッmodテ」ツつ津、ツスツソテ」ツ?暗」ツ?ーティツ可ッテ」ツ??
      int tmp = toInt(s[i]) - k[i%n];
      //ティツイツ?ヲツ閉ーテ」ツつづ」ツ?づ」ツつ甘・ツセツ療」ツつ凝・ツ?エテ・ツ青暗」ツ?ョテ・ツョツ嘉・ツ?ィテ」ツ?ェmodテ」ツ?ョテ・ツ渉姪」ツつ甘ヲツ鳴ケテ」ツ?ッ((x%mod) + mod)%mod
      tmp = ((tmp%M) + M) % M;
      cout << toChar(tmp);
    }
    cout << endl;
  }
}

Measured memory_bytes: 1196
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    string s;
    cin >> s;
    const string target = "AKIHABARA";

    bool success = true;

    int index = 0;
    for (int i = 0; i < target.size(); i++)
    {
        if (target[i] == 'A')
        {
            if (s[index] == 'A')
            {
                index++;
            }
        }
        else
        {
            if (target[i] != s[index])
            {
                success = false;
            }
            index++;
        }
    }
    if (index != s.size())
    {
        success = false;
    }

    cout << (success ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n , d , count=0;
    cin>>n>>d;
    for(int i=1;i<=n;i++)
    {
        long long int x , y;
        cin>>x>>y;
        if(x*x+y*y<=d*d)
            count++;
    }
    cout<<count;
}

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


int main() {

    ll a, b;
    int k;
    cin >> a >> b >> k;
    for (ll i = a; i <= b; ++i) {
        if (i < a + k || i > b - k) cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N,D;

int X[20][20];

bool distance(int i,int j) {
    double sum = 0;
    for(int d = 0;d < D;d++) {
        sum += (X[i][d]-X[j][d])*(X[i][d]-X[j][d]);
    }
    sum = sqrt(sum);

    return ceil(sum) == floor(sum) ? true : false;
}
    
int main(void) {
    cin>>N>>D;

    for(int i = 0;i < N;i++) {
        for(int j = 0;j < D;j++) {
            cin>>X[i][j];
        }
    }

    int ans = 0;
    for(int i = 0;i < N;i++) {
        for(int j = i+1;j < N;j++) {
            if(distance(i,j)) {
                ans++;
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 256
import math
TAX = 1.08
N = int(input())
num = N / TAX
numf = math.floor(num)
numc = math.ceil(num)
if math.floor(numf * TAX) == N:
    print(numf)
elif math.floor(numc * TAX) == N:
    print(numc)
else:
    print(':(')

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

typedef pair <int, int> ii;

int n, k;
int a[200005];
int ans;

bool isPossible(int v) {
	int cur = 0;
	for (int i = 0; i < n; i++) {
		cur += (a[i] - 1) / v;
	}
	return cur <= k;
}

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	int lo = 1, hi = 1000000000, mid;
	while (lo <= hi) {
		mid = (lo + hi) / 2;
		if (isPossible(mid)) {
			hi = mid - 1;
			ans = mid;
		} else lo = mid + 1;
	}
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;

const int N = 51;

set<long long> to[N][N];

int a[N], b[N];

int main() {
  for (int i = N-1; i >= 0; --i) {
    for (int j = i-1; j > 0; --j) {
      int t = i % j;
    }
    to[i][i].insert(0);
    for (int j = i; j > 0; --j) {
      for (long long x : to[i][j]) {
        for (int k = j; k > 0;--k) {
          int t = j % k;
          to[i][t].insert(x | (1LL << k));
        }
      }
    }
  }
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
  }
  bool ok = 1;
  for (int i = 0; i < n; ++i) {
    scanf("%d", b+i);
    if (to[a[i]][b[i]].empty())
      ok = 0;
    // for (long long x : to[a[i]][b[i]])
    //   cerr << a[i] << " " << b[i] << " " << x << endl;
  }
  if (!ok) {
    puts("-1");
    return 0;
  }
  long long now = (1LL << 51) - 1;
  for (int i = 50; i >= 0; --i) {
    now ^= 1LL << i;
    bool ok = 1;
    for (int j = 0; j < n; ++j) {
      ok = 0;
      for (long long x : to[a[j]][b[j]]) {
        if ((x & now) == x)
          ok = 1;
      }
      if (!ok) break;
    }
    if (!ok)
      now ^= 1LL << i;
  }
  cout << now << endl;
  return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<map>
#include<cstdio>
using namespace std;

int main()
{
	int n,m,max=0;
	cin >> n;
	string temp,str;
	map<string,int> my;
	for(int i = 0; i < n; i++) {
		cin >> temp;
		map<string,int>::iterator it;
		it = my.begin();
		while(it != my.end())
		{
			if(it->first == temp) {
				my[temp]++;
				break;
			}
			it++;
		}
		if(it == my.end()) {
			my[temp] = 1;
		}
	}
	cin >> m;
	for(int i=0;i<m;i++)
	{
		cin>>str;
		map<string,int>::iterator it;
		it = my.begin();
		while(it!=my.end())
		{
			if(it->first == str)
			{
				my[str]--;
				break;
			}
			it++;
		}
	}
	map<string,int>::iterator it;
	it = my.begin();
	while(it!=my.end())
	{
		if(it->second>max)
			max=it->second;
        it++;
	}
	printf("%d",max);

}


Measured memory_bytes: 256
//#i#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <cassert>
#include <fstream>
#include <stdio.h>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

int Pow(int x){
    int ret = 1;
    rip(i,x,0) ret *= 2;
    return ret;
}

int main(){
    int n;cin >> n;
    vector<vector<ll>> da(n,vector<ll>(n));
    rip(i,n,0) rip(j,n,0) cin >> da[i][j];
    vector<ll> dp(Pow(n), 0);
    rip(k,Pow(n),0){
        int now = 1;
        rip(i,n,0){
            if(now&k){
                int now2 = 1;
                rip(j,n,0){
                    if(now2&k) dp[k] += da[i][j];
                    now2 <<= 1;
                }
            }
            now <<= 1;
        }
        for(int i=k;i>0;i=(i-1)&k){
            chmax(dp[k], dp[i]+dp[i^k]);
        }
    }
    //vdeb(dp);
    cout << dp.back()/2 << endl;
}

Measured memory_bytes: 768
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

// 最小全域木 O(ElogV)?
template<typename T>
struct Prim {
private:
    struct Edge{
        T cost;
        int to;
        bool operator>(const Edge e)const {
            return this->cost > e.cost;
        }
        bool operator<(const Edge e)const {
            return this->cost < e.cost;
        }
    };
    int V; // 頂点数
    vector<vector<Edge>> G;
public:
    Prim(int V) : V(V) {
        G.resize(V);
    }

    void add_edge(int from, int to, T weight) {
        G[from].push_back({weight,to});
        G[to].push_back({weight,from});
    }

    T build() {
        T res = 0;
        vector<bool> used(V, false);
        priority_queue<Edge, vector<Edge>, greater<Edge>> pq;
        for (const Edge &e : G[0]) {
            pq.push(e);
        }
        used[0] = true;
        while (!pq.empty()) {
            Edge e = pq.top(); pq.pop();
            if (used[e.to]) continue;
            used[e.to] = true;
            res += e.cost;
            for (const Edge &u : G[e.to]) {
                if (used[u.to]) continue;
                pq.push(u);
            }
        }
        return res;
    }
};

int main() {
    int v, e; cin >> v >> e;
    Prim<ll> G(v);
    REP(i,e) {
        int a, b, c; scanf("%d %d %d", &a, &b, &c);
        G.add_edge(a, b, c);
    }
    cout << G.build() << endl;
    return 0;
}


Measured memory_bytes: 10428
# -*- coding: utf-8 -*-
from operator import itemgetter

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.par = [-1 for _ in range(n)]

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

    def root(self, x):
        if self.par[x]<0:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x==y:
            return

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

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

    def size(self,x):
        return -self.par[self.root(x)]

def kruskal(e,n):
    l = []
    for v in range(n):
        for u,c in e[v]:
            l.append((c,v,u))
    l.sort()

    uf = UnionFind(n)
    cost = 0
    res = []
    for c,v,u in l:
        if uf.same(v,u):
            continue
        res.append((v,u,c))
        cost += c
        uf.unite(v,u)
    return res,cost


n = int(input())
e = [[] for _ in range(n)]

ixy = []
for i in range(n):
    x,y = map(int, input().split())
    ixy.append((i,x,y))

ixy.sort(key=itemgetter(1,2))
for i in range(n-1):
    v,a,b = ixy[i]
    u,c,d = ixy[i+1]
    e[v].append((u,min(abs(a-c),abs(b-d))))

ixy.sort(key=itemgetter(2,1))
for i in range(n-1):
    v,a,b = ixy[i]
    u,c,d = ixy[i+1]
    e[v].append((u,min(abs(a-c),abs(b-d))))

r,cost = kruskal(e,n)
print(cost)

Measured memory_bytes: 80276
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 998244353;

int n;
char a[1000005];
int solve()
{
	int ret = 0;
	rep(i, n) if((n - 1 & i) == i) ret ^= a[i] & 1;
	return ret;
}

int main()
{
	scanf("%d%s", &n, a);
	rep(i, n) a[i] -= '1';
	
	bool ev = true;
	rep(i, n) if(a[i] == 1) ev = false;
	
	if(ev) {
		rep(i, n) a[i] /= 2;
		printf("%d\n", solve() * 2);
	} else printf("%d\n", solve());
	return 0;
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    int s=0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        s+=a[i];
    }
    sort(a.rbegin(),a.rend());
    if(a[m-1]*4*m<s) cout << "No\n";
    else cout << "Yes" << "\n";

    return 0;
}

Measured memory_bytes: 256
import java.util.Iterator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int N = new Scanner(System.in).nextInt();

        int[] numberOfFactors = new int[N + 1];
        for (int i = 1; i <= N; i++) {
            numberOfFactors[i] = 1;
        }

        for (int p : primesIterable(N + 1)) {
            for (int j = p; j <= N; j += p) {
                int jc = j / p;
                int exp = 1;
                while (jc >= p && jc % p == 0) {
                    jc /= p;
                    exp++;
                }
                numberOfFactors[j] *= exp + 1;
            }
        }

        long answer = 0;
        for (int i = 1; i <= N; i++) {
            answer += (long) i * numberOfFactors[i];
        }

        System.out.println(answer);
    }

    static Iterable<Integer> primesIterable(final int LIMIT) {
        return () -> new Iterator<>() {
            final boolean[] isComposite = markComposites();
            int prime = 2;

            private boolean[] markComposites() {
                boolean[] isComposite = new boolean[LIMIT];
                for (int p = 2, squareRoot = (int) Math.sqrt(LIMIT - 1); p <= squareRoot; p++)
                    if (!isComposite[p])   // that is, p is a prime.
                        for (int j = p * p; j < LIMIT; j += p) isComposite[j] = true;
                return isComposite;
            }

            public boolean hasNext() {
                return prime < LIMIT;
            }

            public Integer next() {
                int nextPrime = prime;
                do {
                    prime++;
                } while (prime < LIMIT && isComposite[prime]);
                return nextPrime;
            }
        };
    }
}


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

int main()
{
    int n;
    cin >> n;

    vector<int> prime(n + 1, 0);
    for (int i = 1; i <= n; i++)
    {
        int buf = i;
        for (int j = 2; j * j <= i; j++)
        {
            while (buf % j == 0)
            {
                prime[j]++;
                buf /= j;
            }
        }
        if(buf != 1)
        {
            prime[buf]++;
        }
    }
    long long ans = 1;
    for (int i = 2; i <= n; i++)
    {
        ans *= prime[i] + 1;
        ans %= 1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a[4],i,j,h;
	for(i=1;i<=3;i++)scanf("%d",&a[i]);
	for(i=1;i<=3;i++){
		for(j=i+1;j<=3;j++){
			if(a[i]>a[j]){
				h=a[i];
				a[i]=a[j];
				a[j]=h;
			}
		}
	}
	printf("%d %d %d\n",a[1],a[2],a[3]);
	return 0;
}


Measured memory_bytes: 2024
#include <iostream>
#include <stdio.h>
using namespace std;
void cs(int k);

int A[2000001];
int B[2000001];
int n;

// length is n
main(){

  int i,k=0;
  //scanf("%d",&n);
  cin >> n;

  for(i=1;i<=n;i++){
    //scanf("%d",&A[i]);
    cin >> A[i];    
if(A[i]>k) k=A[i];
  }
  // setting is finished

  cs(k);

  for(i=1;i<=n;i++){
    //printf("%d",B[i]);
    cout << B[i];    
    //if(i!=n) printf(" ");   
    if(i!=n) cout << " ";
  }
  // printf("\n");
  cout << endl;
  return 0;
}

void cs(int k){
  int C[k+1];
  int i,j,len;
  for(i=0; i<=k; i++)
    C[i] = 0;

  for(j=1; j<=n;j++)
    C[A[j]]++;

  for(i=1; i<=k; i++)
    C[i] = C[i] + C[i-1];

  for(j=n; j>=1; j--){

    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]]-1;

  }

}

Measured memory_bytes: 16820
import java.util.*

fun main(args:Array<String>){
    solve()
}

fun solve(){
    val s = read()
    var ans = 0
    for(i in 0 until s.length - 1){
        if(s[i] != s[i + 1]) ans++
    }
    println(ans)
}

fun read() = readLine()!!
fun reads() = readLine()!!.split(" ")
fun readint() = readLine()!!.toInt()
fun readints() = readLine()!!.split(" ").map{it.toInt()}
fun readlong() = readLine()!!.toLong()
fun readlongs() = readLine()!!.split(" ").map{it.toLong()}

Measured memory_bytes: 36948
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    string s;
    cin>>s;
    int k;
    cin>>k;
    set<string> st;
    set<char> ss,tt;
    int n=s.size();
    rep(i,n)ss.insert(s[i]);
    while(!ss.empty()){
        char a=*begin(ss);
        tt.insert(a);
        ss.erase(a);
        bool ok=0;
        for(int i=0;i<n;i++){
            if(n-i>=k&&s[i]==a){
                ok=1;
                break;
            }
        }
        if(ok)break;
    }
    while(!tt.empty()){
        char b=*begin(tt);
        tt.erase(b);
        for(int i=0;i<n;i++){
            if(s[i]==b){
                string t;
                for(int j=i;j<n;j++){
                    t+=s[j];
                    st.insert(t);
                    if(j-i+1>=k)break;
                }
            }
        }
        if(st.size()>=k)break;
    }
    while(k>1){
        string u=*begin(st);
        st.erase(u);
        k--;
    }
    cout<<*begin(st)<<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();
      if (a*c < b) {
        System.out.println(c);
      } else {
        System.out.println(b/a);        
      }
    }
}

Measured memory_bytes: 23892
N = int(input())
TXY = [list(map(int,input().split())) for _ in range(N)]

now = (0,0)
now_t = 0
ok = True
for t,x,y in TXY:
  d = abs(x-now[0]) + abs(y-now[1])
  if d <= (t-now_t) and ((t - now_t) - d) % 2 == 0:
    now = (x,y)
    now_t = t
    continue
  ok = False
  break
  
if ok:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 27380
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long m[4][3];
long long a[10][7];
long long ans[10];
int main(){
	long long h, w;
	cin >> h >> w;
	ans[0] = ((h + 2) / 3 - h / 3) * w;
	ans[1] = ((w + 2) / 3 - w / 3) * h;
	ans[2] = abs(h / 3 * w - ((h - h / 3)* ((w + 1) / 2)));
	ans[3] = abs((h + 2) / 3 * w - ((h - (h + 2)/ 3) * (w / 2)));
	ans[4]= abs(w / 3 * h - ((w - w / 3) * ((h + 1) / 2)));
	ans[5] = abs((w + 2) / 3 * h - ((w - (w + 2) / 3) * (h / 2)));
	long long ans1 = 10000000000007;
	for (int i = 0; i < 6; i++) {
		if (ans1 > ans[i]) {
			ans1 = ans[i];
		}
	}
	cout << ans1 << endl;
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,H;
int A[111111],B[111111];

signed main(){
    cin>>N>>H;

    rep(i,N)cin>>A[i]>>B[i];
    int x=*max_element(A,A+N);

    sort(B,B+N);reverse(B,B+N);

    int ans=(H+x-1)/x;
    for(int i=0;i<N;i++){
        H-=B[i];
        int tmp;
        if(H<=0)tmp=0;
        else tmp=(H+x-1)/x;
        chmin(ans,i+1+tmp);

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


Measured memory_bytes: 1792
#include <stdio.h>
int main()
{
    double a,b,c,d,e,f,x,y;
    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) == 6){
        y= (c*d - f*a) / (b*d - a*e);
        x = ((c/a) - ((b/a)*y));
        printf("%.3lf %.3lf\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 1696
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int N = S.Length;
		bool chk = false;
		for(int i=0;i<N;i++){
			if(S[i] == 'C'){
				chk = true;
				continue;
			}
			if(chk && S[i] == 'F'){
				Console.WriteLine("Yes");
				return;
			}
		}
		Console.WriteLine("No");
		
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 2648
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int ans = 0;
  int N;
  int temp;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &temp);
    while (temp % 2 != 1) {
      temp /= 2;
      ans++;
    }
  }
  printf("%d", ans);
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
using namespace std;
long long  a,b,c,d ,sum1,sum2,sum; 
int main()
{     
     cin >> a >> b >> c >> d ;
     if(a >= 0 && c >=0)
     {
     	cout << b*d ;
	 }
	 else if(b <= 0 && d <=0)
	 {
	 	cout << a*c;
	 }
	 else 
	 {
	 	sum1 = a*c ,sum2 =b*d;
	 	sum = max(sum1,sum2);
	 	
	 	sum1 = a*d ,sum2 =b*c;
	 	sum = max(sum,max(sum1,sum2));
	 	cout << sum;
	 }
	return 0;
} 

Measured memory_bytes: 3120
N, L = map(int, input().split())  # N個のりんご, 味の根拠L

Apples = [(L + i) for i in range(N)]

apple_pie = sum(Apples)

min_apple = 99999999999999
for i in range(len(Apples)):
    if min_apple > abs(Apples[i]):
        min_apple = abs(Apples[i])
        if Apples[i] > 0:
            flag = True
        else:
            flag = False

if flag:
    print(apple_pie - min_apple)
else:
    print(apple_pie + min_apple)


Measured memory_bytes: 3060