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

int main() {
    int a, b;
    char op;
    while(1) {
        cin >> a >> op >> b;
        if(op == '?') break;
        if(op == '+') cout << a + b << endl;
        else if(op == '-') cout << a - b << endl;
        else if(op == '/') cout << a / b << endl;
        else if(op == '*') cout << a * b << endl;
    }
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int i,sum=0;
	cin>>s;
	for(i=0;i<=5;i++)
	{
		if(s[i]=='1') sum++;
	}
	cout<<sum<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod=998244353;
vector<ll>ans;

ll add(ll a, ll b)  {return ( (a%mod) + (b%mod) )%mod;}

ll multiply(ll a, ll b) {return ((a%mod) * (b%mod))%mod;}

ll power(ll a, ll b)
{
    if(b==0) return 1;
    ll temp=power(a,b/2);
    if(b%2==1) return multiply(temp,multiply(temp,a));
    else return multiply(temp,temp);
}

int main()
{
  ll x,y;
  cin>>x>>y;
  set<ll>s;
  for(int i=0;i<y;i++)
  {
      ll a;
      cin>>a;
      s.insert(a);
  }
  ll diff=INT_MAX;
  ll ans=0;
  for(int i=0;i<=200;i++)
  {
      if(s.find(i)==s.end())
      {
          if(abs(i-x)<diff)
          {
              ans=i;
              diff=abs(x-i);
          }
      }
  }
  cout<<ans<<"\n";
}

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

using namespace std;

int N, M;
vector<int> vec[100005];

int main(void)
{
	cin >> N >> M;
	int x;
	for(int i = 0; i < N; i++){
		cin >> x;
		vec[x % M].push_back(x);
	}
	for(int i = 0; i < M; i++) sort(vec[i].begin(), vec[i].end());
	
	int ans = 0;
	ans += vec[0].size() / 2;
	if(M % 2 == 0) ans += vec[M/2].size() / 2;
	
	for(int i = 1; i < (M+1)/2; i++){
		int lp = 0, up = 0, prev, cnt;
		
		prev = -1, cnt = 0;
		for(int j = 0; j < vec[i].size(); j++){
			if(prev == vec[i][j]) cnt++;
			else{
				lp += cnt / 2;
				cnt = 1;
			}
			prev = vec[i][j];
		}
		lp += cnt / 2;
		
		prev = -1, cnt = 0;
		for(int j = 0; j < vec[M-i].size(); j++){
			if(prev == vec[M-i][j]) cnt++;
			else{
				up += cnt / 2;
				cnt = 1;
			}
			prev = vec[M-i][j];
		}
		up += cnt / 2;
		
		int max_make = 0, make;
		for(int j = 0; j <= min(vec[i].size(), vec[M-i].size()); j++){
			make = min( ((int)vec[i].size() - j) / 2, lp ) + min( ((int)vec[M-i].size() - j) / 2, up ) + j;
			max_make = max(max_make, make);
		}
		ans += max_make;
	}
	
	cout << ans << endl;
	return 0;
}

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

int main(){
	int W, H;
	string o = "";
	while (true){
		cin >> H >> W;
		if (W == 0 && H == 0){
			break;
		}
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				o += "#";
			}
			o += "\n";
		}
		o += "\n";
	}
	cout << o;
}

