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

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	int a[n], b[n], c[n];
	map <int, int> mp;
	map <int, int> m;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		b[i] = a[i] + i;
		c[i] = i - a[i];
		mp[b[i]] ++;
		m[c[i]] ++;
	}
	int ans = 0;
	for (int i = -n; i <= 2 * n; i++){
		ans += (mp[i] * m[i]);
	}
	cout << ans;
}


Measured memory_bytes: 95804
#include <iostream>

using namespace std;

int main()
{
    int T[100], p[100], r[100];
    int N, M, sum, temp, i, j, k;
    cin>>N;
    for(i = 0, sum = 0; i < N; i++)
    {
        cin>>T[i];
        sum += T[i];
    }
    cin>>M;
    for(i = 0; i < M; i++)
    {
        temp = sum;
        cin>>k>>j;
        p[k] = j;
        r[i] = temp + p[k] - T[k - 1];
    }
    for(i = 0; i < M; i++)
    {
        cout<<r[i]<<endl;
    }
    return 0;
}


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

int main() 
{
    int n=5, sum=0, min=10, y;
    vector <int> v(n);
    for (int i=0; i<n; i++)
    {
        int x;
        cin >> x;
        int ah = x%10;
        if (ah<min && ah!=0)
        {
            y = x;
            min = ah;
        }
        v[i] = x;
    }
    bool z = true;
    for (int i=0; i<n; i++)
    {
        if (v[i] == y && z)
        {
            sum += y;
            z = false;
        }
        else
        {
            int x = v[i];
            int ah = x%10;
            if (ah != 0)
                x = x + (10-ah);
            sum += x;
        }
    }
    cout << sum;
    return 0;
}

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

using namespace std;

