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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n; cin >> n;
    set<int> a; rep(i,n) {int aa; cin >> aa; a.insert(aa);}
    cout << (a.size()%2==1 ? a.size() : a.size()-1) << '\n';
}

Measured memory_bytes: 4992
#include<stdio.h>
int main(){
double a,b,c,d,e,f;
double det;
double det1;
double det2;
double x,y;
while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF){
    det=a*e-b*d;
	det1=c*e-b*f;
	det2=a*f-c*d;
	x=det1/det;
	y=det2/det;
	if(x==-0) x=0;
	if(y==-0) y=0;
	printf("%.3lf %.3lf\n",x,y);
	}
	return 0;
	}

Measured memory_bytes: 652
from math import sqrt 
n= int(input())
xy=[[int(i) for i in input().split()] for _ in range(n)]
def d(x, y):
    return sqrt((x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2)
def nai(x, y, z):
    c,b,a = sorted([d(x, y), d(y, z), d(z, x)])
    co = (b**2 + c**2 - a**2)/(2*b*c)
    if co<0: return a/2
    si = sqrt(1-co**2)
    return a/si/2

if n==2:
    print(d(xy[0],xy[1])/2)
else:
    ans=0
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                ans = max(ans,nai(xy[i],xy[j],xy[k]))
    print(ans)

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

using namespace std;

int cnt = 0;
void insertionSort( vector<int> &elems, int n, int g )
{
	int i, j, v;
	for( i=0; i<n; i++ ) {
		v = elems[i];
		j = i - g;
		while( 0 <= j and v < elems[j] ) {
			elems[ j+g ] = elems[j];
			j -= g;
			cnt++;
		}
		elems[ j+g ] = v;
	}
	return;
}

void shellSort( vector<int> &elems, int n )
{
	cnt = 0;
	int m;
	vector<int> G(100);
	
	G[0] = 1;
	for( int i=1; ; i++ ) {
		m = G[ i-1 ]*3+1;
		if( m < n ) { 
			G[i] = m;
		} else {
			m = i;
			break;
		}
	}
	cout<<m<< '\n';	
	sort( G.rbegin( ), G.rend( ) );
	for( int i=0; i<m; i++ ) {
		cout<<G[i];
		if( i != G.size( )-1 ) { cout<<" "; }
	}
	cout<<'\n';
	
	for( int i=0; i<m; i++ ) {
		insertionSort( elems, n, G[i] );
	}
	cout<<cnt<<'\n';
	
	return;
}

int main( )
{	
    int n;
    cin>>n;
    
    vector<int> elems(n);
    for( int i=0; i<n; i++ ) {
    	cin>>elems[i];
    }
    
    shellSort( elems, n );
    for( int i=0; i<n; i++ ) {
    	cout<<elems[i]<<'\n';
    }	
	return 0;
}

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

int main(){
  string divide[4] = {"erase", "eraser", "dream", "dreamer"};
  string str; cin >> str;
  
  queue<int> BFS;
  BFS.push(0);
  bool flag = false;
  int res;
  while(!BFS.empty()){
    res = BFS.front(); BFS.pop();
    if (res == str.size()) {
      flag = true;
      break;
    }
    for (string s : divide){
      if (str.substr(res, s.size()) == s) BFS.push(res + s.size());
    }
  }
  cout << (flag ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <tuple>

using namespace std;

int main(int, char**) {
    string str;
    cin >> str;
    cout << str[0] << str[1] << str[2] << str[3] << ' ' <<str[4] << str[5] << str[6] << str[7] << str[8] << str[9] << str[10] << str[11] << endl ;
    return 0;
}


Measured memory_bytes: 384
n,k = map(int,input().split())
res_graph = [[1,i] for i in range(2,n+1)]
res = (n-1)*(n-2)//2

if(k > (n-2)*(n-1)//2):
    print(-1)
    exit()

tmp_edge = 2
while res!=k:
    tmp = 1
    for i in range(n-tmp_edge):
        res_graph.append([tmp_edge,tmp+tmp_edge])
        res-=1
        tmp+=1
        if res==k:
            break
    tmp_edge+=1

print(len(res_graph))
for i,j in res_graph:
    print(i,j)


Measured memory_bytes: 9264
N, X, M = map(int, input().split())

L = [-1] * M

a = X
i = 0
while True:
    if L[a] != -1:
        B = L[a]
        C = i - L[a]
        break
    L[a] = i
    a = a * a % M
    i += 1


ans = 0
if N <= B + C:
    a = X
    for i in range(N):
        ans += a
        a = a * a % M
else:
    a = X
    for i in range(B):
        ans += a
        a = a * a % M
    temp = 0
    for i in range(B, B+C):
        temp += a
        a = a * a % M
    ans += (N-B) // C * temp
    for i in range((N-B)%C):
        ans += a
        a = a * a % M
print(ans)
    

Measured memory_bytes: 11172
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> H(N);
  for_each(begin(H), end(H), [](auto& x) { cin >> x; });

  sort(begin(H), end(H));

  while(H.size() > 0 && K > 0) {
    H.pop_back();
    K--;
  }
  ll sum = accumulate(cbegin(H), cend(H), 0LL);

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


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

#define MAX 100000
#define WHITE 0
#define BLACK -1

typedef struct{
  int k;
  int *wgt;
  int *num;
}vector;

int n;
vector M[MAX];

void dijkstra(){
  int i, u, v, minv, tmp;
  int d[n], color[n];

  for( i=0; i<n; i++ ){
      d[i] = INT_MAX;
      color[i] = WHITE;
    }

  d[0] = 0;                  
  while(1){
      minv = INT_MAX;          
      for( i=0; i<n; i++ ){
          if( minv > d[i] && color[i] != BLACK ){
	      u = i;
	      minv = d[i];
	    }
      }
      if( minv == INT_MAX ) break;  
      
      color[u] = BLACK;
      
      for( v=0; v<M[u].k; v++ ){
          tmp = M[u].num[v];  
          if( color[tmp] != BLACK ){
	      if( d[tmp] > d[u] + M[u].wgt[v] )d[tmp] = d[u] + M[u].wgt[v];
		
	    }
      }
    }
    for( i=0; i<n; i++ )printf("%d %d\n", i, d[i]);
}
int main(){
  int i, j, u, k, v, c,p;
  
  scanf("%d", &n);
  
  for( i=0; i<n; i++ ){
      scanf("%d%d", &p, &M[i].k);
      M[p].wgt = (int *)malloc( M[i].k * sizeof(int));
      M[p].num = (int *)malloc( M[i].k * sizeof(int));

      for( j=0; j<M[i].k; j++ ) scanf("%d%d", &M[p].num[j], &M[p].wgt[j]);
  }

  dijkstra();

  for( i=0; i<n; i++ ){
      free( M[i].wgt );
      free( M[i].num );
  }
  return 0;
}
      





Measured memory_bytes: 5456
#include <stdio.h>
#include <string.h>

int check_atcg(char c)
{
  if(c == 'A' || c == 'T' || c == 'C' || c == 'G') {
    return 1;
  }

  return 0;
}

int main(void)
{
  int i = 0,len = 0,maxlen = 0;
  char S[10];
  scanf("%s",S);

  for(i = 0;i < strlen(S);i++) {
    //printf("%c\n",S[i]);

    while(check_atcg(S[i]) == 1) {
      //printf("len %d\n",len);
      len++;
      i++;
    }

  if(len > maxlen) maxlen = len;

  len = 0;

  }

  printf("%d\n",maxlen);

  return 0;
}


Measured memory_bytes: 128
n,k = gets.split.map &:to_i
a = gets.split.map &:to_i

cs = [0]
n.times do |i|
    cs[i+1] = cs[i] + a[i] + 1
end

ans = 0
0.upto(n-k) do |i|
    b = cs[i+k] - cs[i]
    ans = b if ans < b
end

puts ans/2.0

Measured memory_bytes: 16588
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int k;
  cin >> k;
  int no, ne;
  no = (k + 1) / 2;
  ne = k / 2;
  cout << no * ne << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cmath>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define SIZE 100005

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

int A[SIZE];

int main()
{
	int n,x;
	scanf("%d %d",&n,&x);
	ll ret=0;
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	for(int i=1;i<n;i++)
	{
		if(A[i]+A[i-1]>x)
		{
			if(A[i-1]<=x)
			{
				ret+=A[i]-(x-A[i-1]);
				A[i]=x-A[i-1];
			}
			else
			{
				ret+=A[i];
				A[i]=0;
				ret+=A[i-1]-x;
				A[i-1]=x;
			}
		}
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 512
class UnionFind():
    def __init__(self,n):
      self.n=n
      self.root=[-1]*(n+1)
      self.rank=[0]*(n+1)
      
    def find(self,x):
      if self.root[x]<0:
        return x
      else:
        self.root[x]=self.find(self.root[x])
        return self.root[x]
    
    def unite(self,x,y):
      x=self.find(x)
      y=self.find(y)
      if x==y:
        return 0
      elif self.rank[x]>self.rank[y]:
        self.root[x]+=self.root[y]
        self.root[y]=x
      else:
        self.root[y]+=self.root[x]
        self.root[x]=y
        if self.rank[x]==self.rank[y]:
          self.rank[y]+=1
          
    def Same(self,x,y):
      return self.find(x)==self.find(y)
    
    def size(self,x):
      return -self.root[self.find(x)]
import sys
input=sys.stdin.buffer.readline
n,m,k=map(int,input().split())
link=UnionFind(n)
f=[0]*n
block=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    link.unite(a,b)
    f[a]+=1
    f[b]+=1
for _ in range(k):
    a,b=map(int,input().split())
    block[a-1].append(b-1)
    block[b-1].append(a-1)
ans=[]
for i in range(n):
  ret=link.size(i)-f[i]-1
  for j in block[i]:
    if link.Same(i,j):
      ret-=1
  ans.append(ret)
print(*ans)

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

int main(void) {
    int h, w;
    while (1) {
        cin >> h >> w;
        if (h == 0 && w == 0) break;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if ((i + j) & 1) cout << '.';
                else cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    int d, t, s; cin >> d >> t >> s;
    if (s*t >= d) puts("Yes");
    else puts("No");

    return 0;
}

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

int N;
long long K;
typedef pair< int, int > P;
vector<P> v;

int main()
{
	cin >> N >> K;
	for( int i = 0; i < N; i++ ) {
		int a, b;
		cin >> a >> b;
		v.push_back( make_pair( a, b ) );
	}

	sort( v.begin(), v.end() );
	long long bsum = 0;
	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		P p = v[i];
		if( bsum + p.second >= K ) {
			ans = p.first;
			break;
		}
		bsum += p.second;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> a(n), b(m);
    rep(i, 0, n){
        cin >> a[i];
    }
    rep(i, 0, m){
        cin >> b[i];
    }
    while(q--){
        int x;
        cin >> x;
        int ida = upper_bound(a.begin(), a.end(), x) - a.begin();
        int idb = upper_bound(b.begin(), b.end(), x) - b.begin();
        vector<int> da(2, INF), db(2, INF);
        if(ida != n) da[0] = a[ida];
        if(ida != 0) da[1] = a[ida - 1];
        if(idb != m) db[0] = b[idb];
        if(idb != 0) db[1] = b[idb - 1];
        int ans = INF;
        rep(i, 0, 2){
            rep(j, 0, 2){
                ans = min(ans, abs(x - da[i]) + abs(da[i] - db[j]));
                ans = min(ans, abs(x - db[j]) + abs(db[j] - da[i]));
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2944
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define UP(i,a,b) for(int i=(a); i<=(b); ++i)
#define DOWN(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) UP(i,0,(n)-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, int n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n in O(log(n)) time

const int MOD = 1000000007; //10^9+7
const double PI = 3.1415926535897932384626;

/*********** variables ************/
int N, M;
int d[102][102];
int e[1000][3];
/**********************************/


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    REP(i, M) {
        cin>>e[i][0]>>e[i][1]>>e[i][2];
    }

    UP(i, 1, N) {
        UP(j, 1, N) {
            d[i][j] = MOD;
        }
    }
    REP(i, M) {
        int a = e[i][0];
        int b = e[i][1];
        int c = e[i][2];
        d[a][b] = d[b][a] = c;
    }

    UP(k, 1, N) {
        UP(i, 1, N) {
            UP(j, 1, N) {
                if(d[i][j] > d[i][k] + d[k][j]) {
                    d[i][j] = d[i][k] + d[k][j];
                }
            }
        }
    }

    int ans = 0;
    REP(i, M) {
        int a = e[i][0];
        int b = e[i][1];
        int c = e[i][2];
        if(d[a][b] < c) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy 

round1 = "R" * dx + "U" * dy + "L" * dx + "D" * dy
round2 = "L" + "U" * (dy + 1) + "R" * (dx + 1) + "D" + "R" + "D" * (dy + 1) + "L" * (dx + 1) + "U"

print(round1 + round2)


Measured memory_bytes: 3060
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
aaa = na()
ct1 = 0
ct2 = 0
for a in aaa:
    if a % 4 == 0:
        ct1 += 1
    elif a % 2 == 0:
        ct2 += 1
rs = len(aaa) - ct1 - ct2
rs += ct2 % 2
if rs > ct1 + 1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 14764
#include <bits/stdc++.h>
using namespace std;
int main(){
  int TH,TA,AH,AA;
  cin>>TH>>TA>>AH>>AA;
  while(true){
    AH-=TA;
    if(AH>0){
      TH-=AA;
      if(TH>0){
        continue;
      }
      else{
        cout<<"No"<<endl;
        return 0;
      }
    }
    else{
      cout<<"Yes"<<endl;
      return 0;
    }
  }
}

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

int main(){
	int n; //0~nまでの整数で探索
	long long int sum = 0; //合計
	cin >> n;

	for(int i = 1; i <= n; i++){
		if(i%3 != 0 && i%5 != 0){
			sum += i;
		}
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;

typedef long long ll;
const int maxn = 150010;
int n;
vector<pair<int, int>> G[maxn];
vector<pair<ll, ll>> f[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 2, f, w; i <= n; i++) {
        scanf("%d %d", &f, &w), G[f].push_back({i, w});
    }
    ll l = 0, r = 150000LL * n, ans;
    while (l <= r) {
        ll mid = (l + r) >> 1;
        function<void(int)> dfs = [&](int v) {
            if (G[v].empty()) { f[v].push_back({0, 0}); return; }
            for (auto e : G[v]) dfs(e.x);
            auto& ls = f[G[v][0].x], rs = f[G[v][1].x];
            for (auto& p : ls) p.x += G[v][0].y, p.y += G[v][0].y;
            for (auto& p : rs) p.x += G[v][1].y, p.y += G[v][1].y;
            if (ls.size() > rs.size()) swap(ls, rs);
            vector<pair<ll, ll>> V;
            for (int i = 0, j = rs.size() - 1; i < ls.size(); i++) {
                while (~j && ls[i].x + rs[j].x > mid) j--;
                if (j < 0) break;
                V.push_back({ls[i].y, rs[j].y}), V.push_back({rs[j].y, ls[i].y});
            }
            sort(V.begin(), V.end());
            ll mn = LLONG_MAX;
            for (auto p : V) {
                if (mn > p.y) f[v].push_back(p);
                mn = min(mn, p.y);
            }
        };
        for (int i = 1; i <= n; i++) f[i].clear();
        dfs(1);
        !f[1].empty() ? r = (ans = mid) - 1 : l = mid + 1;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 35648
import itertools

N = int(input())
A = tuple(map(int, input().split()))
S = [0] + list(itertools.accumulate(A))

dp = [[0] * (N + 1) for _ in range(N + 1)]
for length in range(2, N + 1):
    for l in range(N - length + 1):
        r = length + l
        dp[l][r] = min(dp[l][m] + dp[m][r] for m in range(l + 1, r)) + S[r] - S[l]
print(dp[0][N])


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

int main() {
  
  int X, A, B;
  cin >> X >> A >> B ;
  
  if (A >= B) {
    cout << "delicious" << endl;
  }
  else if (A + X < B) {
    cout << "dangerous" << endl;
  }
  else {
    cout << "safe" << endl;
  }
  
  
return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main(){
  int n,m;cin>>n>>m;
  int red[n]={};
  red[0]=1;
  int q[n];rep(i,n)q[i]=1;
  rep(i,m){
    int x,y;cin>>x>>y;
    --x;--y;
    if(red[x]==1){
      red[y]=1;
      if(q[x]==1)red[x]=0;
    }
    ++q[y];--q[x];
  }
  int ans=0;
  rep(i,n)ans+=red[i];
  cout<<ans<<endl;
}



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

typedef long long ll;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18


int main() {
    int A,B; cin >> A >> B;
    if(A%2==1 && B%2==1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
t_hp, t_ap, a_hp, a_ap=(int(x) for x in input().split())
while(t_hp > 0):
  a_hp = a_hp - t_ap
  if a_hp < 1:
    print("Yes")
    break
  t_hp = t_hp - a_ap
if t_hp < 1:
  print("No")

Measured memory_bytes: 61824
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1;i <= n;i++){
        ll a = n/i;
        ans += (i+a*i)*a/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
#include <bits/stdc++.h>

using namespace std;

int main(){
  string s;
  cin >> s;
  int a, b;
  a = s.find_first_of('A');
  b = s.find_last_of('Z');
  cout << b - a + 1 << endl;
  return 0;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

static LL P = 1000000007LL;


int A[52][52] = {0};
int B[52][52] = {0};

int N, M;

int ismatch(int u, int v){
	int ret = 1;
	if(u+M-1 >= N || v+M-1 >= N){
		return 0;
	}
	for(int i=0; i<M; i++){
		for(int j=0; j<M; j++){
			if(A[u+i][v+j] != B[i][j]){
				ret = 0;
				break;
			}
		}
		if(ret == 0){
			break;
		}
	}
	return ret;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> M;
	for(int i=0; i<N; i++){
		string a; cin >> a;
		for(int j=0; j<a.size(); j++){
			if(a[j] == '#'){
				A[i][j] = 0;
			}
			else{
				A[i][j] = 1;
			}
		}
	}
	for(int i=0; i<M; i++){
		string b; cin >> b;
		for(int j=0; j<b.size(); j++){
			if(b[j] == '#'){
				B[i][j] = 0;
			}
			else{
				B[i][j] = 1;
			}
		}
	}

	int ans = 0;
	for(int u=0; u<N; u++){
		for(int v=0; v<N; v++){
			ans = ismatch(u, v);
			if(ans == 1){
				break;
			}
		}
		if(ans == 1){
			break;
		}
	}

	if(ans == 1){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}



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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long int n,k;
  cin>>n>>k;
  long long int sum=0;
  for(long long int i=k;i<=n+1;i++){
    sum +=i*(n-i+1)+1;
  }
  cout<<sum%(1000000007);

}


Measured memory_bytes: 3660
#include<stdio.h>
 int main(void){
     int a[1000],b,i,j,m,n,l,s;
        scanf("%d",&m);
         for(n=0;n<m;n++){
           scanf("%d %d %d",&a[0],&a[1],&a[2]);
           for(i=0;i<3;i++){
            for(j=i+1;j<4;j++){
                if(a[i]<a[j]){
                    l=a[i];
                    a[i]=a[j];
                    a[j]=l;
            }
             }
              }
              if(a[0]*a[0]==a[1]*a[1]+a[2]*a[2]) {
        printf("YES\n");
                }
      else printf("NO\n");
               }



 return 0;
 }

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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int x,y,n,m,k;
char s[maxn],t[maxn];

int main() {
    read(n),read(m),read(k),read(x),read(y);
    scanf("%s%s",s+1,t+1);
    int l=1,r=m;
    for(int i=k;i;i--) {
        if(t[i]=='L') r=min(m,r+1);
        if(t[i]=='R') l=max(1,l-1);
        if(s[i]=='R') r--;
        if(s[i]=='L') l++;
        if(l>r) return puts("NO"),0;
        // l=max(l,1),r=min(r,m);
    // printf("%d %d\n",l,r);
    }
    if(y<l||y>r) return puts("NO"),0;
    // puts("OK");
    l=1,r=n;
    for(int i=k;i;i--) {
        if(t[i]=='U') r=min(n,r+1);
        if(t[i]=='D') l=max(1,l-1);
        if(s[i]=='D') r--;
        if(s[i]=='U') l++;
        if(l>r) return puts("NO"),0;
        // l=max(l,1),r=min(r,n);
    }
    if(x<l||x>r) return puts("NO"),0;
    puts("YES");
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> s(n);
  for(int i=0;i<n;i++)
    cin >> s.at(i);
  
  int k=-1;
  vector<int> a(0);
  
  for(int i=0;i<n;i++){
    if(s.at(i)==a.size()+1){
      a.push_back(a.size()+1);
      k=n-a.size();
    }
  }
  cout << k << endl;
}

Measured memory_bytes: 2168
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){
  int a;
  cin >> a;
  cout << a * (1+a+a*a) << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 7;

vector <int> g[N];

vector <int> t;

int used[N];

void dfs(int u) {
    used[u] = 1;
    for (auto v : g[u]) {
        if (!used[v]) {
            dfs(v);
        }
    }
    t.push_back(u);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
    }
    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            dfs(i);
        }
    }
    vector <int> dp(n);
    int ans = 0;
    for (auto u : t) {
        int mx = -1;
        for (auto v : g[u]) {
            mx = max(mx, dp[v]);
        }
        dp[u] = mx + 1;
        ans = max(ans, dp[u]);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a, b;
  cin >> a >> b;
  
  if ( a == 'H' ){
    cout << b << endl; 
  }
  else if ( b == 'H' ) {
    cout << 'D' << endl; 
  }
  else {  
    cout << 'H' << endl; 
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll ans=0;
    ll k;cin>>k;
    rep(i,1,k+1){
        rep(j,1,k+1){
            rep(l,1,k+1){
                ll y=gcd(i,j);
                y=gcd(y,l);
                ans+=y;
            }
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n;cin >> n;
    /*
    1,-2,4,-8,16,-32,...

   -4:-8+4     01100
   -3:-8+4+1   01101
   -2:-2       00010
   -1:1-2      00011
    0:0        00000
    1:1        00001
    2:4-2      00110
    3:1-2+4    00111
    4:4        00100
    5:1+4      00101
    6:16-8-2   11010
    7:16-8-2+1 11011
    */
    string s;
    rep(i,1000){
        if(n%exp(2,i+1)!=0){
            n-=exp(2,i)*(i%2 ? -1 : 1);
            s+='1';
        }else{
            s+='0';
        }
        if(n==0)break;
    }
    reverse(s.begin(),s.end());
    cout << s << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}
const int MAX = (int)1e6;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
     for (int i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }
 // 二項係数計算
 long long COM(int n, int k){  //nCkの計算をする
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }
 //main関数にCOMinit();を忘れない

int main(){
  ll n,a,b,x[100000];
  cin>>n>>a>>b;
  for (int i(0);i<n;i++) cin>>x[i];
  ll ans(0);
  int now(x[0]);
  for (int i(1);i<n;i++){
    int next = x[i];
    if (a*(next - now) > b){
      ans += b;
    }else{
      ans += a*(next - now);
    }
    now = next;
  }
  cout << ans << endl;
  return 0;
}



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

using namespace std;

int main() {
	int n,m;
	cin >> n >> m;
	int arr[m];
	for (int i = 0; i < m; i++) {
		cin >> arr[i];
		n -= arr[i];
	}
	if (n < 0) {
		cout << "-1\n";
	}
	else {
		cout << n << "\n";
	}
	
	
	return 0;
}

Measured memory_bytes: 3664
N = int(input())
arr = []
for _ in range(N):
    x, l = map(int, input().split())
    arr.append((x+l, x-l))

arr.sort()

prev = float('-inf')
ans = 0
for right, left in arr:
    if left < prev:
        ans += 1
    else:
        prev = right
print(N - ans)

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



ll mod = 1e9 + 7;


int main(){
  ll n, m;
  cin >> n >> m;
  vector<int> s(n);
  vector<int> t(m);
  rep(i, n) cin >> s[i];
  rep(i, m) cin >> t[i];


  vector<vector<ll>> dp(n+1, vector<ll>(m+1, 0));
  dp[0][0] = 1 + (s[0] == t[0]);
  rep1(i, n-1) dp[i][0] = dp[i-1][0] + (s[i] == t[0]);
  rep1(i, m-1) dp[0][i] = dp[0][i-1] + (s[0] == t[i]);

  for(ll i = 1; i < n; i++){
    for(ll j = 1; j < m; j++){
      if(s[i] == t[j]){
        dp[i][j] = dp[i-1][j] + dp[i][j-1];
      }
      else{
        dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1];
      }
      dp[i][j] = (dp[i][j]+mod)%mod;
    }
  }

  cout << dp[n-1][m-1] << endl;


  return 0;
}


Measured memory_bytes: 31616
from __future__ import print_function

p = [10, 50, 100, 500]

first = True

while True:
    n = int(raw_input())
    if n == 0:
        break

    if not first:
        print()

    m = [int(_) for _ in raw_input().split()]

    s = sum(pi * mi for pi, mi in zip(p, m))
    r = s - n
    for i in xrange(3, -1, -1):
        pi = p[i]
        ni = r / pi
        m[i] -= ni
        r -= ni * pi

    for pi, mi in zip(p, m):
        if mi > 0:
            print(pi, mi)

    first = False

Measured memory_bytes: 6236
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

#define MAX 1010

int f(char c) {
	if (c == 'J')return 0;
	if (c == 'O')return 1;
	if (c == 'I')return 2;
}

static int sum[3][MAX][MAX] = {};
int ans(int k, int a, int b, int c, int d) {
	int ret = sum[k][c - 1][d - 1];
	if (a != 1)ret -= sum[k][a - 2][d - 1];
	if (b != 1)ret -= sum[k][c - 1][b - 2];
	if (a != 1 && b != 1)ret += sum[k][a - 2][b - 2];
	return ret;
}

signed main() {
	int M, N, K; cin >> M >> N >> K;
	rep(i, 0, M) {
		rep(j, 0, N) {
			char c; cin >> c;
			sum[f(c)][i][j]++;
		}
	}
	//rep(i, 0, M)dumpc(sum[0][i]);
	rep(i, 0, M) {
		rep(k, 0, 3)rep(j, 0, N)sum[k][i + 1][j] += sum[k][i][j];
		rep(j, 0, N) {
			rep(k, 0, 3)sum[k][i][j + 1] += sum[k][i][j];
		}
	}
	//rep(i, 0, M)dumpc(sum[0][i]);
	rep(i, 0, K) {
		int a, b, c, d; cin >> a >> b >> c >> d;
		cout << ans(0, a, b, c, d) << " ";
		cout << ans(1, a, b, c, d) << " ";
		cout << ans(2, a, b, c, d) << endl;
	}
	return 0;
}

Measured memory_bytes: 14784
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(b/a>=c){
		printf("%d\n",c);
	}
	else if(c>b/a){
		printf("%d\n",b/a);
	}
	else if(a>b){
		printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
        sc.Scan()
        i, e := strconv.Atoi(sc.Text())
        if e != nil {
                panic(e)
        }
        return i
}

func main() {
        sc.Split(bufio.ScanWords)
        a := nextInt()
        b := nextInt()
        c := nextInt()

        i := a
        n := 0

        for i <= b {
                if c%i == 0 {
                        n += 1
                }
                i += 1
        }
        fmt.Println(n)
}


Measured memory_bytes: 1116
def readinput():
    n,m=map(int,input().split())
    tries=[]
    for _ in range(m):
        p,s=input().split()
        p=int(p)
        tries.append((p,s))
    return n,m,tries

def main(n,m,tries):
    point=[[0,0] for i in range(n+1)]
    for i in range(m):
        p,s=tries[i]
        if s=='WA':
            if point[p][0]>0:
                continue
            else:
                point[p][1]+=1
        else:
            point[p][0]+=1
    ac=0
    wa=0
    for i in range(1,n+1):
        if point[i][0]>0:
            ac+=1
            wa+=point[i][1]
    
    return ac,wa

if __name__=='__main__':
    n,m,tries=readinput()
    ans=main(n,m,tries)
    print(' '.join(map(str,ans)))



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

int main(){
  int N;
  cin >> N;
  
  ll a[N], b[N], c[N];
  for(int i=0;i<N;i++){cin >> a[i];}
  for(int i=0;i<N;i++){cin >> b[i];}
  for(int i=0;i<N;i++){cin >> c[i];}
  
  sort(a,a+N);
  sort(b,b+N);
  sort(c,c+N);
  
  ll sum=0;
  ll l=0;
  ll u=0;
  
  for(int i=0;i<N;i++){
    for(int j=l;a[j]<b[i] && j<N;j++){l++;}
    for(int k=u;b[i]>=c[k] && k<N;k++){u++;}
    sum += l * (N-u);
  }
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  ll X; cin>>X;
  ll n = X/100;
  ll a = X%100;
  bool ok = (a<=n*5);
  cout << ok <<"\n";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll N, K;
  cin >> N >> K;
  vll D(N);
  ll totalsum = 0;
  priority_queue<ll, vector<ll>, greater<ll>> totalque;
  for(int i = 0; i < N; i++){
    cin >> D.at(i);
    totalsum += D.at(i);
    totalque.push(D.at(i));
  }
  ll ans = -1*INF;

  bool flag = true;
  while(K > N){ //とりあえずN個取る。ここから捨てる個数のパターンは決まっている。
    for(int i = K-N; i >= 0; i-=2){
      ll sum = totalsum;
      if(i > N) continue;
      priority_queue<ll, vector<ll>, greater<ll>> tq2 = totalque;
      //i個捨てる
      for(int j = 0; j < i; j++){
        ll x = tq2.top();
        tq2.pop();
        sum -= x;
      }
      chmax(ans, sum);
    }
    if(flag){
      K--;
      flag = false;
    }
    else {
      K = N;
      break;
    }
  }

  for(int k = 0; k <= K; k++){
  for(int tmp = 0; tmp <= k/2; tmp++){ //戻す数。K-tmp取ってtmp戻し、K-2tmp残る。
    int KK = k-tmp;
    for(int i = 0; i <= KK; i++){ //左から取る数
      ll sum = 0;
      priority_queue<ll, vector<ll>, greater<ll>> que;
      for(int j = 0; j < i; j++){
        sum += D.at(j);
        que.push(D.at(j));
      }
      for(int j = 0; j < KK-i; j++){
        sum += D.at(N-1-j);
        que.push(D.at(N-1-j));
      }
      for(int j = 0; j < tmp; j++){
        ll x = que.top();
        que.pop();
        sum -= x;
      }
      chmax(ans, sum);
    }
  }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c[1010];
cin >> a >> b;
for(int i=0; i<a; i++) cin >> c[i];
  sort(c,c+a);
  int ans = 0;
  for(int i=0; i < b; i++) ans +=c[i];
  cout << ans << endl;
}


Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string s, t;
    cin >> s >> t;
    bool ok = false;
    rep(i, s.length()) {
        s = s.substr(s.length()-1, 1) + s.substr(0, s.length()-1);
        if ( s == t ) {
            ok = true;
            break;
        }
    }
    if ( ok ) cout << "Yes" << endl;
    else      cout << "No" << endl; 
    return 0;
}


Measured memory_bytes: 256
x = list(input())
i_list=[]
w_list=[]
result_list=[]
result = []
a = list(map(str, x))


for i in a:
    i=int(i)*100
    i_list.append(i)
for p in a:
    p=int(p)*10
    w_list.append(p)
con=len(a)
ind=-1
for t in range(con-2):
    ind = ind+1
    v = int(i_list[ind])+int(w_list[ind+1])+int(a[ind+2])
    result_list.append(v)
    
for e in result_list:
    g=abs(e-753)
    result.append(g)

print(min(result))


Measured memory_bytes: 3064
use proconio::input;

fn main() {
    input! {
        X: i64,
    }
    if 400 <= X && X <= 599 {
        println!("8");
    } else if 600 <= X && X <= 799 {
        println!("7");
    } else if 800 <= X && X <= 999 {
        println!("6");   
    } else if 1000 <= X && X <= 1199 {
        println!("5");  
    } else if 1200 <= X && X <= 1399 {
        println!("4");
    } else if 1400 <= X && X <= 1599 {
        println!("3");
    } else if 1600 <= X && X <= 1799 {
        println!("2");
    } else if 1800 <= X && X <= 1999 {
        println!("1");
    }
}

Measured memory_bytes: 2164
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int a, b, c;
		a = scanner.nextInt();
		b = scanner.nextInt();
		c = scanner.nextInt();
		
		int tmp = 0;
		tmp = a;
		a = b;
		b = tmp;
		
		tmp = a;
		a = c;
		c = tmp;
		
		System.out.println(a + " " + b + " " + c);
		

		scanner.close();
	}

}


Measured memory_bytes: 21844
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws ClassNotFoundException, IOException {
		FastScanner sc = new FastScanner();
		String S = sc.next();
		String[] sarray = S.split("");
		int total = S.length();
		int win = 0;
		int lose = 0;
		for(String s : sarray) {
			if(s.equals("o")) {
				win++;
			}else {
				lose++;
			}
		}
		if(win + (15 - total) >= 8) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

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

int main(){
	int n,m;
	cin>>n>>m;
	int x[m];
	for(int i=0;i<m;i++) cin>>x[i];
	if(n>=m){
		cout<<0<<endl;
		return 0;
	}
	sort(x,x+m);
	int y[m-1]={},ans=x[m-1]-x[0];
	for(int i=0;i<m-1;i++) y[i]=x[i+1]-x[i];
	sort(y,y+m-1);
	for(int i=1;i<n;i++){
		ans-=y[m-1-i];
	}
	cout<<ans;
	return 0;
}


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



int main(){
    int n, k;
    cin >> n >> k;
    int d[k];
    rep(i, k)   cin >> d[i];

    for(int cost = n; cost < 10*n; cost++){
        int tmp = cost;
        bool f = true;
        while(f){
            rep(i, k){
                if(d[i] == tmp%10)  f = false;
            }

            if(10 <= tmp)   tmp /= 10;
            else            break;
        }
        if(f){
            cout << cost << endl;
            break;
        }
    }
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#define reg register
#define ios ios::sync_with_stdio(false)
using namespace std;
inline void re(int &x)
{
	short sign=1;x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')sign=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=sign;
}
inline void wr(int x)
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)wr(x/10);
	putchar(x%10+'0');
}
int t[101],p[101];
int main() 
{
	ios;int n,m,sum=0;re(n);
	for(reg int i=1;i<=n;i++)re(t[i]),sum+=t[i];re(m);
	for(reg int i=1,p,x;i<=m;i++)
	{
		re(p),re(x);
		wr(sum-t[p]+x);
		putchar('\n');
	}
    return 0;
}

Measured memory_bytes: 256