akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
#ABC54 C

import sys
sys.setrecursionlimit(10000000)
from itertools import permutations

n,m = map(int,input().split())
G = [[] for _ in range(n)]

for _ in range(m):
    a,b = map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
s = [i for i in range(n)]
t = list(permutations(s))
ans = 0
for i in t:
    if i[0] == 0:
        for j in range(n-1):
            if i[j+1] not in G[i[j]]:
                break
        else:
            ans += 1
print(ans)


Measured memory_bytes: 8052
#include<bits/stdc++.h>
#define ll long long int
using namespace std ;
int main(){
    ll a,b,n; 
    cin>>a>>b>>n; 
    ll x=n;
    if(n>=b-1){
        x=b-1; 
    }
    ll r=(a*x)/b-a*(x/b) ; 
    cout<<r<<endl; 
    return 0; 
}
    
    
    

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


int main(){

    int A[3];
    for( int i = 0; i < 3; i++ ) cin >> A[i];

    int ans;
    sort( A, A+3 );

    ans = A[2] - A[1];
    if( (A[1] - A[0]) % 2 == 0 ) ans += (A[1] - A[0])/2;
    else ans += (A[1] - A[0])/2 + 2;

    cout << ans << endl;    

    return 0;

}

Measured memory_bytes: 256
n = int(input())
dic = {}
for i in range(n):
    word = input()
    if word in dic:
        dic[word] += 1
    else:
        dic[word] = 1
answer = []
max_dic = 0
for word, cnt in dic.items():
    if cnt > max_dic:
        max_dic = cnt
for word, cnt in dic.items():
    if cnt == max_dic:
        answer.append(word)
answer.sort()
for ans in answer:
    print(ans)


Measured memory_bytes: 92248
N = int(input())
moji =  ''
while True:
    if N % 26 == 0:
        moji = 'z' + moji
        N = N // 26 - 1
    elif N % 26 > 0 and N % 26 < 10:
        moji = chr(ord(str(N % 26)) + 48) + moji
        N //= 26
    elif N % 26 > 9 and N % 26 < 20:
        moji = chr(ord(str(N % 26 - 10)) + 58) + moji
        N //= 26
    else:
        moji = chr(ord(str(N % 26 - 20)) + 68) + moji
        N //= 26

    if N == 0:
        break
print(moji)


Measured memory_bytes: 9180
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		
		SimpleDateFormat data = new SimpleDateFormat("yyyy/MM/dd");
		
		Date date1 = data.parse(S);
		Date date2 = data.parse("2019/4/30");
		
		if(date1.compareTo(date2) <= 0) {
			System.out.println("Heisei");
		}else{
			System.out.println("TBD");
		}
	}
}

Measured memory_bytes: 22096
import java.util.*;
import java.util.HashSet;
import java.util.Set;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int d=a+b;
        int e=a+c;
        int f=b+c;
        if((a==f)||(b==e)||(c==d)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    

       

        
        
        }
       
        
    }
        
     

Measured memory_bytes: 23124
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
using Pc=pair<char,char>;
int main() {
    int n,q; string s; cin >> n >> q >> s;
    vector<Pc> td(q);
    for (int i = 0; i < q; ++i) cin >> td[i].fi>>td[i].se;
    //左端
    int low = -1, high = n;
    while (high - low > 1) {
        int mid = (low + high)/2;
        bool check=false;
        int pos=mid;
         for (auto c : td) {
        if (s[pos] != c.fi) continue;
        if (c.se== 'L') --pos;
        else ++pos;
        if (pos < 0){check=true;break;}
        if(pos>=(int)s.size())break;
    }
        if (check) low = mid;
        else high = mid;
    }
    int left_fall = high;

    // 右側の境目
    low = -1, high = n;
    while (high - low > 1) {
        bool check=false;
        int mid = (low + high) / 2;
        int pos=mid;
         for (auto c : td) {
        if (s[pos] != c.fi) continue;
        if (c.se == 'L') --pos;
        else ++pos;
        if(pos<0)break;
        if (pos >=(int)s.size()){check=true;break;}
    }
        if (check) high = mid;
        else low = mid;
    }
    int right_fall = n-1-low;

    cout<< n - (left_fall + right_fall)<<endl;;
}

Measured memory_bytes: 900
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, x int
	fmt.Scan(&N, &x)

	a := make([]int, N)
	for i:=0; i<N;i++ {
		fmt.Scan(&a[i])
	}

	sort.Ints(a)

	sum, count := 0, 0

	for _, v := range a {
		sum += v

		if sum <= x {
			count++
		}
	}

	if sum < x {
		count--
	}

	fmt.Println(count)
}


Measured memory_bytes: 1844
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;


