akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

enum POSITION{ONLINE_BACK = -2, CCW = -1, ON_SEGMENT = 0,
              CW = 1, ONLINE_FRONT = 2};

struct Point{
    long x;
    long y;
    Point(long x, long y) : x(x), y(y) {}
    Point(){}
    Point operator-(Point p){
        return Point(x - p.x, y - p.y);
    }
};
typedef Point Vector;
double cross(Vector v1, Vector v2){
    return v1.x * v2.y - v1.y * v2.x;
}
double dot(Vector v1, Vector v2){
    return v1.x * v2.x + v1.y * v2.y;
}

struct Segment{
    Point p1;
    Point p2;
    Segment(Point p1, Point p2) : p1(p1), p2(p2) {}
    Segment(){}
};
typedef vector<Point> Polygon;

POSITION get_position(Segment s, Point p){
    double c = cross(s.p2 - s.p1, p - s.p1);
    if (c > 0) return CCW;
    if (c < 0) return CW;
    double d = dot(s.p2 - s.p1, p - s.p1);
    if (d < 0) return ONLINE_BACK;
    if (d > dot(s.p2 - s.p1, s.p2 - s.p1)) return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool intersect(Segment s1, Segment s2){
    if (get_position(s1, s2.p1) * get_position(s1, s2.p2) != -1) {
        return false;
    }
    if (get_position(s2, s1.p1) * get_position(s2, s1.p2) != -1) {
        return false;
    }
    return true;
}

int determine_containment(Point p, Polygon poly){
    for (int i = 0, n = poly.size(); i < n; i++) {
        if (get_position(Segment(poly[i], poly[(i+1)%n]), p) == ON_SEGMENT) {
            return 1;
        }
    }
    Segment s_right(p, Point(p.x + 1e5, p.y));
    int count = 0;
    for (int i = 0, n = poly.size(); i < n; i++) {
        if (intersect(s_right, Segment(poly[i], poly[(i+1)%n]))) {
            count++;
        }
    }
    for (int i = 0, n = poly.size(); i < n; i++) {
        if (get_position(s_right, poly[i]) == ON_SEGMENT) {
            int i_pre = (i == 0 ? n - 1 : i - 1);
            while (get_position(s_right, poly[i_pre]) != CCW && get_position(s_right, poly[i_pre]) != CW) {
                i_pre = (i_pre == 0 ? n - 1 : i_pre - 1);
            }
            int i_aft = (i + 1) % n;
            while (get_position(s_right, poly[i_aft]) != CCW && get_position(s_right, poly[i_aft]) != CW) {
                i_aft = (i_aft + 1) % n;
            }
            if (get_position(s_right, poly[i_pre]) * get_position(s_right, poly[(i+1)%n]) == -1) {
                count++;
            }
        }
    }
    if (count % 2) return 2;
    return 0;
}
int main(){
    int q;
    cin >> q;
    Polygon poly(q);
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        poly[i].x = x;
        poly[i].y = y;
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        cout << determine_containment(Point(x, y), poly) << endl;
    }
    return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <set>
#include <map>

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

using namespace std;

int main()
{
	int n = 0, m = 0, a = 0;
	while (cin >> n >> m >> a && n != 0)
	{
		vector<vector<int>> dat(1010, vector<int>(10000, 0));
		int cri = 0;
		rep(i, m)
		{
			int tmp[3] = { 0 };
			cin >> tmp[0] >> tmp[1] >> tmp[2];
			dat[tmp[1]][tmp[0]] = tmp[2];
			dat[tmp[2]][tmp[0]] = tmp[1];
			cri = max(tmp[0], cri);
		}
		rep(i, cri)
		{

			if (dat[a][cri - i] == 0) { continue; }
			else if (dat[a][cri - i] > 0) { a = dat[a][cri - i]; }
		}
		printf("%d\n", a);
	}

	return 0;
}

Measured memory_bytes: 42500
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i+5000*j==y-1000*(n-i-j):
            print(i,j,n-i-j)
            exit()
else:
    print(-1,-1,-1)

Measured memory_bytes: 2940
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    map<LL, int> mp;
    rep(i, n) {
        int a; cin >> a;
        ++mp[a];
    }
    vector<pair<LL, int>> v;
    for (const auto &x: mp) {
        if (x.second >= 2) v.push_back(x);
    }
    sort(v.rbegin(), v.rend());

    LL pre = -1;
    for (const auto &x: v) {
        if (pre != -1) {
            cout << pre * x.first << endl;
            return 0;
        }
        else if (x.second >= 4) {
            cout << x.first * x.first << endl;
            return 0;
        }
        else {
            pre = x.first;
        }
    }

    cout << 0 << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long int ll;
#define MOD 1000000007
#define INF 1e18
#include <ctime>
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define rev(i, n, x) for (ll i = n; i > x; i--)
#define endl "\n"
#define all(c) (c).begin(), (c).end()
#define int long long int
#ifdef mishra
#define debug(x) cout << ">>" << #x << " is " << x << "<<" << endl;
#define print_time() cout << setprecision(6) << "time: " << (clock() - start) / (double)CLOCKS_PER_SEC << '\n';
#else
#define debug(x) ;
#define print_time() ;
#endif

clock_t start;
void FAST(ll argc)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    start = clock();
    if (argc == 2)
        freopen("std.in", "r", stdin);
}

