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

int main(){
  int n;
  cin >> n;
  bool found = false;
  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      if(i * j == n)
        found = true;
    }
  }
  if(found) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(a - x) < abs(b - x)) {
		cout << "A" << endl;
	}
	else {
		cout << "B" << endl;
	}
	return 0;
}



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

def main():
    na = list(map(int, input().split()))
    N, M, Q = na[0], na[1], na[2]
    tc = [0] * (N * N)
    ttc = [0] * (N * N)
    for i in range(M):
        na = list(map(int, input().split()))
        tc[N * (na[1] - 1) + na[0] - 1] += 1
    p_list = []
    q_list = []
    for i in range(Q):
        na = list(map(int, input().split()))
        p_list.append(na[0])
        q_list.append(na[1])


    for r in range(N):
        t = 0
        nr = N * r
        for l in range(r, -1, -1):
            t += tc[nr + l]
            ttc[nr + l] = t

    for l in range(N):
        t = 0
        for r in range(l, N):
            nr = N * r
            t += ttc[nr + l]
            ttc[nr + l] = t


    for i in range(Q):
        print(ttc[N * (q_list[i] - 1) + p_list[i] - 1])

if __name__ == '__main__':
    main()



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

int main(){
  int N,min_cost=1000000000;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  for(int i=-100;i<101;i++){
    int cost=0;
    for(int j=0;j<N;j++){
      cost+=(i-A.at(j))*(i-A.at(j));
    }
    min_cost=min(min_cost,cost);
  }
  cout << min_cost << endl;
} 

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main()
{
	int n,h;
	cin >> n;
	int a[105][105] = {0};
	for (int i = 1; i <= n; i++) {
		cin >> h;
		for (int j = 0; j <= h; j++) {
			a[i][j] = 1;//a[何個目の花][高さjはある]
		}
	}
	int k=0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= 105; j++) {
			if (a[i-1][j] == 0 && a[i][j] == 1)k++;
		}
	}
	
	cout <<k<<endl; 
}

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

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> in(H);
    vector<bool> h(H, false);
    vector<bool> w(W, false);
    for(size_t i = 0; i < H; i++)
    {
        cin >> in[i];
    }
    for(size_t i = 0; i < H; i++)
    {
        for(size_t j = 0; j < W; j++)
        {
            if(in[i][j] == '#')
                h[i] = true;
        }
    }
    for(size_t i = 0; i < W; i++)
    {
        for(size_t j = 0; j < H; j++)
        {
            if(in[j][i] == '#')
                w[i] = true;
        }
    }
    vector<string> ret;
    for(size_t i = 0; i < H; i++)
    {
        if(!h[i])
            continue;
        ret.push_back("");
        for(size_t j = 0; j < W; j++)
        {
            if(w[j])
                ret.back() += in[i].substr(j,1);
        }
        
    }
    for(auto str : ret)
        cout << str << endl;
    return 0;
}

Measured memory_bytes: 256
#import<cstdio>
#define k 1024
#define r(a) for(int i=0;i<a;i++)
#define s(a) scanf("%d",a);
#define m(a,b) a<b?a:b
int w,n,m,c[k],d[k],p[k];main(){s(&n)s(&m)r(n)s(d+i)r(m)s(c+i)r(n)p[i+1]=1e9;r(m*n)w=n-i%n,p[w]=m(p[w],p[w-1]+c[i/n]*d[w-1]);printf("%d\n",p[n]);}

Measured memory_bytes: 1036
#include <iostream>

int main(int argc, char const *argv[]) {
  int N, K;
  std::cin >> N >> K;

  int A[N];
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }

  for (int i = K; i < N; ++i) {
    if (A[i] > A[i - K]) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 4416
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};

