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

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string ans = "";

    for (int i = 0; i < tx - sx; i++)ans += "R";
    for (int i = 0; i < ty - sy + 1; i++)ans += "U";
    for (int i = 0; i < tx - sx + 1; i++)ans += "L";
    for (int i = 0; i < ty - sy + 1; i++)ans += "D";
    ans += "RD";

    for (int i = 0; i < tx - sx + 1; i++)ans += "R";
    for (int i = 0; i < ty - sy + 1; i++)ans += "U";
    for (int i = 0; i < tx - sx + 1; i++)ans += "L";
    for (int i = 0; i < ty - sy; i++)ans += "D";
/*
    int x = sx,y = sy;
    for (int i = 0; i < (int)ans.size(); i++)
    {
        if(ans[i] == 'R')x++;
        if(ans[i] == 'D')y--;
        if(ans[i] == 'L')x--;
        if(ans[i] == 'U')y++;
        cout << x << " " << y << endl;
    }
*/
    cout << ans << endl;
}

Measured memory_bytes: 3648
#!/usr/bin/env python3
import sys
import collections as cl


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()

    que = cl.deque(list(range(1, 10)))

    while N > 1:
        target = que.popleft()
        if target % 10 != 0:
            que.append(target*10 + (target % 10) - 1)

        que.append(target*10 + (target % 10))

        if target % 10 != 9:
            que.append(target*10 + (target % 10) + 1)
        N -= 1

    ans = que.popleft()

    print(ans)


main()


Measured memory_bytes: 74300
#167C
def main():
    import itertools as ite
    import sys, numpy as np
    N,M,X = map(int, sys.stdin.readline().split())
    CA = [np.array(list(map(int, sys.stdin.readline().split()))) for _ in range(N)]
    bit = np.array(list(ite.product([0,1], repeat=N))) #式の展開
    #print(CA)
    #print(bit)
    ans = -1
    for row in bit:
        result = np.array([0 for _ in range(M+1)])
        #print(ans)
        for idx, num in enumerate(row):
            #print(CA[idx]*num)
            result += CA[idx]*num
        if np.all(result[1:]>=X):
            #print(result[0])
            if ans==-1 or ans >result[0]:
                ans = result[0]
    print(ans)
            
        


if __name__=='__main__':
    main()


Measured memory_bytes: 27804
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

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

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

using namespace std;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b == 0) return b;
  else gcd(b, a%b);
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a/gcd(a , b))*b;
}

struct UnionFind {
  vi par; //par[i] : iの親番号（例）par[3] = 2 : 3の親は2

  UnionFind(int N) : par(N) { //最初は全てが根として初期化
    rep(i,N) par[i] = i;
  }

  int root(int x){ //データxが属する木の根を再帰で得る : root(x) = {xの木の根}
    if(par[x] == x)return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){ //xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if(rx == ry)return; //xとyの根が同じ
    par[rx] = ry; //xとyの根が同じでない時、xの根rxをyの根にryにつける。
  }

