akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,a) repi(i,0,a)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define repit(i,a) for(__typeof((a).begin()) i=(a).begin();i!=(a).end();i++)

#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())

#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

int main()
{
    int n, a, s, g;
    while(cin >> n >> a >> s >> g, n || a || s || g) {
        // input
        vector<vector<pair<int , string> > >E(n);
        rep(i, a) {
            int from, to;
            string str;
            cin >> from >> to >> str;
            E[from].pb(mp(to, str));
        }

        // init
        vector<bool> done(n);
        vector<string> dp(n);
        rep(i, n) dp[i] = "";
        done[g] = true;

        // calc
        rep(_, 250) {
            rep(from, n) rep(i, E[from].size()) {
                int to = E[from][i].first;
                if(done[to] && (!done[from] || E[from][i].second + dp[to] < dp[from])) {
                    dp[from] = E[from][i].second + dp[to];
                    done[from] = true;
                }
            }
        }

        
        // output
        if(dp[s] == "" or dp[s].size() > 241) cout << "NO" << endl;
        else cout << dp[s] << endl;
        
    }

    return 0;
}

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

#define NMAX 2000000

main()
{
  char S[NMAX],T[NMAX];
  int alp[26],i,num,k;
  for(i=0;i<26;i++)
    alp[i] = -1;
  scanf("%s",S);
  scanf("%s",T);
  for(num=0;S[num]!='\0';num++);
  for(i=0; i<num; i++)
  {
    if(alp[S[i]-97]==-1)
      alp[S[i]-97]=T[i]-97;
    else
    {
      if(alp[S[i]-97]!=T[i]-97)
      {
        printf("No\n");
        exit(0);
      }
    }
  }
  for(i=0; i<25; i++)
  {
    num = alp[i];
    if(num!=-1)
      for(k=i+1; k<26; k++)
        if(num == alp[k])
        {
          printf("No\n");
          exit(0);
        }
  }
  
printf("Yes\n");
}