int main(){
    ll h,w,n; cin >> h >> w >> n;
    vvl obs(w);
    rep(i,n){
        ll x,y; cin >> x >> y;
        x--; y--;
        obs[y].push_back(x);
    }
    rep(i,w) sort(all(obs[i]));
    ll ans = h;
    ll cnt = 0;
    rep(i,h){
        if(i>=w) break;
        while(binary_search(all(obs[i]),i+cnt)) cnt++;
        auto itr = upper_bound(all(obs[i]),i+cnt);
        if(itr != obs[i].end()) ans = min(ans, *itr);
    }
    cout << ans << endl;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    double t[n], v[n + 2];
    rep(i, n) cin >> t[i];
    repl(i, 1, n + 1) cin >> v[i];
    v[0] = v[n + 1] = 0;
    repr(i, n + 1, 1) minch(v[i], v[i + 1] + t[i - 1]);
    repl(i, 1, n + 1) minch(v[i], v[i - 1] + t[i - 1]);
    double len = 0, vv = 0, tt;
    repl(i, 1, n + 1) {
        if (v[i] <= v[i + 1]) {
            if (v[i] - vv < t[i - 1]) {
                tt = v[i] - vv;
                len += ((vv * tt + 0.5 * tt * tt) + v[i] * (t[i - 1] - tt));
                vv = v[i];
            } else {
                tt = t[i - 1];
                len += (vv * tt + 0.5 * tt * tt);
                vv += tt;
            }
        } else {
            if ((v[i] - vv) + (v[i] - v[i + 1]) > t[i - 1]) {
                tt = (v[i + 1] - vv + t[i - 1]) / 2.0;
                double vvv = vv + tt, ttt = t[i - 1] - tt;
                len += ((vv * tt + 0.5 * tt * tt) + (vvv * ttt - 0.5 * ttt * ttt));
            } else {
                tt = v[i] - vv;
                double vvv = v[i], ttt = v[i] - v[i + 1];
                len += ((vv * tt + 0.5 * tt * tt) + (vvv * ttt - 0.5 * ttt * ttt) + v[i] * (t[i - 1] - tt - ttt));
            }
            vv = v[i + 1];
        }
    }
    printf("%.8f\n", len);
    return 0;
}

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

#define ll long long

#define DEBUG (0)

int main()
{
  int n = 0;

  cin >> n;

  vector<string> str(n,"");
 
  for(int i = 0; i < n; i++){
    cin >> str[i];
  }

  /* 出現回数カウンタ */
  vector<int> count(n,0);

  /* 辞書順にソート */
  sort(str.begin(),str.end());    /* 時間オーダー：O(NlogN) なのでOK? */

#if 0
  for(int i = 0; i < n - 1; i++){   /* 時間オーダー：O(N^2)なのでNG? */
    for(int j = i + 1; j < n; j++){
      if(str[i] == str[j]){
        count[i]++;
      }
    }
  }
#endif

  int tmpCount, countMax = 0;
  string strtmp = "";
  for(int i = 0; i < n; i++){   /* 時間オーダー：O(N)*/
    if(strtmp == str[i]){
      /* 既出 */
      tmpCount++;
    }else{
      /* 初出 */
      strtmp = str[i];
      tmpCount = 1;
    }
    /* str[i]の出現回数をcount[i]へ代入 */
    count[i] = tmpCount;

    /* 最も多い出現回数 */
    countMax = max(tmpCount, countMax);
  }

  for(int i = 0; i < n; i++){
    if(count[i] == countMax){
      cout << str[i] << "\n";
    }
  }

#if 0
  /* 出現回数のMAX */
  int countMax = *max_element(count.begin(), count.end());

  /* countMaxと合致するcountの要素数i の文字列str[i]を表示 */
  for(int i = 0; i < n; i++){
    if(count[i] == countMax){
      cout << str[i] << "\n";
    }
  }
#endif



#if DEBUG
  for(int i = 0; i < n; i++){
    cout << "str[" << i << "]:" << str[i] << ", count[" << i << "]:" << count[i] << "\n";
  }
  cout << "countMax:" << countMax << "\n";
#endif
}


Measured memory_bytes: 15104
#include<iostream>
#include<cmath>
using namespace std;
int n; double x[2000][2], p;
int main() {
	x[0][0] = 0.0; x[0][1] = 0.0;
	x[1][0] = 1.0; x[1][1] = 0.0;
	for (int i = 2; i < 1500; i++) {
		p = asin(x[i - 1][1] / sqrt(x[i - 1][0] * x[i - 1][0] + x[i - 1][1] * x[i - 1][1]))*(180 / 3.141592653589793238);
		x[i][0] = x[i - 1][0] + sin((p + 180)*0.01745329251994);
		p = asin(x[i - 1][0] / sqrt(x[i - 1][0] * x[i - 1][0] + x[i - 1][1] * x[i - 1][1]))*(180 / 3.141592653589793238);
		x[i][1] = x[i - 1][1] + sin((p)*0.01745329251994);
	}
	while (true) {
		cin >> n;
		if (n == -1) { break; }
		cout << x[n][0] << endl << x[n][1] << endl;
	}
}