  bool same(int x, int y){//2つのデータx，yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};


int main(){

  int a, b; cin >> a >> b;
  if(a <= 8 && b <= 8)cout << "Yay!" << endl;
  else cout << ":(" << endl;


  return 0;

}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')

def main():
    X=I()
    ans = 1
    for b in range(2,X):
        p=2
        while True:
            if b**p<=X:
                ans = max(ans, b**p)
            else:
                break
            p+=1
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 5508
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Candy Distribution Again
 */

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

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

int as[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, x;
  scanf("%d%d", &n, &x);

  for (int i = 0; i < n; i++) scanf("%d", &as[i]);
  sort(as, as + n);

  int k = 0;
  while (k < n && x >= as[k]) x -= as[k++];
  if (x > 0 && k >= n) k--;

  printf("%d\n", k);
  return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)

int main() {

    int n; cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    map<string,ll> sums;

    rep(i, n) {
        sort(s[i].begin(), s[i].end());
        if(sums.count(s[i]) == 0) {
            sums[s[i]] = 1;
        } else {
            sums[s[i]]++;
        }
    }

    ll ans = 0;

    for(auto itr = sums.begin(); itr != sums.end(); ++itr) {
        if(itr->second > 1) {
            ll tmp = itr->second-1;
            ans += (tmp*(tmp+1)/2);
        }
    }

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
int main()
{ 	int k;
	cin>>k;
	string s;
	cin>>s;
	if(s.size()<=k)
	cout<<s;
	else
	{ for(int i=k;i<s.size();i++)
	{
	     s.erase(i);  
	}
	  s=s+"...";
	  
	  cout<<s;  
	} 
   	
  
    return 0;
}


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

using namespace std;

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    bool ok = true;
    if (x - r < 0 || x + r > w) {
        ok = false;
    }
    if (y - r < 0 || y + r > h) {
        ok = false;
    }
    string ans = ok ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}



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

using namespace std;

typedef long long ll;

const int N=1000+5;

int n,k;
ll s[N];

vector<ll>a;

vector<ll>w[50];

inline void coo()
{
    for(int j=0;j<50;j++)
    {
        w[j].clear();
    }
    for(int i=0;i<a.size();i++)
    {
        for(int j=0;j<50;j++)
        {
            if(a[i]&(1LL<<j))
            {
                w[j].push_back(a[i]);
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        s[i]=s[i-1]+x;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
        {
            a.push_back(s[i]-s[j-1]);
        }
    }
    coo();
    ll ans=0LL;
    for(int j=49;j>=0;j--)
    {
        if(w[j].size()>=k)
        {
            ans+=(1LL<<j);
            vector<ll>b;
            for(auto &x:a)
            {
                if(x&(1LL<<j))
                {
                    b.push_back(x);
                }
            }
            a=b;
            coo();
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 91756
#include<stdio.h>

int main(){
  int i,j;
  int n;
  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    if(i%3==0){
      printf(" %d",i);
    }
    else{
      for(j=i;j!=0;j/=10){
	if(j%10==3){
	  printf(" %d",i);
	  break;
	}
      }
    }
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, m;
string s, t;

int main(){
	cin >> s >> t;
	ll ans = 0;
	for(ll i = 0; i < 3; i++){
		if(s[i] == t[i]){
			ans++;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
int main()
{
    fio;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll n,x,t;
    cin>>n>>x>>t;
    ll ans = 0,p = 0;
    while(n > p)
    {
        p+=x;
        ans+=t;
    } 
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3632
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    int n,k,ans=0;
	cin >> n;
	int s[n];
	rep(i,n){
		cin >> s[i];
	}

	for(int i=1;i<n-1;i++){
		if((s[i-1]<s[i] && s[i]<s[i+1]) || (s[i-1]>s[i] && s[i]>s[i+1])){
			ans++;
			//cout << s[i] << endl;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
arr = gets.chomp.split(" ").map(&:to_i)

newarr = Array.new(3){0}
    
cnt = 0 

until arr.any? {|v| v.odd? }
    
    arr.each_with_index{|i,index|
        
        newarr[(index+1)%3] += i/2
        newarr[(index+2)%3] += i/2
        
    }
    
    arr = newarr
    newarr = Array.new(3){0}

    cnt += 1
    
    if cnt > 100
        cnt = -1
        break 
    else
    end
        
end 

puts cnt

Measured memory_bytes: 1788
import itertools
import math

N = int(input())
xbox = [list(map(int,input().split())) for _ in range(N)]
lst = list(itertools.permutations(xbox))

num = 0
for i in lst:
    for j in range(N-1):
        line = ((i[j][0]-i[j+1][0])**2 +  (i[j][1]-i[j+1][1])**2)**0.5
        num += line
print(num/len(lst))

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

using ll = long long;
using point = tuple<ll, ll, ll>;

set<point> used;

const int dx[6] = {1, -1, 0, 0, 0, 0};
const int dy[6] = {0, 0, 1, -1, 0, 0};
const int dz[6] = {0, 0, 0, 0, 1, -1};


int main(void) {
	ll a, b, c, n;
	cin >> a >> b >> c >> n;

	ll ans = 2LL * (a * b + b * c + c * a);

	rep(i, n) {
		ll x, y, z;
		cin >> x >> y >> z;

		ll cnt = 0LL;

		rep(j, 6) {
			const int nx = x + dx[j];
			const int ny = y + dy[j];
			const int nz = z + dz[j];

			if (nx < 0 or a <= nx or ny < 0 or b <= ny or nz < 0 or c <= nz ) continue;
			if(used.find(point(nx,ny,nz)) != end(used)) continue;
			cnt++;
		}

		ans += cnt;
		ans -= 6LL - cnt;

		used.insert(point(x, y, z));
	}

	cout << ans << endl;
}

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

int main(){
  int N;
  cin>>N;
  int h[N];
  for(int i=0;i<N;++i) cin>>h[i];
  int x,count,sum=0;
  int ans=0;
  while(ans<N){
    count=0;
    x=0;
    ans=0;
    for(int i=0;i<N;++i){
      if(x==0 && h[i]>0) ++count;
      x=h[i];
      if(h[i]>0) --h[i];
      else ans++;
    }
    sum+=count;
  }
  cout<<sum<<endl;
}

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

int main(){
  using infant= pair<int64_t, int>;
  int N;
  cin >> N;
  
  priority_queue<infant> data;
  int64_t val;
  for(int i=0; i<N; i++){
    cin >> val;
    data.push(make_pair(val, i));
  }

  vector<int64_t> dp(N+1);
  vector<int64_t> buf(N+1);
  for(int n_perm=1; n_perm<= N; n_perm++){
    auto infant_tmp= data.top();
    data.pop();
    int64_t a0; int i0;
    tie(a0, i0)= infant_tmp;
    for(int n_left=0; n_left <= n_perm; n_left++){
      int n_right= n_perm- n_left;
      int i_left = n_left- 1;
      int i_right= N- n_right;

      buf.at(n_left)= (n_left ==0) ? dp.at(n_left)+ a0* abs(i_right- i0)
                     :(n_right==0) ? dp.at(n_left- 1)+ a0* abs(i_left- i0)
                                   : max(dp.at(n_left)+ a0* abs(i_right- i0), dp.at(n_left- 1)+ a0* abs(i_left- i0));
    }

    dp= buf;
  }

  int64_t ans= 0;
  for(auto elem:dp){
    ans= max(ans, elem);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3712
H, W = map(int, input().split())
dp = [[0] * W for i in range(H)]
MOD = 10 ** 9 + 7
T = [[] for i in range(H)]
for i in range(H):
    T[i] = list(input())

for j in range(W):
    if T[0][j] == '.':
        dp[0][j] = 1
    else:
        break
for i in range(H):
    if T[i][0] == '.':
        dp[i][0] = 1
    else:
        break

for i in range(1, H):
    for j in range(1, W):
        dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
        dp[i][j] %= MOD
        if T[i][j] == '#':
            dp[i][j] = 0

print(dp[H - 1][W - 1])



Measured memory_bytes: 51556
package main

import "fmt"

func main() {
	var a, b, c, k int
	fmt.Scan(&a, &b, &c, &k)
	v := max(a, max(b, c))
	for i := 0; i < k; i++ {
		v *= 2
	}
	fmt.Println(a + b + c + v - max(a, max(b, c)))
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

using namespace std;

typedef long long ll;


int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    
    for (int i = 0; i <= 25; i++)
        for (int j = 0; j <= 15; j++)
            if (4*i + 7*j == n) {
                cout << "Yes\n";
                return 0;
            }
    
    cout << "No\n";

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



long long dp[55][55][2550];
int N, A;
int x[55];

int main() {
    while (cin >> N >> A) {
        for (int i = 0; i < N; ++i) cin >> x[i];
        memset(dp, 0, sizeof(dp));
        dp[0][0][0] = 1;
        
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j <= N; ++j) {
                for (int k = 0; k <= 2550; ++k) {
                    dp[i+1][j][k] += dp[i][j][k];
                    dp[i+1][j+1][k + x[i]] += dp[i][j][k];
                }
            }
        }
        long long res = 0;
        for (int j = 1; j <= N; ++j) {
            res += dp[N][j][A*j];
        }
        cout << res << endl;
    }
}




Measured memory_bytes: 61052
l, r = map(int, input().split())
modl = []
result = float("INF")
for i in range(l, r + 1):
    num = i % 2019
    if num == 0:
        print(0)
        exit()
    modl.append(num)
for i in range(r - l + 1):
    for j in range(i + 1, r - l + 1):
        result = min(modl[i] * modl[j] % 2019, result)
print(result)

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

int main(){
    int N;
    cin >> N;
    int d[N];
    int a,b;
    for(int i=0;i<N;i++){
        cin >> d[i];
    }
    for(int i=0;i<N-1;i++){
        a = d[i]; b = d[i+1];
        a = a^b;
        d[i+1] = a;
    }
    //cout << a << endl;
    if(a == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 640
n = int(input())

if n % 2 == 0:
    m = 0
    ans = []
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            if j != n - i + 1:
                m += 1
                ans.append((i, j))
else:
    m = 0
    ans = []
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            if j != n - i:
                m += 1
                ans.append((i, j))

print(m)
for (a, b) in ans:
    print(a, b)

Measured memory_bytes: 3956
#include <stdio.h>
#include <stdio.h>
#include <math.h>

int main()
{
    long long x,y,ans = 0;
    scanf("%lld %lld",&x,&y);

    long long xx = x;
    while (xx <= y)
    {
        xx *= 2;
        ans++;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007

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

using namespace std;
/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int main() {
    ll n, x,l,d = 0, ans = 1;
    cin >> n >> x;
    rep(i, n){
        cin >> l;
        d += l;
        if(d <= x) ans++;
        else {
            cout << ans << endl;
            return 0;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int i,j,n,count;
	cin>>n;
	for(j=n;j<n+1000;j++)
	{
	count=0;
	for(i=2;i<j/2;i++)
	{
		if(j%i==0)
		count+=1;
		
	}
		if (count==0)
		{
		cout<<j;
		exit(0);
		}
	}
	return 0;
}

Measured memory_bytes: 256
inputString = input()
terrainWidth = len(inputString)+1

height = [0] # 土地の高さを求める (左端 = 0)
currentHeight = 0
for c in inputString:
    if c == '_':
        d = 0
    elif c == '/':
        d = 1
    elif c == '\\':
        d = -1
    else:
        pass
    currentHeight += d
    height.append(currentHeight)

leftMax = [] # 各地点における、その地点より左の最大高さを求める
currentMax = 0
for h in height:
    currentMax = max(h, currentMax)
    leftMax.append(currentMax)

rightMax = [0]*terrainWidth # 各地点における、その地点より右の最大高さを求める
currentMax = height[-1]
for i in range(len(height), 0, -1):
    currentMax = max(height[i-1], currentMax)
    rightMax[i-1] = currentMax

floodArea = 0
floodDepth = [0]*terrainWidth # 各地点の水位は leftMax と rightMax の最小値
for i in range(terrainWidth):
    floodDepth[i] = min(leftMax[i], rightMax[i]) - height[i]
    floodArea += floodDepth[i]

pools = []
inPool = False
for depth in floodDepth:
    if depth:
        if inPool:
            pools[-1] += depth
        else:
            inPool = True
            pools.append(depth)
    elif inPool:
        inPool = False

print(floodArea)
if pools:
    print(len(pools), ' '.join([str(p) for p in pools]))
else:
    print(0)



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

int main(){
  int n,A,B;
  cin >> n >> A >> B;
  int ans=0;
  for(int i=1;i<=n;i++){
    int sum=0;
    int x=i;
    for(int j=0;j<5;j++){
      sum+= x%10;
      x/=10;
    }
    if(A <= sum && sum <=B){
      ans += i;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3536
#086a

a, b = map(int, input().split())  # スペースで区切った二つの整数を取得する記載

ab = a * b  # a,bの積を代入

surplus = ab % 2    # 2で割ったあまりを代入

if surplus == 1: # 余りが1なら奇数
    print('Odd')
else:   # 余りが1以外（0)なら偶数
    print('Even')



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

struct CWW{
    CWW(){
        cin.tie(0);
        ios_base::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    }
}STAR;

using D=double;

const D EPS=1e-8;
const D INF=1e9;

const int COUNTER_CLOCKWISE=1;
const int CLOCKWISE=-1;
const int ONLINE_FRONT=2;
const int ONLINE_BACK=-2;
const int ON_SEGMENT=0;

using Point=complex<D>;

struct Segment{
    Point p1,p2;
    Segment(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
};

struct Line{
    Point p1,p2;
    Line(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
};

struct Circle{
    Point c;
    D r;
    Circle(const Point &c=Point(),const D &r=0.0):c(c),r(r){}
};

using Polygon=vector<Point>;

#define EQ(a,b) (abs((a)-(b))<EPS)

istream& operator>>(istream &is,Point &a){
    D x,y;
    is>>x>>y;
    a=Point(x,y);
    return is;
}

ostream& operator<<(ostream& os,const Point &a){
    os<<real(a)<<" "<<imag(a);
    return os;
}

istream& operator>>(istream &is,Line &l){
    Point p1,p2;
    is>>p1>>p2;
    l=Line(p1,p2);
    return is;
}

istream& operator>>(istream &is,Segment &s){
    Point p1,p2;
    is>>p1>>p2;
    s=Segment(p1,p2);
    return is;
}


D dot(const Point &a,const Point &b){
    return real(a)*real(b)+imag(a)*imag(b);
}

D cross(const Point &a,const Point &b){
    return real(a)*imag(b)-imag(a)*real(b);
}

Point projection(const Point &a,const Point &b){
    return a*real(b/a);
}

Point projection(const Line &l,const Point &a){
    return l.p1+projection(l.p2-l.p1,a-l.p1);
}

Point reflection(const Line &l,const Point &a){
    Point p=projection(l,a);
    return 2.0*p-a;
}

int ccw(Point a,Point b,Point c){
    b-=a;c-=a;
    if(cross(b,c)>EPS)return COUNTER_CLOCKWISE;
    if(cross(b,c)<-EPS)return CLOCKWISE;
    if(dot(b,c)<-EPS)return ONLINE_BACK;
    if(norm(b)+EPS<norm(c))return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool isOrthogonal(const Point &a,const Point &b){
    return EQ(dot(a,b),0.0);
}

bool isOrthogonal(const Point &a1,const Point &a2,const Point &b1,const Point &b2){
    return isOrthogonal(a2-a1,b2-b1);
}

bool isOrthogonal(const Line &l,const Line &m){
    return isOrthogonal(l.p1,l.p2,m.p1,m.p2);
}

bool isParallel(const Point &a,const Point &b){
    return EQ(cross(a,b),0.0);
}

bool isParallel(const Point &a1,const Point &a2,const Point &b1,const Point &b2){
    return isParallel(a1-a2,b1-b2);
}

bool isParallel(const Line &l,const Line &m){
    return isParallel(l.p1,l.p2,m.p1,m.p2);
}

bool intersect(const Point &a1,const Point &a2,const Point &b1,const Point &b2){
    return ccw(a1,a2,b1)*ccw(a1,a2,b2)<=0&&
            ccw(b1,b2,a1)*ccw(b1,b2,a2)<=0;
}

bool intersect(Segment &s,Segment &t){
    return intersect(s.p1,s.p2,t.p1,t.p2);
}


int main(){
    int Q;cin>>Q;
    while(Q--){\
        Segment s,t;
    cin>>s>>t;
        cout<<intersect(s,t)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3332
n = int(input())
A = list(map(int, input().split()))
B = [0]
a = 0
S = sum(j for j in A)
ans = [0, 0]
for i in range(n):
  a += A[i]
  if a >= S/2:
    ans[0] = abs(a-A[i]-(S-(a-A[i])))
    ans[1] = abs(a-(S-a))
    break
print(min(ans))

Measured memory_bytes: 26024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define per(i, a, b) for(int i = a; i >= b; i--)
typedef long long LL;
const int maxn = 1e5 + 5;
const LL mod = 1e9 + 7;

int n, q, len;
LL a[maxn], f[maxn], c[maxn];

void Solve(LL d, LL w) {
	int j = upper_bound(a + 1, a + len + 1, d) - a - 1;
	if(!j) c[1] += w, c[d + 1] -= w;
	else f[j] += d/a[j]*w, Solve(d%a[j], w);
}

int main() {
	cin>>n>>q;
	a[++len] = n;
	while(q--) {
		LL x;
		cin>>x;
		while(a[len] >= x && len) len--;
		a[++len] = x; 
	}
	f[len] = 1;
	per(i, len, 2) {
		f[i - 1] += a[i]/a[i - 1]*f[i];
		Solve(a[i]%a[i - 1], f[i]);
	}
	c[1] += f[1];
	c[a[1] + 1] -= f[1];
	rep(i, 1, n) {
		c[i] += c[i - 1];
	    cout<<c[i]<<endl;
	}
}

Measured memory_bytes: 5968
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
    cin>>N>>K;
    vec a(N), visit(N,-1),plusk(N,1);
    vec first(200010,-1),la(200010,-1),inset(200010,-1);
    rep(i,N) cin>>a.at(i);
    rep(i,N){//make roop
        visit.at(i) = i;
        if(la.at(a[i]) == -1){
            la.at(a[i]) = i;
            first.at(a[i]) = i;
        }else{
            ll last = la.at(a[i]);
            visit.at(last) = i;
            plusk.at(last) = 0;
            if(i == N-1) plusk.at(last) = 1;
            la.at(a[i]) = i;
            visit.at(i) = first.at(a[i]);
        }
    }
    ll k = 0;
    ll index = -1;
    while(index != 0){
        if(index == -1) index = 0;
        k += plusk.at(index);
        if(index == N-1 && visit.at(index) == N-1){
            k += 1;
        }
        index = (visit.at(index)+1)%N;
        //cout<<"index"<<index<<' '<<k<<endl;
    }

    /*cout<<k<<endl;
    cout<<visit.at(N-1)<<endl;
    cout<<first.at(3)<<endl;*/

    K %= k;
    index = k = 0;
    ll lindex = 0;
    if(K == 0){

        cout<<endl;

        return 0;
    }
    while(K > k){
        lindex = index;
        k += plusk.at(index);
        if(index == N-1 && visit.at(index) == N-1){
            k += 1;
        }
        index = (visit.at(index)+1)%N;
    }

    //rep(i,N) cout<<plusk.at(i)<<endl;
    //cout<<k<<endl;


    vec s(200010,0);
    ll num = 0; //1;
    reps(i,lindex,N){
        ll newa = a[i];
        if(inset.at(newa) == -1){
            //cout<<"if"<<newa<<endl;
            s.at(num) = newa;
            inset.at(newa) = num;
            ++num;
        }else{
            ll temp = inset.at(newa);
            for(int j = num-1;j >= inset.at(newa); --j){
                //if(j == -1) cout<<i<<' '<<j<<endl;
                inset.at(s.at(j)) = -1;
                if(s.at(j) == newa) break;
            }
            num = temp;
            //cout<<temp<<' '<<i<<endl;
        }
    }
    rep(i,num){
        cout<<s.at(i)<<' ';
    }
    cout<<endl;
}


Measured memory_bytes: 12416
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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


signed main(void) {
    string s;
    cin >> s;
    char c[7][10] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    int ans;
    rep(i,7)if(s == c[i]){
        ans = 7-i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 888
#include <iostream>

 

using namespace std;

 

int main() 
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x-r >= 0 && y-r >=0 && x+r <=w && y+r <= h )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
typedef pair<int, pair<int, int>> PII;
typedef pair<ll, pair<ll, ll>> PLL;
#define endl '\n'
#define INF 2e9
#define LINF 2e15
#define MOD 1000000007

ll a, b, c, d, ans;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	cin >> a >> b >> c >> d;
	cout << max(a * c, max(a * d, max(b * c, b * d))) << endl;
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N;
  cin >> N;
  vector<int> A(N + 2, 0);
  for (int i = 1; i <= N; ++i) {
    cin >> A[i];
  }
  int sum = 0;
  for (int i = 0; i <= N; ++i) {
    sum += abs(A[i] - A[i + 1]);
  }

  for (int i = 1; i <= N; ++i) {
    int ans = sum + abs(A[i - 1] - A[i + 1]) - (abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1]));
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <deque>
#include <utility>
#include <bitset>
#include <limits.h>
#include <time.h>
#include <functional>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int N_ = 100500;

int N;
int freq[N_];
int A[N_];
const ll MOD = (ll)1e9 + 7;
vector<int> can[N_];
ll fac[N_];

int main() {
  scanf("%d", &N);

  fac[0] = 1;
  for(int i = 1; i <= N; i++) {
    int l = i - 1, r = N - i;
    can[abs(l - r)].push_back(i);
    fac[i] = (fac[i-1] * i) % MOD;
  }

  for(int i = 1; i <= N; i++) {
    int a; scanf("%d", &a);
    freq[a]++;
  }

  ll ans = 1;
  for(int c = 0; c <= N; c++) {
    if(can[c].size() != freq[c]) return 0 & puts("0");
    (ans *= fac[can[c].size()]) %= MOD;
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 5376
//abc156_c.cpp
//Sat Feb 22 20:51:54 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

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

	ll ans = LLINF;
	for (int i=1;i<=100;i++){
		ll temp = 0;
		for (int j=0;j<n;j++){
			temp+=(x[j]-i)*(x[j]-i);
		}
		ans = min(temp,ans);
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
N = int(input())
i = 1
while 1:
    if i * (i-1) // 2 < N and N <= i * (i+1) // 2:
        max_ans = i
        break
    else:
        i += 1
not_use = max_ans * (max_ans+1) // 2 - N
for i in range(1, max_ans+1, 1):
    if i != not_use:
        print(i)

Measured memory_bytes: 3316
def main():
    N = int(input())
    X = list(map(int, input().split()))
    X.sort()
    m = 10 ** 100
    for i in range(1, X[-1]+1):
        t = 0
        for j in X:
            t += (j - i)**2
        m = min(t, m)
    print(m)
main()


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
bool safe(int x,int y){
  if(x<0||x>9) return false;
  if(y<0||y>9) return false;
  else return true;
}
int main(){
  int x,y,n,xy[10][10],memxy[10][10];
  while(cin>>x>>y){
    if(x==0&&y==0) break;
    cin >> n;
    int dx[n],dy[n];
    for(int i=0;i<n;i++) cin >> dx[i] >> dy[i];
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++){
	xy[i][j] = -1;
	memxy[i][j] = 0;
      }
    }
    for(int i=-1;i<=1;i++){
      if(safe(x+2,y+i)) xy[x+2][y+i] = 0;
      if(safe(x-2,y+i)) xy[x-2][y+i] = 0;
      if(safe(x+i,y+2)) xy[x+i][y+2] = 0;
      if(safe(x+i,y-2)) xy[x+i][y-2] = 0;
    }
    for(int i=0;i<n;i++){
      for(int j=-1;j<=1;j++){
	for(int k=-1;k<=1;k++){
	  if(safe(dx[i]+j,dy[i]+k)){
	    if(xy[dx[i]+j][dy[i]+k]==i){
	      for(int l=-1;l<=1;l++){
		if(safe(dx[i]+j+2,dy[i]+k+l)) memxy[dx[i]+j+2][dy[i]+k+l] = i+1;
		if(safe(dx[i]+j-2,dy[i]+k+l)) memxy[dx[i]+j-2][dy[i]+k+l] = i+1;
		if(safe(dx[i]+j+l,dy[i]+k+2)) memxy[dx[i]+j+l][dy[i]+k+2] = i+1;
		if(safe(dx[i]+j+l,dy[i]+k-2)) memxy[dx[i]+j+l][dy[i]+k-2] = i+1;
	      }
	    }
	  }
	}
      }
      for(int j=0;j<10;j++){
	for(int k=0;k<10;k++) xy[k][j] = memxy[k][j];
      }
    }
    bool ok = false;
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++) if(xy[i][j]==n) ok = true;
    }
    if(ok) cout << "OK" << endl;
    else cout << "NA" << endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)

void solve();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

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

void solve() {
    ll n;
    cin >> n;
    ll highest = 0;
    ll tall;
    ll sum = 0;
    rep(i, n) {
        cin >> tall;
        if (highest < tall) {
            highest = tall;
        }else {
            sum += highest - tall; 
        }
    }
    cout << sum << "\n";
}


Measured memory_bytes: 3580
import numpy as np
w,h,n=map(int,input().split())
ans=np.ones((h,w),dtype=np.int)
for _ in range(n):
    x,y,a=map(int,input().split())
    if a == 1:
        ans[:,:x]=0
    elif a == 2:
        ans[:,x:]=0
    elif a ==3:
        ans[:y,:]=0
    else:
        ans[y:,:]=0
print(np.count_nonzero(ans))



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

using namespace std;


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

    int n;
    cin >> n;
    long long a[n + 1];
    long long pos[n + 1];
    long long sum[n + 1];
    long long xor_sum[n + 1];
    a[0] = 0;
    pos[0] = 0;
    sum[0] = 0;
    xor_sum[0] = 0;

    long long val;
    long long prev = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> val;
        pos[i] = prev;
        if (val) {
            prev = i;
        }
        // scanf("%lli", &val);
        a[i] = val;
        sum[i] = sum[i - 1] + val;
        xor_sum[i] = xor_sum[i - 1] ^ val;
    }

    long long cnt = 0;
            
    for (int i = 1; i <= n; ++i) {
        for (int j =1; j <= i; ++j) {
            if (j  > 2 && pos[i - j + 2] != i - j + 1) {
                long long diff = (i - j + 1) - pos[i - j + 1];
                cnt += diff;
                j +=  diff - 1;
                continue;
            }
            long long sum_diff = sum[i] - sum[i - j];
            long long xor_sum_diff = xor_sum[i] ^ xor_sum[i - j];
            if (sum_diff != xor_sum_diff) break;
            // cnt += sum_diff == xor_sum_diff;
            cnt ++;
            // if (xor_sum_diff < sum_diff) break;
        }
    }

    cout << cnt << '\n';

    return 0;
}


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

int main() {
  string S;
  cin >> S;

  bool t=true;
  int num;

  for(char c='a';c<='z';c++) {
    num=0;
    for(int i=0;i<S.size();i++) {
      if(S.at(i)==c) num++;
      if(num==2) t=false;
    }
  }
  if(t) cout << "yes" << endl;
  else cout << "no" << endl;
}


Measured memory_bytes: 256
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn main() {
    scan!(n; i32);
    scan!(blocks; Vec<i32>);

    let mut t = 1;

    let s = blocks.iter().filter(|&&i| {
        if i == t {
            t += 1;
            true
        } else {
            false
        }
    }).collect::<Vec<_>>().len() as i32;

    let res = n - s;
    println!("{}", if res < n {res} else {-1});
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i=0; i<N; i++){
      cin >> vec[i];
    }
    int k = 0;
    for(int i=0; i<N; i++){
        if(vec[i] == 1){
            k++;
        }
    }
    if(k == 0){
        cout << -1;
    }
    else{
        int p = 1;
        int count = 0;
        for(int i=0; i<N; i++){
            if(vec[i] != p){
                count++;
            }
            else{
                p++;
            }
        }
        cout << count;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  int cnt = 0;
  int scr[H][W];
  int ssp[H][W];
  int p = 0;
  
  for(int i = 0;i<H;i++){
    for(int k = 0;k<W;k++){
      cin >> scr[i][k];
      ssp[i][k] = scr[i][k];
    }
  }
  for(int i = 0;i<H;i++){
    for(int k = 0;k<W;k++){
      if(scr[i][k] % 2 == 1){
        if(i+1 < H){
          scr[i][k]--;
          scr[i+1][k]++;
          cnt++;
        }
      }
      if(scr[i][k] % 2 == 1){
        if(k+1 < W){
          scr[i][k]--;
          scr[i][k+1] += 1;
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
  for(int i = 0;i<H;i++){
    for(int k = 0;k<W;k++){
      if(ssp[i][k] % 2 == 1){
        if(i+1 < H){
          cout << i+1 << " " << k+1 << " " << i+2 << " " << k+1 << endl;
          ssp[i][k] --;
          ssp[i+1][k] += 1;
        }
      }
      if(ssp[i][k] % 2 == 1){
        if(k+1 < W ){
          cout << i+1 << " " << k+1 << " " << i+1 << " " << k+2 << endl;
          ssp[i][k]--;
          ssp[i][k+1] += 1;
        }
      }
    }
  }
  return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define mod 1000000007

int n;
int dp[100010];

int main(){
  cin>>n;
  rep(i,100001)dp[i]=INF;
  dp[0]=0;
  rep(i,n){
    for(int j=1;i+j<=n;j*=6)minch(dp[i+j],dp[i]+1);
    for(int j=1;i+j<=n;j*=9)minch(dp[i+j],dp[i]+1);
  }
  cout<<dp[n]<<endl;
  return 0;
}


Measured memory_bytes: 640
H, W = map(int, input().split())
grid = [list(input()) for _ in range(H)]
for h in range(H):
    for w in range(W):
        if grid[h][w] == "#":
            for dh, dw in ((1, 0), (-1, 0), (0, 1), (0, -1)):
                next_h, next_w = h + dh, w + dw
                if -1 < next_h < H and -1 < next_w < W:
                    if grid[next_h][next_w] == "#":
                        break
            else:
                print("No")
                exit()
else:
    print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;



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

    int N,K;
    cin >> N >> K;
    int A[N];
    int m[N]={};
    rep(i,N){
        cin >> A[i];
        m[A[i]]--;
    }
    int ans=0;
    int count=0;
    sort(m,m+N);
    rep(i,N){
        count++;
        ans+=m[i];
        if(count==K) break;
    }
    ans=N+ans;
    cout << ans << endl;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  ll n; cin >> n;
  string s; cin >> s;
  V a(n);
  rep(i, n) a[i] = s[i] - '1';

  int sum = 0;
  rep(i, n) {
    sum += (n-1 == (i | (n-1-i))) ? a[i] : 0;
    sum %= 2;
  }
  if (sum == 1) {
    cout << 1 << endl;
    return 0;
  }

  bool exists1 = false;
  rep(i, n) if (a[i] == 1) exists1 = true;
  if (exists1) {
    cout << 0 << endl;
    return 0;
  }

  rep(i, n) a[i] /= 2;
  sum = 0;
  rep(i, n) {
    sum += (n-1 == (i | (n-1-i))) ? a[i] : 0;
    sum %= 2;
  }
  if (sum == 1) {
    cout << 2 << endl;
    return 0;
  }
  else {
    cout << 0 << endl;
    return 0;
  }
}


Measured memory_bytes: 5252
n,k,q = map(int, input().split())
b = []
for i in range(n):
    b.append(0)
for i in range(q):
    a = int(input())
    b[a-1] += 1
for i in range(n):
    if b[i] > q - k:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4620
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>

using namespace std;

int main(){
	int n, m,o;
	list<int> A,B;
	while (cin >> n >> m){
		if (n == 0 && m == 0){
			break;
		}
		for (size_t i = 0; i < n; i++)
		{
			cin >> o;
			A.push_back(o);
		}
		for (size_t i = 0; i < m; i++)
		{
			cin >> o;
			B.push_back(o);
		}
		A.sort();
		B.sort();
		int A_sum = 0, B_sum = 0;
		for (auto e : A){
			A_sum += e;
		}
		for (auto e : B){
			B_sum += e;
		}
		//cout << A_sum << " " << B_sum << endl;
		A_sum -= B_sum;
		int x=A.front(), y=B.front();
		A.pop_front();
		B.pop_front();
		bool f = 1;
		while (1){
			if ((x - y)*2 == A_sum){
				cout << x << " " << y << endl;
				f = 0;
				break;
			}
			else if ((x - y)*2 < A_sum ){
				if (A.empty()){
					break;
				}
				x = A.front();
				A.pop_front();
			}
			else if ((x - y)*2 > A_sum){
				if (B.empty()){
					break;
				}
				y = B.front();
				B.pop_front();
			}
			//cout << x << " " << y << endl;

		}
		if (f){
			cout << "-1" << endl;
		}
		A.clear();
		B.clear();
	}
}

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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
	string t;
	cin >> t;
	int c = 0;
	vector<string>  vec = {"Sunny","Cloudy","Rainy"};
	REP(i,3) if (vec[i] == t ) c = (i+1)%3;
  cout << vec[c] << endl;
}


Measured memory_bytes: 3532
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN = 105;

int n, l[MAXN], s[MAXN], tot[MAXN], m, ans;

bool check(int x, int y, int z) {
	if (l[x] != l[y] && l[x] != l[z] && l[z] != l[y] && l[x] + l[y] > l[z] && l[x] + l[z] > l[y] && l[z] + l[y] > l[x]) return 1;
	else return 0;
}

int main() {
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf ("%d", &l[i]);
	} 
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			for (int k = j + 1; k <= n; k++) {
				if (check(i, j, k)) ans ++;
			}
		}
	}
	printf ("%d\n", ans);
	return 0;
}

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)

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

    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    cout << s << endl;

    return 0;
}



Measured memory_bytes: 3124
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
 
int main(){
    
long long a, b, c, k, result;
cin >> a >> b >> c >>k;
int s_len, t_len;
  if(a>=k){
    result=k;
  }else if(a+b>=k){
    result = a;
  }else{
    result = a-(k-a-b);
  }
  
cout << result << endl;
}

Measured memory_bytes: 3636
def solve():
    a, s = read()
    result = think(a, s)
    write(result)


def read():
    a = read_int(1)[0]
    s = read_line()
    return a, s


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a, s):
    if a >= 3200:
        return s
    else:
        return 'red'


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 38384
import java.lang.Math.max

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    val hs = arrayListOf<List<Int>>()

    for (i in 0 until n) {
        val li = readLine()!!.split(" ").map(String::toInt)
        hs.add(li)
    }

    val dp = Array(n + 1) { arrayOf(0L, 0L, 0L) }

    for (i in 1 until dp.size) {
        if (i == 0)
            continue
        for (j in 0..2) {
            for (k in 0..2) {
                if (j == k)
                    continue
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + hs[i - 1][j])
            }
        }
    }

    println(dp.last().max())

}


Measured memory_bytes: 95516