Measured memory_bytes: 3172
#include <iostream>
using namespace std;
int main() {
int a,b,x;
cin>>a>>b>>x;
while(x>0){
    if( x>a+b || x<a ){
        cout<<"NO";
        break ;
    }
    else if(x!=a || x==a){
        a+=1;
        b-=1;
        cout<<"YES";
        break;
    }
}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
from decimal import Decimal

N = int(input())
A = [int(10**9*Decimal(input())) for _ in range(N)]

def count(a,p):
  n = a
  count = 0
  while n%p == 0:
    n //= p
    count += 1
  return count

Z = np.zeros((19,19), dtype=np.int64)
answer = 0
for a in A:
  c2 = count(a,2)
  c5 = count(a,5)
  answer += Z[max(18-c2,0),max(18-c5,0)]
  Z[:min(18,c2)+1,:min(18,c5)+1] += 1

print(answer)


Measured memory_bytes: 34480
#include<bits/stdc++.h>
using namespace std;
int h,w;
string a[1200];
queue<pair<pair<int,int>,int> >q;
bool vis[1200][1200];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>h>>w;
	for(int i=0;i<h;i++)
		cin>>a[i];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(a[i][j]=='#'){
				q.push(make_pair(make_pair(i,j),0));
				vis[i][j]=true;
			}
		}
	}
	while(!q.empty()){
		int x=q.front().first.first;
		int y=q.front().first.second;
		int stp=q.front().second;
		q.pop();
		for(int i=0;i<4;i++){
			int nx=x+dx[i];
			int ny=y+dy[i];
			if(nx>=0&&nx<h&&ny>=0&&ny<=w){
				if(!vis[nx][ny]&&a[nx][ny]=='.'){
					vis[nx][ny]=true;
					q.push(make_pair(make_pair(nx,ny),stp+1));
				}
			}
		}
		if(q.empty()){
			cout<<stp<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 14608
N = int(input())
A = [int(_) for _ in input().split()]


class SegmentTree():
    def __init__(self, array, m, e, size):
        """
        Parameters
        ----------
        array : list
            to construct segment tree from
        m : func
            binary operation of the monoid
        e : 
            identity element of the monoid
        size : int
            limit for array size
        """
        self.m = m
        self.e = e
        self.size = size
        self.n = n = len(array)
        self.dat = dat = [e] * n + array + [e] * (2 * size - 2 * n)
        for i in range(n - 1, 0, -1):  # build
            dat[i] = m(dat[i << 1], dat[i << 1 | 1])

    def modify(self, p, v):  # set value at position p (0-indexed)
        m, n, dat = self.m, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            dat[p >> 1] = m(dat[p], dat[p ^ 1])
            p >>= 1

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        m, e, n, dat = self.m, self.e, self.n, self.dat
        res = e
        l += n
        r += n
        while l < r:
            if l & 1:
                res = m(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = m(res, dat[r])
            l >>= 1
            r >>= 1
        return res


gcd = lambda x, y: gcd(y, x) if x < y else x if y == 0 else gcd(y, x % y)
e = 0
size = N
ST = SegmentTree(A, m=gcd, e=e, size=size)
ans = 1
for i, a in enumerate(A):
    ST.modify(i, 0)
    ans = max(ans, ST.query(0, N))
    ST.modify(i, a)
print(ans)


Measured memory_bytes: 131848
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    if(S == U) {
        A--;
    } else if(T == U) {
        B--;
    }
    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
#include <memory>
#include <map>
#include <cassert>
#include <array>
#include <iterator>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <array>
#include <numeric>

class Solution {
public:
    long long gcd (long long a, long long b)
    {
      while (a > 0 && b > 0)
      {
        if (a > b)
          a %= b;
        else 
          b %=a;
      }
      return a + b;
    }
    void solve(std::istream& in, std::ostream& out) {
      long long n;
      in >> n;
      long long lcm = -1;
      for (long long i = 0; i < n; ++i)
        {
          long long t;
          in >> t;
          if (lcm >= 0)
            lcm = lcm / gcd (lcm, t) * t;
          else
            lcm = t;
        }
      out << lcm << '\n';
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}

#include <iostream>

int main ()
{
  solve (std::cin, std::cout);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long N, K; cin >> N >> K;
  long ans = 0;
  for(int i = K; i <= N + 1; i++) ans = (ans + (N + 1 - i) * i + 1) % 1000000007;
  cout << ans;
  return 0;
}

Measured memory_bytes: 3608
import math


def trial_division(target):
    dest = int(math.sqrt(target))

    for i in range(2, dest):
        if target % i == 0:
            # print(str(target) + ' is comp')
            return False
    # print(str(target) + ' is prime')
    return True


x = int(input())
pn = 2
while True:
    if trial_division(pn) and x <= pn:
        break
    else:
        pn += 1
print(pn)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue


template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int cnt = 0;
	int ans = 0;
	rep(i, s.size()) {
		if (s.at(i) == 'W') {
			ans += cnt;
		}
		else {
			cnt++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 720
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;

int dp[50][500][500];

int main() {
	
	int i, j, k, n; cin >> n;
	int ma, mb; cin >> ma >> mb;

	int a[50], b[50], c[50];
	for (i = 0; i < n; i++)cin >> a[i] >> b[i] >> c[i];

	for (k = 0; k < 50; k++) {
		for (i = 0; i < 500; i++) {
			for (j = 0; j < 500; j++) {
				dp[k][i][j] = 1000000;
			}
		}
	}

	dp[0][0][0] = 0;

	for (i = 0; i < n; i++) {
		for (j = 0; j <= 400; j++) {
			for (k = 0; k <= 400; k++) {
				if (j + a[i] <= 400 && k + b[i] <= 400) {
					dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
					dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
				}
			}
		}
	}

	int ans = 1000000;
	for (int i = 1; i <= 400; i++) {
		if (ma*i > 400 || mb * i > 400)break;
		ans = min(ans, dp[n][ma*i][mb*i]);
	}
	if (ans == 1000000)ans = -1;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 49024
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+7;

vector< int >edg[MAXN];
bool vis[MAXN];

void dfs(int u) {
    vis[u] = true;
    for (int v : edg[u]) {
        if (vis[v]) continue;
        dfs(v);
    }
}

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

    while (m--) {
        int u, v;
        cin >> u >> v;
        edg[u].push_back(v);
        edg[v].push_back(u);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (vis[i] == 0) {
            dfs(i);
            ans++;
        }
    }

    cout << ans-1 << endl;


    return 0;
}


Measured memory_bytes: 9684
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    string x;
    cin>>x;
    map<char, int> data;
    for(auto i : x){
        data[i]++;
    }
    for(auto i: data){
        if(i.second % 2 ==1){
            cout<<"No"<<endl;
            return;
        }
    }
    cout<<"Yes"<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
X,K,D=map(int,input().split())

def valid(value1, value2, diff):
    if diff%2==0:
        return value1
    else:
        return value2

if abs(X)>K:
    tmp = abs(X)//D
    if tmp>K:
        tmp=K
    if X < 0:
        X += tmp*D
    else:
        X -= tmp*D
    K -= tmp

min_score = abs(X)
for i in range(K):
    if abs(X-D)>abs(X+D):
        X = X+D
    else:
        X = X-D
    if min_score > abs(X):
        min_score=abs(X)
    else:
        a = min([abs(X-D), abs(X+D)])
        min_score = valid(a, abs(X), K-i)
        break
print(min_score)


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

using namespace std;

//#define MD 10

int main(){
   string s;
    cin>>s;
    long int i=s.length()-1;
    
    while(i>=4){
         if(s[i]=='m'){
               if("dream"==s.substr(i-4,5)){
                    i-=5;
                }else{
                    cout<<"NO"<<endl;
                    return 0;
                }
        }else if(s[i]=='e'){
                if("erase"==s.substr(i-4,5)){
                    i-=5;
                }else{
                    cout<<"NO"<<endl;
                    return 0;
                }
        }else if(s[i]=='r'){
             if(i-6>=0){
                if("dreamer"==s.substr(i-6,7)){
                    i-=7;
                    continue;
                }else if("eraser"==s.substr(i-5,6)){
                     i-=6;
                    continue;
                }else{
                    cout<<"NO"<<endl;
                    return 0;
                }
             }else if(i-5>=0){
                if("eraser"==s.substr(i-5,6)){
                    i-=6;
                }else{
                     cout<<"NO"<<endl;
                    return 0;
                }
             }else{
                    cout<<"NO"<<endl;
                    return 0;
             }
        }
    }
  
    if(i<0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 512
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{
  ull n,k;
  cin >> n >> k;
  vector<ull> a(n);

  rep(i,n)
  {
    cin >> a[i];
    a[i]--;
  }

  map<ull,ull> m;

  ull pos = 0;
  ull cnt = 0;
  ull cir = 0;
  ull st = 0;
  m[pos] = cnt;

  bool flg = false;
  ull nocir = 0;

  while(1)
  {
    ull next = a[pos];
    pos = next;

    cnt++;
    if(m.find(next) != m.end())
    {
      cir = cnt - m[next];
      st = m[next];
      pos = next;
      flg = true;
      break;
    }

    if(cnt == k)
    {
      nocir = pos;
      break;
    }

    m[next] = cnt;
  }

  if(flg)
  {
    ull buf = (k - st) % cir;

    rep(i,buf)
    {
      pos = a[pos];
    }
    cout << pos + 1 << endl;
  }
  else
  {
    cout << nocir + 1 << endl;
  }
  
  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 14788
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
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;}
const int MOD = 1000000007;

void solve() {
  int n, k;
  cin >> n >> k;
  vi h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(), h.end());
  int ans = INF;
  rep(i,n-(k-1)) {
    ans = min(ans, abs(h[i] - h[i + k -1]));
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  for (ll i = 0; i + K < N; ++i) {
    if (A.at(i) < A.at(i + K)) {
      cout << "Yes" << "\n";
    }
    else {
      cout << "No" << "\n";
    }
  }
}


Measured memory_bytes: 4780
import sys
input = sys.stdin.readline
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
inf=float("inf")
n,m=map(int,input().split())
G=[[inf]*n for _ in range(n)]
for _ in range(m):
    a,b,c=map(int,input().split())
    G[a-1][b-1]=c
    G[b-1][a-1]=c
#print(G)
from copy import deepcopy
H=deepcopy(G)
#print(H)
H=warshall_floyd(H)
#print(G,H)
cnt=0
for i in range(n):
    for j in range(n):
        if i==j:
            continue
        if G[i][j]==inf:
            continue
        if G[i][j]!=H[i][j]:
            cnt+=1
print(cnt//2)


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


public class A
{
	public static void Main()
	{
		string[] args = Console.ReadLine().Split(' ');
		int A = Int32.Parse(args[0]);
		int B = Int32.Parse(args[1]);
		int C = Int32.Parse(args[2]);

		Console.WriteLine(Math.Min(B/A,C));
	}	
}





Measured memory_bytes: 13140
A,B,C,D=gets.split('').map(&:to_i)
8.times{|i|
    op1=i[0]==1?"+":"-"
    op2=i[1]==1?"+":"-"
    op3=i[2]==1?"+":"-"
    s=("%s"*7) % [A,op1,B,op2,C,op3,D]
    a=eval(s)
    if a==7
        puts s+"=7"
        break
    end
}


Measured memory_bytes: 14280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

const int nCk_MAX = 510000;
ll fac[nCk_MAX], finv[nCk_MAX], inv[nCk_MAX];
bool Pre = true;
void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < nCk_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;
    }
}
ll com(int n, int k) {
    if (Pre) {
        cominit();
        Pre = false;
    }
    if (n < k)return 0;
    if (n < 0 || k < 0)return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

ll modpow(ll x, ll y) {
    ll ret = 1;
    for (; 0 < y; y >>= 1){
        if (y % 2 == 1)(ret *= x) %= mod;
        (x *= x) %= mod;
    }
    return ret;
}

int main() {
    init();

    int n; cin >> n;
    VI a(n + 1); cin >> a;

    int l = -1, r = -1;
    VI itr(n, -1);
    FOR(i, 0, n + 1) {
        if (itr[a[i] - 1] != -1) {
            l = itr[a[i] - 1];
            r = i;
        }
        itr[a[i] - 1] = i;
    }

    eFOR(i, 1, n + 1)cout << (com(n + 1, i) - com(l + n - r, i - 1) + mod) % mod << "\n";
}

Measured memory_bytes: 13952
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef pair <int, int> pii;

int main(){
	int n;
	cin >> n;
	
	vector <int> d(n);
	for(int i = 0; i < n; i++)
		cin >> d[i];
		
	sort(all(d));
	reverse(all(d));
	
	ll sum = d[0];
	int k = n - 2;
	int pos = 1;
	while(k > 0){
		if(k == 1)
			sum += d[pos];
		else
			sum += d[pos] * 2;
		
		k -= 2;
		pos++;
	}
	
	cout << sum << endl;
	return 0;
}


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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define RREP(i, a, n) for(int i = (int)(n); i >= a; i--)
#define all(x) (x).begin(),(x).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 (b<a) { a=b; return 1; } return 0; }

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

    vector<int> H(N);
    rep(i,N) cin >> H[i];

    sort(all(H));
    ll ans = 0;
    rep(i,N-K) ans += H[i];

    cout << ans << endl;
}


Measured memory_bytes: 1024
l = []
while True:
    a = input()
    if a == '-':
        break
    number = 0
    for i in range(int(input())):
        number += int(input())
    l.append(a[number%len(a):len(a)]+a[0:number%len(a)])
for i in range(len(l)):
    print(l[i])


Measured memory_bytes: 5596
N = int(input())

d = {}
for _ in range(N):
    s = input()
    if s not in d:
        d[s] = 0
    d[s] += 1

max_val = max(d.values())
keys = [k for k, v in d.items() if v == max_val]
for k in sorted(keys):
    print(k)

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

int main() {
    int i, j, k, n, b, f, r, v, a[4][3][10] = {};

    cin >> n;
    for(i=0; i<n; ++i) {
        cin >> b >> f >> r >> v;
        a[b-1][f-1][r-1] += v;
    }
    for(i=0; i<4; ++i) {
        for(j=0; j<3; ++j) {
            for(k=0; k<10; ++k) {
                cout << ' ' << a[i][j][k];
            }
            cout << endl;
        }
        if(i < 3) {
            cout << "####################" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3080
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#define REP(i, N) for(int i=0; i<N; i++)
using namespace std;

//#include "atcoder.hpp"

long long gcd(long long a, long long b) {
    if (a>b) swap(a,b);
    
    auto r = b % a;
    
    return (r ? gcd(r, a) : a);
}

int main() {
    int N, num_minus = 0;
    
    cin >> N;
    
    vector<long long> A(N);
    long long mina = LONG_LONG_MAX, sum = 0LL;
    
    for (auto& i : A) {
        cin >> i;
        const auto absi = abs(i);
        mina = min(mina, absi);
        if (i < 0)
            num_minus++;
        sum += absi;
    }

    if (num_minus % 2)
        sum -= mina * 2LL;
    

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





Measured memory_bytes: 1024
#include<iostream>
#include<cctype>
#include<cstdio>
using namespace std;

int main(){
	
	char a;
	
	while(1){
		scanf("%c",&a);
		if (a=='\n') break;
		if (a==' ') cout << " ";
		else if (islower(a))  printf("%c",toupper(a));
		else printf("%c",tolower(a));
	}
	cout << endl;
	return 0;
}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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

int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};

int N, Z, W;
int a[2010];

int dp[2][2010];
int main(){
    ios::sync_with_stdio(false);
    cin >> N >> Z >> W;
    REP(i, N) cin >> a[i];
    function<int(int, bool, int, int)> score = [&](int used, int turn, int x, int y) {
        if (used == N) return abs(x - y);
        if (turn) {
            if (dp[turn][used] != -1) return dp[turn][used];
            int res = INF;
            FOR(i, used + 1, N+1) {
                res = min(res, score(i, turn^1, x, a[i-1]));
            }
            return dp[turn][used] = res;
        } else {
            if (dp[turn][used] != -1) return dp[turn][used];
            int res = 0;
            FOR(i, used + 1, N+1) {
                res = max(res, score(i, turn^1, a[i-1], y));
            }
            return dp[turn][used] = res;
        }
    };
    REP(i, 2010) {dp[0][i] = -1; dp[1][i] = -1;}
    cout << score(0, 0, Z, W) << endl;;
    
    return 0;
}



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

int main() {
  int N;
  int cnt = 1;
  cin >> N;
  vector<int> D(N);
  for(int i = 0;i < N ; i++)
  {
    cin >> D.at(i);
  }
  
  sort(D.begin(),D.end());

  for(int i = 1;i < N ; i++)
  {
    if(D.at(i-1) < D.at(i))
    {
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#define ll long long
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1.0),eps=1e-8;
const ll mod=1e9+7;
ll n,m;
ll a[200010];
ll l,r=0,mid,maxn=INF;
int check(int x)
{
    int ans=0;
    for(int i=1; i<=n; i++)
    {
        if(a[i]!=x)
            ans+=a[i]/x;
        if(ans>m)
            return false;
    }
    return ans<=m;
}
int main()
{
    cin>>n>>m;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        r=max(r,a[i]);
    }
    if(m==0)
    {
        printf("%d\n",r);
        return 0;
    }
    l=1;
    while(l<r)
    {
        mid=(l+r)/2;
        if(check(mid))
        {
            r=mid;
        }
        else
            l=mid+1;
    }
    cout<<r<<endl;
    return 0;
}




Measured memory_bytes: 4752
// NK
#include <bits/stdc++.h>
using namespace std;
#define ii pair<int,int>
#define ll long long
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define psf push_front
#define pof pop_front
#define mkp make_pair
#define mkt make_tuple
#define all(x) x.begin(), x.end()

int main(){
	ios::sync_with_stdio(false), cin.tie(nullptr);
	ll a,b; cin>>a>>b;
	ll modu=a%b;
	ll t1=abs(modu-b), t2=abs(t1-b);
	cout<<min(t1, t2)<<endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		C(sc);
		sc.close();
	}
	
	public static void A(Scanner sc) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println((a+b+1)/2);
	}
	
	public static void B(Scanner sc) {
		//一方の文字を辞書順にソート　他方を逆辞書順にソート
		String s = sc.next();
		String t = sc.next();
		Character[] sch = new Character[s.length()];
		Character[] tch = new Character[t.length()];
		for(int i=0;i<s.length();i++) {
			sch[i] = s.charAt(i);
		}
		for(int i=0;i<t.length();i++) {
			tch[i] = t.charAt(i);
		}
		Arrays.sort(sch);
		Arrays.sort(tch,Collections.reverseOrder());
		s = makeString(sch);
		t = makeString(tch);
		if(s.compareTo(t)<0) System.out.println("Yes");
		else System.out.println("No");
	}
	
	public static String makeString(Character[] c) {
		StringBuilder s = new StringBuilder();
		for(int i=0;i<c.length;i++) {
			s.append(c[i]);
		}
		return new String(s);
	}
	// 数字->頻度のmap 数字>頻度　→　-頻度　　数字＜頻度　→　ー（頻度ー数字）
	public static void C(Scanner sc) {
		int N = sc.nextInt();
		HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
		int sum = 0;
		for(int i=0;i<N;i++) {
			int in = sc.nextInt();
			if(map.containsKey(in)) map.put(in,map.get(in)+1);
			else map.put(in,1);
		}
		for(int i : map.keySet()) {
			if(i>map.get(i)) sum += map.get(i);
			if(i<map.get(i)) sum += map.get(i)-i;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 63524
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	while(true){
		if(a > 0){
			c -= b;
		} else {
			cout << "No" << endl;
			return 0;
		}
		if(c > 0){
			a -= d;
		} else {
			cout << "Yes" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define VALS(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define pf push_front
#define LLINF ((long long)1e18)
#define INF 1234567890ll
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define ll long long int 
#define ld long double
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define f first
#define s second
typedef pair <int, int> pi;
typedef pair <ll, ll> pl;
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
const int MOD = 1e9 + 7;


int main()
{
	IAMSPEED
	vector <int> v;
	int n, k, q; cin >> n >> k >> q;
	map <int, int> mp;
	FOR(i, 0, n-1) {
		v.push_back(k-q);
	}
	FOR(i, 1, q) {
		int x; cin >> x;
		--x;
		++v[x];
	}
	for (auto it : v) {
		if (it > 0) cout << "Yes\n";
		else cout << "No\n";
	}
	
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
int n,m,q;
int dp[501][501];
int le,r;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>m>>q;
	for(int i=1;i<=m;i++){
		cin>>le>>r;
		dp[le][r]++;
	}
	for(int l=1;l<=n;l++){
		for(int i=1;l+i<=n;i++){
			int j=i+l;
			dp[i][j]+=(dp[i][j-1]+dp[i+1][j]-dp[i+1][j-1]);
		}
	}
	for(int i=1;i<=q;i++){
		cin>>le>>r;
		cout<<dp[le][r]<<endl;
	}
	return 0;
}


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

int main() {
    using namespace std;
    constexpr unsigned long maxN = 200010;
    unsigned long N;
    scanf("%lu", &N);
    array<unsigned long, maxN> perm;
    {
        array<pair<long, long>, maxN> p;
        for(unsigned long i = 0; i < N; ++i)scanf("%lu%lu", &p[i].first, &p[i].second);
        sort(p.begin(), p.begin() + N);
        for(unsigned long i = 0; i < N; ++i)p[i] = {p[i].second, i + 1};
        sort(p.begin(), p.begin() + N);
        transform(p.cbegin(), p.cbegin() + N, perm.begin(), [](auto i){return i.second;});
    }

    constexpr unsigned long MOD = 998244353;
    array<unsigned long, maxN> binary;
    unsigned long n = binary[0] = 1;
    generate(binary.begin() + 1, binary.end(), [&n](){if(n >= MOD)n -= MOD;return n <<= 1;});

    array<unsigned long, maxN> fenwick_tree{};
    auto que = [&fenwick_tree, &N](unsigned long i){
        unsigned long s{0}, j{i};
        while (i) { s += fenwick_tree[i]; i -= i & -i; }
        while (j <= N) { ++fenwick_tree[j]; j += j & -j; }
        return s;
    };

    array<unsigned long, maxN> coef{};
    coef[N] = N + MOD - 4;
    for(unsigned long i = 0; i != N; ++i){
        auto p = perm[i], q = que(p);
        ++coef[q];
        ++coef[i - q];
        ++coef[p - q - 1];
        ++coef[N - i - p + q];
    }

    cout << inner_product(binary.begin(), binary.begin() + N + 1, coef.begin(), 4 + MOD - N) % MOD << endl;
    return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int n,d[30];
string ans;
int main()
{
	cin>>n;
	for(int i=0;i<26;i++)
	{
		d[i]=1e9;
	}
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		int cnt[26];
		memset(cnt,0,sizeof(cnt));
		for(int j=0;j<s.size();j++)
		{
			cnt[s[j]-'a']++;
		}
		for(int j=0;j<26;j++)
		{
			d[j]=min(d[j],cnt[j]);
		}
	}
	for(int i=0;i<26;i++)
	{
		for(int j=0;j<d[i];j++)
		{
			ans+=(char)('a'+i);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
  
typedef long long ll;
ll m, n;
  
#define MOD 1000000007
  
ll mod_power(ll x, ll n, ll mod) {
  ll res = 1;
  while(n > 0) {
    if(n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
  
int main() {
  cin >> m >> n;
  cout << mod_power(m, n, MOD) << endl;
  return 0;
}

Measured memory_bytes: 3092
# -*- coding: utf-8 -*-
"""
Trunk Road
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0643

"""
import sys


def solve(H, W, grid):
    ans = float('inf')
    for i in range(H):
        for j in range(W):
            score = 0
            for y in range(H):
                for x in range(W):
                    score += grid[y][x] * min(abs(i-y), abs(j-x))
            ans = min(ans, score)
    return ans


def main(args):
    H, W = map(int, input().split())
    grid = [[int(i) for i in input().split()] for _ in range(H)]
    ans = solve(H, W, grid)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])



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

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

// ********************** CODE ********************** //

int main()
{
    _upgrade
    int n; cin >> n;
    int sm = 0;
    while(n--)
    {
        int l, r; cin >> l >> r;
        sm += r - l + 1;
    }
    cout << sm << "\n";
    return 0;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n;

	cin >> n;

	if (n % 2) {
		cout << n * 2 << endl;
	}
	else {
		cout << n << endl;
	}
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<cstring>
#include<vector>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<iomanip>
#include<functional>
#include<unordered_map>
#define io ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define inf 0x3f3f3f3f
#define ll long long
#define ull unsigned long long
#define P pair<int,int>
#define lc rt*2
#define rc rt*2+1
const int maxn = 1e4 + 10;
const int mod = 1e9 + 7;
const double PI = 3.1415926536;

using namespace std;

char s[105][105];
int dp[105][105];
int flag[105][105];

int main()
{
	io;
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; ++i)
		cin >> s[i];
	if (s[0][0] == '#') {
		dp[0][0] = 1;
		flag[0][0] = 1;
	}
	for (int i = 1; i < w; ++i) {
		if (s[0][i] == '#') {
			dp[0][i] = dp[0][i - 1];
			flag[0][i] = 1;
			if (!flag[0][i - 1])
				++dp[0][i];
		}
		else
			dp[0][i] = dp[0][i - 1];
	}
	for (int i = 1; i < w; ++i) {
		if (s[i][0] == '#') {
			dp[i][0] = dp[i - 1][0];
			flag[i][0] = 1;
			if (!flag[i - 1][0])
				++dp[i][0];
		}
		else
			dp[i][0] = dp[i - 1][0];
	}
	for(int i=1;i<h;++i)
		for (int j = 1; j < w; ++j)
			if(s[i][j]=='#') {
				int u = dp[i - 1][j];
				if (!flag[i - 1][j])
					++u;
				int l = dp[i][j - 1];
				if (!flag[i][j - 1])
					++l;
				if (u < l) {
					dp[i][j] = u;
					
				}
				else {
					dp[i][j] = l;

				}
				flag[i][j] = 1;
			}
			else {
				dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
			}
	cout << dp[h - 1][w - 1];
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
int main(){
  ll x;
  cin >> x;
  ll p=x/100,q=x%100;
  if(5*p>=q){
    cout << 1;
  }else{
    cout << 0;
  }
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;

int main(void) {
    int id;
    string format;
    map<string, int> table;
    table.insert(make_pair("A", 0));
    table.insert(make_pair("B", 0));
    table.insert(make_pair("AB", 0));
    table.insert(make_pair("O", 0));
    
    while(scanf("%d,", &id) != EOF) {
        cin >> format;table[format]++;
    }
    string ary[4] = {"A", "B", "AB", "O"};
    for(int r = 0; r < 4; r++) {
        cout << table[ary[r]] << endl;
    }
    return(0);
}

Measured memory_bytes: 1244
main :: IO ()
main = do
  n <- readLn
  vs <- readInts
  cs <- readInts
  print $ solve n vs cs

solve :: Int -> [Int] -> [Int] -> Int
solve _ vs cs = sum . filter (> 0) $ zipWith (-) vs cs

readInts :: Read a => IO [a]
readInts = map read . words <$> getLine


Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int m = Integer.parseInt(scan.next());
        int k = Integer.parseInt(scan.next());
        scan.close();

        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= m; j++) {
                if (m * i + (n - 2 * i) * j == k) {
                    System.out.println("Yes");
                    return;
                }
            }
        }

        System.out.println("No");
    }
}


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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll x,k;cin>>x>>k;
  vector<ll>rev(k);
  rep(i,0,k)cin>>rev[i];
  rev.PB(INF);
  ll q;cin>>q;
  vector<ll>t(q),a(q);
  rep(i,0,q)cin>>t[i]>>a[i];
  ll idx=0;
  ll la=0,ra=x,l=0,r=x;
  vector<ll>ret(q);
  ll now=0;
  rep(i,0,k+1){
    while(idx<q&&t[idx]<rev[i]){
      ll dt=t[idx]-now;
      if(i&1)dt*=-1;
      if(a[idx]<=l)ret[idx]=min(x,max(0LL,la-dt));
      else if(a[idx]>=r)ret[idx]=min(x,max(0LL,ra-dt));
      else{
        ret[idx]=min(x,max(0LL,a[idx]-l+la-dt));
      }
      idx++;
    }
    if(i==k)break;
    ll dt=rev[i]-now;
    if(i%2==0){
      l=min(l+max(0LL,(dt-la)),x);
      la=max(0LL,la-dt);
      ra=max(0LL,ra-dt);
    }
    else{
      r=max(r-max(0LL,dt-(x-ra)),0LL);
      ra=min(x,ra+dt);
      la=min(x,la+dt);
    }
    //cout<<l spa r spa la spa ra<<endl;
    now=rev[i];
  }
  rep(i,0,q)cout<<ret[i]<<endl;
  return 0;
}

Measured memory_bytes: 4336
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int a[110];
int main()
{
	int n,sum=0,out=0;
	cin>>n;
	rep(i,n){
		cin>>a[i];sum+=a[i];
	}
	rep(i,n){
		if(abs(a[i]*n-sum)<abs(a[out]*n-sum)) out=i;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		long h = sc.nextLong();

		long count = 0;

		while (h > 1) {
			h = h / 2;
			count++;
		}

		System.out.println((long) (Math.pow(2, count + 1)) - 1);

	}

}


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

using namespace std;

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}
const int MOD = 1000000007;
int main()
{
    long n, a, b;
    cin >> n >> a >> b;
    long ans = modpow(2, n, 1000000007);
    long com[b + 1];
    com[0] = 1;

    for (int i = 1; i <= b; i++)
    {
        com[i] = (((com[i - 1] * (n - i + 1)) % MOD) * modinv(i, MOD)) % MOD;
        //cout << com[i] << endl;
    }
    long ans2 = ans - com[a] % MOD - com[b] % MOD - 1;
    while(ans2 < 0)
    {
        ans2 += MOD;
        if(ans2 >= 0)
        {
            cout << ans2 << endl;
            return 0;
        }
    }
    cout << ans2 << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	
	cout << a * b / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
using namespace std;
typedef long long ll;

ll max(ll a, ll b) {
  return a > b ? a : b;
}

int main(void) {
  ll i, j, k, n, max = 0, a, b, c, d, ans = 0;
  scanf("%lld", &n);
  for(i = 0; i < n; ++i) {
    scanf("%lld", &a);
    if(max <= a) max = a, ans++;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 128