akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		int[] charArray = readLine().chars().sorted().toArray();
		if (charArray[0] == charArray[1] && charArray[2] == charArray[3] && charArray[0] != charArray[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	private static String readLine() throws IOException {
		return new BufferedReader(new InputStreamReader(System.in)).readLine();
	}
}


Measured memory_bytes: 28628
N = int(input())
A = input().split()
A = [int(A[i]) for i in range(len(A))]
ans = 1000
kabu = 0
for i in range(N):
    #print('{}:{}:{}'.format(i,ans,kabu))
    if i == N-1:
        ans += kabu*A[i]
        kabu = 0
    else:
        if A[i] < A[i+1]:
            _kabu = ans // A[i]
            ans += -A[i]*_kabu
            kabu += _kabu
        elif A[i] > A[i+1]:
            ans += kabu*A[i]
            kabu = 0
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cstring>

using namespace std;

int main()
{
    string s, t;
    cin >> s;
    int ans = 0;

    while (1) {
        cin >> t;
        if (t == "END_OF_TEXT") break;
        for (int i = 0; i < t.size(); i++) {
            if (t[i] >= 'A' && t[i] <= 'Z') t[i] += 0x20;
        }
        if (t == s) {
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3076
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

enum lim = 10^^5 + 1;

void main() {
    int N, W;
    scan(N, W);
    auto w = new int[](N);
    auto v = new int[](N);
    iota(N).each!(i => scan(w[i], v[i]));

    auto dp = new long[](lim);
    dp[] = infl;
    dp[0] = 0;

    foreach (i ; 0 .. N) {
        foreach_reverse (j ; v[i] .. lim) {
            chmin(dp[j], dp[j - v[i]] + w[i]);
        }
    }

    foreach_reverse (i ; 0 .. lim) {
        if (dp[i] <= W) {
            writeln(i);
            return;
        }
    }
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 2940
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> a(N,0);
    for(ll i=0;i<N;++i)cin>>a[i];
    vector<ll> ans(N,0);
    ll K=0;
    for(auto p: a)K^=p;
    for(ll i=0;i<N;++i){
        for(ll j=0;j<50;++j){
            if((K&(1LL<<j))&&!(a[i]&(1LL<<j)))ans[i]+=(1LL<<j);
        else if(!(K&(1LL<<j))&&(a[i]&(1LL<<j)))ans[i]+=(1LL<<j);
        }
    }
    for(auto p: ans)cout<<p<<" ";

    return 0;
}



Measured memory_bytes: 6320
var std = process.stdin;
std.resume();
std.setEncoding('utf8');

std.on('data', function(chunk){
    var n = +chunk.replace(/\n/, '');
    console.log(call(n));
});

var call = function(n){
    var output = '';
    
    for (var i = 3; i <= n; i++){
        if (i % 3 === 0) {
            output += ' ' + i;
        }
        else if (i % 3 !== 0 && (i+'').match(/3/)) {
            output += ' ' + i;
        }
    }
    
    return output;
};

Measured memory_bytes: 18360
#include <iostream>
using namespace std;
int m,d[200000];
long long c[200000],sum,num;
int main(){
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>d[i]>>c[i];
        sum+=d[i]*c[i];
        num+=c[i];
    }
    cout<<(sum-1)/9+num-1<<endl;
}

Measured memory_bytes: 2560
D = int(input())
c_list = [int(i) for i in input().split()]
s_list = []
t_list = []
for _ in range(D):
    s = [int(i) for i in input().split()]
    s_list.append(s)
for _ in range(D):
    t_list.append(int(input()))
happy = 0
recent = [0 for _ in range(26)]
for i in range(D):
    happy += s_list[i][t_list[i] - 1]
    recent[t_list[i] - 1] = i + 1
    for j, s in enumerate(s_list[i]):
        happy -= c_list[j] * (i + 1 - recent[j])
    print(happy)

Measured memory_bytes: 9364
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3+5;
long long dp[maxn][maxn];
int n;
struct person{
	long long x,a;	
} e[maxn];
bool cmp(person g,person h){
	return g.a > h.a;	
}
int main(){
	cin >> n;
	for (long long i=1;i<=n;i++) {cin>>e[i].a;e[i].x=i;}
	sort(e+1,e+n+1,cmp);
	for (long long i=1;i<=n;i++){
		dp[i][0]=dp[i-1][0]+e[i].a*abs(e[i].x-(n-i+1)); 
		for (long long j=1;j<i;j++){
			dp[i][j] = max(dp[i-1][j-1]+e[i].a*abs(e[i].x-j),dp[i-1][j]+e[i].a*abs(e[i].x-(n-i+j+1)));	
		}
		dp[i][i] = dp[i-1][i-1]+e[i].a*abs(e[i].x-i);
	}
	long long ans = 0;
	for (int i=0;i<=n;i++){
		ans = max(ans,dp[n][i]);		
	}
	cout << ans;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  multiset<double> v;
  for (int i=0; i<N; i++){
    double n;
    cin >> n;
    v.insert(n);
  }

  for (int i=0; i<N-1; i++){
    auto itr2 = v.begin();
    auto itr1 = itr2++;
    double NEW = (*itr1 + *itr2) / 2;
    v.erase(itr1,++itr2);
    v.insert(NEW);
  }

  auto itr = v.begin();
  cout << *itr << endl;
}

Measured memory_bytes: 256
from fractions import gcd
t = int(input())

for i in range(t):
    a,b,c,d = map(int, input().split())

    if a < b or b > d:
        print('No')
        continue

    if b <= c:
        print('Yes')
        continue

    g = gcd(b, d)
    if c >= b - g + (a % g):
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 5176
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define fast_io() ios::sync_with_stdio(false); cin.tie(nullptr)
#define fix(n) fixed << setprecision(n)

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    fast_io();
    
    ll n;
    cin >> n;
    ll divans = roundup(n,1000);
    cout << abs(n - (divans * 1000)) << endl;
    return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,taro[100],hanako[100];
  while(cin>>n>>m&&n&&m){
    int flag=-1,x,sumt=0,sumh=0,t,h,minsum=10000;
    for(int i=0;i<n;++i) {
      cin>>taro[i];
      sumt+=taro[i];
    }
    for(int i=0;i<m;++i){
      cin>>hanako[i];
      sumh+=hanako[i];
    }
    x=sumt-sumh;
    for(int i=0;i<n;++i){
      for(int j=0;j<m;++j){
	if(2*(taro[i]-hanako[j])==x){
	  if(minsum>taro[i]+hanako[j]){
	    flag=1; t=taro[i]; h=hanako[j]; minsum=t+h;
	  }
	}
      }
    }
    if(flag==1) cout<<t<<" "<<h<<endl;
    else cout<<flag<<endl;
  }
  return 0;
}



Measured memory_bytes: 3012
//
// Created by sark2 on 14-01-2020.
//

#include "bits/stdc++.h"

using namespace std;
#define pb push_back
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define CASES int t;cin>>t;while(t--)

using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;

int main() {
    IOS

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

    cout<<(a*b/__gcd(a,b));



}


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

using namespace std;
typedef unsigned long long ullong;

ullong power(ullong x, ullong n, ullong M) {
	ullong res = 1;
	if (n > 0) {
		res = power(x, n / 2, M);
		if (n % 2 == 0)res = (res*res) % M;
		else res = (((res*res) % M)*x) % M;
	}
	return res;
}

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

	cout << power(m, n, 1000000007) << endl;

	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll a, b, n; cin >> a >> b >> n;

    if (n <= b - 1) {
        cout << a * n / b - a * (n / b) << endl;
    } else {
        ll x = n / b * b - 1;
        cout << a * x / b - a * (x / b) << endl;
    }
    return 0;
}

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

#define ln '\n'
#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)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VL a(n);
    REP(i, n) cin >> a[i];
    sort(ALL(a));

    int ans = 0;
    ans = -a.front() + a.back();
    REP(i, n - 2) ans += abs(a[i + 1]);
    cout << ans << ln;

    int x1 = a.back();
    int x2 = a.front();

    FOR(i, 1, n - 2) {
        if(a[i] <= 0) {
            cout << x1 << " " << a[i] << ln;
            x1 -= a[i];
        } else {
            cout << x2 << " " << a[i] << ln;
            x2 -= a[i];
        }
    }

    cout << x1 << " " << x2 << ln;    
    return 0;
}