int main(){
    double n;
    cin>>n;
    int64_t a,b=pow(10,12),c,d;
    for(int i=1;i<=sqrt(n);i++){
        if(n/i==ceil(n/i)){
            a=i+n/i;
            b=min(b,a);
        }
    }
    cout<<b-2<<endl;
}


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

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

long int W = 1e+9+7;
int main(void){
    int n,k;
    cin >> n >> k;
    vector<long int> h(n),dp(n,W);
    rep(i,n){
        cin >> h[i];
    }
    dp[0]=0;
    rep(i,n-1){
        for(int j=i+1; j<=i+k && j<n; j++){
            if(dp[j] > dp[i]+abs(h[i]-h[j])){
                dp[j] = dp[i]+abs(h[i]-h[j]);
            }
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pr pair<long long int, long long int>
using namespace std;
long long int mod = 1e9 + 7;

void dfs(long long node, vector <long long int> v[], long long int j, long long int mark[], queue <long long int> &q)
{
    if(mark[node] != 0)
        return;
    q.push(node);
    mark[node] = j;
    long long len = v[node].size(), i;
    for ( i = 0; i < len; i++)
            dfs(v[node][i], v, j, mark, q);
}

int main()
{
    long long int n, m ,k, i ,j, u, t, len;
    cin >> n >> m >> k;
    vector <long long int> v[n+1];
    vector <long long int> q[n+1];
    queue <long long int> w;
    long long int mark[n+1];
    long long int ans[n+1];
    memset(mark, 0 ,sizeof(mark));
    for ( i = 0; i < m; i++)
    {
        cin >> u >> t;
        v[u].push_back(t);
        v[t].push_back(u);
    }
    for ( i = 0; i < k; i++)
    {
        cin >> u >> t;
        q[u].push_back(t);
        q[t].push_back(u);
    }
    j = 1;
    for ( i = 1; i <= n; i++)
    {
        if(mark[i] == 0)
        {
            dfs(i, v, j ,mark, w);
            len = w.size();
            while (!w.empty())
            {
                ans[w.front()] = len - 1;  
                w.pop();
            } 
            j++;
        }
    }
    // for ( i = 1; i <= n; i++)
    // {
    //     cout << mark[i] << ans[i] << " ";
    // }
    // cout << endl;
    
    for ( i = 1; i <= n; i++)
    {
        len = q[i].size();
        for ( k = 0; k < len; k++)
        {
            long long node = q[i][k];
            if(mark[node] == mark[i])
                ans[i]--;
        }
        
    }
    for ( i = 1; i <= n; i++)
        cout << ans[i] - v[i].size() << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 16576
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include <set>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,m,n) for(int i=m;i<n;i++)
#define endre getchar(); getchar();return 0;
#define pie 3.141592653589793
#define INF 1000000007
bool prime(int n) {
	for (int 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 a[100010];
pair<int, int>b[100010];
signed main() {
	int n,ans=0;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		b[i].first = a[i];
		b[i].second = i;
	}
	sort(b, b + n);
	rep(i, n) {
		if (abs(b[i].second - i) % 2 == 1)ans++;
	}
	cout << ans/2 << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define  _CRT_SECURE_NO_DEPRECATE
using namespace std;
#define maxv 100005
#define che 1LL<<32
#define modi 1000000007
int main()
{
    ll n;
    cin>>n;
    ll i,a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    if(n%2==1)
        cout<<"0"<<endl;
    else
    {
        ll x=n/2;
        if(a[x]==a[x-1])
            cout<<"0"<<endl;
        else
        {
            cout<<a[x]-a[x-1]<<endl;
        }
    }
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;
//ここから

void solve(){
  int a,b,q;
  cin>>a>>b>>q;
  vector<ll>s(a),t(b);
  ll x;
  rep(i,a)cin>>s[i];
  rep(i,b)cin>>t[i];
  rep(i,q){
    cin>>x;
    ll ans=INF;
    int pos=upper_bound(all(s),x)-s.begin();
    int pos2=upper_bound(all(t),x)-t.begin();
    int pos3=lower_bound(all(s),x)-s.begin();
    int pos4=lower_bound(all(t),x)-t.begin();
    chmin(pos,a-1);
    chmin(pos2,b-1);
    chmin(pos3,a-1);
    chmin(pos4,b-1);
    chmax(pos,1);
    chmax(pos2,1);
    chmin(ans,abs(s[pos-1]-t[pos2-1])+min(abs(x-s[pos-1]),abs(x-t[pos2-1])));
    chmin(ans,abs(s[pos-1]-t[pos4])+min(abs(x-s[pos-1]),abs(x-t[pos4])));
    chmin(ans,abs(s[pos3]-t[pos4])+min(abs(x-s[pos3]),abs(x-t[pos4])));
    chmin(ans,abs(s[pos3]-t[pos2-1])+min(abs(x-s[pos3]),abs(x-t[pos2-1])));
    cout<<ans<<"\n";
  }
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


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

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int xx = tx - sx, yy = ty - sy;
	for (int j = 0;j < 2;j++) {
		for (int i = 0;i < abs(xx);i++) {
			if (xx > 0)cout << "R";
			else cout << "L";
		}
		for (int i = 0;i < abs(yy);i++) {
			if (yy > 0)cout << "U";
			else cout << "D";
		}
		xx *= -1;
		yy *= -1;
	}
	for (int j = 0;j < 2;j++) {
		if (yy > 0)cout << "D";
		else cout << "U";
		for (int i = 0;i < abs(xx) + 1;i++) {
			if (xx > 0)cout << "R";
			else cout << "L";
		}
		for (int i = 0;i < abs(yy) + 1;i++) {
			if (yy > 0)cout << "U";
			else cout << "D";
		}
		if (xx > 0)cout << "L";
		else cout << "R";
		xx *= -1;
		yy *= -1;
	}
}

Measured memory_bytes: 256
N=gets.to_i
T,A=gets.split.map(&:to_i)

for i in 2..N do
  t,n=gets.split.map(&:to_i)
  a=(t+T-1)/t
  b=(n+A-1)/n
  c=[a,b].max
  T=t*c
  A=n*c
end

puts T+A

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int s, w;
    cin >> s >> w;
    cout << (w >= s?"unsafe":"safe");    
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=(ll)1e9+7;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(NULL); cout.tie(NULL); 
  ll n,k,i,j,a;
  cin>>n>>k;
  vector<ll> dp(k+1);
  dp[0]=1;
  
  for(j=0;j<n;j++){
    cin>>a;
    vector<ll> sub(k+1);
    swap(sub,dp);
    for(i=1;i<=k;i++)(sub[i]+=sub[i-1])%=mod;  
    for(i=0;i<=k;i++){
      ll left=i-a-1;
      dp[i]=sub[i];
      if(left>=0)dp[i]-=sub[left];
      (dp[i]+=mod)%=mod;
    }
    
  }
  cout<<dp[k];
}

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

#define sz(s) (int)(s).size()
#define re(i, n) for (int i = 1; i <= n; i ++)
#define pb push_back
#define finish(x) return cout << x << endl, 0
#define MP make_mair
#define trav(x, a) for(auto& x: a)
#define all(x) (x).begin,(x).end()
#define Sor(x) sort(all(x))
#define REV(x) reverse(all(x))
#define F first
#define S second
#define I insert
#define N 222222
#define MOD 100000007

using namespace std;

typedef long long ll;
vector <ll> vll;
template <class T> bool umin(T& a, T b) {if(a>b){a = b; return 1;}return 0;}
template <class T> bool umax(T& a, T b) {if(a<b){a=b; return 1;}return 0;}
template <class T, class TT> bool pal(T a, TT n){int k = 0; for(int i =0; i <= n / 2; i ++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

ll powmod(ll a, ll b, ll m = MOD){ll r = 1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}

int a[99999], s;
int main()
{	
		int n;
		cin >> n;
		for (int i = 1; i <= n; i ++)
			cin >> a[i];
            for(int i = 1; i <= n; i++)
	            for(int j = 1; j <= n; j++)
        		     if(i != j)
		                s += a[i]*a[j];
            cout << s/2;









	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int f(string r,string s[],int lx[],int uy[],int rx[],int dy[],int cn[],int m){
  int i,j;
  s[m]=r.substr(r.find('<')+1,r.find('>')-r.find('<')-1);
  lx[m]=atoi(r.substr(r.find('>')+1,r.find(',')-r.find('>')-1).c_str());
  uy[m]=atoi(r.substr(r.find(',')+1,r.find(',',r.find(',')+1)-r.find(',')-1).c_str());
  rx[m]=atoi(r.substr(r.find(',',r.find(',')+1)+1,r.find(',',r.find(',',r.find(',')+1)+1)-r.find(',',r.find(',')+1)-1).c_str());
  dy[m]=atoi(r.substr(r.find(',',r.find(',',r.find(',')+1)+1)+1,r.find('<',r.find('<')+1)-r.find(',',r.find(',',r.find(',')+1)+1)-1).c_str());
  cn[m]=0;
  j=1;
  for(i=1;r.find("</"+s[m]+">")!=r.find('<',i);i=r.find("</"+r.substr(r.find('<',i)+1,r.find('>',r.find('<',i)+1)-r.find('<',i)-1)+">")+1){
    cn[m]++;
    j+=f(r.substr(r.find('<',i),r.find(">",r.find("</"+r.substr(r.find('<',i)+1,r.find('>',r.find('<',i)+1)-r.find('<',i)-1)+">"))-r.find('<',i)+1),s,lx,uy,rx,dy,cn,m+j);
  }
  return j;
}
int main(){
  int i,j;
  int c[100],lx[80],uy[80],rx[80],dy[80],cn[80],m,n,x,y;
  string r,s[80];
  while(cin>>n&&n){
    cin>>r;
    m=f(r,s,lx,uy,rx,dy,cn,0);
    for(i=0;i<n;i++){
      cin>>x>>y;
      for(j=m-1;j>=0;j--){
	if(lx[j]<=x&&x<=rx[j]&&uy[j]<=y&&y<=dy[j])
	  break;
      }
      c[i]=j;
    }
    for(i=0;i<n;i++){
      if(c[i]==-1)
	cout<<"OUT OF MAIN PANEL 1"<<endl;
      else
	cout<<s[c[i]]<<" "<<cn[c[i]]<<endl;
    }
  }
  return 0;
}

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

int main(){

    int array[3], k;
    cin >> array[0] >> array[1] >> array[2] >> k;
    sort(array, array+3);

    while(k--){
        array[2] *= 2;
    }
    cout << array[0] + array[1] + array[2] << endl;
    return 0;
}

Measured memory_bytes: 256
// AGC 011 A
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000

int main(){
    ll n,c,k; cin >> n >> c >> k;
    vector<ll> a;
    for(int i = 0; i < n; i++) {
        ll v; cin >> v;
        a.push_back(v);
    }
    sort(a.begin(),a.end());
    int ans = 0;
    for(int i = 0; i < n;){
        ll key = a[i] + k;
        ll p = c;
        while(p > 0 && key >= a[i] && i < n){
            p--; i++;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  string S;
  ll C=0;
  cin >> S;
  rep(i,S.size()){
    if(S[i]=='2'){
      C++;
    }
  }
  cout << C << endl;
}

Measured memory_bytes: 384
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>

using namespace std;

/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最大公約数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



int main(){
int A,B;
cin >> A >> B;
if(B%A == 0){
    cout << A + B << endl;
}
else{
    cout << B - A << endl;
}
}

Measured memory_bytes: 256
X, Y = list(map(int, input().split()))

def nCr(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

if (2*X-Y)%3 != 0 or (2*Y-X)%3 != 0 or Y > X*2 or X > Y*2:
  print(0)
else:
  m = (2*X-Y)//3
  n = (2*Y-X)//3
  print(nCr(m+n, n))

Measured memory_bytes: 3064
#include <stdio.h>

int bubbleSort(int A[], int N){
  int i,j,sw = 0,temp;

  for( i = 0; i < N; i ++){
    for( j = N - 1; j >= i + 1; j--){
      if( A[j] < A[j-1]){
	temp = A[j];
	A[j] = A[j-1];
	A[j-1] = temp;
	if(i != j)
	sw ++;
      }
    }
  }
  return sw;
}
  

int main(){
  int A[100],N,i,sw;
  
  scanf("%d",&N);
  for( i = 0; i < N; i++)
    scanf("%d",&A[i]);

  sw = bubbleSort(A,N);

  for( i = 0; i < N; i++){
    if( i > 0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",sw);

  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; template <class T> using VVV = V<VV<T>>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1e9 + 7;

signed main() {
  int a, b, Q; cin >> a >> b >> Q;
  VI s(a + 1, -1e17); REP (i, a) cin >> s[i + 1];
  s.push_back(1e17);
  VI t(b + 1, -1e17); REP (i, b) cin >> t[i + 1];
  t.push_back(1e17);
  while (Q--) {
    int x; cin >> x;
    int ans = 1e18;
    int sl = *(lower_bound(ALL(s), x) - 1);
    int sr = *lower_bound(ALL(s), x);
    int tl = *(lower_bound(ALL(t), x) - 1);
    int tr = *lower_bound(ALL(t), x);
    if (sl <= tl) ans = min(ans, x - sl);
    if (tl <= sl) ans = min(ans, x - tl);
    if (sr >= tr) ans = min(ans, sr - x);
    if (tr >= sr) ans = min(ans, tr - x);
    ans = min(ans, (x - sl) * 2 + (tr - x));
    ans = min(ans, (x - tl) * 2 + (sr - x));
    ans = min(ans, (x - tl) + (sr - x) * 2);
    ans = min(ans, (x - sl) + (tr - x) * 2);
    cout << ans << '\n';
  }
}


Measured memory_bytes: 3696
h,w=map(int,input().split())
a=[]
point=0
for _ in range(h):
	x=input()
	a.append(x)
	point+=x.count("#")
cnt=[[10**10 for _ in range(w)] for _ in range(h)]
for i in range(h):
	for j in range(w):
		if a[i][j]==".":
			cnt[i][j]="."
cnt[0][0]=0
lis=[[0,0]]#tate yoko
p=1
while len(lis)!=0:
	x=list()
	for _ in range(len(lis)):
		k=lis.pop(0)
		if k[0]!=0:
			if cnt[k[0]-1][k[1]]==10**10:
				cnt[k[0]-1][k[1]]=p
				x.append([k[0]-1,k[1]])
		if k[1]!=0:
			if cnt[k[0]][k[1]-1]==10**10:
				cnt[k[0]][k[1]-1]=p
				x.append([k[0],k[1]-1])
		if k[0]!=h-1:
			if cnt[k[0]+1][k[1]]==10**10:
				cnt[k[0]+1][k[1]]=p
				x.append([k[0]+1,k[1]])
		if k[1]!=w-1:
			if cnt[k[0]][k[1]+1]==10**10:
				cnt[k[0]][k[1]+1]=p
				x.append([k[0],k[1]+1])
	lis=x
	p+=1
if cnt[-1][-1]==h+w-2==point-1:
	print("Possible")
else:
	print("Impossible")



Measured memory_bytes: 3192
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

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

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

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    N, M = map(int, input().split())
    G = []
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        G.append((a,b))
    ans = 0
    for i in range(M):
        uni = UnionFind(N)
        for j in range(M):
            if i == j:
                continue
            uni.union(G[j][0],G[j][1])
        if uni.group_count() >= 2:
            ans += 1

    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 73948
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    ll k; cin >> k;
    if(!k){
        cout << 2 << endl;
        cout << "0 0\n";
        return 0;
    }else if(k == 1){
        cout << 2 << endl;
        cout << "2 0\n";
        return 0;
    }
    for(ll i = 2; i <= 50; ++i){
        if((i - 1) + k / i + (k % i ? i - k % i : 0) <= 10000000000000000 + 1000 && (i - 1) + k / i + (k % i ? i - k % i : 0) >= i - 1){
            ll mod = k % i;
            cout << i << endl;
            for(int j = 0; j < i; ++j){
                cout << (i - 1) + k / i + (j < mod ? i - mod : -mod) << " ";
            }
            cout << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    set<pair<int, int>> st;
    multiset<int> mst;
    for (int i = 0; i < w; i++) {
        st.emplace(i, i);
        mst.emplace(0);
    }
    st.emplace(w, w);
    int inf = 1e9;
    mst.emplace(inf);
    for (int i = 0; i < h; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        vector<pair<int, int>> v;
        int c = -1;
        for (auto it = st.lower_bound({a, -1}); it != st.end(); it++) {
            pair<int, int> p = *it;
            if (a <= p.first && p.first <= b) {
                c = max(c, p.second);
                v.emplace_back(p);
            } else {
                break;
            }
        }
        for (auto p : v) {
            st.erase(p);
            mst.erase(mst.find((p.first == w ? inf : p.first - p.second)));
        }
        if (c != -1) {
            st.emplace(b, c);
            if (b == w) {
                b = inf;
                c = 0;
            }
            mst.emplace(b - c);
        }
        int res = *mst.begin();
        if (res >= 1e8) {
            cout << -1 << '\n';
        } else {
            cout << res + i + 1 << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 22384
//Circle in a Rectangle
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		String[] WHxyr = in.readLine().split(" ");

		int W = Integer.parseInt(WHxyr[0]);
		int H = Integer.parseInt(WHxyr[1]);
		int x = Integer.parseInt(WHxyr[2]);
		int y = Integer.parseInt(WHxyr[3]);
		int r = Integer.parseInt(WHxyr[4]);

		if (x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17088
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
 
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
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 (a>b) { a=b; return 1; } return 0; }
 
template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }
 
const ll INF = 0x3fffffff;
 
 
vector<int> edge[100005];
bool d[100005] = {};
bool b[100005] = {};
bool ans = false;
int start = -1;
int dfs(int n, int b){
	//cout << "dfs: " << n << " " << b << endl;
	if( d[n] ){
		start = n;
		return -1;
	}
	d[n] = true;
	if( edge[n].size() == 1 ) return 1;
	vector<int> v;
	for(auto t: edge[n]) if(t != b){
		v.push_back( dfs(t, n) );
	}
	int odd = 0;
	int even = 0;
	for(auto t: v){
		if( t >= 0 && (t % 2) ) odd++;
		if( t >= 0 && (t % 2 == 0) ) even++;
		//cout << t << " ";
	}
	//cout << endl;
	//cout << n << "," << b << "  odd:" << odd << " even:" << even << endl;
	if( odd > 1 ){
		ans = true;
		//cout << "true " << ret << endl;
	}
	if( v.size() == even ) return 1;
	if( odd == 1 ) return 0;
	return ( v.size()==1 ? v[0]+1 : -1 );
}
 
int find(int n, int b){
	if( edge[n].size() > 2 ) return n;
	for(auto t: edge[n]) if( t != b ){
		return find(t, n);
	}
	return b;
}
 
int main(){
	//ios_base::sync_with_stdio(0);
	int N;
 
	cin >> N;
	rep(i,N-1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
 
	rep(i,N){
		//cout << "loop" << endl;
		if( edge[i].size() == 1 ){
			Fill( d, false );
			int st = edge[i][0];
			if( b[st] ) continue;
			b[ st ] = true;
			dfs( st, -1 );
			break;
		}
		if( edge[i].size() > 2 ){
			//int st = find(edge[i][0], i);
			int st = i;
			if( b[st] ) continue;
			Fill( d, false );
			b[ st ] = true;
			dfs( st, -1 );
			if( ans ) break;
		}
	}
 
	cout << (ans ? "First" : "Second" ) << endl;
 
	return 0;
}

Measured memory_bytes: 6016
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int d, s, t;
	cin >> d >> t >> s;
	if (d > t * s) {
		cout << "No\n";
	} else {
		cout << "Yes\n";
	}
}

Measured memory_bytes: 3032
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int ans[1 << 18];
int n;
int a[1 << 18];


int x[1 << 18][4];


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


	cin >> n;
	rep(i, 1<<n)cin >> a[i];


	rep(i,1<<n) {
		x[i][0] = a[i];
		sort(x[i], x[i] + 4);
	}
	rep(i, n) rep(b, 1 << n) if (0 != (b & (1 << i))) {
		int src = b ^ 1 << i;
		x[b][0] = x[src][2];
		x[b][1] = x[src][3];
		sort(x[b], x[b] + 4);
	}


	rep(i,1<<n) {
		ans[i] = x[i][2] + x[i][3];
	}

	rep(i, (1<<n)-1) {
		ans[i + 1] = max(ans[i + 1], ans[i]);
	}
	for (int k = 1; k < (1 << n); k++) {
		cout << ans[k] << endl;
	}


	return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <string>

using namespace std;

bool m(int x){
    return (x>0&&x<=12);
}

int main(){
    string S;
    cin>>S;
    int a = stoi(S)/100;
    int b = stoi(S)%100;
    if(!m(a)&&!m(b)) cout<<"NA";
    if(!m(a)&&m(b)) cout<<"YYMM";
    if(m(a)&&!m(b)) cout<<"MMYY";
    if(m(a)&&m(b)) cout<<"AMBIGUOUS";
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

import numpy as np
D = int(input())
Cs = np.array(list(mapint()))
Ss = np.array([list(mapint()) for _ in range(D)], dtype=np.float64)
last = np.zeros(26, dtype=np.float64)

for i in range(D):
    last_2 = last-i
    last_2.astype(np.float64)
    Ss[i] -= last_2*Cs
    idx = np.argmax(Ss[i])
    last[idx] = i+1
    print(idx+1)

def check(Ts):
    last = [0]*26
    
    sati = 0
    for i in range(D):
        t = Ts[i]-1
        sati += Ss[i][t]
        last[t] = i+1
        for j, l in enumerate(last):
            c = Cs[j]
            sati -= (i+1-l)*c
        print(sati)

Measured memory_bytes: 27428
// AtCoder Beginner Contest 129 - Problem D: Lamp (https://atcoder.jp/contests/abc129/tasks/abc129_d)
#include <bits/stdc++.h>

using namespace std;

const int MAX { 2010 };

int rows[MAX][MAX], cols[MAX][MAX];

int solve(int H, int W, const vector<string>& xs)
{
    for (int i = 0; i < H; ++i)
    {
        int L = 0;

        while (L < W)
        {
            if (xs[i][L] == '#')
            {
                ++L;
                continue;
            }

            auto R = L + 1;

            while (R < W and xs[i][R] != '#')
                ++R;

            for (int k = L; k < R; ++k)
                rows[i][k] = (R - L);

            L = R + 1;
        }
    }

    for (int i = 0; i < W; ++i)
    {
        int L = 0;

        while (L < H)
        {
            if (xs[L][i] == '#')
            {
                ++L;
                continue;
            }

            auto R = L + 1;

            while (R < H and xs[R][i] != '#')
                ++R;

            for (int k = L; k < R; ++k)
                cols[k][i] = (R - L);

            L = R + 1;
        }
    }

    int ans = 0;

    for (int x = 0; x < H; ++x)
        for (int y = 0; y < W; ++y)
            ans = max(ans, rows[x][y] + cols[x][y] - 1);

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int H, W;
    cin >> H >> W;

    vector<string> xs(H);

    for (int i = 0; i < H; ++i)
        cin >> xs[i];

    auto ans = solve(H, W, xs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 35968
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0]; 
	let b = v[1];
	let c = v[2];
	if b-a == c - b {
		println!("YES");
	}else{
		println!("NO");
	}
}

Measured memory_bytes: 4352
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String A = sc.next();
    char a = A.charAt(0);
    char b = A.charAt(1);
    char c = A.charAt(2);;
    if(a== '7' || b== '7' || c== '7'){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}



Measured memory_bytes: 35700
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	string s,t;
	cin>>s>>t;
	int ans = 0;
	rep(i,3)if(s[i]==t[i])ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define eps 1e-9
#define HH1 402653189
#define HH2 1610612741

char s[20];

int main() {
	
	scanf("%s", s);
	
	s[4] = 0;
	
	printf("%s\n", (strcmp(s, "YAKI") == 0) ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 256
#abc063_c
N = int(input())
S = [int(input()) for i in range(N)]
S.sort()
m = sum(S)
ans =  0
if m%10 != 0:
    ans = m
else:
    for i in S:
        if i%10!=0:
            ans = m-i
            break
print(ans)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a==3&&b==1) cout<<2<<endl;
	if(a==2&&b==1) cout<<3<<endl;
	if(a==3&&b==2) cout<<1<<endl;
	if(a==1&&b==3) cout<<2<<endl;
	if(a==1&&b==2) cout<<3<<endl;
	if(a==2&&b==3) cout<<1<<endl;
	return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main() {
    int[] buf = readln.chomp.split.to!(int[]);
    int a = buf[0], b = buf[1];

    if (a + b == 15) {
        writeln("+");
    }
    else if (a * b == 15) {
        writeln("*");
    }
    else {
        writeln("x");
    }
}


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	string S;
	cin >> S;

	int ans = 0;
	for (int i = 0; i < N - 2; i++) {
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
			ans++;
		}
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a; string b; cin>>a>>b;
    for(int i=0; i<b.size(); i++)
        a*=10;
    a+=stoi(b);
    for(int i=0; i*i<=a; i++){
        if(i*i == a){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


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

int main(){
    int n;
    cin >> n;
    bool s[4][13];
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            s[i][j]=false;
        }
    }
    char a[54];
    int b[54];
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
        if(a[i]=='S')s[0][b[i]-1]=true;
        else if(a[i]=='H')s[1][b[i]-1]=true;
        else if(a[i]=='C')s[2][b[i]-1]=true;
        else s[3][b[i]-1]=true;
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            if(s[i][j]!=true&&i==0)cout << 'S' << ' ' << j+1 <<endl;
            if(s[i][j]!=true&&i==1)cout << 'H' << ' ' << j+1 <<endl;
            if(s[i][j]!=true&&i==2)cout << 'C' << ' ' << j+1 <<endl;
            if(s[i][j]!=true&&i==3)cout << 'D' << ' ' << j+1 <<endl;
        }
    }
}


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

int a[100005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    int da = a[n-1],xiao;
    int cha = 2147483647;
    for(int i = 0 ; i < n-1; i++)
    {
        if(abs(a[i] - da/2) < cha || abs(a[i] - da/2 - da%2) < cha)
        {
            cha = min(abs(a[i] - da/2),abs(a[i] - da/2 - da%2));
            xiao = a[i];
        }
    }
    printf("%d %d\n",da,xiao);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s[102];
  int sum=0;
  cin>>s;
  int size;
  size=strlen(s);
  for (int i=0;i<size/2;i++){
      if (s[i]!=s[size-i-1])
        sum++;
  }
  cout<<sum<<endl;
  return 0;
}

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

int main() {
    lli K;
    scanf("%lld",&K);

    printf("50\n");
    
    lli ad=K/50,rem=K%50;
    for(int i=0;i<rem;i++) {
        printf("%lld ",49 + ad + 50 - rem + 1);
    }
    for(int i=rem;i<50;i++) {
        printf("%lld ",49 + ad - rem);
    }
    
    return 0;
}


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

using namespace std;

const int M = 26;

char g[M + 1][M + 1]; // g[i][j] char[i] > char[j]
int visit[M + 1];

bool dfs(int i) {
	visit[i] = 1;
	for(int j = 0;j <= M;++j){
		if(g[i][j]) {
			if(visit[j] == 2) continue;
			if(visit[j] == 1) return false;
			if(!dfs(j)) return false;
		}
	}
	visit[i] = 2;
	return true;
}

void ordering(string &a, string &b){
	int len = max(a.length(), b.length());
	for(int i = 0;i < len;++i){
		if(a.length() == i){
			break;
		}
		else if(b.length() == i){
			g[M][a[i] - 'a'] = 1;
			break;
		}
		else if(a[i] != b[i]){
			g[b[i] - 'a'][a[i] - 'a'] = 1;
			break;
		}
	}
	return;
}

int main() {
	int n;
	string s;
	bool judge;
	while(cin >> n, n) {
		vector<string> seq;
		set<char> m;
		memset(g, 0, sizeof(g));
		memset(visit, 0, sizeof(visit));
		judge = true;
		for(int i = 0;i < n;++i){
			cin >> s;
			seq.emplace_back(s);
		}
		g[seq[0][0] - 'a'][M] = 1;
		for(int i = 1;i < n;++i){
			ordering(seq[i - 1], seq[i]);
		}
		for(int i = 0;i <= M;++i){
			judge = judge && dfs(i);
		}
		if(judge){
			cout << "yes" << endl;
		}
		else{
			cout << "no" << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3144
n = gets.to_i
vs = gets.split.map(&:to_i)
vs1_h = Hash.new(0)
vs2_h = Hash.new(0)

vs.length.times{|x|
    vs1_h[vs[x]] = vs1_h[vs[x]] + 1 if x % 2 == 0
    vs2_h[vs[x]] = vs2_h[vs[x]] + 1 if x % 2 != 0
}

n1,n2 = vs1_h.sort_by{|_,v| v}.reverse
m1,m2 = vs2_h.sort_by{|_,v| v}.reverse

n1f,n1b = n1
m1f,m1b = m1

n2f,n2b = n2
m2f,m2b = m2


if (n2 == nil) && (m2 == nil)
    if n1f == m1f
        ans = vs.length / 2
    else
        ans = 0
    end
elsif (n2 != nil) && (m2 == nil)
    if n1f == m1f
        ans = vs.length / 2 - n2b
    else
        ans = vs.length / 2 - n1b
    end
elsif (n2 == nil) && (m2 != nil)
    if n1f == m1f
        ans = vs.length / 2 - m2b
    else
        ans = vs.length / 2 - m1b
    end
else
    if n1f == m1f
        ans = vs.length - [n1b+m2b,n2b+m1b].max
    else
        ans = vs.length - m1b - n1b
    end
end

puts ans


Measured memory_bytes: 20856
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define PI 3.1415926535897932384626
#define mod 1000000007
#define fo(i,n) for(i=0;i<n;i++)
#define endl "\n"
#define mset(m,v) memset(m,v,sizeof(m))
typedef vector<int>	vi;

void solve()
{
	int n,i;
	cin >> n ;
	if(n>=30)cout << "Yes";
	else cout << "No";
	cout << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}

Measured memory_bytes: 3632
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

a, b, c, d = map(int, input().split(' '))

# a <= n, n <= bの整数のうち c, dで割り切れる数
c_div = (b // c) - ((a-1) // c)
d_div = (b // d) - ((a-1) // d)


# a <= n, n <= bの整数のうち c,dの最小公倍数で割り切れる数
c_d = lcm(c, d)
c_d_div = (b // c_d) - ((a-1) // c_d)

# a <= n, n <= bの整数の数
i_count = b - a + 1

print(i_count - (c_div + d_div - c_d_div))

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

int main()
{
  ll n;
  cin >> n;
  
  ll s = 0, t = 0;
  string ans = "";
  
  rep(i,100)
  {
    s = t;
    t = pow(26, i+1) + t;
    if(n <= t)
    {
      n = n - s - 1;
      rep(j,i+1) ans.push_back('a');
      int cnt = 0;
      while(n)
      {
        ans[cnt] += n % 26;
        n /= 26;
        cnt++;
      }
      break;
    }
    //cout << t << endl;
    
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 4020
N,M = map(int, input().split())
A=[-1 for i in range(N)]

ans=True
for i in range(M):
    s, c = map(int, input().split())
    if A[s-1]==-1:
        A[s-1]=c
    elif A[s-1]!=c:
        ans=False
        
if A[0]==0:
    ans=False        

head=True
for i in range(N):       
    if A[i]==-1:
        if head and N!=1:
            A[i]=1
            head=False
        else:
            A[i]=0 
    elif A[i]==0:
        pass
    else:
        head=False


if ans and not head:
    A=[str(a) for a in A]
    print("".join(A))
elif head and N==1:
    print(0)
else:     
    print(-1)


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1000000000 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int N;
    cin >> N;
    int S = 0;
    int m = 200;
    int tmp;
    REP(i, N){
        cin >> tmp;
        S += tmp;
        if(tmp%10!=0){
            m = min(m, tmp);
        }
    }
    if(S%10!=0){
        cout << S << endl;
    }else{
        if(m==200){
            cout << 0 << endl;
        }else{
            cout << S - m << endl;
        }
    }
    return 0;
}

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

int main(){
    ll n; cin >> n;
    ll ans=0;
    vector<ll> A(n);
    for (int i=0;i<n;i++){
        cin >> A[i];
    }
    ll now=A[0];
    for (int i=1;i<n;i++){
        if (A[i]>=now){
            now=A[i];
        }
        else{
            ans+=now-A[i];
        }
    }
    cout << ans << "\n";
}



Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N,A,B;
  cin>>N>>A>>B;
  cout<<min(N*A, B)<<endl;

  return 0;
}


Measured memory_bytes: 256