Measured memory_bytes: 1344
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  ll n, a, b;
  cin >> n >> a >> b;
  vl x(n);
  rep(i,n) cin >> x[i];
  
  ll ans = 0;
  rep(i,n-1) {
    ans += min(a*(x[i+1]-x[i]),b);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using pi = pair <int, int>;
using ll = long long;
const ll mod = 1e9 + 7;
const int N = 2e5 + 10;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int c = 1;
    for (int i = 0; i < n; ++i)
	{
		int x;
		cin >> x;
		if (x == c)
			++c;
	}
	cout << (c == 1 ? -1 : n - c + 1);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int k = Convert.ToInt32(str[0]);
            int x = Convert.ToInt32(str[1]);

            int minX = -1000000;
            int maxX = 1000000;

            int rangeMin;
            int rangeMax;
            if ((x - k + 1) < minX)
            {
                rangeMin = minX;
            } else
            {
                rangeMin = x - k + 1;
            }

            if ((x + k - 1) > maxX)
            {
                rangeMax = maxX;
            } else
            {
                rangeMax = x + k - 1;
            }

            List<string> ret = new List<string>();
            for (int i = rangeMin; i <= rangeMax; i++)
            {
                ret.Add(i.ToString());
            }
            string res = String.Join(" ", ret.ToArray());

            System.Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 13140
<?php

$numbers = preg_split("/[\s,]+/", rtrim(fgets(STDIN)));
$d = intval($numbers[0]);
$e = intval($numbers[1]);

while($d != 0){
    $min = 9999;
    for ($x = 0; $x < $d; $x++){
        // | √(x2 + y2) - E | 
        //最短距離の判定
        // $d = $x + $y;
        $y = $d - $x;
        $s = abs(sqrt($x**2 + $y**2) - $e);
        if($min > $s){
            $min = $s;
        }
    }
    
    print $min;
    print "\n";
    $numbers = preg_split("/[\s,]+/", rtrim(fgets(STDIN)));
    $d = intval($numbers[0]);
    $e = intval($numbers[1]);
}



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

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

	bool can = true;

	for (int i = 0; i < n; i++) {
		int  tmp; cin >> tmp;
		if (tmp % 2 == 0) {
			if (!(tmp % 3 == 0 || tmp % 5 == 0)) {
				can = false;
			}
		}
	}
	
	if (can) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;

    return 0;
}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

const int mod = 1e9+7;
const ll maxn = 2e5+10;

ll fat[maxn],inv[maxn];

ll modpow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1){
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}

void precalc(){
	fat[0] = 1;
	for(int i=1;i<maxn;++i){
		fat[i] = (i*fat[i-1])%mod;
	}
	inv[0] = 1;
	for(int i=1;i<maxn;++i){
		inv[i] = modpow(fat[i],mod-2)%mod;
	}
}

ll C(ll n,ll k){
	ll res=1;
	for(ll i=n;i>=n-k+1;--i){
		res = (res*i)%mod;
		if(res<0)
			res+=mod;
	}
	res = (res*inv[k])%mod;
	if(res<0)
		res+=mod;
	return res;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	precalc();
	int n,a,b;
	cin>>n>>a>>b;
	ll tot = (modpow(2,n)-1)%mod;
	ll xa=C(n,a),xb=C(n,b);
	tot=(tot-xa-xb)%mod;
	if(tot<0)
		tot+=mod;
	cout<<tot<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  int nw;
  int mx = 0;
  int mxp = 0;
  for(int i = 0; n > i; i++){
    int t;cin>>t;
    if(!i){
      nw = t;
    }else{
      if(nw > t){
        nw = t;
      }else{
        if(mx < t-nw){
          mx = t-nw;
          mxp = 1;
        }else if(mx == t-nw){
          mxp++;
        }
      }
    }
  }
  cout << mxp << endl;
}
        