/*vector<ll> v;
void seive()
{
    v.pb(2);
    for (int i = 3; i < 100000; i += 2)
    {
        for (int j = 0; j < v.size(); j++)
        {
            if (i % v[j] == 0)
                break;
            if (v[j] * v[j] > i)
            {
                v.pb(i);
                break;
            }
        }
    }
}
/*
void prime_factor(ll x, vector<ll> &r)
{
    ll sqrt_x = sqrt(x);

    for (ll i : v)
    {
        if (i > sqrt_x)
            break;

        if (x % i == 0)
            r.pb(i);

        while (x % i == 0)
        {
            x /= i;
        }
    }

    if (x >= 2)
        r.pb(x);
}
*/
/*
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % MOD;
        y = y >> 1;
        x = (x * x) % MOD;
    }
    return res;
}
*/
/*
inline void dfs(ll curr, ll prev)
{

    for (ll i : a[curr])
        if (i != prev)
            dfs(i, curr);
}
*/
/*
ll multi(ll a, ll b)
{
    return ((a * b) % MOD);
}
*/
//---------------------CODE STARTS HERE---------------------

signed main(char argc, char *argv[])
{
    FAST(argc);

    ll testcase = 1;
    //cin >> testcase;

    while (testcase--)
    {
        int n, w;
        cin >> n >> w;
        pair<int, int> a[n];
        rep(i, 0, n)
                cin >>
            a[i].first >> a[i].second;

        sort(a, a + n);
        // int z[w + 5] = {0};
        map<int, int> m;
        m[0] = 0;
        bool ck = 0;

        rep(i, 0, n)
        {
            int x = a[i].first;
            int y = a[i].second;
            // z[x] = max(z[x], y);
            stack<pair<int, int> > st;
            for (auto it : m)
            {
                if (it.first + x > w)
                    break;
                st.push(make_pair(it.first + x,max(it.second + y, m[it.first + x])));
            }
            while(st.empty()==0)
            {
                auto z= st.top();
                st.pop();
                m[z.first] = z.second;
            }
        }
        int ans = 0;
        for (auto it : m)
        {
            ans = max(ans,it.second);
            if (it.first > w)
                break;
        }
        cout << ans << endl;
        //--------??--------CLEAR VECTORS--------??--------
        m.clear();
    }

    //v.clear();
    print_time();
    return 0;
}

Measured memory_bytes: 8192
while True:
  item_num = int(input())
  if item_num == 0:
    break

  price_dict = {}
  for _ in range(item_num):
    item, price = input().split()
    price_dict[item] = int(price)

  recipe_num = int(input())
  recipe_dict = {}
  for _ in range(recipe_num):
    recipe = input().split()
    recipe_dict[recipe[0]] = recipe[2:]

  result_dict = {}

  def get_price(item):
    if item in result_dict:
      return result_dict[item]
    if item not in recipe_dict:
      result_dict[item] = price_dict[item]
      return price_dict[item]

    price = 0
    for recipe_item in recipe_dict[item]:
      price += get_price(recipe_item)
    result = min(price, price_dict[item])
    result_dict[item] = result
    return result

  item = input()
  print(get_price(item))



Measured memory_bytes: 5604
#include <stdio.h>

int main() {
    int n, a[100], i;
    scanf("%d", &n);
    for (i = n - 1; i >= 0; i--) {
        scanf("%d", &a[i]);
    }
    for (i = 0; i < n - 1; i++) {
        printf("%d ", a[i]);
    }
    printf("%d\n", a[i]);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define REP(i,a,b) for(int(i)=(a);(i)<(b);++(i))
#define RREP(i,a,b) for(int(i)=(a)-1;(i)>=(b);--(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;

int main()
{
  int X,A;
  cin >> X >> A;
  int ans = (X < A) ? 0 : 10;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    target = int(input())
    withdraw_counts = [0] * (target + 1)

    for i in range(target + 1):
        if i < 6:
            withdraw_counts[i] = i
        elif i < 9:
            withdraw_counts[i] = i - 5
        else:
            needed_withdraw_counts = [withdraw_counts[i-1]]
            exp_n = 1
            while 6 ** exp_n <= i:
                needed_withdraw_counts.append(withdraw_counts[i - 6 ** exp_n])
                exp_n += 1
            exp_n = 1
            while 9 ** exp_n <= i:
                needed_withdraw_counts.append(withdraw_counts[i - 9 ** exp_n])
                exp_n += 1
            withdraw_counts[i] = min(needed_withdraw_counts) + 1
    print(withdraw_counts[target])


Measured memory_bytes: 3828
#include <iostream>

using namespace std;

int n, m, k, mp[10][10], tot, ans;

int main() {
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            char c;
            cin >> c;
            if (c == '#') {
                mp[i][j] = 1;
                tot++;
            }
        }
    }
    for (int i = 0; i < (1 << n); i++) {
        for (int j = 0; j < (1 << m); j++) {
            int cnt = 0;
            for (int x = 1; x <= n; x++) {
                for (int y = 1; y <= m; y++) {
                    if (((1 << (x - 1)) & i) || ((1 << (y - 1)) & j)) {
                        cnt += mp[x][y];
                    }
                }
            }
            if (tot - cnt == k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
///

int main(){
    int n;
    I(n);
    int ar[n+2];
    int dp[21][2];
    int DP[21];
    SET(DP);
    SET(dp);
    for(int i= 1; i<=n;i++){
        I(ar[i]);
    }

    ll res =0;
    for(int i= 1; i<=n;i++){
        for(int j=0;j<20;j++){
            if( ( ar[i]&(1<<j))){
                DP[j]^=1;
                // cout<<j<<" lol"<<DP[j]<<endl;
                dp[j][DP[j]] = i;
            }
        }
        int k =0;
        for(int j=0;j<20;j++){
            k = max(k, dp[j][DP[j]^1]);
        }
        // cout<<k<<" "<<i<<endl;
        res += ( i-k);
    }
    PL(res);



    return 0;
}

Measured memory_bytes: 4596
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

/*Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}
*/
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    } 
    else {
      x = x->right;
    }
  }
  z->parent = y;
  
  if( y == NIL ){
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else {
    y->right = z;
  }
  

}

void inorder(Node u){
  
  // 左のノードがある場合左のノードへ
  if(u->left != NIL){ 
    inorder(u->left);
    
  }
  
  // 左のノードがない、もしくは左側を踏破したとき現在のノードのキーを表示
  printf(" %d",u->key);


  // 右のノードがある場合右のノードへ
  if(u->right != NIL){
    inorder(u->right);
    
  }


}
void preorder(Node u){
  
  
  // 現在のノードのキーを表示
  printf(" %d",u->key);
  
  // 左のノードがある場合左のノードへ
  if(u->left != NIL){ 
    preorder(u->left);
    
  }
  
  // 右のノードがある場合右のノードへ
  if(u->right != NIL){
    preorder(u->right);
    
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);

    /*if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else*/ if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } /*else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }*/
  }

  return 0;
}