Measured memory_bytes: 2432
#include<iostream>
using namespace std;
//
int step[8][2] = {
    -1, -1,
    -1, 0,
    -1, 1,
    0, -1,
    0, 1,
    1, -1,
    1, 0,
    1, 1,
};
char matrix[50 + 5][50 + 5];
int main() {
    int h, w;
    while(cin >> h >> w) {
        for(int i = 1; i <= h; i++)
            for(int j = 1; j <= w; j++) {
                cin >> matrix[i][j];
                if(matrix[i][j] == '.')
                    matrix[i][j] = '0';
            }
        for(int i = 1; i <= h; i++)
            for(int j = 1; j <= w; j++)
                if(matrix[i][j] == '#')
                    for(int index = 0; index < 8; index++)
                        if(matrix[i + step[index][0]][j + step[index][1]] != '#')
                            matrix[i + step[index][0]][j + step[index][1]]++;
        for(int i = 1; i <= h; i++) {
            for(int j = 1; j <= w; j++)
                cout << matrix[i][j];
            cout << endl;
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

// gcd(a, b)
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

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

    int n;cin>>n;
    map<ll,ll> mp;
    for(int i=0;i<n;i++){
        ll a;cin>>a;
        mp[a]++;
    }
    int res=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        P p = *itr;
        if(p.second%2) res++;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 6528
import itertools

n, k = map(int, input().split())

t = ( n - 1 ) * ( n - 2 ) // 2 - k

if t < 0:
  print( -1 )

else:
  print( n - 1 + t )
  
  for i in range(1, n):
    print(1, i+1)
  
  for i,j in itertools.combinations(range(1,n),2):
    if t == 0:
      break
    print(i+1,j+1)
    t -= 1


Measured memory_bytes: 3608
def pre_order(u):
    if u == -1:
        return
    print('', u, end='')
    pre_order(T[u])
    pre_order(T[u + N])

def in_order(u):
    if u == -1:
        return
    in_order(T[u])
    print('', u, end='')
    in_order(T[u + N])

def post_order(u):
    if u == -1:
        return
    post_order(T[u])
    post_order(T[u + N])
    print('', u, end='')

N = int(input())
T = [0, 0] * N
for _ in range(N):
    a, b, c = map(int, input().split())
    T[a], T[a + N] = b, c
root = (set(range(N)) - set(T)).pop()
print('Preorder')
pre_order(root)
print('\nInorder')
in_order(root)
print('\nPostorder')
post_order(root)
print()


Measured memory_bytes: 5628
#include <iostream>
using namespace std;
int main(void){
    int n, a[100] = {0};
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    cout << a[n-1];
    for(int i = 1; i < n; i++){
        int j = (n-1) - i;
        cout << " " << a[j];
    }
    cout << endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL read()
{
    LL x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

const int maxn=1e5+7;
int a[maxn];
int main()
{
    int n=read(),x=read();
    for(int i=1;i<=n;i++)a[i]=read();
    sort(a+1,a+1+n);
    int ans=0;
    for(int i=1;i<=n;i++){
        if(i==n){
            if(x==a[i])ans++;
            break;
        }
        if(x>=a[i]){
            x-=a[i];
            ans++;
        }
        else break;
    }
    printf("%d\n",ans);
    return 0;
}


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

int main(){
  int a, b, c;
  cin>>a>>b>>c;

  if(a > b) swap(a, b);
  if(b > c) swap(b, c);
  if(a > b) swap(a, b);

  cout<<a<<" "<<b<<" "<<c<<endl;
  return 0;
}



Measured memory_bytes: 3076
#include <stdio.h>

int main(){
  int n,i;
  scanf("%d",&n);
  int up,down;
  up=2;
  down = 1;
  for(i=0;i<=100;i++){
    if(down <= n && n < up){
      break;
    }
    up *=2;
    down *= 2;
  }
  printf("%d",down);
  return 0;
}


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

char s[4],t[4];
int n=3;

int main() {
    int ans=0;
    scanf("%s%s",s,t);
    for(int i=0;i<n;i++) ans+=s[i]==t[i];
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <iostream>
#define BIG 1000000007
using namespace std;
int main(){
	int n;
	scanf("%d", &n);
	char s1[n], s2[n];
	scanf("%s", s1);
	scanf("%s", s2);
	vector<bool> pieces(0);//縦がtrue、横がfalse
	for(int i = 0; i < n; i++){
		if(s1[i] == s2[i]){
			pieces.push_back(true);
		}else{
			pieces.push_back(false);
			i++;
		}
	}
	int size = pieces.size();
	long ans = 1;
	for(int i = 0; i < size; i++){
		if(i == 0){
			if(pieces[i] == true){
				ans *= 3;
			}else{
				ans *= 6;
			}
		}else{
			if(pieces[i] == true){
				if(pieces[i-1] == true){
					ans *= 2;
				}
			}else{
				if(pieces[i-1] == true){
					ans *= 2;
				}else{
					ans *= 3;
				}
			}
		}
		ans %= BIG;
	}
	printf("%ld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double PI = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	long long n, m, a, b;
	string s;
	cin >> n >> m >> a >> b;
	ll xa, xb;
	if (n < m)
		xa = n;
	else
		xa = m;
	if (a < b)
		xb = a;
	else
		xb = b;
	cout << xa + xb << endl;

	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int K;cin>>K;
    int now=7%K;
    if(now==0){
        cout<<1<<endl;
        return 0;
    }
    
    for(int t=1;t<=10000000;t++){
        if(now==0){
            cout<<t<<endl;
            return 0;
        }
        now*=10;
        now+=7;
        now%=K;
    }
    
    cout<<-1<<endl;
}


Measured memory_bytes: 3652
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int User_input_rate= input.nextInt();
    Set<String>Work=new HashSet<>();
    for(int i =0;i<User_input_rate;i++) {
    	String order = input.next();
    	String input_content = input.next();
    	if(order.equals("insert")) {
    		Work.add(input_content);
    	}
    	if(order.equals("find")) {
    		if(Work.contains(input_content)) {
    			System.out.println("yes");
    		}else {
    			System.out.println("no");
    		}
    	  }   	
        }
      }
    }


Measured memory_bytes: 253732
def isCLKWISE(ph):
    a = [-ph[-3][0]+ph[-1][0],ph[-1][1]-ph[-3][1]]
    b = [-ph[-3][0]+ph[-2][0],ph[-2][1]-ph[-3][1]]
    crs = b[1]*a[0] - a[1]*b[0]
    if crs < 0 : return False
    else : return True
     
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) : break
            else :
                del phU[-2]
                if len(phU) == 2 : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) : break
            else :
                del phL[-2]
                if len(phL) == 2 : break
    ph = phU + phL[1:-1]
    return ph
 
n = int(input())
P = []
for i in range(n):
    P.append([int(x) for x in input().split()])
     
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R:
    print(r[0],r[1])

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

    int k,mul;
    cin>>k;
    mul=7%k;
    for(int i=1;i<=k;i++)
    {
        if(mul==0)
        {
            cout<<i<<endl;
            return 0;
        }
        mul=((mul*10)+7)%k;

    }
    cout<<-1<<endl;

}



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

int main(){
  int N, A, B;
  int P[3]={};
  cin >> N>> A >> B;
  for(int i=0; i<N; i++){
    int p; cin >> p;
    if(p<=A) P[0]++;
    else if(p<=B) P[1]++;
    else P[2]++;
  }
  cout << min(min(P[0],P[1]),P[2]) << endl;
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(N)]
cd = [tuple(map(int, input().split())) for _ in range(M)]

for a, b in ab:
    check_point_dist = 10 ** 8 * 4 + 1
    check_point = 0
    count = 0
    for c, d in cd:
        count += 1
        if check_point_dist > abs(a - c) + abs(b - d):
            check_point = count
            check_point_dist = abs(a - c) + abs(b - d)
    else:
        print(check_point)

Measured memory_bytes: 9208
#include <stdio.h>
#define MAX 100
#define INF 1000000
void dfs(int,int);
int n,A[MAX],B[MAX][MAX],C[MAX][MAX],U[MAX];

int main(){

  int i,j,bb;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){

    scanf("%d",&bb);
    scanf("%d",&A[i]);

    for(j=0;j<A[i];j++){

      scanf("%d%d",&B[i][j],&C[i][j]);
      
    }
  }

  
  for(i=0;i<n;i++)U[i]=INF;

  dfs(0,0);
  
  for(i=0;i<n;i++){

    printf("%d %d\n",i,U[i]);

  }

  return 0;

}

void dfs(int a,int b){

  int i;
  //printf("U[%d]is%d\n",a,b);
  U[a]=b;
  for(i=0;i<A[a];i++){
    if(U[B[a][i]]>b+C[a][i])dfs(B[a][i],b+C[a][i]);
  }
  
}


  



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

#define ll long long 

using namespace std;

int n,l;
int sum;
int check;
int dif = 1e6;
int r;
int k;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>l;
    vector <int> v;
    for (int i=1; i<=n; i++){
       sum+=l+i-1; 
    }
    
    k=1;
    for (int i=1; i<=n; i++){
        check=0;
        for (int j=1; j<=n; j++){
            if (j!=k){
                check+=l+j-1;
            }
        }    
        if (abs(sum-check)<dif){
            dif=abs(sum-check);
            r=check;
        }
        k++;
    }
    cout<<r;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define maxn 100005
int main(){__
	int n;
	cin >> n;
	vi a(n);
	vi ans(n);
	int tot =0;
	for(int i=0; i < n; i++){
		cin >> a[i];
		tot^=a[i];
	}
	for(int i=0; i < n; i++){
		ans[i] = tot ^ a[i];
	}
	for(int x : ans){
		cout << x << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 4780
import string
  
count = {x: 0 for x in string.ascii_lowercase}
lines = ""
  
while True:
    try:
        lines += input().lower()
    except EOFError:
        break
          
for c in lines:
    if 'a' <= c <= 'z':
        count[c] += 1
          
for key in string.ascii_lowercase:
    print("{0} : {1}".format(key, count[key]))

Measured memory_bytes: 8004
#include <iostream>
#include <vector>
#include <map>

using namespace std;

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

	map<int, int> m;

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (m[a[i]] == 0)
		{
			m[a[i]] = 1;
		}
		else
		{
			m[a[i]]++;
		}
	}

	long long sum = 0;

	for (auto m_ : m)
	{
		sum += (long long)m_.second * (m_.second - 1) / 2;
	}
	
	for (auto ai : a)
	{
		cout << sum - (m[ai] - 1) << endl;
	}
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> Mo(N);
  for (int i=0;i<N;i++){
    cin>>Mo.at(i);
  }
  sort(Mo.begin(),Mo.end());
  int i=0;
  int x=1;
  while(i<N-1){
	if(Mo.at(i)<Mo.at(i+1)){
      x++;
    }
    i++;
  }
  cout<<x<<endl;
}

Measured memory_bytes: 256
n = int(input())
li = []
for i in range(n):
    li.append(int(input()))
    
cnt = 0
a = 1  
while a != 2 and cnt < 100000:
    a = li[a-1]
    cnt += 1
if cnt == 100000:
    print(-1)
else:
    print(cnt)

Measured memory_bytes: 7084
from sys import stdin
import string
import numpy as np

S = (stdin.readline().rstrip())
remain = string.ascii_lowercase

if S == remain[::-1]:
    print(-1)

else:

    for i in S:
        remain = remain.replace(i, "")

    if remain != "":
        ans = S + sorted(remain)[0]
        print(ans)

    else:
        S = np.array(list(S))
        for i in range(25, 0, -1):
            S_left = S[:i]
            S_right = np.sort(S[i:])
            if len(S_right[S_right > S_left[-1]]) != 0:
                ans = list(S[:i-1]) + list(S_right[S_right > S_left[-1]][0])
                ans = "".join(ans)
                print(ans)
                break

Measured memory_bytes: 12484
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; string S; cin >> N >> S;

    F0R(i, sz(S)) {
        int X = S[i] - 'A';
        X += N; X %= 26;
        S[i] = ('A' + X);
    }
    cout << S << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#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 Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

  

int main() {
  string n;
  cin >> n;
  int sum = 0;
  rep(i, n.size()) {
    sum += n.at(i) - '0';
  }
  if (sum%9 == 0) {
    coYes;
  }
  else {
    coNo;
  }
  //cout << sum << endl;
  //cout << 0 % 9 << endl;
}
 

Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int N, M;
priority_queue<ll> q;


int main() {
    cin >> N >> M;
    rep(i, N) {
        ll a; cin >> a;
        q.push(a);
    }

    rep(i, M) {
        ll t = q.top();
        q.pop();
        q.push(t / 2);
    }

    ll ans = 0;
    while (!q.empty()) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}


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

int main() 
{
    ll a, b;
    double tmp;
    cin >> a >> tmp;
    b = tmp * 100 + 0.5;

    ll ans = a*b/100;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String A = sc.next();
        String B = sc.next();

        boolean isALarger = false;
        boolean isEqual = true;

        if (A.length() > B.length()) {
            isALarger = true;
            isEqual = false;
        } else if (A.length() < B.length()) {
            isALarger = false;
            isEqual = false;
        } else {
            int n = A.length();
            for (int i = 0; i < n; i++) {
                if (A.charAt(i) == B.charAt(i)) {
                    continue;
                }
                isALarger = A.charAt(i) > B.charAt(i);
                isEqual = false;
                break;
            }
        }

        if (isEqual) {
            System.out.println("EQUAL");
        } else if (isALarger) {
            System.out.println("GREATER");
        } else {
            System.out.println("LESS");
        }
    }

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define has_str(s, c)	((s).find(c) != string::npos)
typedef long long ll;
int main() {
#ifdef LOCAL
    //freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> dp(3,0);
    for(int day = 0; day < n; ++day) {
        vector<int> a(3);
        vector<int> t_dp(3,0);
        for(int i = 0; i < 3; ++i)
            cin >> a[i];
        for(int i = 0; i < 3; ++i) {
            for(int j = 0; j < 3; ++j) {
                if(i == j)
                    continue;
                t_dp[j] = max(t_dp[j], dp[i] + a[j]);
            }
        }
        dp = t_dp;
    }
    cout << max({dp[0], dp[1], dp[2]});

    return 0;
}

Measured memory_bytes: 3652
import java.util.*;

import java.io.*;

public class Main {
	static HashMap<Integer,Integer>[] map;
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int[][] ia = new int[n-1][2];
		map = new HashMap[n + 1];
		for(int i = 1; i <= n; i++) {
			map[i] = new HashMap<Integer,Integer>();
		}
		for(int i = 0; i < n - 1; i++) {			
			int a = ni();
			int b = ni();
			ia[i][0] = a;
			ia[i][1] = b;
			map[a].put(b, 0);
			map[b].put(a, 0);			
		}
		
		int max = 0;
		List<Node> nl = new ArrayList<Main.Node>();
		for(int i = 1; i <= n; i++) {
			nl.add(new Node(i,map[i].keySet().size()));
			max = Math.max(max, map[i].keySet().size());
		}
		Comparator<Node> comparator = Comparator.comparing(Node::getCnt).reversed();
		nl.sort(comparator);
		Node head = nl.get(0);
		color(head.id,0);
		
		System.out.println(max);
		for(int i = 0; i < n - 1; i++) {
			System.out.println(map[ia[i][0]].get(ia[i][1]));
		}
	}
	
	static void color(int node,int pcolor) {
		int color = 1;
		HashMap<Integer,Integer> nmap = map[node];
		for(Integer next:nmap.keySet()) {
			if(nmap.get(next) == 0) {			
				if(color == pcolor)color++;
				nmap.put(next, color);
				map[next].put(node, color);				
				color(next,color);
				color++;
			} else {
				continue;
			}			
		}	
		
	}
	
	static class Node{
		public int id;
		public int cnt;
		public Node(int id, int cnt) {
			this.id = id;
			this.cnt = cnt;
		}
		public int getId() {
			return this.id;
		}
		public int getCnt() {
			return this.cnt;
		}
	}
	
	//Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 195636
#include<stdio.h>
int main ()
{
	int a,b=0,sum=0,i,z;
	float p;
	scanf("%d",&a);
	int x[a];
	for(i=0;i<a;i++)
    {
        scanf("%d",&x[i]);
        sum=sum+x[i];
    }
    p=(float)sum/(float)a;
    z=p;
    p=p-z;
    if(p>0.5)
    {
        z++;
    }
    for(i=0;i<a;i++)
    {
        x[i]=x[i]-z;
        b=b+(x[i]*x[i]);
    }
    printf("%d\n",b);


	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		char[] s = sc.nextLine().toCharArray();
		int[] lw = new int[n];
		int[] re = new int[n];
		for (int i = 1; i < n; i++) {
			lw[i] = lw[i - 1] + (s[i - 1] == 'W' ? 1 : 0);
		}
		for (int i = n - 2; i >= 0; i--) {
			re[i] = re[i + 1] + (s[i + 1] == 'E' ? 1 : 0);
		}

		int answer = n - 1;
		for (int i = 0; i < n; i++) {
			answer = Math.min(answer, re[i] + lw[i]);
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 34492
from fractions import gcd

if __name__ == '__main__':
    def factorize(n):
        fct = []
        b, e = 2, 0
        while b * b <= n:
            while n % b == 0:
                n = n // b
                e = e + 1
            if e > 0:
                fct.append((b, e))
            b, e = b + 1, 0
        if n > 1:
            fct.append((n, 1))
        return fct


    a, b = map(int, input().split())
    facts = factorize(gcd(a, b))
    print(len(facts) + 1)


Measured memory_bytes: 5304
import java.util.*;
import java.io.*;

/*
   AtCoder contest code
   coder : yoichidon
 */

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long A = sc.nextLong();
        long B = sc.nextLong();
        long C = sc.nextLong();
        long D = sc.nextLong();

        for(int plus = 0; plus<N; plus++){
            int minus = (N-1)-plus;
            long max = A + D * plus - C * minus;
            long min = A + C * plus - D * minus;
            if(min <= B && B <= max){
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");

    }
}


Measured memory_bytes: 22996
N = int(input())
SP = []
for n in range(N):
    l = input().split()
    l.append(n+1)
    SP.append(l)

tmp = sorted(SP, key=lambda sp: int(sp[1]), reverse=True)
tmp2 = sorted(tmp, key=lambda sp: sp[0])

for sp in tmp2:
    print(sp[2])

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
	int i,n,aa,ab;
	int a[10000],b[10000];
	while(1){
		aa=0;
		ab=0;
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d %d",&a[i],&b[i]);
			if(a[i]>b[i])aa+=a[i]+b[i];
			else if(a[i]<b[i])ab+=a[i]+b[i];
			else if(a[i]==b[i]){
			aa+=a[i];
			ab+=b[i];
			}
		}
		printf("%d %d\n",aa,ab);
	}
	return 0;
}

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

int main(){
  int n;
  int sum=0;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  sort(p.begin(),p.end());
  for(int i=0;i<n;i++){
    if(i==n-1){
      sum += p[i]/2;
    }else{
      sum += p[i];
    }
  }
    cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
sunuke = a[0]
arai = sum(a) - sunuke
ans = abs(sunuke - arai)
for i in range(1,n-1):
    sunuke += a[i]
    arai -= a[i]
    ans = min(ans,abs(sunuke-arai))
print(ans)

Measured memory_bytes: 24832
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include<bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	ll ans = 0;
	ans = a * c;
	ans = max(ans, a * d);
	ans = max(ans, b * c);
	ans = max(ans, b * d);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define ff first
#define ss second

template <class T>
void print(vector<T>& v){
    for(T x:v) cout<<x<<" ";
    cout<<"\n";
}
void inp(vector<int>& v, int n){
    for (int i=0; i<n; ++i) scanf("%d ", &v[i]);
}


void sol(){
    string s;
    cin>>s;
    int a=0, res=0;
    for (char c:s){
        if (c=='R'){
            a++;
            res=max(a, res);
        } else a=0;
    }
    cout<<res<<endl;
}


int main() {
    // int t;
    // cin>>t;
    // t++;
    // for (int i=1; i<t; ++i){ 
        sol();
    // }
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int n, ans;

int main(){
	cin >> n;
	for(int i = 1; i <= n; i *= 100){
		if(i*10 <= n) ans += i*9;
		else ans += n - i + 1;
	}
	cout << ans << "\n";
}

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

int main(){
    int N;
    cin >> N;
    if (N%10==2 ||N%10==4 ||N%10==5 ||N%10==7 ||N%10==9)
    {
        cout<<"hon"<<endl;
    }
    else if (N%10==0 ||N%10==1 ||N%10==6 ||N%10==8 )
    {
        cout<<"pon"<<endl;
    }
    else if (N%10==3)
    {
        cout<<"bon"<<endl;
    }
    
}

Measured memory_bytes: 3628
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]
plan = 0
for i in range(1,n+2):
    plan += abs(a[i] - a[i-1])
for i in range(n):
    if (a[i+1] - a[i]) * (a[i+2] - a[i+1]) >= 0:
        print(plan)
    else:
        print(plan - abs(a[i+1] - a[i]) - abs(a[i+2] - a[i+1]) + abs(a[i+2] - a[i]))


Measured memory_bytes: 14048
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

vector<int> as;

int solve(const int N, const int K) {
    int ans = 0;

    int pos = 0;
    while (pos < N - 1) {
        ans++;
        pos += K - 1;
    }

    return ans;
}

int main(void) {
    int N, K;
    cin >> N >> K;

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }

    if (K >= N) {
        cout << 1 << endl;
    } else {
        cout << solve(N, K) << endl;
    }

    return 0;
}


Measured memory_bytes: 640
// ABC114_B
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    string S;
    cin >> S;
    
    // calculation
    ll res = 1000;
    for (ll i = 0; i < S.length()-2; ++i) {
        res = min(abs(stoll(S.substr(i, 3)) - 753), res);
    }
    
    cout << res << "\n";
    
    return 0;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  set<int> s;
  for (int i=1;i<=sqrt(M);i++){
    if (M%i==0){
      s.insert(i);
      s.insert(M/i);
    }
  }
  int n=*lower_bound(s.begin(),s.end(),N);
  int ans=M/n;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define reset(N) memset(N,0,sizeof(N))
#define clear(N) while(N.size()>0) N.pop()
#define f(a,v,b) for(int a=v;a<b;a++)
#define cb(N) __builtin_popcount(N)
#define cbl(N) __builtin_popcountl(N)
#define cbll(N) __builtin_popcountll(N)
using namespace std;
int n,w;
int we[101],va[101];
ll dp[101][100001];
void solve(){
	cin>>n>>w;
	f(i,1,n+1){
		cin>>we[i]>>va[i];
	}
	f(i,1,n+1) f(j,1,w+1){
		if(j>=we[i]) dp[i][j]=max(dp[i-1][j],dp[i-1][j-we[i]]+va[i]);
		else dp[i][j]=dp[i-1][j];
	}
	cout<<dp[n][w]<<'\n';
}
int main(){
	ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 78336
import sys
import math
sys.setrecursionlimit(10 ** 7)

# 桁DP
# 再帰

N = input()
K = int(input())
lenN = len(N)


# 組み合わせの数
def comb(n, k):
    return math.factorial(n) // (math.factorial(k) * math.factorial(n-k))


# i桁目から
# 残りk個 Non-Zero
# Nよりもsmallerか？
# というときの組み合わせの数
def CntAlmostZero(i, k, smaller):
    # N桁まで取り出した時
    if i == lenN:
        if k == 0:
            return 1
        else:
            return 0

    if k == 0:
        return 1

    # Nよりも小さい時
    if smaller:
        # 残りの桁でK個使える時
        if (lenN - i) >= k:
            return comb(lenN - i, k) * (9 ** k)
        # 無理なら 0
        else:
            return 0
    # 前がNと同じ桁の時(初期は0なので必ずこっち)
    else:
        # 見てる桁が0の時
        if N[i] == '0':
            return CntAlmostZero(i + 1, k, False)
        # 見てる桁が0以外の時
        else:
            # 0だったら
            zero = CntAlmostZero(i+1, k, True)
            # 同じだったら
            same = CntAlmostZero(i+1, k-1, False)
            # その間だったら
            aida = CntAlmostZero(i+1, k-1, True) * (int(N[i]) - 1)

            return zero + same + aida

    return 1


ans = CntAlmostZero(0, K, False)
print(ans)


Measured memory_bytes: 3064
function f()
    input = map(x->parse(Int, x), split(chomp(readline()), " "))
    n = input[1]
    m = input[2]

    s = []

    for i in 1:n
        inp = map(x->parse(Int, x), split(chomp(readline()), " "))
        push!(s, inp)
    end

    ret = []
    for i in 1:m
        push!(ret, 0)
    end

    for i in 1:n
        for j in 2:(s[i][1]+1)
            ret[s[i][j]] += 1 
        end
    end

    ret2 = 0
    for i in 1:m
        if ret[i] == n
            ret2 += 1
        end
    end

    print(ret2)
end
f()

Measured memory_bytes: 168208
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <queue>
     
using namespace std;
typedef long long ll;
     
     
bool debug = false;
     


unordered_map<ll, ll> idPlusHeightCount;
//vector<ll> A;
ll A[200005];

int main()
{
	std::ios::sync_with_stdio(false);
    
    ll n;

    cin >> n;

    ll res = 0;

    for (int i = 1; i <= n; i++)
    {
        cin >> A[i];

        res += idPlusHeightCount[i - A[i]];

        idPlusHeightCount[i + A[i]]++;

        /*
        for (int j = 1; j < i; j++)
        {
            if (i - j == A[i] + A[j]) // i - A[i] == j + A[j]
                res++;
        }
        */

    }

    cout << res;

    return 0;
}

Measured memory_bytes: 20104
num_apple, num = map(int, input().split())

taste_list = []
for i in range(num_apple):
  taste_list.append(num + i)

def func_abs(n):
    return abs(n)
  
min_abs = min(taste_list, key=func_abs)
taste_list.remove(min_abs)
print(sum(taste_list))

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


int main() {
  double N,T,A;
  cin >>N>>T>>A;
  double minT = 10000000;
  int num = 0;
  vector<int> H(N);
  for (int i = 0; i < N; i++)
  {
    cin >> H[i];
    double aveT = T-H[i]*0.006;
    if(minT>abs(A-aveT)){num = i+1;}
    minT = min(minT,abs(A - aveT));
    
  }
  
  cout << num << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//要素数受け取り
		int n = sc.nextInt();
		int sum = 0;
		Integer [] list = new Integer[n];
		for(int i = 0; i < n; i ++){
			list[i] = sc.nextInt();
		}
		Arrays.sort(list,Collections.reverseOrder());
		if(n%2 == 0){
			for(int t = 0; t < n-1; t += 2){
				sum += list[t] - list[t+1];
				}
			}else{
				for(int t = 0; t < n-2; t += 2){
					sum += list[t] - list[t+1];
				}
				sum += list[n-1];
			}
			System.out.println(sum);
		}
}


Measured memory_bytes: 23764
import bisect

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cum_a = [0]
for i in range(n):
    cum_a.append(cum_a[i] + a[i])

cum_b = [0]
for i in range(m):
    cum_b.append(cum_b[i] + b[i])

ans = 0
val = m
for i in range(n + 1):
    if cum_a[i] > k:
        break

    val = bisect.bisect_right(cum_b, k - cum_a[i]) - 1

    # while cum_b[val] > k - cum_a[i]:
    #    val -= 1

    ans = max(ans, i + val)

print(ans)


Measured memory_bytes: 47568
import java.util.Scanner;
public class Main{
	static long[] fact;
	static long mod;
	static long[] inv;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		mod=1000000007;
		fact=new long[200001];
		fact[1]=1;
		fact[0]=1;
		for(int i = 2; i<200001; i++){
			fact[i]=(fact[i-1]*i)%mod;
		}
		inv=new long[200001];
		inv[200000]=pow(fact[200000],mod-2);
		inv[0]=1;
		for(int i = 199999; i>0; i--){
			inv[i]=(inv[i+1]*(i+1))%mod;
		}
		long ans=0;
		for(int i = 0; i<w-b; i++){
			ans+=(comb(w+h-a-2-i,w-i-1)*comb(a-1+i,i))%mod;
			ans%=mod;
		}
		System.out.println(ans);
	}
	static long comb(int t,int y){
		long re=1;
		re*=fact[t];
		re*=inv[y];
		re%=mod;
		re*=inv[t-y];
		return re%mod;
	}
	
	static long pow(long p,long q){
		long res=1;
		while(q>0){
			if((q & 1)==1){
				res*=p;
				res%=mod;
			}
			q>>=1;
			p*=p;
			p%=mod;
		}
		return res;
	}
}


