akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define REP(i, n) for(int i(0); i<(int)(n);i++)
#define FOR(i, a, b) for (int i(a); i<=(int)(b); i++)

using LL = long long;
using PII = pair<int, int>;
using VI = vector<int>;


int main() {
    LL n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(0LL, a + b - n) << endl;
    return 0;
}

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

int main(){ 
  int K, X;
  cin >> K >> X;
  
  int left, right;
  left = X - K + 1;
  right = X + K - 1;
  
  for (int i = left; i < right; i++) {
    cout << i << " ";
  }
  cout << right << endl;

}


Measured memory_bytes: 256
let solve d n m =
  let dp = Array.init (n + 1) (fun i -> i) in
  for i = 1 to m - 1 do
    for j = d.(i) to n do
      if dp.(j - d.(i)) + 1 < dp.(j) then dp.(j) <- dp.(j - d.(i)) + 1;
    done
  done;
  dp.(n)

let () =
  let n, m = Scanf.scanf "%d %d " (fun n m -> n, m) in
  let d = Array.init m (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  solve d n m |> Printf.printf "%d\n"

Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    int a;
    cin >> a;
    int n = 9;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(i*j==a){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;

}


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

/*
int f(int k, vector<int> vec, int j) {
	if (j == 0) {
		int x = 0;
		for (int i = 0; i < k; i++) {
			x += vec.at(i);
		}
		return x;
	}
	return f(k, vec, j - 1) + vec.at(j + k -1) - vec.at(j - 1);
}
*/

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

	vector<int> vec(n);
	vector<int> sum(n);
	for (int i = 0; i < n; i++) {
		cin >> vec.at(i);
		sum.at(i) = (1 + vec.at(i));
	}

  
	vector<long long> ans(n - k + 1);
	for (int j = 0; j < n - k + 1; j++) {
		if (j == 0) {
			int x = 0;
			for (int i = 0; i < k; i++) {
				x += sum.at(i);
			}
			ans.at(j)= x;
		}
		else ans.at(j) = ans.at(j - 1) - sum.at(j - 1) + sum.at(j + k - 1);
	}

  
	sort(ans.begin(), ans.end());
  int ff = ans.at(ans.size() - 1);
  if (ff % 2 == 0) cout << ff / 2 << endl;
	else {
    double finalfinal;
      finalfinal = (double)ans.at(ans.size() - 1);
      cout << fixed << setprecision(1);
    cout << finalfinal / 2 << endl;
  }
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  long long n,a[50]={},p,ans=1;
  cin >> n >> p;
  bool odd=false;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    if(a[i]%2==1) {
      odd=true;
    }
  }
  for(int i=0; i<n-1; i++) {
    ans*=2;
  }
  if(odd) {
    cout << ans << endl;
  }
  else {
    if(p==0) {
      cout << ans*2 << endl;
    }
    else {
      cout << 0 << endl;
    }
  }
}

Measured memory_bytes: 256
i,j,n,x,y,a,b,map[30][30];
main()
{
  char c,t;
  for(;scanf("%d",&n),n;puts(n?"No":"Yes"))
    {
      for(i=0;i<30;i++)
	for(j=0;j<30;j++)
	  map[i][j]=0;
      for(j=n;j--;map[x][y]=1)
	  scanf("%d%d",&x,&y);
      scanf("%d",&j);
      getchar();
      for(a=b=10;j--;)
	{
	  i=c=0;
	  while((t=getchar())!='\n')
	    if(t>='0' &&t<='9')
	      i=i*10+t-'0';
	    else if(t>'A' && t<'Z')
	      c=t;
	  for(;i--;)
	    {
	      if(c=='N')
		b++;
	      if(c=='E')
		a++;
	      if(c=='S')
		b--;
	      if(c=='W')
		a--;
	      if(map[a][b]==1)
		  map[a][b]=0,n--;
	    }
	}
    }
  exit(0);
}

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

const int mod = (int) 1e9 + 7;
 
int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> s(n), t(m);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> t[i];
  }
  vector<long long> dp(m + 1, 1);
  for (int i = 0; i < n; ++i) {
    vector<long long> newDp(m + 1);
    for (int j = 1; j <= m; ++j) {
      if (s[i] == t[j - 1]) {
        (newDp[j] += dp[j - 1]) %= mod;  
      }  
    }
    for (int j = 1; j <= m; ++j) {
      (newDp[j] += newDp[j - 1]) %= mod;
    }
    for (int j = 0; j <= m; ++j) {
      (newDp[j] += dp[j]) %= mod;
    }
    swap(dp, newDp);
  }
  cout << dp.back() << '\n';
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(){
	ios::sync_with_stdio(false);
	
    int n;
    cin >> n;
    unordered_map <string, int> mp;

    FOR(i, n){
    	string s;
    	cin >> s;

    	sort(ALL(s));
    	mp[s]++;
    }

    ll ans = 0;
    for(auto p:mp){
    	ans += (ll) p.second*(p.second - 1)/2;
    }

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


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int coin; cin>>coin;
    long long int point =0;
    long long int a = coin/500;
    point = point + (a*1000);
    coin = coin - (500*a);
    long long int b = coin/5;
    point = point + (b*5);
    cout<<point<<endl;
    
}