Measured memory_bytes: 2688
fun main(args:Array<String>):Unit {
    val (w, h, c) = readLine()!!.trim().split(' ').map(String::toInt)
    println(w * h * c / gcd(w, h) / gcd(w, h))
}
fun gcd(a:Int, b:Int):Int {
    return when(b){
        0 -> a
        else -> gcd(b, a % b)
    }
}


Measured memory_bytes: 32224
import java.util.Scanner;

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

        int[] price = new int[N];
        int[][] grow = new int[N][M];
        for(int i = 0; i < N; i++) {
            price[i] = sc.nextInt();
            for(int j = 0; j < M; j++) {
                int tmp = sc.nextInt();
                grow[i][j] = tmp;
            }
        }
        int min = Integer.MAX_VALUE;
        for(int bit = 0; bit < (1<<N); bit++) {
            int[] total = new int[M];
            int tmpMin = 0;
            for(int i = 0; i < N; i++) {
                if(((bit >> i) & 1) == 1) {
                    tmpMin += price[i];
                    for(int j = 0; j < M; j++) {
                        total[j] += grow[i][j];
                        int t = 0;
                    }
                }
            }
            for(int k = 0; k < M; k++) {
                if(total[k] < X) break;
                if(k == M-1) {
                    min = Math.min(min, tmpMin);
                }
            }
        }
        if(min == Integer.MAX_VALUE) {
            System.out.println("-1");
        } else {
            System.out.println(min);
        }
    }
}