Measured memory_bytes: 25940
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

int main() {
  string s;
  cin >> s;
  
  bool ans=false;
  if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]) ans=true;
  if(s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]) ans=true; 
  if(s[0]==s[3] && s[1]==s[2] && s[0]!=s[1]) ans=true;
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main()
{
long long int n;
long long int c=0,d=0,f=0,i;
scanf("%lld",&n);
c=(int)sqrt((double)n);
for(i=c;i>=1;i--)
{
	if(n%i==0)
	{
	f=i;
	d=n/i;
	break;
	}
	else
	f=n;
	d=1; 
	
}
printf("%lld",f+d-2);

	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#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;
int N,M;
int c[MC];

int main(){
	scanf("%d%d" , &N , &M);
	repp(i,0,M){
		int a,b;
		scanf("%d%d" , &a , &b);
		c[a]++;
		c[b]++;
	}
	repp(i,1,N+1){
		if(c[i]%2==1){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 512
unittest
{
	assert( [ "4", "1 2 3 4" ].parse.expand.solve == "4 2 1 3" );
	assert( [ "3", "1 2 3" ].parse.expand.solve == "3 1 2" );
	assert( [ "1", "1000000000" ].parse.expand.solve == "1000000000" );
	assert( [ "6", "0 6 7 6 7 0" ].parse.expand.solve == "0 6 6 0 7 7" );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto ts = new long[ as.length ];
	auto ti = as.length / 2;
	
	foreach( ai, a; as )
	{
		ts[ ti ] = a;
		
		// 次の要素を入れる場所を計算
		if( as.length % 2 == 0 )
		{
			// Aの長さが偶数のときは左、右の順で追加していく
			if( ai % 2 == 0 ) ti -= ai + 1;
			else              ti += ai + 1;
		}
		else
		{
			// Aの長さが奇数のときは右、左の順で追加していく
			if( ai % 2 == 0 ) ti += ai + 1;
			else              ti -= ai + 1;
		}
	}
	
	return ts.to!( string[] ).join( " " );
}


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

int visited[60][60], map[60][60];
int dr[]={-1, -1, -1, 0, 0, 1, 1, 1};
int dc[]={-1, 0, 1, -1, 1, -1, 0, 1};
int h, w, k;

void dfs(int r, int c)
{
    int i;
    if (visited[r][c]) return;
    visited[r][c]=k;
    for(i=0;i<8;++i) {
        int nr=r+dr[i], nc=c+dc[i];
        if (nr<0 || nr>=h || nc<0 || nc>=w || visited[nr][nc] || map[nr][nc]!=1) continue;
        dfs(nr, nc);
    }
}

int main()
{
    while (1) {
        int i, j;
        scanf("%d%d", &w, &h);
        if (w==0) break;

        memset(map, 0, sizeof(map));
        memset(visited, 0, sizeof(visited));
        for(i=0;i<h;++i) {
            for(j=0;j<w;++j) scanf("%d", &map[i][j]);
        }

        k=1;
        for(i=0;i<h;++i) for(j=0;j<w;++j)
            if (map[i][j] && !visited[i][j]) { dfs(i, j); ++k; }
        printf("%d\n", k-1);
    }
    return 0;
}

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

#define reint register int
#define coint const int

using namespace std;

typedef long long ll;

coint MOD = 1e9 + 7;

ll dp[100 + 5][2][35000], sum[100 + 5][2][35000];

inline ll mod(const ll num) { return num >= MOD ? num - MOD : num; }

int main(void) {
    int n, k;
    scanf("%d%d", &n, &k);
    int sqrtn = sqrt(n) + 1, divi = n / sqrtn;
    if (divi * sqrtn == n) --divi;
    sqrtn = n / (divi + 1);
    //printf("sqrtn = %d, divi = %d\n", sqrtn, divi);

    for (reint i = 1; i <= sqrtn; ++i)
        dp[1][0][i] = 1, sum[1][0][i] = mod(sum[1][0][i - 1] + dp[1][0][i]);
    for (reint i = 1; i <= divi; ++i)
        dp[1][1][i] = n / i - n / (i + 1),
        sum[1][1][i] = mod(sum[1][1][i - 1] + dp[1][1][i]);

    for (reint i = 2; i <= k; ++i) {
        for (reint j = 1; j <= sqrtn; ++j)
            dp[i][0][j] = mod(
                    mod(sum[i - 1][1][divi] - sum[i - 1][1][j - 1] + MOD) +
                    sum[i - 1][0][min(sqrtn, n / j)]);
        for (reint j = 1; j <= divi; ++j)
            dp[i][1][j] = (ll)(n / j - n / (j + 1)) * sum[i - 1][0][j] % MOD;
        for (reint j = 1; j <= sqrtn; ++j)
            sum[i][0][j] = mod(sum[i][0][j - 1] + dp[i][0][j]);
        for (reint j = 1; j <= divi; ++j)
            sum[i][1][j] = mod(sum[i][1][j - 1] + dp[i][1][j]);

        //for (reint j = 1; j <= sqrtn; ++j)
            //printf("dp[%d][0][%d] = %lld\n", i, j, dp[i][0][j]);
        //for (reint j = 1; j <= divi; ++j)
            //printf("dp[%d][1][%d] = %lld\n", i, j, dp[i][1][j]);
    }

    ll ans = mod(sum[k][0][sqrtn] + sum[k][1][divi]);
    printf("%lld\n", ans);

    return 0;
}



Measured memory_bytes: 110208
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
vector<vector<P>> G;
vector<int> c;
void dfs(int i, int p, int pc) {
    int id = 1;
    for (auto &e : G[i]) {
        if (e.first == p) {
            continue;
        }
        if (id == pc) {
            id++;
        }
        c[e.second] = id;
        dfs(e.first, i, id);
        id++;
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    G.resize(n);
    c.resize(n);
    int ma = 0;
    vector<int> d(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(P(b, i));
        G[b].push_back(P(a, i));
        d[a]++;
        d[b]++;
    }
    for (int i = 0; i < n; i++) {
        chmax(ma, d[i]);
    }
    cout << ma << endl;
    dfs(0, -1, -1);
    for (int i = 0; i < n - 1; i++) {
        cout << c[i] << endl;
    }
}

Measured memory_bytes: 8576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC145A
{
  class Program
  {
    static void Main(string[] args)
    {
      int a, b, c, x;
      
      var word = Console.ReadLine().Split(' ');
      
      a = int.Parse(word[0]);
      b = int.Parse(word[1]);
      c = int.Parse(word[2]);
      
      x = a * b;
      
      if (x < c)
        Console.WriteLine(x);
      
      else if (c < x)
        Console.WriteLine(c);
      
      else
        Console.WriteLine(x);
      
      Console.ReadKey();
    }
  }
}

Measured memory_bytes: 11092