Measured memory_bytes: 256
import java.util.Scanner;

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 ans = 0;
        if (a + b >= c) { // 全解毒
            ans = b + c;
        } else {
            int sa = c - (a + b);
            ans = c + b - sa + 1;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22100
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    string s;
    cin >> s;
    for (auto &e : s)
    {
        if (e == '1')
        {
            e = '9';
        }
        else
        {
            e = '1';
        }
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void yes(bool c) { if (c)print("Yes"); else print("No"); };
void YES(bool c) { if (c)print("YES"); else print("NO"); };

void solve() {
    const double PI = acos(-1);
    // DEBUG(PI);
    ll A,B,H,M; cin >> A >> B >> H >> M;
    double deg = (60*H+M)*PI*(11.0/360);
    // DEBUG(deg);
    double ans = sqrt(A*A + B*B - 2*A*B*cos(deg));
    print(ans);
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 4120
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Two Anagrams
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int sn = s.size(), tn = t.size(), n = min(sn, tn);
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());

  for (int i = 0; i < n; i++)
    if (s[i] != t[tn - 1 - i]) {
      if (s[i] < t[tn - 1 - i]) puts("Yes");
      else puts("No");
      return 0;
    }

  if (sn < tn) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
# import bisect
# from collections import Counter, defaultdict, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    r = int(input())

    if r < 1200:
        print("ABC")
    elif r < 2800:
        print("ARC")
    else:
        print("AGC")

if __name__ == '__main__':
    main()

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



int main(){
    int n,m;
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import permutations

N = int(input())

P = tuple(int(y) for y in input().split())
Q = tuple(int(y) for y in input().split())

N_list = [x for x in range(1,N+1)]

numbers = list(permutations(N_list,N))
sor_numbers = sorted(numbers)

P_answer = sor_numbers.index(P)
Q_answer = sor_numbers.index(Q)


print(abs(P_answer - Q_answer ))

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

int main() {
	int a,b;
	char c;
	cin>>a>>c>>b;
	if(c=='+')cout<<a+b<<endl;
	else cout<<a-b<<endl;
	return 0;
}

Measured memory_bytes: 764
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-(n ** 0.5) // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def main():
    N = int(input())
    if N == 1:
        print(0)
        return
    fact = factorization(N)
    counter = []
    cnt = 0
    for i in range(1, 41):
        cnt += i
        counter.append(cnt)
    answer = 0
    for f in fact:
        for j in range(40):
            c = counter[j]
            if c > f[1]:
                answer += j
                break
            else:
                continue
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9508
#include<bits/stdc++.h>
#include <atcoder/all>
#define ll long long int
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
using namespace atcoder;

const ll mod=1000000007;
const ll inf=1000000000;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n,k;
  cin >> n >> k;
  mcf_graph<ll,ll> g(2*n+2);
  ll s=2*n,t=2*n+1;

  for(ll i=0;i<n;i++){
    g.add_edge(s,i,k,0);
    g.add_edge(n+i,t,k,0);
  }

  for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < n; j++) {
            ll a;
            cin >> a;
            g.add_edge(i, n + j, 1, inf - a);
        }
    }
    g.add_edge(s, t, n * k, inf);    

    auto result = g.flow(s, t, n * k);
    cout << 1LL * n * k * inf - result.second << endl;

    vector<string> grid(n, string(n, '.'));
    auto edges = g.edges();
    for (auto e : edges) {
        if (e.from == s || e.to == t || e.flow == 0) continue;

        grid[e.from][e.to - n] = 'X';
    }

    for (int i = 0; i < n; i++) {
        cout << grid[i] << endl;
    }

  return 0;
}

Measured memory_bytes: 3964
#include <stdio.h>

int main(void) {
	int a,b,c,d,e;
	scanf("%d",&a);
	b=a/3600;
	c=a%3600;
	d=c/60;
	e=c%60;
	printf("%d:%d:%d\n",b,d,e);
	return 0;
}

Measured memory_bytes: 592
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	int n=Integer.parseInt(input.readLine());
	String str=input.readLine();
	String str_ary[]=str.split(" ");
	int a[]=new int[n];
	int x=0;
	for(int i=0;i<n;i++)
	    {
		a[i]=Integer.parseInt(str_ary[i]);
	    }
	for(int i=0;i<n;i++)
	    {
		int mini=i;
		int lowkey=a[i];
		for(int j=i;j<n;j++)
		    {
			if(a[j]<lowkey)
			    {
				mini=j;
				lowkey=a[j];
				
			    }
			
		    }
		if(a[i]>lowkey)
		    {
		int temp=a[i];
		a[i]=a[mini];
		a[mini]=temp;
		    }
		else x++;
	    }	
	for(int i=0;i<n;i++)
	    {
		System.out.print(a[i]+((i!=n-1)?" ":"\n"));
	    }
	System.out.println(n-x);
    }
}

Measured memory_bytes: 17064
n=int(input())
A=[int(i) for i in input().split()]
for i in range(n):
    A[i]-=i+1