Measured memory_bytes: 24040
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,k,i,dx,t,a,l;
  vector<bool> d(11,false);
  cin >> n >> k;
  for (i=0;i<k;i++){
    cin >> dx;
    d.at(dx)=true;
  }
  t=n;
  while (1){
    a=t;
    while (a){
      l=a%10;
      if (d.at(l)) break;
      a=(a-l)/10;
    }
    if (a==0) break;
    t++;
  }
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    int m_c(0), c_index(-1);
    cin >> S;
    if (S.at(0) == 'A')
    {
        for (int i = 2; i < S.size() - 1; ++i)
        {
            if (S[i] == 'C')
            {
                m_c++;
                c_index = i;
            }
        }
        if (m_c == 1)
        {
            bool ans(true);
            for (int i = 1; i < S.size(); ++i)
            {
                if (i == c_index)
                    continue;
                if (isupper(S[i]))
                    ans = false;
            }
            if (ans == true)
            {
                cout << "AC" << endl;
                return 0;
            }
        }
    }
    cout << "WA" << endl;
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0); 
  int n, m, d;
  cin >> n >> m;
  vector <pair<bool,int>> p(n);
  string s;
  int ca = 0, pen = 0;
  for (int i = 0; i < m; ++i){
	cin >> d >> s;
	--d;
	if (s == "WA" && p[d].first == false){
		++p[d].second;	
	}
	if (s == "AC" && p[d].first == false){
		p[d].first = true;
		pen += p[d].second;
		++ca;
	}	
  }
cout << ca << " " << pen << "\n"; 
return 0;
}


Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <stack>
using namespace std;