Measured memory_bytes: 256
import java.util.*; 
import java.io.*; 
import java.lang.Math; 
public class Main
{
     public static void main(String []args)
     {
        Scanner in=new Scanner(System.in);
        int n;
        long sum=0,ans=0;
        n=in.nextInt();
        long a[]=new long[n];
        long suf[]=new long[n];
        for(int i=0;i<n;i++)
        {
          	a[i]=in.nextLong();
          	suf[i]=a[i];
        }
       for(int i=n-2;i>=0;i--)
       {
         	suf[i]=suf[i]+suf[i+1];
       }
       long m=1000000007;
       for(int i=0;i<n-1;i++)
       {
         	ans=ans+(a[i]%m)*(suf[i+1]%m);
         	ans=ans%m;
       }
       System.out.println(ans%m);
     }
}



Measured memory_bytes: 62952
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main()
{
       int n, a, b;

       scanf("%d %d %d", &n, &a, &b);

       if( a * n > b )
              printf("%d\n", b);
       else
              printf("%d\n", a * n );
      
       return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N),b(N);
    rep(i,N){
        cin >> a.at(i) >> b.at(i);
    }
    sort(all(a));
    int cnt=0;
    cnt += a.at(0);
    for (int i=1;i<N;i++){
        cnt += a.at(i)-a.at(i-1);
    }
    vector<int>::iterator minIter = min_element(all(b));
    size_t minIndex = distance(b.begin(), minIter);
    int min = b.at(minIndex);
    cnt += min;
    cout << cnt << endl;
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    rep(i,N) cin >> p[i];
    int ans = 0, curm = p[0];
    rep(i,N){
        curm = min(curm, p[i]);
        if(p[i] <= curm) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint mpow(mint x, int n){
  if(n==1)return x;
  if(n==0)return 1;

  if(n%2==0){
    return mpow(x*x, n/2);
  }else{
    return mpow(x*x, n/2) * x;
  }
}

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

  mint memo[100001];

  mint ans = 0;
  for(int i = k; i >=1; i--){
    mint t = (k/i);
    // mint s = 1;
    // REP(j,n)s*=t;
    mint s = mpow(t,n);

    FOR(j,2,k/i+1)s-=memo[i*j];
    memo[i] = s;
    ans += s * i;
  }

  // REP(i,k+1){
  //   cout << i << " " << memo[i].x << endl;
  // }

  cout << ans.x << endl;

}



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

using namespace std;

int main() {

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	char a;
	std::cin >> a;
	if(a<='z'&&a>='a') print((char)('a'));
	else print((char)('A'));
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int k;
	string s;
	cin >> k >> s;	
	if(s.size() > k) cout << s.substr(0, k) << "..." << endl;
	else cout << s << endl;
}





Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define mp            make_pair
#define PI            3.14159265
#define M             1000000007
#define MM            998244353
#define fr            first
#define sc            second
#define all(v)        (v).begin(),(v).end()
#define rall(v)       (v).rbegin(),v.rend()
#define vc            vector
#define vi            vector<int>
#define pii           pair<int,int>
#define psi           pair<string,int>
#define pis           pair<int,string>
#define mii           map<int,int>
#define msi           map<string,int>

int solve(){
   int n,l,s=1000000,ans=0,t=0; cin>>n>>l;
   for (int i = 1; i <= n; ++i)
   {
        if(abs(l+i-1)<s){
            s=abs(l+i-1);
            t=l+i-1;
        }
       ans+=l+i-1;
   }
   cout<<ans-t;
}

signed main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
  // input[0] => １行目, input[1] => 2行目
  input = input.split(" ");

  const n = parseInt(input[0], 10);
  const a = parseInt(input[1], 10);
  const b = parseInt(input[2], 10);

  const train = n * a;
  const taxi = b;

  train > taxi ? console.log("%d", taxi) : console.log("%d", train)
}

// *型変換
// 文字列から10進数
// let a = parseInt(input[0], 10)

// *出力
// console.log('%d', number);
// console.log('%s', string);


// 編集しない
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<stdio.h>

