akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using P = pair<int, int>;
using ll = long long;

int main() {
    int dx[] = {1, 0, -1, 0};
    int dy[] = {0, -1, 0, 1};
    // P p(2,4);
    // cout << p.first << endl;
    int h, w;
    cin >> h >> w;
    char s[h][w];
    rep(i, h)rep(j, w){
        cin >> s[i][j];
    }
    int ans = 0;

    rep(i, h)rep(j, w){
        // int i = 0, j = 0;
        // int step = 0;
        int mx = 0;
        if(s[i][j] == '#') continue;
        queue<P> q;
        vector<vector<int>> dist(h, vector<int>(w, -1));
        dist[i][j] = 0;
        q.push(P(i,j));
        while(!q.empty()){
            P tmp = q.front();
            q.pop();
            // step++;
            auto update = [&](int i, int j, int k){
                q.push(P(i, j));
                dist[i][j] = k;
                mx = max(mx, dist[i][j]);
            };

            rep(i, 4)rep(j, 4){
                int y = tmp.first + dx[i];
                int x = tmp.second + dy[i];
                if(y >= h || x >= w || y < 0 || x < 0) continue;
                if(s[y][x] == '#') continue;
                if(dist[y][x] != -1) continue;
                update(y, x, dist[tmp.first][tmp.second]+1);

            }
            // rep(i, h){
            //     rep(j, w){
            //         cout << dist[i][j] << " ";
            //     }
            //     cout << endl;

            // }
            // cout << endl;
        }

        ans = max(ans, mx);
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using PL = pair<ll,ll>;


int main()
{
    int n, k;
    cin >> n >> k;
    int ans = 0;
    deque<int> dq(n);
    for(int i = 0; i < n; i++)cin >> dq[i];

    for(int i = 0; i <= k; i++) {
        for(int j = 0; j <= k; j++) {
            for(int t = 0; t <= k; t++) {

                if(i + j + t > k)continue;
                auto deq = dq;
                priority_queue<int, vector<int>, greater<int>> que;
                //i : 左から j : 右から

                for(int x = 0; x < i && deq.size(); x++) {
                    que.push(deq.front());
                    deq.pop_front();
                }

                for(int x = 0; x < j && deq.size(); x++) {
                    que.push(deq.back());
                    deq.pop_back();
                }

                for(int x = 0; x < t && que.size(); x++){
                    if(que.top() > 0)continue;
                    que.pop();
                }

                int sum = 0;
                while(que.size()) {
                    sum += que.top();
                    que.pop();
                }

                ans = max(sum, ans);

            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    long long ans=0,n,a,b;
    cin>>n>>a>>b;
    vector<long long>p(n);
    rep(i,n)cin>>p[i];
    rep(i,n-1){
        ans+=min(a*(p[i+1]-p[i]),b);
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 4048
#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(){
    int k, a, b;
    cin >> k >> a >> b;
    string x = "NG";
    for(int i=a;i<=b;++i){
        if(i%k==0){
            x="OK";
        }
    }
    cout << x << endl;
    return 0;
}


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

int main(void)
{
  int num;
  int cnt_five = 0;
  int cnt_seven = 0;

  for (int i = 0; i < 3; i++) {
    std::cin >> num;

    if (num == 5) {
      cnt_five++;
    }
    else if (num == 7) {
      cnt_seven++;
    }
  }

  if ((cnt_seven == 1) && (cnt_five == 2)) {
    std::cout << "YES" << std::endl;
  }
  else {
    std::cout << "NO" << std::endl;
  }
  
  return 0;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void printVec(vector<int>& vec) {
    for (auto& e : vec) {
        cout << e << " ";
    }
    cout << endl;
}

int func(std::string S) {
    // cout << fixed << setprecision(8);

    if (S == "Sunny") {
        cout << "Cloudy" << endl;
    }
    if (S == "Cloudy") {
        cout << "Rainy" << endl;
    }
    if (S == "Rainy") {
        cout << "Sunny" << endl;
    }

    return 0;
}

int main() {
    std::string S;
    std::cin >> S;

    func(S);

    return 0;
}

// Sunny
// Cloudy
// Rainy


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		long N = in.nextInt();
		if (N % 2 == 0) {
			System.out.println(N);
		} else {
			System.out.println(N * 2);
		}
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
  
ll N,K;
  
ll check(ll x){
  ll num=x;
  ll cnt=x+1;  
  for(int i=0;i<N-1;i++){
    cnt-=num/K;
    if(num==0)break;
    if(num%K==0)num--;
    num=num-1-num/K;    
  }
  if(cnt>=N)return 1;
  return 0;
}
  
ll solve(){
  ll L=0,R=1000000000000000000LL,M;
  while(L<R){
    M=(L+R)/2LL;
    
     
    if(check(M)){
      R=M;
    }else{
      L=M+1;
    }
  }
  return L;
}
  
int main(){
  cin>>N>>K;
  for(int i=2;i<=10;i++){
    //  cout<<i << ' ' << check(i) << endl;
  }
   
  cout<<solve()<<endl;
  return 0;
}

Measured memory_bytes: 3116
Number_list=list(map(int,input().split()))
taget_number=[]
for i in range(1,Number_list[0]+1):
    sum_digit=0
    for s in str(i):
        sum_digit+=int(s)
    if sum_digit>=Number_list[1] and sum_digit<=Number_list[2]:
        taget_number.append(i)
print(sum(taget_number))

Measured memory_bytes: 3296
N = int(input())
A = list(map(int,input().split()))
ans = []
flg = 0

A.sort(reverse=True)

for i in range(N-1):
  if A[i] == A[i+1] and flg == 0:
    ans.append(A[i])
    flg = 1
  else:
    flg = 0

if len(ans) > 1:
  print(ans[0]*ans[1])
else:
  print(0)

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

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n+1),b(n);
  ll i;
  for(i=0;i<n+1;i++){
    cin >> a.at(i);
  }
  for(i=0;i<n;i++){
    cin >> b.at(i);
  }
  
  ll s=0;
  for(i=0;i<n;i++){
    if(a.at(i)>=b.at(i)){
      s += b.at(i);
      a.at(i) -= b.at(i);
      b.at(i)=0;
    }else{
      s += a.at(i);
      b.at(i) -= a.at(i);
      a.at(i)=0;
      if(a.at(i+1)>=b.at(i)){
        s += b.at(i);
        a.at(i+1) -= b.at(i);
        b.at(i)=0;
      }else{
        s += a.at(i+1);
        b.at(i) -= a.at(i+1);
        a.at(i+1)=0;
      }
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 4724
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         int a= sc.nextInt();
         int b= sc.nextInt();
         int c= sc.nextInt();
         if(a<b && b<c){
         System.out.println(a+" "+b+" "+c);
         }else if(b<=a && a<=c){
        	 System.out.println(b+" "+a+" "+c);
         }else if(a<=c && c<=b){
        	 System.out.println(a+" "+c+" "+b);
         }else if(b<=c && c<=a){
        	 System.out.println(b+" "+c+" "+a);
         }else if(c<=a && a<=b){
        	 System.out.println(c+" "+a+" "+b);
         }else if(c<=b && b<=a){
        	 System.out.println(c+" "+b+" "+a);
   	 }
    }
}

Measured memory_bytes: 26284
import sys
import math

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()
mod = 1000000007

s = int(math.sqrt(n))
dp = [1] * (n//s+1)
ep = [0] * s
dp[0] = 0

for i in range(1,s):
    ep[i] = 1 # n//i-n//(i+1)

for z in range(k-1):
    ndp = [0] * (n//s+1)
    nep = [0] * s

    for i in range(1,n//s+1):
        if i < s:
            nep[i] += dp[i]
        else:
            ndp[n//i] += dp[i]
    for i in range(1,s):
        ndp[i] += ep[i] * (n//i-n//(i+1))
        ndp[i] %= mod
    for i in range(2, s):
        nep[i] += nep[i-1]
        if nep[i] >= mod:
            nep[i] -= mod
    ndp[n//s] += nep[-1]
    ndp[n//s] %= mod
    for i in range(n//s-1, 0, -1):
        ndp[i] += ndp[i+1]
        if ndp[i] >= mod:
            ndp[i] -= mod
    dp, ep = ndp, nep

ans = sum(dp)
for i in range(1, s):
    ans += ep[i] * (n//i-n//(i+1))
print(ans%mod)

Measured memory_bytes: 61404
///////////////////// author : TrEbLeCleF /////////////////////
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
#define FOr(i, a, b) for (int i=a; i<(b); i++)
#define For(i, a) for (int i=0; i<(a); i++)
#define FOrr(i,a,b) for (int i = (b)-1; i >= a; i--)
#define Forr(i,a) for (int i = (a)-1; i >= 0; i--)
/////////////////////////// ..... ///////////////////////////
#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args){
cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }
/////////////////////////// ..... ///////////////////////////
#define int ll
#define pb(x) push_back(x)
#define print(v,s,e) for(int i = s; i < e; i++)cout << v[i]<<" ";cout<<"\n";
#define INF 1e17
#define PI 3.14159265358979323846 
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
/////////////////////////// GLOBAL ///////////////////////////


/////////////////////////// GLOBAL ///////////////////////////
void solve(){
	int n;cin >> n;
	int a[n];
	For(i,n)cin >> a[i];
	int dp[n][n];
	memset(dp,0,sizeof(dp));
	Forr(L,n){
		For(R,n){
			if(L==R)dp[L][R]=a[L];
			else
			dp[L][R] = max((L+1<n?a[L]-dp[L+1][R]:-INF),(R-1>=0?a[R]-dp[L][R-1]:-INF));
		}
	}
	cout << dp[0][n-1] <<"\n";

}

int32_t main(){ 
	#ifndef ONLINE_JUDGE
		clock_t tStart = clock();
		freopen("TC", "r", stdin);
		//freopen("output.txt","w",stdout);
	#endif 
    ios_base:: sync_with_stdio(false); 
   	cin.tie(0); 
	int t=1;
	//cin >> t;
	for(int tt=1;tt<=t;tt++){
		//cout << "Case #"<<tt<<": ";
		solve();
	}
	#ifndef ONLINE_JUDGE
    	cerr << "\nRun Time -> "<<(double)(clock()-tStart)/CLOCKS_PER_SEC <<" sec\n";
    #endif
}

Measured memory_bytes: 73908
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e20;

signed main(){
    string S;cin>>S;
    int count=0;
    REP(i,S.size()-1){
        if(S[i]!=S[i+1])count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 512
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int a[3000],b[3000],c[3000][3001],n,m,l;
int fn(int p,int q){  
  if(p==n)
    return 0;
  if(c[p][q]>=0)
    return c[p][q];
  int mx=fn(p+1,q);
  if((l<=q||q+b[p]<=l)&&q+b[p]<=m)
    mx=max(mx,a[p]+fn(p+1,q+b[p]));
  if(q<l&&l+b[p]<=m)
    mx=max(mx,a[p]+fn(p+1,l+b[p]));
  return c[p][q]=mx;
}
int main(){
  int i;
  scanf("%d%d%d",&n,&m,&l);
  for(i=0;i<n;++i)
    scanf("%d%d",a+i,b+i);
  memset(c,-1,sizeof(c));
  printf("%d\n",fn(0,0));
  return 0;
}

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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define go(i,s) for(int i = head[s]; i; i = e[i].next)
#define pb push_back
#define mp make_pair
const int maxn = 100050;

int x, l, r, mid, ans;

bool judge(int y)
{
	int k = x;
	k -= y;
	fd(i,y-1,1) if(k >= i) k -= i;
	return k == 0;
}

int main()
{
	cin >> x;
	l = 1; r = x;
	while(l <= r)
	{
		mid = l+r >> 1;
		if(judge(mid)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	printf("%d",ans);
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int m = (n/2)*2;
    int a = (m-2)*m/2;
    if(n%2 == 0) cout << a << endl;
    else cout << a+m << endl;
    for(int i=1; i<=m; i+=2){
        for(int j=i+2; j<=m; j+=2){
            cout << i << ' ' << j << endl;
        }
        for(int j=2; j<=m; j+=2){
            if(i+j==m+1) continue;
            cout << i << ' ' << j << endl;
        }
        for(int j=i+3; j<=m; j+=2){
            cout << i+1 << ' ' << j << endl;
        }
    }
    if(n%2 == 1){
        for(int i=1; i<n; i++){
            cout << i << ' ' << n << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define mod (1000000007)
using namespace std;
int main(){

  int N;
  cin>>N;
  vector<long long>A(N);
  long long ans=0;
  long long allsum=0;
  for(int i=0;i<=N-1;i++){
  
    cin>>A[i];
    allsum+=A[i];
    allsum%=mod;
  }
  for(int i=0;i<=N-2;i++){
  
    allsum-=A[i];
    if(allsum<0)allsum+=mod;
    ans+=allsum*A[i];
    ans%=mod;
  }
  cout<<ans;
  return 0;
}

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

int main(){
	int a[5],i;
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4]){
		sort(a,a+5,greater<int>());
		i=0;
		for(int i=0;i<5;i++){
			cout << a[i];
			if(i!=4)cout << " ";
			else cout << endl;
		}
	}
}

Measured memory_bytes: 0
class BinaryIndexTree:  # 1-indexed
    def __init__(self, N):
        """
        INPUT
        N [int] -> 全部0で初期化
        N [list] -> そのまま初期化
        """
        if isinstance(N, int):
            self.N = N
            self.depth = N.bit_length()
            self.tree = [0] * (N + 1)
            self.elem = [0] * (N + 1)
        elif isinstance(N, list):
            self.N = len(N)
            self.depth = self.N.bit_length()
            self.tree = [0] + N
            self.elem = [0] + N
            self._init()
        else:
            raise "INVALID INPUT: input must be int or list"

    def _init(self):
        size = self.N + 1
        for i in range(1, self.N):
            if i + (i & -i) > size:
                continue
            self.tree[i + (i & -i)] += self.tree[i]

    def add(self, i, x):
        self.elem[i] += x
        while i <= self.N:
            self.tree[i] += x
            i += i & -i

    def sum(self, i):
        res = 0
        while i > 0:
            res += self.tree[i]
            i -= i & -i
        return res

    def lower_bound(self, val):
        if val <= 0:
            return 0
        i = 0
        k = 1 << self.depth
        while k:
            if i + k <= self.N and self.tree[i + k] < val:
                val -= self.tree[i + k]
                i += k
            k >>= 1
        return i + 1


if __name__ == "__main__":
    N = int(input())
    P = list(map(int, input().split()))
    idx = {a: i for i, a in enumerate(P, start=1)}

    bit = BinaryIndexTree(N)
    ans = 0
    for i in range(1, N + 1):
        bit.add(idx[i], 1)
        s = bit.sum(idx[i])
        l = bit.lower_bound(s)-bit.lower_bound(s-1)
        r = bit.lower_bound(s+1) - idx[i]
        ans += i*l*r
    print(ans)

Measured memory_bytes: 100860
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n; cin >> n;
    vector<int> w(n);
    rep(i, n) cin >> w[i];

    int ans = 100000;
    int total = 0;
    rep(i, n) total += w[i];

    
    rep(t, n-1) {
        int s1 = 0, s2 = 0;
        rep(i, t+1) {
            s1 += w[i];
        }
        s2 = total - s1;
        ans = min(ans, abs(s1-s2));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

string toUpperCamelCase(string s) {
	string res;

	for (int i = 0; i < (int)s.size(); i++) {
		if (i == 0) {
			res += toupper(s[i]);
		} else if (s[i] == '_') {
			res += toupper(s[i + 1]);
			i++;
		} else {
			res += s[i];
		}
	}

	return res;
}

string toLowerCamelCase(string s) {
	string res;

	for (int i = 0; i < (int)s.size(); i++) {
		if (i == 0) {
			res += tolower(s[i]);
		} else if (s[i] == '_') {
			res += toupper(s[i + 1]);
			i++;
		} else {
			res += s[i];
		}
	}

	return res;
}

string toSnakeCase(string s) {
	string res;

	for (int i = 0; i < (int)s.size(); i++) {
		if (i == 0) {
			res += tolower(s[i]);
		} else if (isupper(s[i])) {
			res += '_';
			res += tolower(s[i]);
		} else {
			res += s[i];
		}
	}

	return res;
}

int main(void) {
	string s;
	char c;

	while (true) {
		cin >> s >> c;
		if (c == 'X') break;

		switch (c) {
			case 'L':
				s = toLowerCamelCase(s);
				break;
			case 'U':
				s = toUpperCamelCase(s);
				break;
			case 'D':
				s = toSnakeCase(s);
				break;
		}

		cout << s << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
package main
import "fmt"
func main() {
  var a,b,c,n int
  fmt.Scan(&a,&b,&c)
  a,b,c = sort(a,b,c)
  a,b,c = 0,b-a,c-a
  n = c-b
  n += (c-n)/2 + ((c-n)%2)*2
  fmt.Println(n)
}
func sort(a int,b int,c int) (int,int,int) {
  var min,mid,max int
  min,max = a,a
  if min > b { min = b }
  if max < b { max = b }
  if min > c { min = c }
  if max < c { max = c }
  mid = a+b+c-min-max
  return min,mid,max
}

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

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

    bool ok = false;

    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= m;j++){
            if(i*(m-j) + j*(n-i) == k) ok = true;
        }
    }

    cout << (ok ? "Yes" : "No") << endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.nextLine().toCharArray();
		long K = sc.nextLong();
		sc.close();
		char a = '1';
		for(int i=0;i<K;i++){
			if(i >= S.length) break;
			if(S[i] != '1'){
				a = S[i];
				break;
			}
		}
		System.out.println(a);

	}

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#include<cmath>
#include<queue>
#include<algorithm>

using namespace std;
using ll=long long;
using db=double;

typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<bool> vbl;

int inf=(1LL<<31)-1;
int MOD=1000000007;

#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define f_i(a,b) for(int i=a;i<=b;i++)
#define f_j(a,b) for(int j=a;j<=b;j++)
#define vvii(c,a,b) vector<vector<ii>> c(a,vector<ii>(b,0))
#define vvll(c,a,b) vector<vector<ll>> c(a,vector<ll>(b,0))
#define vvstr(c,a,b) vector<vectorM<string> c(a,vector<string>(b,0))

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    vector<vector<ll>> num(4,vector<ll>(13,0));
    int n=0;
    cin >> n;
    fi(0,n)
    {
        ll a;
        char s;
        cin >> s >> a;
        if(s=='S')
        {
            num.at(0).at(a-1)=1;
        }
        else if(s=='H')
        {
            num.at(1).at(a-1)=1;
        }
        else if(s=='C')
        {
            num.at(2).at(a-1)=1;
        }
        else if(s=='D')
        {
            num.at(3).at(a-1)=1;
        }
    }
    fi(0,4)
    {
        fj(0,13)
        {
            if(num.at(i).at(j)!=1)
            {
                if(i==0)
                {
                    cout << "S" << " " << j+1 << endl;
                }
                else if(i==1)
                {
                    cout << "H" << " " << j+1 << endl;
                }
                else if(i==2)
                {
                    cout << "C" << " " << j+1 << endl;
                }
                else if(i==3)
                {
                    cout << "D" << " " << j+1 << endl;
                }
            }
        }
    }
    return(0);
}


Measured memory_bytes: 3136
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>

int main()

{
    int s,w;
    scanf("%d %d",&s,&w);
    if(s>w)
    {
        printf("safe\n");
    }
    else
    {
        printf("unsafe\n");
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;
int n,cnt[26];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n;++i) {
		string s;
		cin>>s;
		int k[26];
		memset(k,0,sizeof k);
		for(int j=0;j<s.size();++j) {
			k[s[j]-'a']++;
		}
		for(int j=0;j<26;++j) {
			if(i==0) cnt[j]=k[j];
			else cnt[j]=min(cnt[j],k[j]);
		}
	}
	for(int i=0;i<26;++i) {
		for(int j=0;j<cnt[i];++j)
			cout<<(char)(i+'a');
	}
}

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

using namespace std;

int main(){

    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for(int i = 0; i < N; i++) cin >> h.at(i);

    int count = 0;
    for(int i = 0; i < N; i++) if(h.at(i) >= K) count++;

    cout << count << endl;

    return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
typedef map<int,int> mp;

const int MOD = 1e9 + 7;


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

    ll n;
    cin >> n;

    ll ans = 0;
    ll a = 10;
    if(n % 2 == 0){
        while(n >= a){
            ans += n / a;
            a *= 5;
        }
    }else{
        ans = 0;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>
using namespace std;
int main(){

  string tmp;
  stack <int> a;
  int tmp1;

  while(cin>>tmp){
    if(tmp=="+"){
      tmp1=a.top(); a.pop();
      tmp1+=a.top(); a.pop();
      a.push(tmp1);
    } else if(tmp=="*"){
      tmp1=a.top(); a.pop();
      tmp1*=a.top(); a.pop();
      a.push(tmp1);
    } else if(tmp=="-"){
      tmp1=-a.top(); a.pop();
      tmp1+=a.top(); a.pop();
      a.push(tmp1);
    } else a.push(atoi(tmp.c_str()));
  }
  cout<<a.top()<<endl;
  return 0;
}

Measured memory_bytes: 3072
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()

	x, a := io.Int(), io.Int()
	
	if x < a{
		fmt.Println(0)
	}else{
		fmt.Println(10)
	}
}

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) Int() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Float() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

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

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


Measured memory_bytes: 640
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();
    double t=sc.nextInt();
    int s=0;
    for(int i=1;i*a<t+0.5;i++){
      s=s+b;
    }
    System.out.println(s);
  }
}


Measured memory_bytes: 21844
#include<iostream>
#include<math.h>
#include<algorithm>
#include<queue>
#include<string>
#include<bits/stdc++.h>


using namespace std;

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

main(){
    string S;
    int out = 0;
    cin >> S;
    FOR(i, 0, 4){
        if(S[i] == '+')out += 1;
        else out -= 1;   
    }
    cout << out << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define int ll
#define pi pair <int, int>
#define pii pair <pi, pi>
#define vi vector <int>
#define in insert
#define er erase
#define fd find
int n, m, a[100001], b[100001], ans[100002], p[100001], s[100001];

int root(int a){
    if(p[a]==a) return a;
    return p[a]=root(p[p[a]]);
}

void unite(int x, int y){
    x=root(x);
    y=root(y);
    if(s[x]>s[y]) swap(x, y);
    s[y]+=s[x];
    p[x]=y;
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n>>m;
    for(int i=1; i<=n; i++) p[i]=i,s[i]++;
    for(int i=1; i<=m; i++) cin>>a[i]>>b[i];
    ans[m+1]=0;
    for(int i=m; i>=1; i--){
        int x=a[i], y=b[i];
        if(root(x)==root(y)) ans[i]=ans[i+1];
        else{
            x=root(x);
            y=root(y);
            ans[i]=ans[i+1]+((s[x]+s[y])*(s[x]+s[y]-1)/2)-(s[y]*(s[y]-1)/2)-(s[x]*(s[x]-1)/2);
            unite(x, y);
        }
    }
    for(int i=2; i<=m+1; i++) cout<<n*(n-1)/2-ans[i]<<"\n";
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, M, X;
int C[20];
int A[20][20];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M >> X;
    for(int i = 0; i < N; ++i){
        cin >> C[i];
        for(int j = 0; j < M; j++){
            cin >> A[i][j];
        }
    }
    int ans = inf;
    for(int i = 0; i < (1 << N); ++i){
        int sum[20] = {};
        int res = 0;
        for(int j = 0; j < N; ++j){
            if(!(i >> j & 1)) continue;
            res += C[j];
            for(int k = 0; k < M; ++k){
                sum[k] += A[j][k];
            }
        }
        bool f = true;
        for(int j = 0; j < M; ++j){
            if(sum[j] < X) f = false;
        }
        if(f) chmin(ans, res);
    }
    cout << (ans == inf ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for(int i = 0; i < N; i++) {
    cin >> B[i];
  }
  for(int i = 0; i < N; i++) {
    cin >> C[i];
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  long ans = 0;
  for (int i = 0; i < N; i++) {
    auto Iter1 = lower_bound(A.begin(), A.end(), B[i]);
    auto Iter2 = upper_bound(C.begin(), C.end(), B[i]);
    long k1 = Iter1 - A.begin();
    long k2 = C.end() - Iter2;
    ans += k1 * k2;
  }
  cout << ans << "\n";
  return 0;
}

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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;
typedef vector<unordered_map<lli,lli>> graph;

lli n;
vll a;
mat ans;

int main(){
  cin >> n;
  a = vll(n);
  for(lli i = 0;i < n;i++) cin >> a[i];
  lli t = max_element(a.begin(),a.end())-a.begin();
  lli l = min_element(a.begin(),a.end())-a.begin();
  if(a[t]+a[l] >= 0){
    for(lli i = 0;i < n;i++){
      ans.push_back(vll({t+1,i+1}));
    }
    for(lli i = 1;i < n;i++){
      ans.push_back(vll({i,i+1}));
    }
  }else{
    for(lli i = 0;i < n;i++){
      ans.push_back(vll({l+1,i+1}));
    }
    for(lli i = n;i > 1;i--){
      ans.push_back(vll({i,i-1}));
    }
  }
  cout << ans.size() << endl;
  for(lli i = 0;i < ans.size();i++){
    cout << ans[i][0] << " " << ans[i][1] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, N , x ;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  x = 0;

 for (int i = 0; i < N; i++) {
   x += min(A.at(i)*2 , (K - A.at(i)) *2);
 }
    cout << x << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cstring>
using namespace std;

int main() {
  unsigned long int N,P,n;
  int T;
  int i = 0;
  cin >> N;
  n = N;
  while(n > 9){
    n /= 10;
    i++;
  //  cout << N << '\n';
  }
  P = pow(10,i);
  //cout << P << '\n';
  if((N+1) % P == 0)
    n++;
  T = n + (i*9) - 1;
  cout << T << '\n';
  return 0;
}

Measured memory_bytes: 256
//....SARANSH GUPTA....\\

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(p,n) for(int i=p;i<n;i++)
#define FIO ios_base::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);
#define endl "\n"
#define mp make_pair
#define pb push_back
#define mod 1000000007
int main()
{
    FIO
    string a,b;
    cin>>a>>b;
    int n=a.length();
    int c=0;
    fo(0,n)
    {
        if(a[i]!=b[i])
        c++;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 3784
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        t: i64,
        a: i64,
        hh: [i64;n]
    }
    let res = hh.iter().map(|h| t * 1000 - h * 6)
        .enumerate().min_by_key(|x| (1000 * a - x.1)
        .abs()).unwrap();
    println!("{:?}", res.0+1);
}


Measured memory_bytes: 4352
S = input()

ans = True

if(S[0] != "A"):
    ans = False
if not "C" in S[2:-1]:
    ans = False
count = 0
for c in S:
    if c.isupper():
        count += 1

if count > 2:
    ans = False

print("AC" if ans else "WA")

Measured memory_bytes: 3060
class Simultaneous
  def initialize(input)
    @a,@b,@c,@d,@e,@f = input.split(" ").map(&:to_f)
  end

  attr_accessor :a,:b,:c,:d,:e,:f

  def calc
    x = (@c * @e - @b * @f) / (@a * @e - @b * @d).to_f
    y = (@c * @d - @a * @f) / (@b * @d - @a * @e).to_f
    x = 0 if x.abs == 0.0
    y = 0 if y.abs == 0.0
    return [x, y]
  end
end

while data = gets
  ans = Simultaneous.new(data).calc
  puts sprintf("%.3f %.3f", ans[0], ans[1])
end

Measured memory_bytes: 6140
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
signed main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	if (n > 999) { cout << "ABD"; }
	else { cout << "ABC"; }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
signed main(){
	ll n, i, sum=0;
	cin>>n;
	ll a[10000], b[10000], c[10000];
	for(i=1; i<=n; i++){
		cin>>a[i];
	}
	for(i=1;i<=n; i++){
		cin>>b[i];
		sum += b[i];
	}
	for(i=1; i<=n-1; i++){
		cin>>c[i];
	}
	for(i=1; i<n; i++){
		if(a[i+1]-a[i]==1){
			sum += c[a[i]];
		}
	}
	cout<<sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll H1, H2, M1, M2, K;
    cin>>H1>>M1>>H2>>M2>>K;
    ll time=H2*60+M2-H1*60-M1;
    cout<<time-K<<endl;
    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		do
		{
			int a = scanner.nextInt(); //a1
			int b = scanner.nextInt(); //b1
			int c = scanner.nextInt(); //c1
			int d = scanner.nextInt(); //a2
			int e = scanner.nextInt(); //b2
			int f = scanner.nextInt(); //c2
			double x = (double)(c*e - f*b) / (a*e - d*b);
			double y = (double)(a*f - d*c) / (a*e - d*b);
			if(String.format("%.1f", x).equals("-0.0"))
			{
				x = 0D;
			}
			if(String.format("%.1f", y).equals("-0.0"))
			{
				y = 0D;
			}
			System.out.println(String.format("%.3f %.3f", x, y));
		}
		while(scanner.hasNext());
	}
}

Measured memory_bytes: 19040
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    string S;
    cin >> S;
    int N = S.length();
    string subr1, subr2;
    subr1 = S.substr(0, (N - 1) / 2);
    subr2 = S.substr((N + 1) / 2, (N + 1) / 2);
    if(subr1 == subr2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline().rstrip())
PList=list(map(int,sys.stdin.readline().split()))

PListSort=sorted(PList)

exchangeCounter=0
for i in range(N):
  if PList[i] != PListSort[i]:
    exchangeCounter+=1
    
if exchangeCounter <= 2:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; cin >> n;
  map<string,int> s;
  for(int i; i<n; i++){
    string t;  cin >> t;
    s[t] += 1;
  }
  int mv = 0;
  for(const auto& x : s){
    int v = x.second;
    if(v > mv) mv = v;
  }
  for(auto i = s.begin(); i != s.end(); i++){
    if(i->second == mv){
      cout << i->first << endl;
    }
  }
}

Measured memory_bytes: 25216
package main

import (
	"fmt"
)

func getMax(numbers ...int) int {
	var max int
	max = numbers[0]
	for _, v := range numbers {
		if max < v {
			max = v
		}
	}
	return max
}
func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	max := getMax(a, b, c)
	i := max * 3
	if (a+b+c)%2 == i%2 {
		fmt.Println((i-(a+b+c))/2)
	} else {
		i += 3
		fmt.Println((i-(a+b+c))/2)
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

typedef pair<long long int, long long int> P;

int main() {

	long long int n, h;
	cin >> n >> h;

	vector<P> kk(n);

	long long int maxa = 0;

	for (long long int i = 0; i < n; i++) {
		cin >> kk[i].first >> kk[i].second;
		maxa = max(maxa, kk[i].first);
	}

	vector<long long int> k2;
	priority_queue<long long int> pq;

	for (long long int i = 0; i < n; i++) {
		if (kk[i].first == maxa) {
			k2.push_back(kk[i].second);
		}
		else if (kk[i].second > maxa) {
			pq.push(kk[i].second);
		}
	}

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

	for (long long int i = 1; i < k2.size(); i++) {
		if (k2[i] > maxa) {
			pq.push(k2[i]);
		}
	}

	long long int ans = 0;
	while (h > 0) {
		if (k2[0] >= h) {
			ans++;
			break;
		}
		if (!pq.empty()) {
			long long int a = pq.top();
			pq.pop();
			h -= a;
			ans++;
		}
		else {
			if (k2[0] > maxa) {
				long long int b = (h - k2[0]) / maxa;
				if ((h - k2[0]) % maxa != 0) {
					b++;
				}
				ans += b;
				ans++;
				break;
			}
			else {
				long long int b = h / maxa;
				if (h%maxa != 0) {
					b++;
				}
				ans += b;
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4084
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

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

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

    lint a, b;
    cin >> a >> b;

    if(b % a == 0LL){
        cout << -1 << endl;
        return 0;
    }

    lint ans = b / a * a + a;
    lint cnt = 0, t = ans;
    cnt += t / b;
    t %= b;
    cnt += t / a;
    t %= a;
    cnt += t;
    if(cnt <= ans / a){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}


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

using namespace std;

int main(){

int cnt = 0;
string s;
cin >> s;

for(int i = 0; i < s.size(); ++i){
	if(s[i] == 'o'){
		cnt++;
	}
}

int asdf = 15 - s.size();

if(asdf + cnt >= 8){
	cout << "YES" << endl;
}else{
	cout << "NO" << endl;
}


  return 0;
}

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


public class D
{
	public static void Main()
	{
		int N = GetInt();
		int M = GetInt();
		int[] a = new int[M];	// num of edges (!= N)
		int[] b = new int[M];	// num of edges (!= N)
		long[] c = new long[M];	// num of edges (!= N)
		for(int i = 0; i < M; i++)
		{
			a[i] = GetInt();
			b[i] = GetInt();
			c[i] = -GetLong();
		}
		
		long INF = long.MaxValue;
		long[] d = new long[N+1];  // d[1] = 0
		for(int i = 2; i <= N; i++)
			d[i] = INF;
		for(int i = 0; i < N-1; i++)
		{
			for(int j = 0; j < M; j++)
			{
				if(d[a[j]] == INF)
					continue;
				d[b[j]] = Math.Min(d[b[j]], d[a[j]] + c[j]);
			}
		}

		long ans = -d[N];
		bool[] isNegative = new bool[N+1];
		for(int i = 0; i < N; i++)
		{
			for(int j = 0; j < M; j++)
			{
				if(d[a[j]] == INF)
					continue;

				if(d[b[j]] > d[a[j]] + c[j])
				{
					d[b[j]] = d[a[j]] + c[j];
					isNegative[b[j]] = true;
				}

				if(isNegative[a[j]])
					isNegative[b[j]] = true;
			}
		}		
	
		Console.WriteLine(isNegative[N] ? "inf" : ans.ToString());		
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 11220
n, x, y = map(int, input().split())
l = list(range(1,n+1))

k = [0]*(n-1)
for i in range(1,n+1):
    for j in range(i+1,n+1):
        if i < x:
            if j <= x:
                k[j-i-1] += 1
            else:
                k[min(j-i,abs(x-i)+abs(y-j)+1)-1] += 1
        elif i < y:
            k[min(j-i,abs(x-i)+abs(y-j)+1)-1] += 1
        else:
            k[j-i-1] += 1

for i in k:
    print(i)

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

#define ll          long long
#define ld          long double
#define pb          push_back
#define pii         pair<int,int> 
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F         first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define mem(x)      memset(x,0,sizeof(x));
#define what_is(x)  cerr << #x << " is " << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)

using namespace std;



void solve(){
    string s,t;
    cin>>s>>t;
    int n=sz(s);
    int m=sz(t);

    int dp[n+1][m+1];

    rep(i,0,n+1){
        rep(j,0,m+1){
            if(i==0||j==0)
                dp[i][j]=0;

            else
                dp[i][j]=max(dp[i-1][j-1]+(int)(s[i-1]==t[j-1]),max(dp[i-1][j],dp[i][j-1]));
        }
    }

    string ans="";

    int i=n,j=m;
    

    while(j>0&&i>0){
        if(dp[i][j]==dp[i][j-1]){
            
            j--;
        }
        else if(s[i-1]==t[j-1]){
            ans+=t[j-1];
            i--;
            j--;
        }
        else i--;
    }

    reverse(all(ans));
    cout<<ans<<endl;
}



int main(){
    // #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
   

    int t=1,i=1;
    //cin>>t;
    

    while(t--){
       // cout<<"Case #"<<i++<<": ";
        solve();
    
    }

    return 0;
}

Measured memory_bytes: 35456
// C - :(Colon)
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(int)(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
    long double a, b, h, m;
    cin >> a >> b >> h >> m;
    long double ans = 0.0;
    long double longhand = m*6;
    long double shorthand = (h*60+m)*360/(12*60);
    long double handangle = shorthand - longhand;
    long double x = handangle*(M_PI/180);
    ans = a*a + b*b - 2*a*b*cos(x);
    cout << fixed << setprecision(20) << sqrt(ans) << endl; 
    return 0;
}

Measured memory_bytes: 4152
#include<bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  int N = (int)S.size();
  int ans = 0;
  int b = 0;
  for (int i = 0; i < N; i ++) {
    if (S[i] == 'S') b ++;
    else {
      if (b == 0) ans ++;
      else b --;
    }
  }
  cout << ans * 2 << endl;
}


Measured memory_bytes: 640
import java.util.*;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String sstack;
    char cstack;
    
    for(int i = 0;i < 3;i++){
    	sstack=sc.next();
      	cstack = (char)((int)sstack.charAt(0) - 32);
      	System.out.print(cstack);
    }
    System.out.println();
  }
}


Measured memory_bytes: 35700
#素因数分解
def Prime_Factorization(N):
    if N<0:
        R=[[-1,1]]
    else:
        R=[]

    N=abs(N)
    k=2
    while k*k<=N:
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
        k+=1

    if N!=1:
        R.append([N,1])
    if not R:
        R.append([N,1])

    return R
#================================================
from math import gcd
N=int(input())
A=list(map(int,input().split()))

#Pairwise?
P=set()
F=True
for a in A:
    K=Prime_Factorization(a)
    for (p,_) in K:
        if p in P and p!=1:
            F=False
            break
        else:
            P.add(p)

    if not F:
        break

if F:
    print("pairwise coprime")
    exit()

#Setwise?
g=A[0]
for a in A:
    g=gcd(g,a)

if g==1:
    print("setwise coprime")
else:
    print("not coprime")


Measured memory_bytes: 197308
import sys
X,K,D = map(int,input().split())
X = abs(X)
if X > K * D:
    print(X - K*D)
    
elif X != 0:
    if (X // D) % 2 == K % 2:
        print(X % D)
    elif (X // D) % 2 != K % 2:
        print(abs(X % D - D))
        
else:
    if K % 2 == 0:
        print(0)
    else:
        print(D)

Measured memory_bytes: 61684