int main() {
	int x, y;
	cin >> x >> y;

	for (int i = 0; i <= x; ++i) {
		int n = i * 2 + (x - i) * 4;
		if (n == y) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";

	return 0;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        List<Long> list = new ArrayList<>();
        for (long i = 0; Math.pow(i, 5) <= Long.MAX_VALUE; i++) {
            long num = (long) Math.pow(i, 5);
            list.add(num);
        }

        String[] nums = new String[2];
        for (int i = 0; i < list.size(); i++) {
            for (int j = 0; j < list.size(); j++) {

                long left = (long) list.get(i);
                long right = (long) list.get(j);
                long target = (long) x;

                if (left - right == target) {
                    nums[0] = Integer.toString(i);
                    nums[1] = Integer.toString(j);
                    break;
                }
                if (left + right == target) {
                    nums[0] = Integer.toString(i);
                    nums[1] = Integer.toString(j * -1);
                    break;
                }
                if (left + right == target * -1) {
                    nums[0] = Integer.toString(i * -1);
                    nums[1] = Integer.toString(j);
                    break;
                }
            }
        }
        String result = String.join(" ", nums);

        // 出力
        System.out.println(result);
    }
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

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

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

void solve()
{
    int N;
    cin >> N;
    map<int, int> mp;
    set<int> s;
    REP0 (i, N)
    {
        int a;
        cin >> a;
        mp[a]++;
        s.insert(a);
    }

    if (mp.count(0) and mp[0] == N)
    {
        std::cout << "Yes" << endl;
        return;
    }
    
    if (N % 3 != 0)
    {
        std::cout << "No" << endl;
        return;
    }

    if (s.size() == 2 and mp.count(0))
    {
        bool isok = true;
        for (auto n : s)
        {
            if (n == 0 and mp[n] != N / 3)
            {
                isok = false;
            }
        }
        if (isok)
        {
            std::cout << "Yes" << endl;
        }
        else
        {
            std::cout << "No" << endl;
        }
        return;
    }

    if (s.size() == 3)
    {
        int e = 0;
        for (auto n : s)
        {
            e ^= n;
            if (mp[n] != N / 3)
            {
                std::cout << "No" << endl;
                return;
            }
        }
        if (e == 0)
        {
            std::cout << "Yes" << endl;
        }
        else
        {
            std::cout << "No" << endl;
        }
        return;
    }

    std::cout << "No" << endl;
    return;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n, k; cin >> n >> k;
  vector<int> a(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
  }
  vector<int> dp(k+1);
  dp[0] = 0;
  for(int i=1;i<=k;++i) {
    set<int> s;
    for(int j=0;j<n;++j) {
      if(i - a[j] < 0) continue;
      s.insert(dp[i-a[j]]);
    }
    for(int j=0;j<=k;++j) {
      if(s.find(j) == s.end()) {
        dp[i] = j;
        break;
      }
    }
  }
  if(dp[k] == 0) cout << "Second" << endl;
  else cout << "First" << endl;
}


Measured memory_bytes: 640
import sys
def input(): return sys.stdin.readline().rstrip()
import heapq
def main():
    n,m=map(int,input().split())
    AB=[tuple(map(int,input().split())) for i in range(n)]
    AB.sort(reverse=True)
    H=[]
    ans=0
    for i in range(1,m+1):
        while AB and AB[-1][0]<=i:
            a,b=AB.pop()
            heapq.heappush(H,(-b,a))
        if H:
            bb,aa=heapq.heappop(H)
            ans-=bb
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 17248
#include <bits/stdc++.h>
using namespace std;
// clang-format off

using LL = long long;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
 
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
// clang-format on

// unsigned euclidean_gcd(unsigned a, unsigned b) {
//   if (a < b)
//     return euclidean_gcd(b, a);
//   unsigned r;
//   while ((r = a % b)) {
//     a = b;
//     b = r;
//   }
//   return b;
// }

LL gcd(LL x, LL y) {
  return (x % y) ? gcd(y, x % y) : y;
}

void solve(long long K) {
  // solver code

  LL sum = 0;

  for (int a = 1; a <= K; a++) {
    for (int b = 1; b <= K; b++) {
      for (int c = 1; c <= K; c++) {
        //
        LL tmp = gcd(a, b);
        LL res = gcd(tmp, c);
        // COUT(res);
        sum += res;
      }
    }
  }

  cout << sum << endl;
}

int main() {
  long long K;
  scanf("%lld", &K);
  solve(K);
  return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  for(int i=1;i<10;i++)
  {
     for(int j=1;j<10;j++)
     {
        if(i*j==n)
        {
           cout<<"Yes";
          return 0;
        }
     }
  }
  cout<<"No";
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
int main() {
    ll a,b,n;
    ll z=0;
    cin>>a>>b>>n;
    if (n<b)
    {
        /* code */
        cout<<a*n/b<<endl;
    }
    else if(a<=b){
        cout<<a*(b-1)/b<<endl;
    }
    else
    {
        cout<<max(z,a*(b-1)/b)<<endl;
    }
    
    
    
}

Measured memory_bytes: 3592
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List

f [n, x] = length [(a, b, c) | a <- [1..n], b <- [a+1..n], c <- [b+1..n], a+b+c==x]

main = do
    getContents >>= mapM_ print . map f . takeWhile (any (/=0)) . map (map read . words) .lines  

Measured memory_bytes: 4520
def search_unblanced_position(char_str):
    for i in range(len(char_str)-1):
        if s[i] == s[i+1]:
            return i+1,i+2
 
    for i in range(len(char_str)-2):
        if s[i] == s[i+2]:
            return i+1,i+3
 
    return -1,-1
 
s = input()
 
a,b = search_unblanced_position(s)
 
print (a,b)

Measured memory_bytes: 3188
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }

int main(){
  ll a, b, x, n, m;
  cin >> a >> b >> x;
  b != 0 ? n = b / x + 1 : n = 1;
  a != 0 ? m = (a - 1) / x + 1 : m = 0;
  
  cout << n - m << ln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll A, B, C;
        cin >> A >> B >> C;
        if (A == B and B == C and even(A) and even(B) and even(C)) {
                cout << -1 << endl;
                return 0;
        }

        ll ans = 0;
        for (;;) {
                if (odd(A) or odd(B) or odd(C)) break;
                ll a = A;
                ll b = B;
                ll c = C;
                A = b/2 + c/2;
                B = a/2 + c/2;
                C = a/2 + b/2;
                ++ans;
        }
        cout << ans << endl;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long int li;

int main(void){
    ll i=0;
    ll j=0;
    ll ans=0;
    char s[200001];
    for(ll p=1;p<=200000;p++){
        s[p]=0;
        cin >> s[p];
}
    for(ll p=1;p<=200000;p++){
    if(s[p]=='B')i++;
    if(s[p]=='W'){
        j++;
        ans+=i;
    }
}

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

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

int main() {
  long long N, K;
  cin >> N >> K;
  vector<pair<long long, long long>> AB(N);
  for (long long i = 0, a, b; i < N && cin >> a >> b; i++) AB.at(i) = {a, b};
  sort(AB.begin(), AB.end());

  long long ans = 0, sum = 0;
  for (long long i = 0; i < N; i++) {
    sum += AB.at(i).second;
    if (sum >= K) {
      cout << AB.at(i).first << "\n";
      break;
    }
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;
int main() {
	int N, X;
	cin >> N >> X;
	vector<int> v(N+1);
	for (int i = 1; i <= N; i++) {
		cin >> v[i];
	}
	for (int i = 1; i <= N; i++) {
		v[i] += v[i-1];
	}
	int ans = 0;
	for (int i = 0; i <= N; i++) {
		if (v[i] <= X) {
			ans++;
		}
		else {
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
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; }
const long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];
const int MOD = 1000000007;

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

    rep(i, n + 1)
    {
        rep(j, n + 1)
        {
            int l = n - i - j;
            if (l*10000 + j*5000 + i*1000 == y && l + i + j == n && l >= 0 && l <= n)
            {
                cout << l << " " << j << " " << i << endl;
                return 0;
            }
        }
    }
    //cout << 1000*944 + 5000*54 + 10000*2 << endl;
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

ll gcd(ll a, ll b) {
    return b != 0 ? gcd(b, a % b) : a;
}

int main() {
    int T;
    cin >> T;
    for (int i = 0; i < T; i++) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        bool ok = true;
        if (d < b) {
            ok = false;
        } else if (d == b) {
            if (a < b) {
                ok = false;
            }
            a = a % b;
            if (a > c) {
                ok = false;
            }
        } else {
            if (a < b) {
                ok = false;
            }
            a = a % b;
            if (a + b > c) {
                if (c < a && a < b) {
                    ok = false;
                }
                ll e = d - b;
                ll f = gcd(e, b);
                ll bre = b - c - 1;
                if (bre > 0) {
                    ll lo = (c - a) / f;
                    ll hi = (b - a + f - 1) / f;
                    if (hi - lo > 1) {
                        ok = false;
                    }
                }
            }
        }
        if (ok) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
B = list(map(int,readline().split()))
Q = int(readline())
m = map(int,read().split())
LR = sorted(zip(m,m))

class MaxSegTree():
    def __init__(self,N):
        self.Nelem = N
        self.size = 1<<(N.bit_length()) # 葉の要素数
        self.data = [0] * (2*self.size)
        
    def build(self,raw_data):
        # raw_data は 0-indexed
        for i,x in enumerate(raw_data):
            self.data[self.size+i] = x
        for i in range(self.size-1,0,-1):
            x = self.data[i+i]; y = self.data[i+i+1]
            self.data[i] = x if x>y else y
    
    def update(self,i,x):
        i += self.size
        self.data[i] = x
        i >>= 1
        while i:
            x = self.data[i+i]; y = self.data[i+i+1]
            self.data[i] = x if x>y else y
            i >>= 1
    
    def get_data(self,i):
        return self.data[i+self.size]

    def get_max(self,L,R):
        # [L,R] に対する値を返す
        L += self.size
        R += self.size + 1
        # [L,R) に変更
        x = 0
        while L < R:
            if L&1:
                y = self.data[L]
                if x < y: x = y
                L += 1
                
            if R&1:
                R -= 1
                y = self.data[R]
                if x < y: x = y
            L >>= 1; R >>= 1
        return x

"""
・ある場所まで確定して、そこから先を全て1で埋めた場合
・ある場所まで確定して、そこから先を全て0で埋めた場合
の加算スコア
"""
add0 = [0] * (N+1)
add1 = [0] * (N+1)
x = sum(B)
add1[0] = x
add0[0] = N-x
for i,x in enumerate(B,1):
    if x == 0:
        add0[i]=add0[i-1]-1; add1[i] = add1[i-1]
    else:
        add1[i]=add1[i-1]-1; add0[i] = add0[i-1]

"""
ある場所を右端としてとった時点での
・残りをすべて0で埋めたときのスコア
・残りをすべて1で埋めたときのスコア
dp0, dp1 をseg木で管理
"""

dp0 = MaxSegTree(N+1)
dp0.build([add0[0]] + [0] * N)
dp1 = MaxSegTree(N+1)
dp1.build([add1[0]] + [0] * N)

for L,R in LR:
    # dp1[R] を計算したい。[L,inf) が1で埋まったときのスコア
    x = dp1.get_data(R)
    y = dp0.get_max(0,L-1) + add1[L-1] - add0[L-1] # 0埋め部分を1埋めに修正してdp1[R]に遷移
    z = dp1.get_max(L,R-1) # そのままdp1[R]に遷移
    if y < z: y = z
    if x < y:
        dp1.update(R,y)
        dp0.update(R,y - add1[R] + add0[R])

# 一致を数えていたので、距離に修正
answer = N - dp0.data[1]
print(answer)

Measured memory_bytes: 135752
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
int h,w,n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>h>>w>>n;
    h=max(h,w);
    if (n%h==0) cout<<n/h;
    else cout<<n/h+1;
}

Measured memory_bytes: 892
def resolve():
    K = int(input())
    lst = [-1]*K
    st = 7
    count =1
    while True:
        st %= K
        if st ==0:
            print(count)
            return
        if lst[st]!=-1:
            print(-1)
            return
        lst[st]=1
        st = (st*10+7)%K
        count +=1
resolve()

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

const int maxn = 110;

int n, id[maxn];
long double x[maxn], y[maxn], ans;

long double solve() {
	long double ax=0, ay=0, dis=0, tmp;
	random_shuffle(id, id+n);
	for (int i = 0; i < n; ++i) {
		ax += x[id[i]];
		ay += y[id[i]];
		tmp = sqrt(ax*ax+ay*ay);
		if (tmp > dis) dis = tmp;
		else ax -= x[id[i]], ay -= y[id[i]];
	}
	return dis;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> x[i] >> y[i];
		id[i] = i;
	}
	for (int i = 0; i < 10000; ++i)
		ans = max(ans, solve());
	cout << setprecision(13) << ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

void stop(void) {
    cout << "No" << endl;
    exit(0);
}

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::string s, t;
    cin >> s >> t;

    bool is_used[30]   = {};
    char link[30]      = {};
    bool is_linked[30] = {};

    for (int i = 0; i < s.length(); i++) {
        char cs = s[i], ct = t[i];
        if (is_linked[cs - 'a']) {
            if (link[cs - 'a'] != ct) {
                stop();
            }
        } else {
            if (is_used[ct - 'a']) {
                stop();
            } else {
                link[cs - 'a']      = ct;
                is_used[ct - 'a']   = true;
                is_linked[cs - 'a'] = true;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 1020
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }
    
    static object process(TextReader input) {
        var s   = input.ReadLine();

        int count = 0;
        for(int i=0; i<s.Length/2; i++) {
            if (s[i] != s[s.Length - i - 1]) count++;
        }

        return count;
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define sort(a) sort(all(a))
using P = pair<int, int>;
using ll = long long;
using ld = long double;
int dx[4] = { 0, 1, 0,-1 };
int dy[4] = { 1, 0,-1, 0 };

signed main() {
  string s;
  cin >> s;
  if (s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}

ll max(ll a, ll b) { return (a > b) ? a : b; }
template<typename T>
struct edge {

	int src, to;
	T cost;

	edge(int to, T cost) : src(-1), to(to), cost(cost) {}

	edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

	bool operator<(const edge<T> e1) {
		return cost < e1.cost;
	}


	edge &operator=(const int &x) {
		to = x;
		return *this;
	}

	operator int() const { return to; }

};
template<typename T>
using Edge = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edge<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;


template<typename T>
vector<T> dijkstra(WeightedGraph<T> &g, int s) {
	const auto INF = numeric_limits<T>::max();
	vector<T> dist(g.size(), INF);

	using Pi = pair<T, int>;

	priority_queue<Pi, vector<Pi>, greater<Pi>> q;

	dist[s] = 0;

	q.emplace(dist[s], s);

	while (!q.empty()) {
		T cost;
		int idx;

		tie(cost, idx) = q.top();
		q.pop();
		if (dist[idx] < cost) continue;

		for (auto &e : g[idx]) {
			auto next_cost = cost + e.cost;
			if (dist[e.to] <= next_cost) continue;
			dist[e.to] = next_cost;
			q.emplace(dist[e.to], e.to);

		}
	}
	return dist;
}


ll H, W, K;

char A[805][805];

int ceil(int a, int K) {
	if (a < K)
		return 1;

	else if (a % K == 0)
		return a / K;
	
	return ((a / K) + 1);
}

int main() {

	cin >> H >> W >> K;

	WeightedGraph<ll> e2(2 * H * W);
	ll sx, sy;
	auto in = [&](int x, int y) {return x >= 0 && y >= 0 && x < H && y < W; };
	auto idx = [&](int x, int y) { return W * x + y; };

	rep(i, H)
		rep(j, W)
		cin >> A[i][j];


	rep(i, H) {
		rep(j, W) {
			if (A[i][j] == 'S') { sx = i; sy = j; }

			rep(k, 4) {
				int nx = i + dx[k].first, ny = j + dx[k].second;
				if (in(nx, ny) && A[nx][ny] != '#' && A[i][j] != '#') e2[idx(i, j)].emplace_back(idx(nx, ny), 1);
			}

		}
	}


	vector<ll> dist2 = dijkstra(e2, idx(sx, sy));


	ll m1 = inf;


	rep(i, H) {
		rep(j, W) {
			if (dist2[idx(i, j)] <= K) {
				m1 = min(m1, min(H - 1 - i, i));
				m1 = min(m1, min(W - 1 - j, j));
			}
		}

	}

	
	if (m1 != 0) {
		cout << (1 + ceil(m1, K)) << endl;
	}
	else {
		cout << 1 << endl;
	}

	return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    string ch;
    cin>>ch;
    ll c=0;
    for(ll i=0;i<n;i++){
        if(ch[i] !=ch[i+1]){
            c++;
        }
    }
    cout<<c;
    
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ma = 0;
    int current = 0;
    REP(i, S.length()) {
        if(S[i] == 'I') {
            current++;
            ma = max(ma, current);
        } else {
            current--;
        }
    }
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
			Scanner scan = new Scanner(System.in);
			int num = scan.nextInt();
			int h = num / 3600;
			int m = (num%3600)/60;
			int s = num%60;
			System.out.println(h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 26220
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = s()
if N[0] == N[1] == N[2]:
    print('Yes')
elif N[1] == N[2] == N[3]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 77236
function isTriangle(input){
//  console.log("Please input the numbers");
  const input3 = input.split(' ');
//  console.log(input3);
  A = parseInt(input3[0].replace(/\r?\n/g,''));
  B = parseInt(input3[1].replace(/\r?\n/g,''));
  C = parseInt(input3[2].replace(/\r?\n/g,''));
//  console.log(A);
//  console.log(B);
//  console.log(C);
  if (A < 1 || 100 < A) {
//    console.log("A is out of range");
    return;
  }
  if (B < 1 || 100 < B) {
//    console.log("B is out of range");
    return;
  }
  if (C < 1 || 100 < C) {
//    console.log("C is out of range");
    return;;
  }
  if (A==B && B==C && C==A){
    console.log("Yes");
  }else{
    console.log("No");
  }
}

isTriangle(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
# include <iostream>
# include <algorithm>
# include <vector>
using namespace std;
int main(){
  std::vector<std::vector<int>> G{{1, 3, 5, 7 ,8 ,10 ,12}, {4, 6, 9, 11},{2}};
  bool frag = true;
  int x,y;
  cin >> x >> y;
  for(int i=0;i<3;i++){
    auto f1 = find(G[i].begin(),G[i].end(),x);
    auto f2 = find(G[i].begin(),G[i].end(),y);
    if (f1 != G[i].end() && f2 != G[i].end()) {
      cout << "Yes" << endl;
      frag = false;
    }
  }
  if(frag)
  cout << "No" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,t;
  vector<int> v;
  cin>>n>>m>>t;
  v.push_back(-m);
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    v.push_back(a);
  }
  v.push_back(t+m);
  int ans=0;
  for(int i=1;i<v.size();i++){
    ans+=max(0,v[i]-v[i-1]-2*m);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int h,w;
int a[502][502];
vector<string> sv;
int sm[502];
int main(){
  cin>>h>>w;
  bool write_w=false,write_h=false;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
     cin>>a[j][i];
    }
  }
  int j=1;
  for(int j=1;j<=h;j++){
    write_w = false;
    for(int i=1;i<w;i++){
      sm[j] = (a[i][j]+sm[j])%2;
      if(a[i][j]%2==1){
        if(write_w)
          write_w = false;
        else
          write_w = true;
      }
      if(write_w){
        sv.push_back(to_string(j) + " " + to_string(i) + " " + to_string(j) + " " + to_string(i+1));        
      }
    }
    sm[j] = (a[w][j]+sm[j])%2;
    if(j!=h){
      if(sm[j]==1){
        if(write_h)
          write_h = false;
        else
          write_h = true;
      }
        if(write_h)
          sv.push_back(to_string(j) + " " + to_string(w) + " " + to_string(j+1) + " " + to_string(w));
    }
  }
/*    */
  cout<<sv.size()<<endl;
  for(int i=0;i<sv.size();i++){
    cout<<sv[i]<<endl;
  }

}

Measured memory_bytes: 13556
"""
author : halo2halo
date : 24,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline().rstrip())
A = int(readline().rstrip())


print("Yes" if N % 500 <= A else "No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int n, xxx;
    cin >> n >> xxx;
    vector<int> a(n + 1, 0);
    rep(i, 1, n + 1) cin >> a[i];

    int maxrep = min(((int)floor(log(n))) + 100, xxx);
    rep(i, 0, maxrep) {
        vector<int> imos(n + 1, 0);
        rep(k, 1, n + 1) {
            int l = k - a[k] - 1;
            int r = k + a[k];
            imos[(l < 0) ? 0 : l]++;
            imos[(r > n) ? n : r]--;
        }
        rep(k, 1, n + 1) {
            a[k] = a[k - 1] + imos[k - 1];
        }
    }

    rep(i, 1, n + 1) cout << a[i] << (i == n ? "" : " ");
    cout << endl;
}


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

using namespace std;

struct team {
    int id, acc, time, was[10];
    team(int i=0) : id(i), acc(0), time(0) {fill(was, was+10, 0);}

    void judge(int m, int p, int j)
    {
        if(j)
        {
            was[p-1]++;
        }
        else
        {
            acc++;
            time += m + 20 * was[p-1];
        }
    }
};

bool operator<(const team& a, const team& b)
{
    if(a.acc==b.acc)
    {
        if(a.time==b.time)
        {
            return a.id>b.id;
        }
        return a.time<b.time;
    }
    return a.acc>b.acc;
}

int main()
{
    int m, t, p, r;
    while(cin >> m >>t >> p >> r, m|t|p|r)
    {
        team ts[t];
        for(int i=0; i<t; i++) ts[i] = team(i+1);
        while(r--)
        {
            int mi, ti, pi, ji;
            cin >> mi >> ti >> pi >> ji;
            ts[ti-1].judge(mi, pi, ji);
        }
        sort(ts, ts+t);
        cout << ts[0].id;
        for(int i=1; i<t; i++)
        {
            cout << ((ts[i].acc==ts[i-1].acc && ts[i].time==ts[i-1].time) ? "=" : ",") << ts[i].id;
        }
        cout << endl;
    }
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int C = A * N;

  if (C <= B) {
    cout << C << endl;
  }

  if (C > B) {
    cout << B << endl;
  }
  
}

Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main() {
	int x, y, tmp;

	while(1){
		cin >> x >> y;
		if(x == 0 & y == 0) break;
		if(x > y){
			tmp = x;
			x = y;
			y = tmp;
		}
		cout << x << " " << y << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#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>;

// ------------------------

void solve() {
    int A, B; cin >> A >> B;
    if( A <=9 && B <= 9 ) cout << A*B << "\n"; else cout << -1 << "\n";
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin>>n;
    ll ans=0;
    ll t=1;
    while(t<n){
        t*=3;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3204
N,Z,W=map(int,input().split())
a=list(map(int,input().split()))
INF=10**19
dp=[[0]*2 for i in range(N+1)]
for i in range(N-1,-1,-1):
    dp[i][0]=-INF
    if i: Y=a[i-1]
    else: Y=W
    dp[i][0]=max(dp[i][0],abs(Y-a[N-1]))
    for j in range(i+1,N): dp[i][0]=max(dp[i][0],dp[j][1])

    dp[i][1]=INF
    if i: X=a[i-1]
    else: X=Z
    dp[i][1]=min(dp[i][1],abs(X-a[N-1]))
    for j in range(i+1,N): dp[i][1]=min(dp[i][1],dp[j][0])
print(dp[0][0])


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



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

	string word[101];
	bool tmp = true;
	for (int i = 0; i < n; i++) {
		string w;
		cin >> w;
		word[i] = w;
		for (int j = 0; j < i; j++) {
			if (w == word[j]) {
				tmp = false;
			}
		}
		if (i != 0) {
			if (w[0] != word[i - 1][word[i - 1].size()-1]) {
				tmp = false;
			}
		}
		if (tmp == false)break;
	}

	if (tmp == false) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}


	return 0;
}


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

int main(){
    vector<int> science(4);
    vector<int> human(2);
    rep(i, 4){
        cin>>science.at(i);
    }
    rep(i, 2){
        cin>>human.at(i);
    }
    sort(science.begin(), science.end());
    sort(human.begin(), human.end());
    int ans=0;
    rep(i, 4){
        ans+=science.at(i);
    }
    rep(i, 2){
        ans+=human.at(i);
    }
    ans=ans-human.at(0)-science.at(0);
    cout<<ans<<endl;
}


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

using namespace std;

#define ff(i, a, b) for(int i = (a); (i <= (b)); ++i)
#define FF(i, a, b) for(int i = (a); (i >= (b)); --i)
#define ll long long

const int M = 1000000000 + 7;

struct re {
    int x, y;
//    const bool operator < (const re &a) const {
//        if (x != a.x) return x < a.x;
//        return y < a.y;
//    }
};

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    //freopen("", "r" , stdin);
    //freopen("", "w", stdout);
    int n, k, x, res = 0;
    cin >> n >> k;
    ff(i, 1, n) {
        cin >> x;
        res += (x >= k);
    }
    cout << res;
}
//This code belongs to s34vv1nd


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}
int a[3];
signed main() {
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] + a[1] << endl;
}


Measured memory_bytes: 256
n=int(input())
s=input()
a=[0]*26
for j in range(len(s)):
	a[ord(s[j])-ord("a")]+=1
for i in range(n-1):
	s=input()
	b=[0]*26
	for j in range(len(s)):
		b[ord(s[j])-ord("a")]+=1
	for j in range(26):
		a[j]=min(a[j],b[j])
x=""
for i in range(26):
	x+=chr(97+i)*a[i]
print(x)


Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<iostream>
#include<string>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define REP(i,x) for (int i=0;i<x;i++)
#define REPP(i,x,y) for (int i=x;i<=y;i++)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define MX3(x,y,z) max({x,y,z})
#define MX4(x,y,z,p) max({x,y,z,p})
#define MX5(x,y,z,p,q) max({x,y,z,p,q})
#define MN3(x,y,z) min({x,y,z})
#define MN4(x,y,z,p) min({x,y,z,p})
#define MN5(x,y,z,p,q) min({x,y,z,p,q})
#define amax(x,y) x=max(x,y)
#define amin(x,y) x=min(x,y)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef tuple<int,int,int> ti;
typedef tuple<ll,ll,ll> tl;
// #####################################################################

void solve() {

    ll n;
    SL(n);
    ll ans = 0;
    for(ll i = 1 ; i*i <= n ; i++) {
        if(n % i == 0) {
            ll x = n / i - 1;
            if(x == 0) continue;
            if(n / x == n % x) ans += x;
        }
    }
    printf("%lld\n", ans);
}

void init() {
    


}

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




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define  sci(x)   scanf("%d", &x)
#define  scl(x)   scanf("%lld", &x)
#define  scd(x)   scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
 
int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//CODE TONOY
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	for (int i=0;i<100;i++){
		c-=b;
		a-=d;
		
		if (c<=0){
			cout<<"Yes";
			break;
		}
		
		
		if (a<=0){
			cout<<"No";
			break;
		}
		
	}
	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >>C;
  
  if(A == B && B == C){
  cout << "1" << endl;
  }
  else if(A == B || B == C || A == C){
  cout << "2" << endl;
  }
  else
    cout << "3" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 30;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };



string s;
string win;

int main() {
	while ( cin >> s ) {
		VS _array( 3 );
		for ( int i = 0; i < 3; i++ ) {
			_array[ i ] = s.substr( i * 3, 3 );
		}
		win = "d";
		for ( int i = 0; i < 3; i++ ) {
			if ( i == 0 ) {
				if ( _array[ i ][ i ] != 's' && _array[ i ][ i ] == _array[ i + 1 ][ i + 1 ] && _array[ i ][ i ] == _array[ i + 2 ][ i + 2 ] ) {
					win = _array[ 0 ].substr( 0, 1 );
					break;
				}
			}
			if ( _array[ 0 ][ i ] != 's' && _array[ 0 ][ i ] == _array[ 1 ][ i ] && _array[ 0 ][ i ] == _array[ 2 ][ i ] ) {
				win = _array[ 0 ].substr( i, 1 );
				break;
			}
			if ( _array[ i ][ 0 ] != 's' && _array[ i ][ 0 ] == _array[ i ][ 1 ] && _array[ i ][ 0 ] == _array[ i ][ 2 ] ) {
				win = _array[ i ].substr( 0, 1 );
				break;
			}
			if ( i == 2 ) {
				if ( _array[ 0 ][ i ] != 's' && _array[ 0 ][ i ] == _array[ 1 ][ i - 1 ] && _array[ 0 ][ i ] == _array[ 2 ][ i - 2 ] ) {
					win = _array[ 0 ].substr( i, 1 );
					break;
				}
			}
		}
		printf( "%s\n", win.c_str() );
	}
	return 0;
}

Measured memory_bytes: 1164
import java.util.*;
 
public class Main {
  public static void main (String[] arg) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int A = scan.nextInt();
    int B = scan.nextInt();
    
    if(N*A <= B){
      System.out.println(N*A);
    } else {
      System.out.println(B);
    }
  }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;


int main(){
   int n,l;cin >>n>>l;
   ll sum=0;
   int m=INF;
    for (int i = 0; i < n; ++i) {
        sum+=(l+i);
        if(abs(m)>abs(l+i))m=l+i;
    }
    sum-=m;
    cout <<sum<<endl;
}

Measured memory_bytes: 3620
#include <stdio.h>

int solve(int, int);

int a[2000],n;

int main(){

  int m,q,i,x,r;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++)
    scanf("%d",&a[i]);

  scanf("%d",&q);

  for(i = 0 ; i < q ; i++){
 
    scanf("%d",&x);
    r = solve(0,x);
    
    if(r==1) printf("yes\n");
    else if(r==0) printf("no\n");
    
  }
 
  return 0;
 
}

int solve(int i, int x){

  int res;


if(x==0) return 1;

if(i>=n) return 0;

res = solve(i+1, x) || solve(i+1, x-a[i]);


 return res;

}

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

int main() {
  string S;
  cin >> S;
  
  if(S=="Sunny"){
    cout << "Cloudy" << endl;
  }
  
  else if(S=="Cloudy"){
    cout << "Rainy" << endl;
  }

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

Measured memory_bytes: 256
val bList = mutableListOf<Long>()
val pList = mutableListOf<Long>()

fun main(args: Array<String>) {
    val (nTemp, x) = readLine()!!.split(' ').map(String::toLong)
    val n = nTemp.toInt()
    bList.add(0L)
    pList.add(1L)
    for (i in 1..n) {
        bList.add(bList[i - 1] * 2 + 2)
        pList.add(pList[i - 1] * 2 + 1)
    }
    print(calc(n, x))
}

fun calc(n: Int, x: Long): Long {
    val length = bList[n] + pList[n]
    if (x == 0L) return 0L
    if (n == 0) return x
    if (length / 2 + 1 == x) {
        return pList[n] / 2 + 1
    } else if (length / 2 + 1 < x) {
        return pList[n] / 2 + 1 + calc(n - 1, x - (length / 2 + 1) - if (length == x) 1 else 0)
    } else {
        return calc(n - 1, x - 1)
    }
}


Measured memory_bytes: 38304
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int a[5];
  rep(i,5)cin>>a[i];
  sort(a,a+5,greater<int>());
  rep(i,5)cout<<a[i]<<(i!=4?' ':'\n');
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9;
int main() {
  ll N, D, A;
  cin >> N >> D >> A;
  vector<P> X(N);
  REP(i, N) cin >> X[i].first >> X[i].second;
  sort(X.begin(), X.end());
  ll ans = 0, nowbomb = 0;
  queue<P> que;
  REP(i, N) {
    while (!que.empty()) {
      if (que.front().first < X[i].first) {
        nowbomb -= que.front().second;
        que.pop();
      } else {
        break;
      }
    }
    if (X[i].second <= nowbomb * A) continue;
    ll num = X[i].second - nowbomb * A;
    num = (num + A - 1) / A;
    ans += num, nowbomb += num;
    que.push(P(X[i].first + 2 * D, num));
  }
  cout << ans << endl;
}

Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<long long> a(n);
  long long height = 0ll;
  for(int i = 0; i < n; i++){
    long long x; cin >> x;
    a.at(i) = x;
    if(i == 0) height = x;
  }
  long long ans = 0ll;
  for(int i = 1; i < n; i++){
    if(height <= a.at(i)){
      height = a.at(i);
    }
    else
      ans += abs(height - a.at(i));
  }
  cout << ans;
}

Measured memory_bytes: 4840