int main(){
  int flag =1;
  int count=0,n,i,j,data[100],temp;
  scanf("%d",&n);
  for(i = 0;i < n;i++){
  scanf("%d",&data[i]);
  }
  while(flag){
    flag = 0;
    for(j = n-1;j > 0;j--){
      if(data[j] < data[j-1]){
        temp = data[j];
        data[j] = data[j-1];
        data[j-1] = temp;
        count++;
        flag= 1;
      }
    }
  }
  for(i = 0;i < n-1;i++)printf("%d ",data[i]);
  printf("%d",data[i]);
  printf("\n%d\n",count);
  return 0;
}



Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sumvec(vector<S>&a){return accumulate(all(a),S());}
template<class S>S maxvec(vector<S>&a){return *max_element(all(a));}
template<class S>S minvec(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}


int main(void){
  	cin.tie(0);
  	ios::sync_with_stdio(false);
    
    ll n,x;
    cin>>n;
    vl s(n+1);
    range(i,1,n+1){
        cin>>x;
        s[x]=i;
    }
    range(i,1,n+1){
        cout<<s[i];
        if(i!=n) cout<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    // if (1 <= n && n <= 9) {
    //     cout << n << endl;
    // } else if (10 <= n && n <= 99) {
    //     cout << 9 << endl;
    // } else if (100 <= n && n <= 999) {
    //     cout << 9 + n % 100 + 1 << endl;
    // } else if (1000 <= n && n <= 9999) {
    //     cout << 909 << endl;
    // } else if (10000 <= n && n <= 99999) {
    //     cout << 909 + n % 10000 + 1 << endl;
    // } else if (n == 100000) {
    //     cout << 90909 << endl;
    // }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int j = i;
        int cnt = 0;
        while (j > 0) {
            j /= 10;
            cnt++;
        }
        if (cnt % 2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def solve(ary)
  if ary.size <= 1
    return ary[0] if eval(ary[0]) == 10
  else
    idxs = [*0...ary.size]
    idxs.combination(2) do |i, j|
      a, b = ary[i], ary[j]
      nxt = (idxs - [i, j]).map{|x| ary[x]}
      ["(#{a} + #{b})", "(#{a} - #{b})", "(#{b} - #{a})", "#{a} * #{b}"].each do |st|
        result = solve(nxt + [st])
        return result if result
      end
    end
  end
  nil
end

until (given = $<.gets.chomp.split) == ["0", "0", "0", "0"]
  ans = solve(given)
  puts ans ? ans : 0
end


Measured memory_bytes: 9360
#include<iostream>
using namespace std;
int main(){
	long long a;
	cin>>a;
	string s;
	do{
		if(a%2) {
			a-=1;
			s='1'+s;
		} else 
			s='0'+s;
		
	}while(a/=-2);
	cout<<s;
}

Measured memory_bytes: 256
#include"iostream"
using namespace std;
int main() {
	while (1) {
		int n, m, t[100], h[100], sumt = 0, sumh = 0, mint = 101, minh = 101;
		cin >> n >> m;
		if (n == 0 && m == 0)break;
		for (int i = 0; i < n; i++) {
			cin >> t[i];
			sumt += t[i];
		}
		for (int i = 0; i < m; i++) {
			cin >> h[i];
			sumh += h[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (sumt - t[i] + h[j] == sumh - h[j] + t[i]) {
					if (h[j] + t[i] < mint + minh) {
						mint = t[i];
						minh = h[j];
					}
				}
			}
		}
		if (mint == 101 && minh == 101)cout << "-1" << endl;
		else cout << mint << " " << minh << endl;
	}
	return 0;
}




Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<ll,ll> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


int main(){
  ll n,m; cin>>n>>m;
  vector<P> p(n);
  rep(i,n) cin>>p[i].first>>p[i].second;

  sort(p.begin(),p.end());
  ll ans=0;
  ll nm=0;
  rep(i,n){
    if(m-nm<p[i].second){
      ans+=(p[i].first)*(m-nm);
      break;
    }else{
      ans+=(p[i].first)*(p[i].second);
      nm+=p[i].second;
    }
  }

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


Measured memory_bytes: 1920
import sys
import math
# sys.stdin  = open("input.txt")
n=int(input())
a=[int(o) for o in input().split()]
s=0
for i in range(n-1):
    if a[i+1]<a[i]:
        s+=(a[i]-a[i+1])
        a[i+1]=a[i]
print(s)



Measured memory_bytes: 94016
#include <iostream>
using namespace std;
   
#define check cnt=0;for(j=0;j<6;j++)if(d[q][j]==d[r][j])cnt++;
#define m tmp=d[r][1];d[r][1]=d[r][3];d[r][3]=d[r][4];d[r][4]=d[r][2];d[r][2]=tmp;
#define y tmp=d[r][0];d[r][0]=d[r][3];d[r][3]=d[r][5];d[r][5]=d[r][2];d[r][2]=tmp;
   
bool same(int d[][6],int q,int r){
 int tmp,cnt,a=1,i,j,k;
 check if(cnt==6)a=0;
   
 while(a){
  for(i=0;i<5;i++){
   for(k=0;k<4;k++){
    check if(cnt==6)break;
    m
   }
   check if(cnt==6)break;
   tmp=d[r][0];
   d[r][0]=d[r][1];
   d[r][1]=d[r][5];
   d[r][5]=d[r][4];
   d[r][4]=tmp;
  }
  if(cnt==6)break;
  y
  for(k=0;k<4;k++){
   check if(cnt==6)break;
   m
  }
  if(cnt==6)break;
  y y
  for(k=0;k<4;k++){
   check if(cnt==6)break;
   m
  }
  a=0;
 }
   
 if(cnt==6)return true;
 return false;
}
 
int main(){
 int n,judge=0;
 cin >> n;
 int d[n][6];
   
 for(int i=0;i<n;i++)for(int j=0;j<6;j++)cin >> d[i][j] ;
   
 for(int q=0;q<n-1;q++)for(int r=q+1;r<n;r++)if(same(d,q,r))judge++;
 
 if(judge>0)cout << "No" << endl ;
 else cout << "Yes" << endl ;
   
 return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<ll> vec(n);
  rep(i,n){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int cnt = 1;
  vector<ll> array;
  REP(i,1,n){
    if (vec.at(i) == vec.at(i-1)){
      cnt++;
    }
    else {
      cnt = 1;
    }
    if (cnt == 2){
      array.push_back(vec.at(i));
      cnt = 1;
      i++;
    }
  }
  if (array.size() < 2){
    cout << 0 << endl;
    return 0;
  }
  reverse(array.begin(),array.end());
  cout << array.at(0) * array.at(1) << endl;
  return 0;
}


Measured memory_bytes: 4596
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < n; i++){
            int tmp = scanner.nextInt();
            map.put(tmp,map.getOrDefault(tmp,0)+1);
        }
        int ans = 0;
        for(Integer key: map.keySet()){
            int val = map.get(key) - key;
            if(val < 0){
                ans += map.get(key);
            }else if(val > 0){
                ans += Math.min(map.get(key) - key, map.get(key));
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 63768
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int a,b;
	cin >> a >> b;

  	cout << max({a+b, a-b, a*b}) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;

struct UnionFind{
  vector<int> par;
  vector<int> size;

  UnionFind(int n):par(n),size(n){
    for(int i=0;i<n;i++){
      par[i]=i;
      size[i]=1;
    }
  }

  int find_par(int x){
    if(par[x]==x){
      return x;
    }else{
      return par[x]=find_par(par[x]);
    }
  }
  void merge_tree(int x,int y){
    x=find_par(x);
    y=find_par(y);
    if(x==y){return ;}
    if(size[x]<size[y]){swap(x,y);}
    par[y]=x;
    size[x]+=size[y];
  }
  bool same(int x,int y){
    return find_par(x)==find_par(y);
  }
  int print_size(int x){
    return size[find_par(x)];
  }

};

int main(){
  int N,M,K;cin>>N>>M>>K;
  vector<int> a(M),b(M);
  vector<int> c(K),d(K);
  UnionFind uf(N);
  vector<int> ans(N,-1);
  for(int i=0;i<M;i++){
    cin>>a[i]>>b[i];
    a[i]--,b[i]--;
    uf.merge_tree(a[i],b[i]);
  }
  for(int i=0;i<K;i++){
    cin>>c[i]>>d[i];
    c[i]--,d[i]--;
  }
  for(int i=0;i<N;i++){
    ans[i]+=uf.print_size(i);
  }
  for(int i=0;i<K;i++){
    if(uf.same(c[i],d[i])){
      ans[c[i]]--;
      ans[d[i]]--;
    }
  }
  for(int i=0;i<M;i++){
    if(uf.same(a[i],b[i])){
      ans[a[i]]--;
      ans[b[i]]--;
    }
  }
  for(int i=0;i<N;i++){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
}


Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

struct Point {
    int x;
    int y;
};

int main()
{
    int n;
    cin >> n;
    struct Point *p = new Point[n];

    for (int i = 0; i < n; i++) {
        cin >> p[i].x;
        cin >> p[i].y;
    }

    int power = 1;
    for (int i = 2; i <= n; i++) {
        power *= i;
    }

    int count = n * (n - 1) / 2;
    double *result = new double[count];
    int index = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            result[index++] = sqrt((p[i].x - p[j].x) * (p[i].x - p[j].x) + (p[i].y - p[j].y) * (p[i].y - p[j].y));
        }
    }

    double sum = 0.0;
    for (int i = 0; i < count; i++) {
        sum += result[i];
    }

    double retval = sum * (n - 1) / (double)count;
    printf("%.10f", retval);

    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<string>
#include<iostream>

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

using namespace std;

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

	string prog[100];
	bool isgoto[100]={};
	rep(i,n){
		getline(cin,prog[i]);
		prog[i].erase(--prog[i].end());
		if(prog[i].length()>=4 && prog[i].substr(0,4)=="goto") isgoto[i]=true;
	}

	int m=0,pos[100];
	rep(i,n) if(isgoto[i]) pos[m++]=i;

	map<string,int> f;
	rep(pc,n) if(!isgoto[pc]) f[prog[pc]]=pc;

	// 0-1 BFS
	int d[101];
	rep(i,n+1) d[i]=(i==0?0:n);

	int Q[5000],head=2500,tail=2500;
	Q[tail++]=0;
	while(head<tail){
		int pc=Q[head++];

		if(pc==n) break;

		if(!isgoto[pc]){
			if(d[pc+1]>d[pc]){
				d[pc+1]=d[pc];
				Q[--head]=pc+1;
			}
		}
		else{
			if(d[pc+1]>d[pc]+1){
				d[pc+1]=d[pc]+1;
				Q[tail++]=pc+1;
			}

			int pc2=f[prog[pc].substr(5)];
			if(d[pc2]>d[pc]){
				d[pc2]=d[pc];
				Q[--head]=pc2;
			}
		}
	}

	cout<<d[n]<<endl;

	return 0;
}

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

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<#a<<':'<<a<<endl

const ll INF = 1e9+7;

template<typename T>inline T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int a,b;cin>>a>>b;
  int ans = max(a-b*2,0);
  print(ans);
  return 0;
} 

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException
	{
		int n,h,m,s;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
		n = Integer.parseInt(br.readLine() );

		h = n/3600;

		m = (n/60)%60;

		s = n%60;

		System.out.println( h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 24440
#include<iostream>
#include<map>
using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;
map<ll, ll>mp;

inline ll f(ll x) {
	if (mp[x])return mp[x];
	return mp[x] = (f(x / 2) + f((x - 1) / 2) + f((x - 2) / 2)) % mod;
}

int main() {
	ll n; cin >> n;
	mp[0] = 1, mp[1] = 2;
	cout << f(n) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include <stdio.h>

using namespace  std;

int n,m,now,t;

int main(void){

  while( cin >> n >> m , n || m ){

    queue<int>Q;
    for(int i = 0 ; i < n ; i++ ) Q.push(i + 1);
    
    now = 1;
    
    while( Q.size() > 1 ){
      
      t = Q.front();
      
      if( now % m != 0){
	Q.push(t);
      }
      
      now++;
      Q.pop();
      
    }
    
    printf("%d\n",Q.front() );
  }
  return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int N = 4;
constexpr int N2 = 16;
constexpr int dx[4] = {0, -1, 0, 1};
constexpr int dy[4] = {1, 0, -1, 0};

struct Puzzle {
    int f[N2], space, MD;
    int cost;

    bool operator<(const Puzzle& p) const {
        rep(i, 0, N2) {
            if (f[i] == p.f[i]) { continue; }
            return f[i] < p.f[i];
        }
        return false;
    }
};

struct State {
    Puzzle puzzle;
    int estimated;
    bool operator<(const State& s) const { return estimated > s.estimated; }
};

void init_md(vvi& MDT) {
    rep(i, 0, N2) {
        rep(j, 0, N2) { MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N); }
    }
}

int get_md(const Puzzle& pz, const vvi& MDT) {
    int sum = 0;
    rep(i, 0, N2) {
        if (pz.f[i] == N2) { continue; }
        sum += MDT[i][pz.f[i] - 1];
    }
    return sum;
}

int astar(Puzzle& s, const vvi& MDT) {
    s.MD = get_md(s, MDT);
    s.cost = 0;

    map<Puzzle, bool> V;
    Puzzle u, v;

    priority_queue<State> PQ;
    State initial;
    initial.puzzle = s;
    initial.estimated = s.MD;
    PQ.push(initial);

    while (!PQ.empty()) {
        State st = PQ.top();
        PQ.pop();

        u = st.puzzle;

        if (u.MD == 0) { return u.cost; }
        V[u] = true;

        int sx = u.space / N;
        int sy = u.space % N;

        rep(i, 0, 4) {
            int tx = sx + dx[i];
            int ty = sy + dy[i];
            if (tx < 0 || ty < 0 || tx >= N || ty >= N) { continue; }

            v = u;
            v.MD -= MDT[tx * N + ty][v.f[tx * N + ty] - 1];
            v.MD += MDT[sx * N + sy][v.f[tx * N + ty] - 1];

            swap(v.f[sx * N + sy], v.f[tx * N + ty]);
            v.space = tx * N + ty;
            if (!V[v]) {
                ++v.cost;
                State news;
                news.puzzle = v;
                news.estimated = v.cost + v.MD;
                PQ.push(news);
            }
        }
    }
    return -1;
}

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

    Puzzle P;
    rep(i, 0, N2) {
        cin >> P.f[i];
        if (P.f[i] == 0) {
            P.f[i] = N2;
            P.space = i;
        }
    }

    vvi MDT(N2, vi(N2));
    init_md(MDT);

    cout << astar(P, MDT) << endl;

    return 0;
}


Measured memory_bytes: 257592
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int a , h ;
	cin >> h >> a ;
	int cnt =0 ;
	while(h>0){
		h-=a;
		cnt++;
	}
	cout << cnt << endl;
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

int main()
{
    ll n, m;
    ll a;
    ll temp = 0;
    cin >> n >> m;
    for (ll i = 0; i < m; i++)
    {
        cin >> a;
        temp += a;
    }
    if (n < temp)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << n - temp << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
// Problem : B - String Palindrome
// Contest : AtCoder - AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
#define pi 3.141592653589793238
using namespace std;
bool check(string s){
	string p="";
	for(lli i=s.length()-1;i>=0;i--)
	p+=s[i];
	if(p==s) return true;
	else return false;
	
}
int main()
{
	lli n;
	string s,t,k;
	cin>>s;
	n=s.length();
	t=s.substr(0,(n-1)/2);
	k=s.substr((n+3)/2-1,n-1/2);
	// cout<<t<<" "<<k<<"\n";
	if(check(s)&&check(t)&&check(k)){
		cout<<"Yes";
	}
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;

const int MAX_N=1e5;

int N,A[MAX_N];

ll ans[MAX_N];

struct stone{
	int inx,n;
	bool operator < (const stone &s)const{
		if (n!=s.n){
			return n<s.n;
		}
		return inx>s.inx;
	}
};

int main(){
	scanf("%d",&N);
	REP(i,N){
		scanf("%d",&A[i]);
	}
	int mxa=0;
	FOR(i,1,N){
		if (A[i]>A[mxa]){
			mxa=i;
		}
	}
	priority_queue<stone> pque[2];
	REP(i,mxa){
		pque[0].push((stone){i,A[i]});
	}
	FOR(i,mxa+1,N){
		pque[1].push((stone){i,A[i]});
	}
	ll sline,cnt;
	sline=cnt=0;
	while(mxa!=0){
		int nxt;
		while(1){
			int inx=pque[0].top().inx;
			pque[0].pop();
			if (inx<mxa){
				nxt=inx;
				break;
			}
		}
		ans[mxa]=A[mxa]-A[nxt];
		ans[mxa]+=sline*(cnt-A[nxt]);
		while(!pque[1].empty() && pque[1].top().n>A[nxt]){
			ans[mxa]+=pque[1].top().n-A[nxt];
			pque[1].pop();
			sline++;
		}
		cnt=A[nxt];
		sline++;
		FOR(i,nxt+1,mxa){
			pque[1].push((stone){i,A[i]});
		}
		mxa=nxt;
	}
	ll sum=0;
	REP(i,N){
		sum+=A[i];
	}
	REP(i,N){
		sum-=ans[i];
	}
	ans[0]=sum;
	REP(i,N){
		printf("%lld\n",ans[i]);
	}
	return 0;
}


Measured memory_bytes: 3188
S = input()

if S =="SUN":
    print(7)

elif S =="MON":
    print(6)
    
elif S =="TUE":
    print(5)

elif S =="WED":
    print(4)
    
elif S =="THU":
    print(3)
    
elif S =="FRI":
    print(2)

else:
    print(1)

Measured memory_bytes: 38256
#include<iostream>
using namespace std;
int main(){
long n,i,x,y,p,d1,d2;
while(cin>>n){
if(n==0)break;
for(x=i=0;i<n;i++){
cin>>p>>d1>>d2;
if(x<d1+d2){x=d1+d2;y=p;}
}
cout<<y<<" "<<x<<endl;
}
return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

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

int main()
{
  int A, B, K;
  cin >> A >> B >> K;
  int g = gcd(A, B);
  vector<int> vc;
  REP1(i, g)
  {
    if (g % i == 0)
      vc.push_back(i);
  }
  cout << vc[vc.size() - K] << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

_n = int(input())
_s = input()[:-1]


def chker(n, s):
    if n % 2 != 0:
        print('No')
        return

    hs = len(s) // 2
    ls, rs = s[:hs], s[hs:]
    if ls == rs:
        print('Yes')
    else:
        print('No')


chker(_n, _s)


Measured memory_bytes: 2940
#include <stdio.h>
int arr[3][3];
int main(void) {
	int a[3][3], i, j, k, n, num, flag=0, sum;
	for(i=0; i<3; i++){
		for(j=0; j<3; j++){
			scanf("%d", &a[i][j]);
		}
	}
	scanf("%d", &n);
	for(k=0; k<n; k++){
		scanf("%d", &num);
		for(i=0; i<3; i++){
			for(j=0; j<3; j++){
				if(a[i][j]==num){
					arr[i][j]=1;
				}
			}
		}
	}
	for(i=0; i<3; i++){
		sum=0;
		for(j=0; j<3; j++){
			sum+=arr[i][j];
		}
		if(sum==3)
			flag=1;
	}
	for(i=0; i<3; i++){
		sum=0;
		for(j=0; j<3; j++){
			sum+=arr[j][i];
		}
		if(sum==3)
			flag=1;
	}	
	if(arr[0][0]+arr[1][1]+arr[2][2]==3)
		flag=1;
	if(arr[2][0]+arr[1][1]+arr[0][2]==3)
		flag=1;	
	if(flag==1)
		printf("Yes");
	else
		printf("No");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<vector<ll>> g;
vector<ll> fac;
vector<ll> inv;

long long ppow(const long long &v, const long long &n, const long long &mod)
{
    long long ret = 1;
    long long num = n;
    long long now = v;
    
    while (num > 0)
    {
        if (num & 1)
        {
            ret = ret * now % mod;
        }
        now = now * now % mod;
        num = num >> 1;
    }
    
    return ret;
}


long long calc(const long long &n, const long long &k, const long long &mod)
{
    long long ret;
    fac = vector<long long>(n + 1, 1);
    inv = vector<long long>(n + 1, 1);
    
    for (int i = 1; i <= n; ++i)
    {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = ppow(fac[i], mod - 2, mod);
    }
    
    ret = fac[n] * inv[k] % mod * inv[n - k] % mod;
    
    return ret;
}

int main() {
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll x, y;
    cin >> x >> y;
    
    if ((x + y) % 3 != 0 || (x > 2 * y || y > 2 * x))
    {
        cout << 0 << endl;
        return 0;
    }
    
    ll c = (x + y) / 3;
    ll cc = min(x, y) - c;
    cout << calc(c, cc, mod) << endl;
    
    return 0;
}

Measured memory_bytes: 10624
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

int main() {
	int x[5];
	{
		string s;
		getline(cin, s);
		sscanf(s.c_str(), "%d %d %d %d %d", &x[0], &x[1], &x[2], &x[3], &x[4]);
	}

	for (int i = 0; i < 5; i++) {
		if (x[i] == 0)
			cout << i + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;
const ll mod=1000000007;
 
int n;
string a,b;
 
int main()
{
	cin>>n;
	cin>>a>>b;
	
	ll ans=1;
	ll cur=-1;
	for(int i=0;i<n;i++){
		if(a[i]==b[i]){
			if(cur==-1){
				ans*=3;
				ans%=mod;
			}
			else if(cur==0){
				ans*=2;
				ans%=mod;
			}
			cur=0;
		}
		else{
			if(cur==-1){
				ans*=6;
				ans%=mod;
			}
			else if(cur==0){
				ans*=2;
				ans%=mod;
			}
			else{
				ans*=3;
				ans%=mod;
			}
			cur=1;
			i++;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define rep(i, n)  for (int i = 0; i < (int) (n); i++)
#define Rrep(i, n) for (int i = ((int) n - 1); i >= 0; i--)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
#define INF 2e15
#define MOD 10e9 + 7

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



int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    ll x, k, d;
    cin >> x >> k >> d;

    ll preans1, preans2;
    ll idou1, idou2;

    idou1   = llabs(x / d);
    preans1 = llabs(llabs(x) - idou1 * d);

    preans2 = llabs(preans1 - d);
    idou2   = idou1 + 1;

    if (preans1 > preans2) { swap(preans1, preans2); swap(idou1, idou2); }

    if (idou1 > k) {
        cout << llabs(llabs(x) - d * k) << endl; // answer
    }
    else if ((k - idou1) % 2 == 0) {
        cout << preans1 << endl;
    }
    else {
        cout << preans2 << endl;
    }

    return 0;
}


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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  for (int i = A; i <= B; i++) {
    if (i % K == 0) return cout << "OK" << "\n", 0;
  }
  cout << "NG" << "\n";
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

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

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

    ll n;
    cin >> n;
    cout << (1000-n%1000)%1000 <<endl;

    
    return 0;
}



Measured memory_bytes: 3616
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
import math

n=int(input().rstrip())
h=[int(i) for i in input().split()]
ans=0
while 1:
    for i in range(n):
        if h[i]:
            j=i
            break
    else:
        print(ans)
        exit()
    while h[j]!=0:
        h[j]-=1
        if j<n-1:
            j+=1
        else: break
    ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>

using namespace std;
using ull = unsigned long long;

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

	vector<pair<int, int>> vec(N); // cost, value

	for (size_t i = 0; i < N; i++) {
		cin >> vec[i].first;
	}
	for (size_t i = 0; i < N; i++) {
		cin >> vec[i].second;
	}

	int sum = 0;

	for (size_t i = 0; i < N; i++) {
		const int sa = vec[i].first -vec[i].second;
		if (sa > 0) {
			sum += sa;
		}
	}

	cout << sum  << endl;
	return 0;
}



Measured memory_bytes: 256
n, m, k = gets.chomp.split(" ").map(&:to_i)
black = []
(0..n).each do |i|
  (0..m).each do |j|
    cnt = i * m + j * n - i * j * 2
    black << cnt
  end
end
if black.include?(k) then
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 11516
#!/usr/bin/env python3
#
# Author: Tetsuya Ishikawa <tiskw111@gmail.com>
# Date  : June 30, 2020
##################################################### SOURCE START #####################################################

def manhattan(p, q):
    return abs(p[0] - q[0]) + abs(p[1] - q[1])

N = int(input().strip())
ts = [None for _ in range(N+1)]
ps = [None for _ in range(N+1)]

ts[0] = 0
ps[0] = (0, 0)

for n in range(1, N+1):
    t, p, q = tuple(map(int, input().strip().split()))
    ts[n] = t
    ps[n] = (p, q)

for n in range(N):
    dt = ts[n+1] - ts[n]
    dist = manhattan(ps[n+1], ps[n])
    if (dist > dt) or (dt % 2) != (dist % 2):
        print("No")
        exit()

print("Yes")

##################################################### SOURCE FINISH ####################################################
# vim: expandtab tabstop=4 shiftwidth=4 fdm=marker


Measured memory_bytes: 23176
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) throws Exception {
		
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        
        String boxx[] = line.split(" ");
        
        
        int n = Integer.parseInt(boxx[0]);   //n
        int k = Integer.parseInt(boxx[1]); 
		
        
        
        if(n+k==15){
        	System.out.println("+");
        }else if(n*k ==15){
        	System.out.println("*");
        }else{
        	System.out.println("x");
        }
        
	}

}


Measured memory_bytes: 22612
n = int(input())
a = list(map(int, input().split()))

x = max(a)
m = x/2
a.remove(x)
a.sort()
ans = x

for i in a:
    y = abs(i - m)
    if ans >= y:
        ans = y
    else:
        break    
    z = i
      
print(x, z)

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

int main() {
    vector<int> abc(3);
    cin >> abc[0] >> abc[1] >> abc[2];
    int k;
    cin >> k;
    sort(abc.begin(), abc.end());
    for (int i=0; i<k; i++) {
        abc[2] *= 2;
    }
    cout << abc[0] + abc[1] + abc[2] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <climits>
#include <cassert>
using namespace std;

int top, S[1000];
void push(int x) {
	//??????????????????????????????????????????
	S[++top] = x;
}

int pop() {
	top--;
	return S[top + 1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];
	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if(s[0]=='-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a*b);
		}
		else {
			push(atoi(s));
		}
	}
	printf("%d\n", pop());

	return 0;
} 

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

int main() {
  int N;
  cin >> N;
  if(N<1200) cout<<"ABC"<<endl;
  else cout<<"ARC"<<endl;
}


Measured memory_bytes: 3544
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		int len;
		String str = new String();
		Scanner scan = new Scanner(System.in);
		int min = 0;
		int temp;

		len = scan.nextInt();
		str = "E" + scan.next() + "W";

		for(int i = 1;i < len + 1;i++) {
			if(str.charAt(i) == 'E') {
				min++;
			}
		}

		temp = min;

		for(int i = 1;i < len + 1;i++) {
			if(str.charAt(i-1) == 'W') temp++;
			if(str.charAt(i) == 'E') temp--;

			if(temp < min) min = temp;
		}

		System.out.println(min);

		scan.close();

	}
}

Measured memory_bytes: 31028
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
	ll N;
	cin >> N;
	double ans = 0;
	for (int i = 0; i < N; ++i) {
		string x, u;
		cin >> x >> u;
		if (u == "JPY") {
			ans += std::stoi(x);
		}
		else {
			ans += std::stod(x) * 380000.0;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n,i;
  
  while(scanf("%d",&n)!=EOF){
      if(n>39)n=n%39;
      if(n==0){
	  printf("3C39\n");
	}
      for(i=1;i<40;i++){
	  if(i==n){
	      if(i>9)printf("3C%d\n",i);
	      else printf("3C0%d\n",i);
	      break;
	    }
	}
    }
  return 0;
}

Measured memory_bytes: 0