Measured memory_bytes: 37488
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"

signed main()
{
    FAST;
    
    int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
    int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,anss=0,start=0,end=0,r=0,qq=0,total=0;
    int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
    int reqd=0;
    
    cin>>n;
    int a[n-1],b[n+1];
    for(i=0;i<n+1;i++)
    {
        b[i]=0;
    }
    for(i=0;i<n-1;i++)
    {
        cin>>a[i];
        b[a[i]]++;
    }
    
    for(i=1;i<=n;i++)
    {
        cout<<b[i]<<endl;
    }
    
    
    
    
}

Measured memory_bytes: 6780
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
   int p, q, r;
   cin >> p >> q >> r;
   cout << min(p + q, min(q + r, r + p)) << endl;
   return 0;
}


Measured memory_bytes: 256
N, D = map(int, input().split())

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

count = 0
for i in range(N):
	for j in range(i + 1, N):
		il, jl = X[i], X[j]
		distance = 0
		for d in range(D):
			distance += (il[d] - jl[d])** 2
		distance **= 0.5
		#print(distance, int(distance))
		if distance == int(distance):
			count += 1
print(count)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
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; }

ll dp[100005][3];

int main(void){
  ll n; cin >> n;
  ll a[n],b[n],c[n];
  rep(i,n) cin >> a[i] >> b[i] >> c[i];
  rep(i,n){
    rep(j,3) dp[i][j] = 0;
  }
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  for(int i = 1; i < n; i++){
    chmax(dp[i][0],dp[i-1][1]+a[i]);
    chmax(dp[i][0],dp[i-1][2]+a[i]);
    chmax(dp[i][1],dp[i-1][0]+b[i]);
    chmax(dp[i][1],dp[i-1][2]+b[i]);
    chmax(dp[i][2],dp[i-1][0]+c[i]);
    chmax(dp[i][2],dp[i-1][1]+c[i]);
  }
  cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << endl;
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cout << a[i] << " "; cout << "\n"; }
ll dbgt = 1; void err() { cout << "passed " << dbgt++ << "\n"; }
template<class H, class... T> void err(H&& h,T&&... t){ cout<< h << (sizeof...(t)?" ":"\n"); if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ld dp[3000][3000];
int main() {
    init();
    ll N;
    cin >> N;
    dp[0][0] = 1;
    rep(i,N){
        ld p;
        cin >> p;
        rep(j,i+1){
            dp[i + 1][j + 1] += dp[i][j] * p;
            dp[i + 1][j] += dp[i][j] * (1 - p);
        }
    }

    ld ans = 0;
    repe(i,(N+2)/2, N+1){
        ans += dp[N][i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 139008
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int a,b;
    cin >> a >> b;
    if ((a + b) % 2 == 1) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << (a + b) / 2 << endl;
    }

    return 0;
}

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

using namespace std;;

int main(){
  long xbox[1000];
  long ybox[1000];
  int size=0;
  long xtemp,ytemp;
  long x,y,swap,mod;
  long step;
  
  while(true){
    scanf("%ld %ld", &xtemp,&ytemp);
    if(xtemp == 0 && ytemp == 0) break;
    if(xtemp>ytemp){
      xbox[size] = xtemp;
      ybox[size] = ytemp;
    }else{
      xbox[size] = ytemp;
      ybox[size] = xtemp;
    }
    size++;
  }
  for(int i=0; i<size; i++){
    step = 0;
    x = xbox[i];
    y = ybox[i];
    while(true){
      step++;
      mod = x%y;
      x = mod;
      swap = x;
      x = y;
      y = swap;
      if(y==0)break;
    }
    printf("%ld %ld\n", x,step);
  }
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
vector<i64> a;

bool is(int k){
  for(int i = 2;i * i <= k;i++){
    if(k % i == 0) return false;
  }
  return true;
}

int main(){
  cin >> N;
  int i = 2;
  while(a.size() < N){
    if(is(i) && i % 5 == 1) a.push_back(i);
    i++;
  }

  for(int j : a){
    cout << j << " ";
  }

  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> steps(N + 1, -1);
    steps[0] = 1;
    steps[1] = 1;
    for(int i = 0; i < M; ++i)
    {
        int a = 0;
        cin >> a;
        steps[a] = 0;
    }

    for(int i = 0; i < N + 1; ++i)
    {
        if(steps[i] == -1)
        {
            steps[i] = steps[i - 2] + steps[i - 1];
            steps[i] %= 1000000007;
        }
    }

    cout << steps[N];
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define int int64_t
#define mp make_pair
#define f first
#define s second
#define mod 1000*1000*1000+7
int dp[1000001];
int power(int a,int b)
{
    int ans=1;
    while(b>0)
    {
        if(b&1)
        {
            ans*=a;
            ans%=mod;
            b--;
        }
        b/=2;
        a*=a;
        a%=mod;
    }
    return ans;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    dp[0]=1;
    for(int i=1;i<=1e6;i++)
    {
        dp[i]=dp[i-1]*i;
        dp[i]%=mod;
    }
    int a,b;cin>>a>>b;
    if((a+b)%3!=0||max(a,b)>2*min(a,b))
    {
        cout<<"0\n";
    }
    else
    {
        int x=min(a,b);
        int y=max(a,b);
        int diff=2*x-y;
        diff/=2;
        int moves=(x+y);
        moves/=3;
       // cout<<moves<<" "<<diff<<"\n";
        diff=moves-(y-x);
      	diff/=2;
        int ans=dp[moves];
        ans*=power(dp[diff],mod-2);
        ans%=mod;
        ans*=power(dp[moves-diff],mod-2);
        ans%=mod;
        cout<<ans<<"\n";
    }
    return 0;
}


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

const int MAX_N = 1e5+10;
int N, M;
int P[MAX_N], Y[MAX_N];
string ans[MAX_N];

void solve()
{
	map<int,  vector<int>> v;
	for(int i=0;i<M;++i){
		v[P[i]].push_back(Y[i]);
	}
	for(auto& p : v) sort(p.second.begin(), p.second.end());
	for(int i=0;i<M;++i){
		string p = to_string(P[i]);
		while((int)p.length()<6) p="0"+p;
		int j = lower_bound(v[P[i]].begin(), v[P[i]].end(), Y[i])-v[P[i]].begin();
		string y = to_string(j+1);
		while((int)y.length()<6) y="0"+y;
		cout<<p+y<<'\n';
	}
}

int main()
{
	cin >> N >> M;
	for(int i=0;i<M;++i){
		cin >> P[i] >> Y[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 18436
#include<iostream>
#define N 10000 
using namespace std;
int main(){
  int a[N],b[N],n,scoreA,scoreB;
  while(cin >> n,n != 0){
  
    scoreA = 0; scoreB =0;
  for(int i = 0;i < n;i++){
    cin >> a[i] >> b[i];
  }
  for(int i = 0;i < n;i++){
    if(a[i] > b[i]){
      scoreA += a[i]+b[i];
    } else if(a[i] < b[i]){
      scoreB += a[i]+b[i];
	} else if(a[i]==b[i]){
      scoreA = scoreA + a[i]; scoreB += b[i];
    }
  }
  
  cout << scoreA <<" " << scoreB << endl;
  }

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

#define MAX_N 200005
vector<int> pre_G[MAX_N];
vector<int> G[MAX_N];
int par_[MAX_N];
int flag_netsukigi[MAX_N];
void make_netsukigi(int r){
    queue<int> que;
    que.push(r);
    flag_netsukigi[r] = 1;
    par_[r] = -1;

    while(que.size() > 0){
        int x = que.front();
        que.pop();
        flag_netsukigi[x] = 1;
        rep(i,pre_G[x].size()){
            if(flag_netsukigi[pre_G[x][i]] == 0){
                par_[pre_G[x][i]] = x;
                G[x].push_back(pre_G[x][i]);
                que.push(pre_G[x][i]);
            }
        }
    }
}

const ll MOD = 1000000007;

int cnt[MAX_N];
vector<ll> v[MAX_N];
ll two[MAX_N];

// ax + by = gcd(a, b) となるような (x, y) を求める
// 多くの場合 a と b は互いに素として ax + by = 1 となる (x, y) を求める
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK) 
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}

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

    rep(i,n-1){
        int a, b;
        scanf("%d%d", &a, &b);
        a--; b--; // 0-indexにするため.
        pre_G[a].push_back(b);
        pre_G[b].push_back(a);
    }

    make_netsukigi(0);

    queue<int> que;
    rep(i,n){
        if(G[i].size() == 0){
            que.push(i);
        }else{
            cnt[i] = G[i].size();
        }
    }

    while(que.size() > 0){
        int x = que.front(); que.pop();
        int tmp = 1;
        rep(i, v[x].size()){
            tmp += v[x][i];
        }
        v[par_[x]].push_back(tmp);
        cnt[par_[x]]--;
        if(cnt[par_[x]] == 0){
            que.push(par_[x]);
        }
    }

    two[0] = 1;
    srep(i,1,MAX_N){
        two[i] = two[i-1] * 2 % MOD;
    }

    ll u = 0;
    ll d = modinv(two[n], MOD);

    rep(i,n){
        if(v[i].size() == 0)continue;
        int all = 1;
        rep(j,v[i].size())all += v[i][j];
        if(n - all > 0)v[i].push_back(n - all);
        ll tmp = two[n-1];
        rep(j,v[i].size()){
            ll tmp2 = two[v[i][j]] - 1;
            tmp = tmp + MOD - tmp2;
            tmp %= MOD;
        }
        tmp += MOD - 1;
        tmp %= MOD;

        u += tmp;
        u %= MOD;
    }

    

    ll ans = u * d % MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 36480
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
constexpr int kMaxV = 1e5 + 1;
typedef long long LL;

LL dp[101][kMaxV] = {};

int main() {
  LL N, W; cin >> N >> W;
  dp[0][0] = 0;
  for (int j = 1; j < kMaxV; ++j) dp[0][j] = W + 1;

  for (int i = 0; i < N; ++i) {
    LL w, v; cin >> w >> v;
    for (int j = 0; j < v; ++j) dp[i + 1][j] = dp[i][j];
    for (int j = v; j < kMaxV; ++j) dp[i + 1][j] = min(dp[i][j], dp[i][j-v] + w);
  }

  for (int j = kMaxV - 1; j >= 0; --j) {
    if (dp[N][j] <= W) {
      cout << j << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 82424
import java.util.Scanner

fun main() {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val k = scn.nextInt()
	val arr = BooleanArray(n){false}
	repeat(k) {
		val d = scn.nextInt()
		repeat(d){
			arr[scn.nextInt()-1] = true
		}
	}
	println(arr.count{!it})
}

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

int main() {
  
  int N,X;
  cin>>N>>X;
  vector<int> V(N);
  int S=1;
  int D=0;
  
  for (int i=0;i<N;i++) {
    cin>>V[i];
  }
  
  for (int i=0;i<N;i++) {
    D+=V[i];
    if (X>=D) {
      S++;
    }
    else break;
  }
  cout<<S<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
const int MAX = 2e5 + 5;
int a[MAX];
int main() {
	int n;
	long long sum = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", a + i);
		sum += a[i];
	}
	
	long long left,right,temp;
	
	left = sum - a[n - 1];
	right = a[n - 1];
	long long min = left > right ? left - right : right - left;
	left = 0;
	for (int i = 0; i < n-2; i++) {
		left += a[i];
		right = sum - left;
		temp = left > right ? left - right : right - left;
		if (temp < min)
			 min=temp;
	}
	printf("%d\n", min);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(int)(n);i++)
#define foi(i,k,n) for(int i=(k); i<(int)(n); i+=1)
#define fod(i,n,k) for(int i=k; i>=(int)n; i-=1)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define endl "\n"


#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef long long int llint;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<llint> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
llint toint(string s) {stringstream ss(s); llint x; ss >> x; return x;}
//gp_hash_table<string, llint> table;


//int mpow(llint base, llint exp) {
  //base %= MOD;
  //llint result = 1;
  //while (exp > 0) {
    //if (exp & 1) result = ((llint)result * base) % MOD;
    //base = ((llint)base * base) % MOD;
    //exp >>= 1;
  //}
  //return result;
//}


//void makegraph(int n, int m){
	//int i, u, v;
	//while(m--){
		//cin>>u>>v;
		//u--, v--;
		//g[u].pb(v);
		//g[v].pb(u);
	//}
//}

//void dfs(int u, int par){
	//for(int v:g[u]){
		//if (v == par) continue;
		//dfs(v, u);
	//}
//}


// ------------------------------------------------------------------ILB----------------------------------------------------------------  //

//n * d = abs(x)

void solve(){
	llint x, k, d, ans;
	cin >> x >> k >> d;
	if(d == 0){
		cout << x;
		return;
	}
	llint n = abs(x) / d;
	if(n > k){
		ans = abs(x) - (k*d);
	}
	else{
		k -= n;
		x = abs(x) - n*d;
		if(k%2) ans = abs(x) - d;
		else ans = x;
	}
	cout << abs(ans);
}




int main() {
	fast_io;
    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }
    return 0;
}



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


class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;
    Random r;

    void calc()
    {
        long S = cin.nextLong();
        long X1, Y1, X2, Y2, X3, Y3;
        X1 = 0;
        Y1 = 0;

        r = new Random();

        long baseNum = (long) Math.Sqrt(S);
        long minNum = baseNum / 2 - 10;
        if (minNum <= 0) minNum = 1;
        long maxNum = baseNum * 3 / 2 + 10;
        if (maxNum >= (long)1e9) maxNum = (long)1e9;

        for (int i = 0; ; i++)
        {
            X2 = r.Next((int)minNum, (int)maxNum);
            if (i < 10) X2 = maxNum - i;
            Y3 = (S + X2 - 1) / X2;
            if (Y3 > (long)1e9) continue;
            long diff = X2 * Y3 - S;
            if (diff < (long)1e9)
            {
                Y2 = 1;
                X3 = diff;
                break;
            }

        }
        Console.Error.WriteLine((X2 * Y3) - (X3 * Y2));

        Console.WriteLine($"{X1} {Y1} {X2} {Y2} {X3} {Y3}");
       

    }

}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13264
#include <stdio.h>

const int station[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1};

int calc_start(int begin, int end)
{
	if (begin <= 5 && end < begin){
		return (15 - begin) % 15;
	}
	else {
		return begin;
	}
}

int main(void)
{
	int n;
	
	scanf("%d", &n);
	while (n--){
		int begin, end;
		int i;
		
		scanf("%d %d", &begin, &end);
		for (i = calc_start(begin, end); station[i] != end; i = (i + 1) % 15){
			printf("%d ", station[i]);
		}
		printf("%d\n", end);
	}
	
	return 0;
}

Measured memory_bytes: 600
N = int(input())
H = list(map(int,input().split()))

r = 'Yes'
for i in range(N-1):
  if H[i] <= H[i+1]:
    if i == 0 or H[i] > H[i-1]:
      H[i] -=1
  else:
    if H[i]-1 > H[i+1]:
      r = 'No'
      break
    else:
      if H[i] > H[i-1]:
        H[i] -=1
      else:
        r = 'No'
        break
print(r) 
  

Measured memory_bytes: 20764
#include <iostream>

using namespace std;

const int kMaxW = 100;
const int kMaxH = 100;

int main() {
	char in[kMaxH][kMaxW] = { 0 };

	int width, height;

	cin >> height;
	cin >> width;

	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cin >> in[i][j];
		}
	}

	int outHeight = height * 2;
	for (int i = 0; i < outHeight; i++) {
		for (int j = 0; j < width; j++) {
			int widthIndex = (i + 2) / 2;
			cout << in[widthIndex - 1][j];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 384
n=int(input())
a=[int(i) for i in input().split()]

ans = 0

#nns は　負の整数の数を表す
nns = len([x for x in a if x < 0])

ans = sum([abs(x) for x in a])

if nns%2 != 0:
  ans -= 2*min(abs(i) for i in a)
  
print(ans)

Measured memory_bytes: 14412
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**7)


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


MOD = 10**9 + 7


def dfs(colors, graph, parent, current):
    if colors < len(graph[current]):
        return 0

    num_avail_colors = colors - 1 if parent < 0 else colors - 2
    num_cases = 1
    neighbors = graph[current]
    for neighbor in neighbors:
        if neighbor == parent:
            continue

        num_cases *= num_avail_colors
        num_avail_colors -= 1
        num_cases %= MOD

    for neighbor in neighbors:
        if neighbor == parent:
            continue

        num_cases *= dfs(colors, graph, current, neighbor)
        num_cases %= MOD

    return num_cases


def main():
    N, K = read_h()
    graph = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = read_h()
        graph[a - 1].append(b - 1)
        graph[b - 1].append(a - 1)

    ans = K * dfs(K, graph, -1, 0) % MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 92960
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 305

int N;
ll input_table[NUM][NUM],min_dist[NUM][NUM];

int main(){

	scanf("%d",&N);

	for(int row = 0; row < N; row++){
		for(int col = 0; col < N; col++){

			scanf("%lld",&input_table[row][col]);
			min_dist[row][col] = input_table[row][col];
		}
	}

	for(int mid = 0; mid < N; mid++){
		for(int start = 0; start < N; start++){
			for(int goal = 0; goal < N; goal++){

				if(min_dist[start][goal] > min_dist[start][mid]+min_dist[mid][goal]){

					min_dist[start][goal] =  min_dist[start][mid]+min_dist[mid][goal];
				}
			}
		}
	}

	ll sum = 0;

	for(int row = 0; row < N; row++){
		for(int col = 0; col < N; col++){

			if(input_table[row][col] > min_dist[row][col]){
				printf("-1\n");
				return 0;
			}
			sum += input_table[row][col];
		}
	}

	sum /= 2;

	//不要な辺を除去する
	bool FLG;

	for(int from = 0; from < N-1; from++){
		for(int to = from+1; to < N; to++){
			if(input_table[from][to] == 0)continue;

			FLG = false;

			//他の辺の組み合わせで最短距離が実現可能なら、不要
			for(int mid = 0; mid < N; mid++){
				if(mid == from || mid == to)continue;

				if(min_dist[from][mid]+min_dist[mid][to] == input_table[from][to]){
					FLG = true;
					break;
				}
			}

			if(FLG){

				sum -= input_table[from][to];
			}
		}
	}

	printf("%lld\n",sum);

	return 0;
}


Measured memory_bytes: 1664
// C - 755
#include <bits/stdc++.h>
using namespace std;

int N;//limit value
int Digit;//limit number of digit
int Count;//anser

void dfs(int x, int depth, bool is3, bool is5, bool is7){
	if(x > N) return;//exceeded value limit?
	if(is3 && is5 && is7) Count++;//{3,5,7} all used
	if(depth >= Digit) return;//limit of digits?
	dfs(x*10+3, depth+1, true, is5, is7);
	dfs(x*10+5, depth+1, is3, true, is7);
	dfs(x*10+7, depth+1, is3, is5, true);
}

int main(){
	string s; cin>>s;
	Digit = s.size();
	N = stoi(s);
	dfs(0, 0, false, false, false);
	cout<< Count <<endl;
}

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

int main(){
    int n, cnt = 1;
    while(cin >> n, n){
        vector<double> x(n), y(n), r(n), xax, yax;
        xax.push_back(-300.0); yax.push_back(-300.0);
        xax.push_back(300.0);  yax.push_back(300.0);
        for(int i = 0; i < n; i++){
            cin >> x[i] >> y[i] >> r[i];
            xax.push_back(x[i]-r[i]); xax.push_back(x[i]+r[i]);
            yax.push_back(y[i]-r[i]); yax.push_back(y[i]+r[i]);
        }
        sort(xax.begin(), xax.end());
        sort(yax.begin(), yax.end());
        xax.erase(unique(xax.begin(),xax.end()), xax.end());
        yax.erase(unique(yax.begin(),yax.end()), yax.end());
        int xn = xax.size(), yn = yax.size();
        auto fx = [&](double val)->int{
            return lower_bound(xax.begin(), xax.end(), val)-xax.begin();
        };
        auto fy = [&](double val)->int{
            return lower_bound(yax.begin(), yax.end(), val)-yax.begin();
        };
        vector<vector<int>> v(xn, vector<int>(yn, 0));
        for(int i = 0; i < n; i++){
            int a = fx(x[i]-r[i]), b = fx(x[i]+r[i]), c = fy(y[i]-r[i]), d = fy(y[i]+r[i]);
            v[a][c]++, v[b][d]++;
            v[a][d]--, v[b][c]--;
        }
        for(int i = 0; i < xn; i++) for(int j = 1; j < yn; j++) v[i][j] += v[i][j-1];
        for(int j = 0; j < yn; j++) for(int i = 1; i < xn; i++) v[i][j] += v[i-1][j];
        double s = 0;
        for(int i = 0; i < xn; i++){
            for(int j = 0; j < yn; j++){
                if(v[i][j] == 0)    continue;
                s += (xax[i+1]-xax[i])*(yax[j+1]-yax[j]);
            }
        }
        printf("%d %.2f\n", cnt++, ((int)(s*100))/100.0);
    }
    return 0;
}


Measured memory_bytes: 3232
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

void swap(int* a, int* b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

    if (a % b == 0)
        return b;
    else
        return gcd(b, a % b);
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
        printf("res:%lld a:%lld\n", res, a);
    }
    return res;
}


lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/

int d(long long int N)
{
    int count = 0;

    while (N > 0)
    {
        N /= 10;
        count++;
    }

    return count;
}

double rad2(double x)
{
    return x * (M_PI / 180);
}

int kaibun(char S[], int n)
{
    for (int i = 0; i < n / 2; i++)
    {
        if (S[i] != S[n - i - 1])
            return 0;
    }
    return 1;
}

int main()
{
    long double A, B;

    scanf("%Lf%Lf", &A, &B);

    printf("%lld", (long long int)(A * B));
}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   string s, t;
   cin>>s>>t;

   if(s.length()+1==t.length() && s==t.substr(0, s.length())){
      cout<<"Yes"<<endl;
   }
   else cout<<"No"<<endl;
   return 0;
}


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


int main()
{
	int a,b;
	while(cin>>a>>b)
	{
		if(a>b)
		{
			for(int i=1;i<=a;i++) cout<<b;
			cout<<"\n";
		}
		else 
		{
			for(int i=1;i<=b;i++) cout<<a;
			cout<<"\n";
		}
	}
}

Measured memory_bytes: 256
n, m = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
w = 0
for i in range(1, n):
  w += i*(n-i)*(xs[i]-xs[i-1])
h = 0
for i in range(1, m):
  h += i*(m-i)*(ys[i]-ys[i-1])
r = w*h%1000000007
print(r)


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

double abs( double n )
{
  return ( n < 0 ? -n : n );
}

int main()
{
  while(true)
  {
    int n;
    cin >> n;
    if ( n == 0 ) break;

    double min_diff = 10000000;
    int min_num;
    for (int i=0; i<n; i++)
    {
      int num;
      double height, weight;
      cin >> num >> height >> weight;
      double bmi = weight / ( height*height*0.0001);
      double bmi_diff = abs(22.0 - bmi);
      if ( bmi_diff < min_diff )
      {
        min_diff = bmi_diff;
        min_num = num;
      }
      else if ( bmi_diff == min_diff )
      {
        if ( num < min_num )
        {
          min_diff = bmi_diff;
        }
      }
    }
    cout << min_num << endl;
  }
}

Measured memory_bytes: 1228
fn main() {
    let v = read_vec::<u32>();
    let r = v[0];
    let g = v[1];
    let b = v[2];
    yn((r * 100 + g * 10 + b) % 4 == 0);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("YES");
    } else {
        println!("NO");
    }
}


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

int main()
{
  int n;
  cin>>n;
  int x=2*100000;
  int mp[n+1]={0};
  int a[n]={0};
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    mp[a[i]]++;
  }
  ll ans = 0;
    
    for(int i=1;i<=n;i++) ans+=((1LL*mp[i]*(mp[i]-1))/2);
  for(int i=0;i<n;i++) {
        ll temp = ans;
        temp -= ((1LL * (mp[a[i]] * (mp[a[i]]-1)))/2);
        temp += ((1LL * ((mp[a[i]]-2) * (mp[a[i]]-1)))/2);
        cout << temp << endl;
    }
}



Measured memory_bytes: 4096
import java.util.*;
import java.math.*;

public class Main{
    public static void main(final String[] args){
        final Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        int ans = 0;
        long q = 2;
        int e = 1;
        long div;

        if(N == 1){
            System.out.println(0);
            return;
        }

        while(true){
            div = (long) Math.pow(q, e);
            if(N % div == 0){
                N /= div;
                ans++;
                e++;
            }else{
                while(N % q == 0){
                    N /= q;
                }
                q++;
                e = 1;
                if(q * q > N) break;
            }
        }

        if(N != 1){
            ans++;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 35844
import sys

input = sys.stdin.readline

N = int(input())
tmp = 0
for _ in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        tmp += 1
        if tmp == 3:
            print("Yes")
            sys.exit()
    else:
        tmp = 0

print("No")

Measured memory_bytes: 9172
n,k = map(int,input().split())
a = input()
L = [0]*n

for i in range(n-1):
    if a[i] == "A" and a[i+1] == "C":
        L[i] = 1

L = [0]+L
for i in range(n):
    L[i+1] += L[i]
#print(L)
for i in range(k):
    c,d = map(int,input().split())
    print(L[d-1]-L[c-1])

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

using namespace std;

int main() {
  long N, L;
  cin >> N >> L;
  
  long res = 0;
  if (0 <= L) {
    for (long n = L + 1, i = 0; i < N - 1; ++i, ++n) res += n;
  } else if (L < 0 && L + N > 0) {
    for (long n = L, i = 0; i < N; ++i, ++n) res += n;
  } else {
    for (long n = L, i = 0; i < N -1; ++i, ++n) res += n;
  }
  cout << res << endl;
  
  return 0;
}

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

int main()
{
  string C1, C2;
  cin >> C1 >> C2;

  int count = 0;
  for (int i = 0; i < 3; i++) {
    if (C1[i] != C2[2-i]) break;
    else count++;
  }

  if (count == 3) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	px := 0
	py := 0
	for i := 0; i < N; i++ {
		t, x, y := sc.NextInt(), sc.NextInt(), sc.NextInt()

		p := abs(x-px) + abs(y-py)

		if (p-t) > 0 || (p-t)%2 != 0 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")

}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a;
  cin >> a;
  if(a<1200) co("ABC");
  else if(a<2800) co("ARC");
  else co("AGC");
  return 0;
}


Measured memory_bytes: 256