A.sort()
if n%2==0:
    B=A.copy()
    C=A.copy()
    for i in range(n):
        s=A[n//2]
        B[i]=abs(B[i]-s)
    a=sum(B)
    for i in range(n):
        t=A[n//2-1]
        C[i]=abs(C[i]-t)
    b=sum(C)

    print(min(a,b))
else:
    B=A.copy()
    for i in range(n):
        B[i]=abs(B[i]-A[n//2])
    print(sum(B))

Measured memory_bytes: 27584
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

S = s()

a = S.find('C')
b = S.find('F', a)

if a == -1 or b == -1:
    print 'No'
else:
    print 'Yes'


Measured memory_bytes: 4644
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007

vi c;
int s,n;
int sum=0;


int main(){
	vi p(8);
	while(1){
		rep(i,8)cin>>p[i];
		if(cin.eof())break;
		// rep(i,8){
		// 	if(i!=0)cout<<" ";
		// 	cout<<p[i];
		// }
		vi v(8,1);
		v[1]=v[3]=2;
		v[5]=v[7]=4;
		s=n=IMAX;
		rep(i,8){
			sum=0;
			vi u;
			rep(j,8){
				sum+=max(p[j]-v[j],0);
				u.pb(v[(j+1)%8]);
			}
			//cout<<sum<<endl;
			if(sum<s){
				s=sum;
				c=v;
			}
			if(sum==s&&v<c){
				c=v;
			}
			v=u;
			// rep(i,8){
			// 	if(i!=0)cout<<" ";
			// 	cout<<v[i];
			// }
			// cout<<endl;
		}
		rep(i,8){
			if(i!=0)cout<<" ";
			cout<<c[i];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1216
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<math.h>
#include<list>
#include<complex>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


ll const MOD = 1e9 + 7;
ll mod_p(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return (x + y + MOD) % MOD;
}

ll mod_m(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return x * y%MOD;
}

ll mod_pow(ll x, ll t) {
	x %= MOD;
	if (t == 0) {
		return 1;
	}
	else {
		ll v = mod_pow(x, t / 2);
		if (t % 2 == 0) {
			return v * v % MOD;
		}
		else {
			return v * v%MOD * x %MOD;
		}
	}
}

ll mod_inv(ll x) {
	return mod_pow(x, MOD - 2);
}

struct edge
{
	long long to; long long len;
	bool operator<(const edge& rhs) const {
		return len > rhs.len;
	}
};
ll const MAX = 1e3 + 5;

vector<vector<char>> ans(MAX, vector<char>(MAX, '.'));
//char ans[MAX][MAX];
void fillin(ll i, ll j, ll d) {
	if (d == 0) {
		ans[i][j] = '^';
		ans[i + 1][j] = 'v';
	}
	else {
		ans[i][j] = '<';
		ans[i][j + 1] = '>';
	}
}
ll hh, ww;
ll h, w, a, b;
void oput() {
	cout << "YES" << endl;
	REP(i, 1, hh) {
		REP(j, 1, ww) {
			cout << ans[i][j];
		}
		cout << endl;
	}
}
int main() {
	cin >> h >> w >> a >> b;
	hh = h; ww = w;
	//cout << h * w << " " << (a + b) * 2 << endl;
	if (h % 2 > 0) {
		ll i = h;
		ll j = 1;
		
		while (j + 1 <= w && a > 0) {
			fillin(i, j, 1);
			a--;
			j = j + 2;
		}
		h--;
		
	}
	
	if (w % 2 > 0) {
		ll i = 1;
		ll j = w;
		while (i + 1 <= h && b > 0) {
			fillin(i, j, 0);
			b--;
			i = i + 2;
		}
		w--;
	}
	//cout << h << " " << w << " " << h * w << endl;
	//cout << a << " " << b << " " << (a + b) * 2 << endl;
	if (h*w < (a + b) * 2) {
		cout << "NO" << endl;
		return 0;
	}

	if (a == 0 && b == 0) {
		oput();
		return 0;
	}
	
	ll yb = a / 2 + a % 2;
	ll tb = b / 2 + b % 2;
	bool flag = 0;
	for (ll i = 1; i <= h; i = i + 2) {
		if (flag) {
			break;
		}
		for (ll j = 1; j <= w; j = j + 2) {
			if (a > 1) {
				fillin(i, j, 1);
				fillin(i + 1, j, 1);
				a -= 2;
			}
			else if (b > 1) {
				fillin(i, j, 0);
				fillin(i, j + 1, 0);
				b -= 2;
			}
			else if (b == 1) {
				fillin(i, j, 0);
				b--;
			}
			else if (a == 1) {
				fillin(i, j, 1);
				a--;
			}
			else {
				flag = 1;
				break;
			}
		}
	}
	if (a == 0 && b == 0) {
		oput();
	}
	else if (a == 1 && b == 0 && hh % 2 == 1 && ww % 2 == 1) {
		fillin(hh - 1, ww, 0);
		fillin(hh - 2, ww - 1, 1);
		oput();
	}
	else {
		cout << "NO" << endl;
	}
	
}

Measured memory_bytes: 2304
#include <iostream>

using namespace std;

int main()
{
    int x,a;
    cin>> x >> a;
    if(x<a){
        cout<< "0" <<endl;
       // cout<< x <<" is less then " << a <<" ,so we should print 0." ;
        
    }
    else
        cout<< "10" <<endl;
       // cout<< x <<" is not less then " << a <<" ,so we should print 10." ;
    
    return 0;
}

Measured memory_bytes: 256
/*
TEMPLATE
by.YXH_XianYu
   2018.6.20
 */
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define rep(i,j,k) for(int i=j,lim=k;i<=lim;i++)
#define MXN 100005

int n,k,min=1000000000,
	a[MXN],
	ans;

int main(){
	//freopen("TEMPLATE.in","r",stdin);
	//freopen("TEMPLATE.out","w",stdout);

	scanf("%d%d",&n,&k);
	rep(i,1,n)
		scanf("%d",&a[i]),
		min=std::min(min,a[i]);
	int cnt=0;
	k--;
	for(int i=1;i<=n;i++){
		if(a[i]!=min)
			cnt++;
		if(cnt==k)
			ans++,cnt=0;
	}
	if(cnt!=0)ans++;
	printf("%d\n",ans);

	return 0;
}


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

#define modulo 1000000007
#define mod(x) (((long long)x)%modulo)


struct combi{
	deque<int> kaijou;
	deque<int> kaijou_;
	
	int kaijou_set(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(mod(kaijou[i-1]*i));
		}
		int a = kaijou[n];int b = 1;int m = modulo-2;
		while(m!=0){
			if(m%2){
				b=mod(b*a);
			}
			a=mod(a*a);
			m/=2;
		}
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(mod(kaijou_[0]*k));
		}
	}
	
	int combination(int n,int r){
		if(r>n)return 0;
		int a = mod(kaijou[n]*kaijou_[r]);
		a=mod(a*kaijou_[n-r]);
		return a;
	}
	
	int junretsu(int a,int b){
		int x = mod(kaijou_[a]*kaijou_[b]);
		x=mod(x*kaijou[a+b]);
		return x;
	}
	
};

int main(){
	int N,M;
	cin>>N>>M;
	combi c;
	c.kaijou_set(100100);
	int cnt[100000]={};
	
	for(long long i=2;i*i<=M;i++){
		if(M%i==0){
			cnt[i]++;
			M/=i;
			i--;
			continue;
		}
	}
	int ans = 1;
	if(M!=1){
		if(M<=100000)cnt[M]++;
		else ans = N;
	}
	for(int i=0;i<100000;i++){
		if(cnt[i]!=0){
			ans = mod(ans*c.combination(N+cnt[i]-1,cnt[i]));
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

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

int main()
{
	ll n, res = 100000;
	cin >> n;
	while (n--) {
		res = (res + res / 20 + 999) / 1000 * 1000;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2996
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		for(;;){
			int H = sc.nextInt();
			int W = sc.nextInt();
			
			if(H == 0 && W == 0)
				break;
		
			for(int i = 0;i < H;i++){
				for(int j = 0;j < W;j++){
					System.out.print("#");
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
}

Measured memory_bytes: 30312
n = gets.to_i
a = gets.split.map(&:to_i)
flag = 1
sum = 0
while flag==1 do
	flag = 0
	(n-1).downto(1) do |j|
		if a[j]<a[j-1] then
			v = a[j]
			a[j] = a[j-1]
			a[j-1] = v
			sum += 1
			flag = 1
		end
	end
end

puts a.join(' ')
puts sum


Measured memory_bytes: 6860
import Control.Monad( replicateM)
main = do
    n_ <- readLn::IO Int
    let
	readPair = do
	    [a,b] <- return . map read . words =<< getLine
	    return (b,a)
    bas_ <- replicateM n_ readPair
    let
	proc::Integer->[(Integer,Integer)]->[Integer]
	proc _ [] = []
	proc add ((b,a):bas) = let d = diff b (a+add)
	    in
		d:(proc (d+add) bas)
	  where
	    diff b a = case a `mod` b of
			0   -> 0
			md  -> b-md
    print . sum . proc  0 $ reverse bas_

Measured memory_bytes: 77180
int main(void){
  int A,B,X;
  int rem;
  int ans;
  scanf("%d %d %d",&X,&A,&B);
  rem=X-A;
  for(int i=1;i<=10000;i++){
    if(rem<B*i){
      ans=rem-(B*(i-1));
      break;
    }
  }
  printf("%d",ans);
  return 0;
}

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

using namespace std;

int main(){
  int n; cin >> n;
  vector<int> fib;
  fib.push_back(0); fib.push_back(1);

  for(int i=0; i<n; i++)
    fib.push_back(fib[i]+fib[i+1]);

  cout << fib.back() << endl;

  return 0;
}


Measured memory_bytes: 3152
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++)
		{
			if(n==i*j)
			{
				cout<<"Yes";
				return 0;
			}
		}
	cout<<"No";
}

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

int main(){
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    if ((i+1) % 3 == 0 || (i+1) % 10 == 3 ||
        (i+1)%100/10 == 3 || (i+1)%1000/100 ==3 || (i+1)/1000 == 3) {
      cout << " " << i+1;
    }
  }
  cout << endl;
}


Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<queue>
#define N (998244353)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> Q;

int p[200010];



int main(void){
    ll k;
    string s;
    cin>>s>>k;
    vector<P>pi;
    for(int i=0;i<s.length();){
        int j=i;
        while(true){
            if(i==s.length())break;
            if(s[i]==s[j])i++;
            else{
                break;
            }
        }
        pi.push_back(P(s[j]-'a',i-j));
    }
    if(pi.size()==1){
        ll se = pi[0].second;
        if(pi[0].second%2==0){
            cout<<(pi[0].second/2)*k<<endl;
        }
        else{
            ll e = (se-1)/2;
            ll o = e+1;
            if(k%2==0)cout<<e*(k/2)+o*(k/2)<<endl;
            else cout<<((k-1)/2)*o+((k-1)/2+1)*e<<endl;
        }
    }
    else{
        if(pi[0].first!=pi[pi.size()-1].first){
            ll seq=0;
            for(int i=0;i<pi.size();i++){
                if(pi[i].second==1)continue;
                else seq+=(pi[i].second/2);
            }
            cout<<seq*k<<endl;
        }
        else{
            ll seq = 0;
            for(int i=1;i<pi.size()-1;i++){
                if(pi[i].second==1)continue;
                else seq+=(pi[i].second/2);
            }
            ll seq1=0;
            ll num1 = pi[0].second;
            ll num2 = pi[pi.size()-1].second;
            if((num1%2==1)&&(num2%2==1)){
                ll t = num1/2+num2/2+1;
                cout<<seq*k+t*(k-1)+num1/2+num2/2<<endl;
            }
            else{
                cout<<((num1+num2)/2)*k+seq*k<<endl;
            }
        }
    }
    return 0;
}

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

int i, j, n, r, p, c, ans;

int main (){

        while (cin >> n >> r && n != 0 && r != 0){
                vector<int> A(n);
                //auto Xe = A.begin();
                for (i = 0; i < n; i++){
                        A[i] = n - i;
                }
                for (i = 0; i < r; i++){
                        cin >> p >> c;
                        rotate (A.begin(), A.begin() + p - 1, A.begin() + p + c - 1);
                }
                cout << A[0] << endl;
        }

        return 0;
}



Measured memory_bytes: 3148
#include <algorithm> // min
#include <cmath> // abs
#include <iostream>
using namespace std;
int main(){
 string S;
 cin >> S;
 int N = S.size();
 int ans = 999;
   for(int i = 0; i <= N - 3; ++i){
     int num = (S[i] - '0') * 100 + (S[i+1] - '0') * 10 + S[i+2] - '0';
     ans = min(ans, abs(num - 753));
   }
   cout << ans << endl; 
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100

int main(){
  int n,a[MAX],ans = 0,i,j,tmp;

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

  for(i = 0 ; i < n ; i++){
    for(j = n-1 ; j > i ; j--){
      if(a[j] < a[j-1]){
	tmp = a[j];
	a[j] = a[j-1];
	a[j-1] = tmp;
	ans++;
      }
    }
  }

  for(i = 0 ; i < n ; i++){
    if(i != n-1){
      printf("%d " ,a[i]);
    }else{
      printf("%d\n%d\n" ,a[i],ans);
    }
  }

  return 0;
}



Measured memory_bytes: 2104
n, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
t = gets.chomp.split("")

a = t.map.with_index.group_by {|v, i| i % k}

score = {"r" => p, "s" => r, "p" => s}

ans = 0
prev = ""
a.each do |k, aa|
  aa.each do |aaa|
    if prev != aaa[0]
      ans += score[aaa[0]]
      prev = aaa[0]
    else
      prev = ""
    end
  end
  prev = ""
end
p ans

Measured memory_bytes: 34580
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int x; cin >> x;
    x -= 400;
    int d = x / 200;
    cout << 8-d << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

enum command { ADD = 0, GETSUM = 1 };



void update(vector<int> &st, int i, int a) {
  const int n = st.size() - 1;
  for (; i <= n; i += (i & -i))
    st[i] += a;
}

// get sum of [l,r);
ll getSum(vector<int> &st, int l, int r) {
  r--;
  l--;
  ll sum = 0;
  for (; r > 0; r -= (r & -r))
    sum += st[r];
  for (; l > 0; l -= (l & -l))
    sum -= st[l];
  return sum;
}

int main(int argc, char const *argv[]) {
  int n, q, comm, x, y;
  cin >> n >> q;

  vector<int> st(n + 1, 0);

  for (int i = 0; i < q; i++) {
    cin >> comm;
    cin >> x >> y;
    switch (comm) {
    case ADD:
      update(st, x, y);
      break;
    case GETSUM:
      cout << getSum(st, x, y + 1) << endl;
      break;
    }
  }

  return 0;
}



Measured memory_bytes: 3096
/*

Author : @karngyan
Team : BlundersPride
Date : 09-03-2019
Time : 05:20:14

*/


#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
ll a[100][100];
ll b[100];
signed main()
{
	fast;
////////////////////////////////////////////////////////////////////////////////////////////
	
	ll n ,m , c;
	cin >> n >> m >> c;
	rep(i,0,m)
	{
		cin >> b[i];
	}

	rep(i,0,n)
	{
		rep(j,0,m)
		{
			cin >> a[i][j];
		}
	}

	ll ans = 0;

	rep(i,0,n)
	{
		ll res = c;
		rep(j,0,m)
		{
			res += a[i][j]*b[j];
		}
		if(res > 0)
			ans++;
	}

	cout<<ans<<endl;



////////////////////////////////////////////////////////////////////////////////////////////
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;
 
int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif
  int n, m, x;
  cin >> n >> m >> x;
  int mn = inf;
 
  vector <int> c(n);
  vector <vector <int> > a (n, vector <int> (m, 0));
 
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    for (int j = 0; j < m; j++) cin >> a[i][j];
  }
 
  for (int i = 1; i < (1 << n); i++) {
    int cost = 0;
    vector <int> temp(m, 0);
    for (int j = 0; j < n; j++) {
      if (i&(1 << j)) {
        cost += c[j];
        for (int k = 0; k < m; k++) temp[k] += a[j][k];
      }
    }
    bool ok = true;
    for (auto val: temp) ok &= (val >= x);
    if (ok) mn = min(mn, cost);
  }
 
  cout << (mn == inf ? -1 : mn) << endl;
  return 0;
}

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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}
int n, a[200020], ans;
bool v[1000020];
int main(){
    n = read();
    for (int i = 1; i <= n; i++){
        a[i] = read();
    }
    sort(a+1, a+n+1);
    memset(v, 1, sizeof(v));
    for (int i = 1; i <= n; i++){
        if(v[a[i]]){
            ans++;
            for (int j = a[i]; j <= a[n]; j+=a[i])
                v[j] = 0;
            if(a[i] == a[i+1]) ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
 
ll dfs(ll d, ll t,int first){
  if(t==0) return (d==0);
  ll res=0;
  int v=(d%10+10)%10;
  res+=(10-v-first)*dfs((d-t*v)/10,t/100,0);
  if(t) res+=(v-first)*dfs((d+(10-v)*t)/10,t/100,0);
  return res;
}
 
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
 
  ll D; cin>>D;
  if(D%9){
    cout<<0<<endl;
    return 0;
  }
  D/=9;
  int ans=0;
  ll p10=1;
  for(int i=1;i<=18;i++){
    p10*=10;
    ans+=(i%2?10:1)*dfs(D,p10/10/9,1);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

x = [int(input()) for _ in range(5)]
k = int(input())

if max(x) - min(x) <= k:
    print('Yay!')
else:
    print(':(')





Measured memory_bytes: 64620
#include<stdio.h>

int main(void)
{
   int a,b;
   char op;

   scanf("%d\n",&a);
   scanf("%c",&op);
   scanf("%d",&b);
   if(op=='+') printf("%d\n",a+b);
   else printf("%d\n",a-b);
   
   return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF 2e9
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

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

	queue<long long int>que;
	rep(i, 0, 9)que.push(i + 1);

	while (1)
	{
		long long int x = que.front();
		if (K == 1)
		{
			cout << x << endl;
			return 0;
		}
		for (int i = -1; i <= 1; i++)
		{
			int d = x % 10 + i;
			if (d < 0 || d > 9)continue;
			que.push(x * 10 + d);
		}

		que.pop();
		K--;
	}
	return 0;
}


Measured memory_bytes: 5140
#include<cstdio>
#include<cstring>
using namespace std;

char s[100001];

int main()
{
	scanf("%s",s);
	for(int i=0;i<strlen(s);i++)
		if(s[i]=='A'&&s[i+1]=='C')
		{
			printf("Yes");
			return 0;
		}
	printf("No");
}

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

#define ll long long
#define ld long double
#define pi 3.14159265359
int main(){
    string S; cin >> S;
    int N = S.size();
    vector<char> S1((N - 1) / 2), S2((N - 1) / 2), copyS1((N - 1) / 2), copyS2((N - 1) / 2);
    for (int i = 0; i < (N - 1) / 2; i++) {
        S1.at(i) = S.at(i);
        S2.at(i) = S.at(i + (N + 1) / 2);
        copyS1.at(i) = S.at(i);
        copyS2.at(i) = S.at(i + (N + 1) / 2);
    }
    string copyS = S;
    reverse(copyS.begin(), copyS.end());
    reverse(copyS1.begin(), copyS1.end());
    reverse(copyS2.begin(), copyS2.end());
    string ans = "Yes";
   if (S1 != copyS1 || S2 != copyS2 || S != copyS) {
       ans = "No";
   }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  
  cin >> A >> B >> C >> D;
  
  if ((A + B) > (C + D)) {
   cout << "Left" << endl;
  } else if ((A + B) == (C + D)) {
   cout << "Balanced" << endl;
  } else {
   cout << "Right" << endl;
  }
}

Measured memory_bytes: 3616