static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c){
    stack<int> S;
    S.push(r);
    color[r] = c;
    while(!S.empty()){
        int u = S.top(); S.pop();
        for(int j=0; j<G[u].size(); j++){
            int v = G[u][j];
            if(color[v]==NIL){
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor(){
    int id=1;
    
    for(int i=0; i<n; i++){
        color[i] = NIL;
    }
    for(int i=0; i<n; i++){
        if(color[i]==NIL)
            dfs(i, id++);
    }
}

int main(){
    int s,t,m,q;
    
    cin >> n >> m;
    for(int i=0; i<m; i++){
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    
    assignColor();
    
    cin >> q;
    for(int i=0; i<q; i++){
        cin >> s >> t;
        if(color[s]==color[t])
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 8952
#include <stdio.h>
typedef long long ll;
int main() {
	int n;
	ll ans = 1, a[100000];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		if (a[i] == 0) {
			printf("0\n");
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		if (a[i] <= 1000000000000000000 / ans) {
			ans *= a[i];
		} else {
			ans = -1;
			break;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2504
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define per(i,n) for ((i)=n;(i)>=(1);(i)--)
using namespace std;
int n,m;
int a,b;
int c[100005];
int i;
int main(){
	scanf("%d%d",&n,&m);
	rep(i,m){
		int a,b;
		scanf("%d%d",&a,&b);
		c[a]^=1;c[b]^=1;
	}
	rep(i,n) if(c[i]){
		puts("NO");
		return 0;
	}
	puts("YES");
	return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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 rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  int n;
  cin >> n;
  cout << 180 * (n - 2) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.io.IOException;

class Main 
{
	/* m ... 1000
	 * c ... 100
	 * x ... 10 
	 * i ... 1
	 * figure = m | c | x | i
	 * num = 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
	 */

	public static void main(String[] args) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		String s1, s2;
		int n = sc.nextInt();

		for(int i = 0; i < n; i++)
		{
			s1 = sc.next();
			s2 = sc.next();

			System.out.println(addMCXI(s1, s2));
		}
	}

	public static String addMCXI(String s1, String s2)
	{
		int num = mcxi2int(s1) + mcxi2int(s2);
		return int2mcxi(num);
	}

	private static int mcxi2int(String str)
	{
		int num = 0, tmp;
		int[] a = new int[4];
		int[] base = {1000, 100, 10, 1};
		int[] index = new int[4];
		char[] mcxi = {'m', 'c', 'x', 'i'};

		for(int i = 0; i < 4; i++)
		{
			index[i] = str.indexOf(mcxi[i]);
		}

		for(int i = 0; i < 4; i++)
		{
			if(index[i] == -1)
			{
				a[i] = 0;
			}
			else if(index[i] == 0) 
			{
				a[i] = 1;	
			}
			else
			{
				tmp = str.charAt(index[i] - 1) - '0';
				if(2 <= tmp && tmp <= 9)
				{
					a[i] = tmp;
				}
				else
				{
					a[i] = 1;
				}
			}
		}

		for(int i = 0; i < 4; i++)
		{
			num += a[i] * base[i];
		}
		
		return num;
	}

	private static String int2mcxi(int num)
	{
		String str = "";
		int[] a = new int[4];
		int[] base = {1000, 100, 10, 1};
		String[] mcxi = {"m", "c", "x", "i"};

		for(int i = 0; i < 4; i++)
		{
			a[i] = num / base[i] % 10;
		}

		for(int i = 0; i < 4; i++)
		{
			switch(a[i])
			{
				case 0:
					break;
				case 1:
					str += mcxi[i];
					break;
				default:
					str += Integer.toString(a[i]) + mcxi[i];
					break;
			}
		}

		return str;
	}
}

Measured memory_bytes: 30344
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int mp[1002*1002];
char ch[1002*1002];
int w,h,goal;
int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};
int change(int i,int j){
 return i*w+j;
}

int find(int x){
  if(mp[x] == x) return mp[x];
  else return mp[x] = find(mp[x]);
}

void unite(int x,int y){
  x= find(x),y = find(y);
  if(x < y) swap(x,y);
  mp[x] = y;
}

bool same(int x, int y){
  if(find(x) == find(y)) return true;
  return false;
}

int solve(){
  int ans = -1;
  if(same(0,goal)==true)ans = 0;
  int q;
  cin >> q;
  for(int i=1;i<=q;i++) {
    int x,y;
    cin >> x >> y;
    if(ans != -1) continue;
    ch[change(y,x)] = '.';
    for(int j=0;j<4;j++){
      int nx = x+dx[j];
      int ny = y+dy[j];
      int nxy = change(ny,nx);
      if(nx<0||ny<0 || nx>=w || ny>=h ||ch[nxy] == '#') continue;
      unite(change(y,x),nxy);
    }
    if(same(0,goal) == true) ans = i;
  }
  return ans;
}

int main(){
  while(cin >>w >>h){
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin >> ch[i*w+j];

    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	mp[i*w+j] = i*w+j;
	if(ch[i*w+j] == '#') continue;
	if(ch[i*w+j] == 't') goal = i*w+j;
	for(int k=0;k<2;k++){
	  int nx = j+dx[k];
	  int ny = i+dy[k];
	  int nxy= change(ny,nx);
	  if(nx<0||ny<0||nx>=w||ny>=h||ch[nxy] == '#') continue;
	  unite(change(i,j),nxy);
	}
      }
    cout << solve() <<endl;
  }
  return 0;
}

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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int s[10][10];
  int k[10];
  int p[10];
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int r = 0; r < (1 << n); r++) {
    bool ok = true;
    for (int i = 0; i < m; i++) {
      int cnt = 0;
      for (int j = 0; j < k[i]; j++) {
        cnt += (r & (1 << (s[i][j]-1))) >> (s[i][j]-1);
      }
      if (cnt % 2 != p[i]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

string S, T; vector<int>V1, V2; int N;

int solve() {
	int minx = (1 << 30);
	for (int i = 0; i <= N; i++) {
		if (i != S.size()) {
			if (S[i] != T[0] || (i >= 1 && S[i] == S[i - 1])) continue;
		}
		if (i == S.size()) {
			if (S[i - 1] == T[0]) continue;
		}
		int score = 0;
		for (int j = 0; j < i; j++) {
			if (S[j] != S[j + 1]) score += (j + 1);
		}
		int pos1 = lower_bound(V1.begin(), V1.end(), i) - V1.begin();
		int pos2 = lower_bound(V2.begin(), V2.end(), 0) - V2.begin();

		while (true) {
			pos1++; pos2++;
			if (pos1 == V1.size() || pos2 == V2.size()) break;
			score += abs(V1[pos1] - V2[pos2]);
		}
		for (int i = pos1; i < V1.size(); i++) score += abs((int)S.size() - V1[i]);
		for (int i = pos2; i < V2.size(); i++) score += abs((int)T.size() - V2[i]);
		minx = min(minx, score);
	}
	int S1 = 0;
	for (int i = 0; i < V1.size(); i++) S1 += abs(V1[i] - 0);
	for (int i = 0; i < V2.size(); i++) S1 += abs(N - V2[i]);
	minx = min(minx, S1);
	int S2 = 0;
	for (int i = 0; i < V1.size(); i++) S2 += abs(N - V1[i]);
	for (int i = 0; i < V2.size(); i++) S2 += abs(V2[i] - 0);
	minx = min(minx, S2);
	return minx;
}

int main() {
	cin >> N >> S >> T;
	V1.push_back(0); for (int i = 0; i < S.size() - 1; i++) { if (S[i] != S[i + 1]) V1.push_back(i + 1); } V1.push_back(S.size());
	V2.push_back(0); for (int i = 0; i < T.size() - 1; i++) { if (T[i] != T[i + 1]) V2.push_back(i + 1); } V2.push_back(T.size());
	
	int v1 = solve(); swap(S, T); swap(V1, V2);
	int v2 = solve(); swap(S, T); swap(V1, V2);
	cout << min(v1, v2) << endl;
	return 0;
}

Measured memory_bytes: 384
while(True):
    n, x = map(int, input().split())
    if(n == 0 and x == 0):
        break

    w = 0

    for i in range(1, n - 1):
        for j in range(i + 1, n):
            for k in range(j + 1, n + 1):
                if(i + j + k == x):
                    w += 1
    print(w)


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

static const int MAX = 55;
int H, W;
char s[MAX][MAX];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  rep(i, MAX) {
    rep(j, MAX) s[i][j] = '.';
  }

  cin >> H >> W;

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) cin >> s[i][j];
  }

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (s[i][j] == '#') {
        bool flag = false;
        rep(k, 4) {
          if (s[i+dx[k]][j+dy[k]] == '#') flag = true;
        }
        if (!flag) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }

  cout << "Yes" << endl;

  return 0;

}

Measured memory_bytes: 256
def calc(A):
    res = 0
    
    for i in range(N-1):
        res += abs(A[i+1]-A[i])
    
    return res

N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()

if N%2==0:
    l1 = A[:N//2]
    l2 = A[N//2:]
    l1.reverse()
    l2.reverse()
    B = [-1]*N
    
    for i in range(N):
        if i%2==0:
            B[i] = l1[i//2]
        else:
            B[i] = l2[i//2]
            
    ans = calc(B)
    print(ans)
else:
    l1 = A[:N//2]
    l2 = A[N//2:]
    B = [-1]*N
    B[0] = l2[0]
    B[-1] = l2[1]
    
    for i in range(1, N-1):
        if i%2==0:
            B[i] = l2[i//2+1]
        else:
            B[i] = l1[i//2]
    
    l1 = A[:N//2+1]
    l2 = A[N//2+1:]
    C = [-1]*N
    C[0] = l1[-1]
    C[-1] = l1[-2]
    
    for i in range(1, N-1):
        if i%2==0:
            C[i] = l1[i//2-1]
        else:
            C[i] = l2[i//2]
   
    ans = max(calc(B), calc(C))
    print(ans)

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

using namespace std;

int main(){
  int n, first, second;
  vector<int> a;
  cin >> n;
  first = 0;
  second = -1;
  for (int i=0;i<n;i++) {
    int input, tmp;
    cin >> input;
    a.push_back(input);
    if (input > first) {
      second = first;
      first = input;
    } else if (input > second) {
      second = input;
    }
  }
  for (auto it = a.begin();it != a.end();it++) {
    if (*it == first) {
      cout << second << endl;
    } else {
      cout << first << endl;
    }
  }
  return(0);
}


Measured memory_bytes: 2548
#include <cstdio>
int main()
{
 int n;
 double ans=0;
 scanf("%d",&n);
 for(int i=1;i<=n;i++)
 {
  int x;
  scanf("%d",&x);
  ans+=1.0/x;
 }
 printf("%.10lf\n",1/ans);
 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define optimize ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long
#define ld long double
#define lint __int128
#define vi vector<int>
#define pb push_back
#define lp(i,a,b) for(int i = a ; i <= b ; i ++)
#define rlp(i,a,b) for(int i = b ; i >= a ; i --)
#define a_sort(v) sort(v.begin(), v.end())
#define d_sort(v) sort(v.rbegin(), v.rend())
#define pii pair<int,int>
#define pi 3.14159265358979323846264338327950
using namespace std ;
// #define debug

const int MOD = 1E9 + 7 ;
const int N = 1E5 ;

int main() {
    #ifdef debug
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif // debug
    optimize

    string a , b ; cin >> a >> b ;
    if(a.size() > b.size()) cout << "GREATER\n" ;
    else if(a.size() < b.size()) cout << "LESS\n" ;
    else {
        if(a > b) cout << "GREATER\n" ;
        else if(a < b) cout << "LESS\n" ;
        else cout << "EQUAL\n" ;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int prim(int );

int a[N][N];
int d[N],p[N],color[N];
int i,j,n;

int main(){


  scanf("%d",&n);

  for( i=0 ; i<n ; i++ ){
    p[i] = 0;
    d[i] = 2001;
  }
  d[0] = 0;

  for( i=0 ; i<n ; i++ ){
    for( j=0 ; j<n ; j++ ){
      scanf("%d",&a[i][j]);
    }
  }
      printf("%d\n",prim(n));

      return 0;
}



int prim(int n){
  int min, minj, total=0;

  for( i=0 ; i<n-1 ; i++ ){
    min = 2001;
    for( j=0 ; j<n ; j++ ){
      if( d[j] < min && p[j] == 0){
	min = d[j];
	minj = j;
      }
    }
    p[minj] = 1;

    for( j=0 ; j<n ; j++ ){
      if( a[minj][j] != -1 && a[minj][j] < d[j] && p[j] == 0 ){
	d[j] = a[minj][j];
      }
    }
  }
  for( i=0 ; i<n ; i++ ){
    total += d[i];
  }
  return total;
}

Measured memory_bytes: 640
n,m=map(int,input().split())
p=list(map(int,input().split()))
num=[[] for _ in range(n)]
for i in range(m):
    x,y=map(int,input().split())
    num[x-1].append(y)
    num[y-1].append(x)
seen=[False]*n
ans=list(range(n))
for i in range(n):
    if seen[i]==False:
        queue=[i]
        seen[i]=True
        for j in range(n):
            if len(queue)==0:
                break
            num1=queue.pop()
            ans[num1]=i
            for k in range(len(num[num1])):
                num2=num[num1][k]-1
                if seen[num2]==False:
                    queue.append(num2)
                    seen[num2]=True
ans2=0
for i in range(n):
    if ans[i]==ans[p[i]-1]:
        ans2+=1
print(ans2)


Measured memory_bytes: 34528
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

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

int max_rect(VI a){
    int n = a.size();
    VI l(n), r(n);

    stack<int> st;
    REP(i,n){
        while (!st.empty() && a[st.top()] >= a[i]) st.pop();
        l[i] = (st.empty() ? 0 : st.top() + 1);
        st.push(i);
    }

    while (!st.empty()) st.pop();
    FORR(i,n-1,0){
        while (!st.empty() && a[st.top()] >= a[i]) st.pop();
        r[i] = (st.empty() ? n : st.top());
        st.push(i);
    }

    int ret = 0;
    REP(i,n){
        ret = max(ret, a[i] * (r[i] - l[i]));
    }
    return ret;
}

int main(){
    int h, w;
    cin >> h >> w;

    VVI a(h, VI(w));
    REP(i,h) REP(j,w) cin >> a[i][j];

    VVI b(h, VI(w));
    REP(j,w){
        REP(i,h){
            if (a[i][j] == 0){
                b[i][j] = (i == 0 ? 1 : b[i-1][j] + 1);
            }
        }
    }

    int ans = 0;
    REP(i,h) ans = max(ans, max_rect(b[i]));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 18132
#include <bits/stdc++.h>
#define mod 1000000007
using ll = long long;
using namespace std; 
const double pi = acos(-1);

int main() {
    ll a;
	double b;
    cin >> a >> b;
    ll d=b*100+0.1;
	ll ans=a*d/100;
	cout << ans << "\n";
}



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

const int N = 1e5 + 10;
int n, a[N], gl[N], gr[N], ans;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	
	int t = a[0];
	for (int i = 0; i < n; i++){
		gl[i] = __gcd(a[i], t);
		t = gl[i];
	}
	t = a[n - 1];
	for (int i = n - 1; i >= 0; i--){
		gr[i] = __gcd(a[i], t);
		t = gr[i];
	}
	
	ans = max(gr[1], gl[n - 2]);
	for (int i = 1; i < n - 1; i++)
		ans = max(ans, __gcd(gl[i - 1], gr[i + 1]));
	
	cout << ans;	
}

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

using namespace std;

int main()
{
    int N, K;
    long long ans = 1000000000;
    vector<int> h;
    cin >> N >> K;
    for(int i = 0; i < N; ++i) {
        int buf; cin >> buf; h.push_back(buf);
    }
    sort(h.begin(), h.end());
    for(int i = 0; i <= N - K; ++i) {
        ans = min(ans, static_cast<long long>(abs(h[i] - h[i + K - 1]))); 
    }
    cout << ans << endl;
}


Measured memory_bytes: 892
import java.util.*;

public class Main{
    static int[] cards;
    static int[] hindo;
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){
	    String[] line = sc.next().split(",");
	    cards = new int[5];
	    hindo = new int[14];
	    for(int i=0; i<cards.length; i++){
		cards[i] = Integer.parseInt(line[i]);
		hindo[cards[i]]++;
	    }

	    String ans = solve();

	    System.out.println(ans);

	}
    }

    public static String solve(){
	int four = 0;
	int three = 0;
	int two = 0;
	int firstOne = 0;
	for(int i=0; i<hindo.length; i++){
	    if(hindo[i]==1 && firstOne==0){firstOne=i;}
	    if(hindo[i]==4){four++;}
	    if(hindo[i]==3){three++;}
	    if(hindo[i]==2){two++;}
	}
	if(four==1){return "four card";}
	if(three==1 && two==1){return "full house";}
	if(three==1){return "three card";}
	if(two==2){return "two pair";}
	if(two==1){return "one pair";}
	if(firstOne>hindo.length-4){return "null";}

	boolean straight1 = true;
	for(int i=firstOne; i<=firstOne+4; i++){
	    if(i==14){i=1;}
	    if(hindo[i]!=1){straight1 = false;}
	}
	boolean straight2 = true;
	int count = 0;
	for(int i=firstOne; ; i--){
	    if(count==5){break;}
	    if(i==0){i=13;}
	    if(hindo[i]!=1){straight2 = false;}
	    count++;
	}
	if(straight1 || straight2){return "straight";}

	else return "null";
    }
}

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



int main(){
	int n, ta = 0, mu = 0;
	cin >> n;
	mu = n;
	while (n) {
		ta += n % 10;
		n /= 10;
	}
	if (mu%ta == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	else {
		cout << "No" << endl;
		return 0;
	}
}

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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int i = a;i < b;++i) cout << ary[i] << (b-1 == i ? "]\n" : ", "); } while(0)
#define p_map(map,it) do {cout << "{";for (auto it = map.begin();;++it) {if (it == map.end()) {cout << "}\n";break;}else cout << "" << it->first << "=>" << it->second << ", ";}}while(0)

int main () {
    int n,m;
    string s,t;
    cin >> s >> t;
    n = s.size();m = t.size();
    vector<vector<int>> dp(n+1,vector<int>(m+1,0));
    for (int i = 0;i < n;++i) for (int j = 0;j < m;++j) {
            if (s[i] == t[j]) dp[i+1][j+1] = max(dp[i][j]+1,max(dp[i+1][j],dp[i][j+1]));
            else dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
    }
    int i = n,j = m;
    vector<char> ans;
    while (i+j > 0) {
        if (dp[i][j] == dp[i][j-1]) j--;
        else if (dp[i][j] == dp[i-1][j]) i--;
        else if (dp[i][j] == dp[i-1][j-1]+1) {
            i--;j--;
            ans.push_back(s[i]);
        }
    }
    for (int i = ans.size();i > 0;--i) cout << ans[i-1];
    cout << "\n";
    return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
#define N
#define debug(x) cout<<#x<<":"<<x<<endl;
using namespace std;
map<int,bool>mark;
int main(){
	char a[100];
	int ans=0;
	scanf("%s",a);
	for(int i=0;i<4;i++){
//		printf("%c",a[i]);puts("");
		if(!mark[a[i]-'A'])ans++,mark[a[i]-'A']=1;
	}
//	printf("%d",ans);
	if(ans==2)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#define int long long
using namespace std;
int data[26][500005];
int n;
inline int lowbit(int x){return x&(-x);}
void change(int z,int x,int y)
{
    for(int i=x;i<=n;i+=lowbit(i))
    {
        data[z][i]+=y;
    }
}
int query(int z,int x)
{
    if(x==0)return 0;
    int ans=0;
    for(int i=x;i;i-=lowbit(i))
    {
        ans+=data[z][i];
    }
    return ans;
}
char s[500005];int xx;int l,r;
signed main()
{
	cin>>n;
	cin>>s+1;
	for(int i=1;i<=n;i++)
	{
		change(s[i]-'a',i,1);
	}
    int m;cin>>m;
    for(int i=1;i<=m;i++)
    {
    	cin>>xx;
    	if(xx==1)
    	{
			int weizhi;
			char c;
			cin>>weizhi;
			cin>>c;
			if(s[weizhi]!=c)
			{
				change(s[weizhi]-'a',weizhi,-1);
				change(c-'a',weizhi,1);
				s[weizhi]=c;
			}
		}
		else if(xx==2)
		{
			cin>>l>>r;
			int ans=0;
			for(int j=0;j<26;j++)
			{
				if((query(j,r)-query(j,l-1))>=1)
				{
					ans++;
				}
			}
			cout<<ans<<endl;
		}
	}
}

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

#define ll long long

int main()
{
    ll n;
    cin >> n;
    int ans = 0;

    for (ll i = 2; i * i <= n; i++)
    {
        int cnt = 0;
        if (n % i)
        {
            continue;
        }
        while (n % i == 0)
        {
            n /= i;
            cnt++;
        }
        for (int j = 1; j <= cnt; j++)
        {
            cnt -= j;
            ans++;
        }
    }

    if (n > 1)
        ans++;

    cout << ans << endl;
}

Measured memory_bytes: 3596
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    d, t, s = map(int, input().split())
    if d <= t * s:
        print("Yes")
    else:
        print("No")
resolve()

Measured memory_bytes: 61684
let () =
  Scanf.scanf "%d %d" @@ fun n k ->
  let kk = 2*k in
  let a = Array.init n (fun _ ->
    Scanf.scanf " %d %d %c" (fun x y z -> (x+1) mod kk, (y+1) mod kk, z)) in

  let b = Array.init (kk+1) (fun _ -> Array.make (kk+1) 0) in
  let fill lx ly ux uy = begin
    let r x = x |> max 0 |> min kk in
    let lx, ly = r lx, r ly in
    let ux, uy = r ux, r uy in
    b.(lx).(ly) <- b.(lx).(ly) + 1; b.(ux).(ly) <- b.(ux).(ly) - 1;
    b.(lx).(uy) <- b.(lx).(uy) - 1; b.(ux).(uy) <- b.(ux).(uy) + 1;
  end in

  a |> Array.iter (fun (x,y,c) ->
    let x, y = match c with
      | 'B' -> x, y
      | _   -> (x+k) mod kk, y in
    [(-k,-k); (-k,k); (0,-kk); (0,0); (k,-k); (k,k)] |> List.iter @@ fun (dx,dy) ->
      fill (x+dx) (y+dy) (x+dx+k) (y+dy+k)
  );

  for i = 0 to kk do
    for j = 0 to kk do
      if i > 0 then b.(i).(j) <- b.(i).(j) + b.(i-1).(j);
      if j > 0 then b.(i).(j) <- b.(i).(j) + b.(i).(j-1);
      if i > 0 && j > 0 then b.(i).(j) <- b.(i).(j) - b.(i-1).(j-1);
  done done;
  Array.fold_left (Array.fold_left max) 0 b |> Printf.printf "%d\n"

Measured memory_bytes: 39808
#include <iostream>

using namespace std;

int main(){
    long int n;
    cin>>n;
    long long int dp[n+1]={0};
    dp[0]=0; 
    dp[1]=0;
    for(long int i=2; i<=n; i++){
        dp[i]=dp[i-1];
        long long int noOfFactors=1;
        long long int no=i-1;
        for(long long int j=2; j*j<=no; j++){
            if(no%j==0){
                long long int p=0;
                while(no%j==0){
                    no/=j;
                    p++;
                }
                noOfFactors*=(p+1);
            }
        }
        if(no!=1)
        {
            noOfFactors*=2;
        }
        dp[i]+=noOfFactors;
    }
    cout<<dp[n];
}

Measured memory_bytes: 11440
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using graph = vector<vector<long long int>>;
using wgraph = vector<vector<pair<long long int, long long int>>>;
long long int INF = 1001001001001001LL;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(long long int i = 0; i < (n); i++)
#define rrep(i,n) for(long long int i = 1; i <= (n); i++)
#define drep(i,n) for(long long int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(long long int i = s; i < t; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  int n; cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  int tmp = 0;
  int ans = 0;
  int cur = -1;
  
  rep(i, n) {
    if(cur >= h[i]){
      tmp++;
      
    }else{
      ans = max(ans, tmp);
      tmp = 0;
    }

    cur = h[i];
  }

  ans = max(ans, tmp);
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> vec;
    
    for(int i = 0; i < N; ++i)
    {
        int Num; cin >> Num;
        vec.push_back(Num);
    }
    
    cin >> N;
    for(int i = 0; i < N; ++i)
    {
        int b, e, t;
        cin >> b >> e >> t;
        for(int k = 0; k < e-b; ++k)
        {
            int tmp = vec[k+b];
            vec[k+b] = vec[k+t];
            vec[k+t] = tmp;
        }
    }
    
    for(int i = 0; i < vec.size(); ++i)
      cout << (i == 0 ? "" : " ") << vec[i];
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdarg>
#include <set>
#include <limits>
#include <iomanip>

using namespace std;
#define INF 2e9 + 9
#define MOD 1000000007
#define ALL(v) v.begin() , v.end()
#define Int int64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T, vector<T>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
#define ll(n) Int n; cin >> n;
#define LL(...) Int __VA_ARGS___; cin >> __VA_ARGS___;
#define OUT(...) cout << __VA_ARGS___;
#define RP(n, i, s) for(Int i = s ;i < n ;i++)
#define REP(n, i) for (Int i = 0; i < n; i++)
#define REPe(n, i) for (Int i = 1; i <= n; i++)
#define RPe(n, i, s) for (Int i = s; i <= n; i++)
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;

void ansYes(bool flag){
    if (flag) cout << "Yes" << endl; else  cout << "No" << endl;
}

void ansYES(bool flag){
    if (flag) cout << "YES" << endl; else  cout << "NO" << endl;
}

struct node {
    Int to;
    Int length;
};


vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return (ret);
}

/*
vector<vector<int>> to;
vector<int> flag;
vector<int> c;


Int dfs(int from, int mae) {
    flag[from] = 1;
    Int mini = 0;
    for (auto next : to[from]) {
        if (next == mae) continue;
        if (flag[next] == 1) {
            return -1;
        } else {
            mini = min(mini, dfs(next, from));
        }
    }
    return mini;
}*/

int dx8[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

int main(){
    Int x , y, z ,k;
    cin >> x >> y >> z >> k;
    vector<Int> a(x);
    vector<Int> b(y);
    vector<Int> c(z);
    REP(x,i){
        cin >> a.at(i);
    }
    REP(y,i){
        cin >> b.at(i);
    }
    REP(z,i){
        cin >> c.at(i);
    }
    sort(c.begin(),c.end(),greater<>());
    vector<Int> d;
    REP(x,i){
        REP(y,k){
            d.push_back(a.at(i) + b.at(k));
        }
    }
    sort(d.begin(),d.end(),greater<>());
    Int esize = min((Int)d.size(),(Int)3000);
    vector<Int> e(esize);
    for (int i = 0; i < esize; i++) {
        e.at(i) = d.at(i);
    }
    vector<Int> f;
    for (auto z : e){
        for (auto k : c){
            f.push_back(z + k);
        }
    }
    sort(f.begin(),f.end(),greater<>());
    for (int i = 0; i < k; i++){
        cout << f.at(i) << endl;
    }

}

Measured memory_bytes: 43112
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,i,j,k,l;
    l=1;
    k=0;
    m=0;
    scanf("%lld",&n);
    while(n)
    {
        k+=l;
        l*=2;
        n/=2;
    }
    printf("%lld\n",k);
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	long n = Long.parseLong(sc.next());
    long k = Long.parseLong(sc.next());
    long min = n % k;
    long a = k - min;  
      if(min > a)
        min = a;	
	System.out.println(min);
	}
}

Measured memory_bytes: 35648