akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#define ll long long
using namespace std;
ll k[100004];
int main()
{
 	ll n;
 	ll m;
 	ll y=0;
	 ll ans=1e9;
 	scanf("%lld%lld",&n,&m);
	ll p=m;
 	for(ll i=1;i<=n;i++)
 	{
 		scanf("%lld",&k[i]);
	}
	sort(k+1,k+n+1);
	for(ll i=1;i<=n-m+1;i++)
	{
		ans=min(k[p]-k[i],ans);
		p=p+1;
	}
	printf("%lld\n",ans);
	return 0;
}
//int main()
//{
//    int n, k;
//    scanf("%d %d", &n, &k);
//    int h[100005];
//    for(int i = 1; i <=n; i++)
//        scanf("%d", &h[i]);
//    sort(h+1, h + n+1);
//    int ans = 1e9;
//    for(int i = 1; i <= n - k+1; i++)
//        ans = min(ans, h[i+k-1] - h[i]);
//    printf("%d\n", ans);
//    return 0;
//}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
using ll = long long;
const int N = 2e6 + 15;
int main(){
	ll P = 100;
	ll X;
	cin >> X;
	ll ans;
	for (ll i = 1; ; ++i) {
		ll cur = P + P/100;
		if (cur >= X) {
			ans = i;
			break;
		}
		P = cur;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define mp make_pair
#define F first
#define S second
const int maxN = 2e5 + 10;

int n;
int p[maxN];

struct Tree{
  vector< pii > maxvt;
  vector< pii > minvt;
  int n;

  Tree(int _n = 0) : n(_n) {
    maxvt.resize(n * 4);
    fill(maxvt.begin(), maxvt.end(), mp(0, 0));

    minvt.resize(n * 4);
    fill(minvt.begin(), minvt.end(), mp(n+1, n+1));
  }

  pii getMax(pii L, pii R) {
    pair<int, int> ret;
    if (L.F == R.F) {
      return mp(L.F, R.F);
    }
    if (L.F < R.F) {
      ret.F = R.F;
      if (L.F > R.S) {
        ret.S = L.F;
      } else {
        ret.S = R.S;
      }
    } else {
      ret.F = L.F;
      if (R.F > L.S) {
        ret.S = R.F;
      } else {
        ret.S = L.S;
      }
    }
    return ret;
  }

  pii getMin(pii L, pii R) {
    pair<int, int> ret;
    if (L.F == R.F) {
      return mp(L.F, R.F);
    }
    if (L.F > R.F) {
      ret.F = R.F;
      if (L.F < R.S) {
        ret.S = L.F;
      } else {
        ret.S = R.S;
      }
    } else {
      ret.F = L.F;
      if (R.F < L.S) {
        ret.S = R.F;
      } else {
        ret.S = L.S;
      }
    }
    return ret;
  }

  void update(int u, int v, int id, int vt, int delta, int type) {
    if (u > vt || v < vt) return;

    if (u == vt && v == vt) {
      if (type == 0) {
        maxvt[id].F = delta;
      } else {
        minvt[id].F = delta;
      }
      return;
    }

    int mid = (u + v) / 2;
    update(u, mid, id * 2, vt, delta, type); update(mid + 1, v, id * 2 + 1, vt, delta, type);

    if (type == 0) {
      maxvt[id] = getMax(maxvt[id*2], maxvt[id*2+1]);
    } else {
      minvt[id] = getMin(minvt[id*2], minvt[id*2+1]);
    }
  }

  pii get(int u, int v, int id, int l, int r, int type) {
    if (u > r || v < l) {
      if (type == 0) return mp(0, 0);
      return mp(n+1,n+1);
    }
    if (l <= u && v <= r) {
      if (type == 0) return maxvt[id];
      return minvt[id];
    }
    int mid = (u + v) / 2;
    if (type == 0) {
      return getMax(get(u, mid, id * 2, l, r, 0) , get(mid + 1, v, id * 2 + 1, l, r, 0));
    }
    return getMin(get(u, mid, id * 2, l, r, 1) , get(mid + 1, v, id * 2 + 1, l, r, 1));
  }

};

pii l[maxN], r[maxN];

int main(){
  ios_base::sync_with_stdio(0); cin.tie(NULL);
//  freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
  }
  Tree node(n);

  for (int i = 1; i <= n; ++i) {
    if (p[i] != n) l[i] = node.get(1, n, 1, p[i] + 1, n, 0);
    node.update(1, n, 1, p[i], i, 0);
  }

  for (int i = n; i > 0; --i) {
    if (p[i] != n) r[i] = node.get(1, n, 1, p[i] + 1, n, 1);
    node.update(1, n, 1, p[i], i, 1);
  }
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (p[i] == n) continue;
    int lenL = i - l[i].F, lenR = r[i].F - i;
    int lenL2 = l[i].F - l[i].S, lenR2 = r[i].S - r[i].F;
    ans = ans + 1ll * p[i] * (1ll * lenL * lenR2 + 1ll * lenR * lenL2);
  }
  cout << ans;
return 0;
}


Measured memory_bytes: 11332
sealed class ImmutableList<out T>{
    data class Cons<T>(val head:T, val tail: ImmutableList<T>): ImmutableList<T>()
    object Nil: ImmutableList<Nothing>()
}
class UnionFindTree{
    private var mParent: UnionFindTree? = null
    private var mSize = 1
    val size: Int
        get() = parent().mSize
    private fun parent(): UnionFindTree {
        mParent = mParent?.parent()
        return mParent ?: this
    }
    private fun isSameUnion(that:UnionFindTree): Boolean{
        return parent() == that.parent()
    }
    fun union(that:UnionFindTree): Unit {
        if (!isSameUnion(that)){
            that.parent().mSize += this.parent().mSize
            parent().mParent = that
        }
    }
}
class Paper(val width:Int, val height:Int){
    private val mArray = Array(height){Array(width){ UnionFindTree()}}
    private var mTop = 0
    private var mBottom= height - 1
    private var mLeft = 0
    private var mRight = width - 1
    private var mIsVerticalFlipped = false
    private var mIsHorizontalFlipped = false
    fun foldHorizontal(cutPos: Int): Unit {
        val line = if (mIsVerticalFlipped) mBottom - cutPos else mTop + cutPos - 1
        val size = if (line - mTop + 1 >= mBottom - line) mBottom - line else line - mTop + 1
        for (dy in 0 until size){
            for (x in mLeft .. mRight) {
                mArray[line - dy][x].union(mArray[line + dy + 1][x])
            }
        }
        if (line - mTop + 1 >= mBottom - line){
            if (!mIsVerticalFlipped) mIsVerticalFlipped = true
            mBottom = line
        }else {
            if (mIsVerticalFlipped) mIsVerticalFlipped = false
            mTop = line + 1
        }
    }
    fun foldVertical(cutPos: Int): Unit {
        val line = if (mIsHorizontalFlipped)  mRight - cutPos else mLeft + cutPos - 1
        val size = if (line - mLeft + 1 >= mRight - line) mRight - line else line - mLeft + 1
        for (dx in 0 until size){
            for (y in mTop .. mBottom){
                mArray[y][line - dx].union(mArray[y][line + dx + 1])
            }
        }
        if (line - mLeft + 1 >= mRight - line){
            if (!mIsHorizontalFlipped) mIsHorizontalFlipped = true
            mRight = line
        }else{
            if (mIsHorizontalFlipped) mIsHorizontalFlipped = false
            mLeft = line + 1
        }
    }
    fun holeCount(x: Int, y: Int): Int {
        val xPos = if (mIsHorizontalFlipped) mRight - x else mLeft + x
        val yPos = if (mIsVerticalFlipped) mBottom - y else mTop + y
        return mArray[yPos][xPos].size
    }
}
fun main(args:Array<String>){
    while (true){
        val (n, m, t, p) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0 && m == 0 && t == 0 && p == 0) return
        val paper = Paper(n, m)
        repeat(t){
            val (d, c) = readLine()!!.trim().split(' ').map(String::toInt)
            when(d){
                1 -> paper.foldVertical(c)
                else -> paper.foldHorizontal(c)
            }
        }
        repeat(p){
            val (x, y) = readLine()!!.trim().split(' ').map(String::toInt)
            println(paper.holeCount(x, y))
        }
    }
}


Measured memory_bytes: 33712
N,M = map(int,input().split())
H = list(map(int,input().split()))
L = [0] * N
for _ in range(M):
    a,b = map(int,input().split())
    if H[a-1] > H[b-1]:
        L[b-1] += 1
    elif H[a-1] < H[b-1]:
        L[a-1] += 1
    else:
        L[a-1] += 1
        L[b-1] += 1
ans = L.count(0)
print(ans)

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

using namespace std;

vector<bool> V(10, false);
//二進数に変換
void change(int n, vector<bool> &V){
  int i = 0;
  while(n > 0){
    int x;
    x = n%2;
    V[i] = x;
    n /= 2;
    i++;
  }
}

int main(){
  int N;
  cin >> N;
  int ans = -10000000000;
  
  vector<vector<bool>> inf(100, vector<bool> (10, false));
  rep(i, N){
    rep(j, 10){
      int F;
      cin >> F;
      if(F == 1){
        inf[i][j] = true;
      }
    }
  }
  
  vector<vector<int>> benefit(N, vector<int> (11));
  rep(i, N){
    rep(j, 11){
      int P;
      cin >> P;
      benefit[i][j] = P;
    }
  }
  
  for(int i = 1; i < 1024; i++){//営業時間を決める
    vector<bool> V(10, false);//初期化
    change(i, V);
    //チェック
     //rep(i, 10){
       //cout << V[i];
   // }
    //cout << endl;
    
    int sum = 0;
    
    rep(j, N){//店を決める      
      //被っている回数を数える
      int counter = 0;
      rep(k, 10){
        if(V[k] == true && inf[j][k] == true){
          counter++;
        }
      }
     //cout << j << " " << counter << endl;//テスト
      
      //cout << benefit[j][counter] << endl;
      sum += benefit[j][counter];
    }
    
   //cout << sum << endl;//テスト
    
    ans = max(ans, sum);
  }
  
  cout << ans << endl;
}
       

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

//region Template
#include "ext/pb_ds/assoc_container.hpp"
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int MOD = 1000000007;

using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
void print() {}
template<typename T, typename... Args>
void print(T firstArg, Args... args) {
	#ifdef LOCAL
	cout << firstArg << "\t";
	print(args...);
	#endif
}
//endregion

/* Notes:
 * Farah </3
 */

const int MAXN = 1e5 + 6;
const int INF = 2e9;

int a[MAXN], b[MAXN];
int aa[MAXN], bb[MAXN];

int main() {
	#ifdef LOCAL
	setIn("in.txt");
	setOut("out.txt");
	#endif

	string s, t;
	cin >> s >> t;

	int q;
	cin >> q;

	for(int i = 1; i <= s.size(); i++){
		a[i] = a[i - 1] + (s[i - 1] == 'A');
		b[i] = b[i - 1] + (s[i - 1] == 'B');
	}
	for(int i = 1; i <= t.size(); i++){
		aa[i] = aa[i - 1] + (t[i - 1] == 'A');
		bb[i] = bb[i - 1] + (t[i - 1] == 'B');
	}
	for(int i = 0; i < q; i++){
		int x, y, xx, yy;
		cin >> x >> y >> xx >> yy;

		int af = a[y] - a[x - 1];
		int as = aa[yy] - aa[xx - 1];
		int bf = b[y] - b[x - 1];
		int bs = bb[yy] - bb[xx - 1];

		int c = abs(af - as);

		if(c == 0){
			cout << (abs(bf - bs) % 3 == 0 ? "YES\n" : "NO\n");
			continue;
		}
		else{
			if(af > as){
				bf += c * 2;
			}
			else{
				bs += c * 2;
			}
			cout << (abs(bf - bs) % 3 == 0 ? "YES\n" : "NO\n");
			continue;
		}
	}
}


Measured memory_bytes: 2560
N = int(input())
st = []
for i in range(N):
    st.append(list(input().split()))
X = input()

start = False
ans = 0
for i in range(N):
    if start:
        ans += int(st[i][1])
    if X == st[i][0] and not(start):
        start = True

print(ans)

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
public class Main
{
    public static void main(String[] args) throws IOException{
    int sum = 0;
    int n = 0;
    int i = 1;
    String s;
    int a = 0;
    int b = 0;
    int c = 0;
        while(i>0){
            BufferedReader x = new BufferedReader(new InputStreamReader(System.in));
            s = x.readLine();
            StringTokenizer st = new StringTokenizer(s," ");
            a = Integer.parseInt(st.nextToken());
            b = Integer.parseInt(st.nextToken());
            c = Integer.parseInt(st.nextToken());
            if(a >= 1 && a <= 10000 )
                i = -1;
            else if(b >= 1 && b <= 10000)
                i = -1;
            else if(c >= 1 && c <= 10000)
                i = -1;
            else if(a <= b)
                i = -1;
            else
                i = 1;
         }
         for(n=a; n<=b;n++){
            if(c%n == 0)
            sum++;
         }
         System.out.println(""+sum+"");
    }
}

Measured memory_bytes: 24404
n = gets.chomp.to_i
nums = gets.chomp.split(' ').map(&:to_i)

res = 0
(1..n-2).each do |i|
  res += 1 if (nums[i-1] < nums[i] && nums[i] < nums[i+1]) || (nums[i+1] < nums[i] && nums[i] < nums[i-1])
end

puts res

Measured memory_bytes: 1788
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int ans=0,i,n,m,a[110],sum=0;
  scanf("%d %d\n",&n,&m);
  for(i=0;i<n;i++){
    scanf("%d ",&a[i]);
    sum+=a[i];
    a[i]=a[i]*4*m;
  }
  for(i=0;i<n;i++){
    if(a[i]>=sum){
      ans++;
    }
  }
  if(ans>=m){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

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

int h, w, d;
string col = "RGBY";
vector<string> res;
vector<vector<int>> memo, ch;

void solve();
void dfs(int i, int j);

int main() {
  cin >> h >> w >> d;
  solve();
  for (auto s : res) cout << s << endl;
  return 0;
}

void solve() {
  memo.assign(h, vector<int>(w, -1));
  ch.assign(h, vector<int>(w, 0));
  // dfs(0, 0);
  res.resize(h);
  if (d & 1) {
    for (int i = 0; i < h; ++i)
      for (int j = 0; j < w; ++j) memo[i][j] = (i + j) & 1;
  } else if (d == 2) {
    for (int i = 0; i < h; ++i)
      for (int j = 0; j < w; ++j)
        memo[i][j] = (i & 1) * 2 + (((j / 2) ^ (i / 2)) & 1);
  } else {
    for (int i = -d; i < h + d; ++i)
      for (int j = -d; j < w + d; ++j)
        if ((i + j) % d == 0 && (i % (d / 2) == 0)) {
          int c = (i % d != 0) * 2 + ((((i + d) / d) ^ ((j + d) / d)) & 1);
          int pm[2] = {1, -1};
          for (int t = 0; t < 2; ++t) {
            int len = d, x = i, y = j;
            while (len) {
              for (int k = 0; k < len; ++k) {
                int ny = y + k;
                if (x >= 0 && x < h && ny >= 0 && ny < w) memo[x][ny] = c;
              }
              len -= 2;
              x += pm[t];
              ++y;
            }
          }
        }
  }
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j) res[i] += col[memo[i][j]];
}

void dfs(int i, int j) {
  if (i == h) {
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) cout << memo[i][j];
      cout << endl;
    }
    cout << endl;
    return;
  }
  auto change = [&](int c) {
    bool res = 1;
    int pm[2] = {1, -1};
    for (int px = 0; px < 2; ++px)
      for (int py = 0; py < 2; ++py)
        for (int dx = 0; dx <= d; ++dx) {
          int dy = d - dx;
          int nx = i + dx * pm[px], ny = j + dy * pm[py];
          if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
          ch[nx][ny] ^= 1 << c;
          if (ch[nx][ny] == 15 || memo[nx][ny] == c) res = 0;
        }
    return res;
  };
  for (int c = 0; c < 4; ++c)
    if (!(ch[i][j] >> c & 1)) {
      int nx = i, ny = j + 1;
      if (ny == w) {
        ny = 0;
        ++nx;
      }
      memo[i][j] = c;
      if (change(c)) dfs(nx, ny);
      change(c);
      memo[i][j] = -1;
    }
}

Measured memory_bytes: 6084
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  ll n, m;
  cin >> n >> m;
  cout << (2*n+4>m ? min(n,m/2) : (2*n+m)/4) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<numeric>
#include<limits.h>
#include<utility>
#include<cstdlib>
#define LP(i,n) for(int i=0;i<n;i++)
#define LPIN(n,a) for(int i=0;i<n;i++)cin >> a[i]
using namespace std;
 
int main(){
 int n;
 cin >> n;
 string v[n];
 int a[n];
 int num[n];
 for(int i=0;i<n;i++){
cin >> v[i];
cin >> a[i];
num[i] = i+1;
 }
 for(int i=0;i<n;i++){
   for(int j=0;j<n;j++){
   if(v[i] < v[j]){
     string temp;
     temp = v[i];
     v[i] = v[j];
     v[j] = temp;
     swap(a[i],a[j]);
     swap(num[i],num[j]);
   }
 }
 }
  for(int i=0;i<n;i++){
   for(int j=0;j<n;j++){
   if(v[i] == v[j] && a[i]   > a[j]){
     swap(a[i],a[j]);
     swap(num[i],num[j]);
   }
 }
  }
  for(int i=0;i<n;i++){
//cout << v[i] << " " << a[i] <<  " " << num[i] << endl;
cout << num[i] << endl;
  }
 return 0;
}

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

int main() {
  int a , b , c , d ;
  cin >> a >> b >> c >> d ;
  if (a+b == c+d )
    cout << "Balanced" << endl;
  if (a+b > c+d )
    cout << "Left" << endl;
  if (a+b < c+d )
    cout << "Right" << endl;
}


Measured memory_bytes: 256
import { readFileSync } from 'fs'

const check = (a: number, b: number) => {
  const aIsMonth = 1 <= a && a <= 12
  const bIsMonth = 1 <= b && b <= 12

  if (aIsMonth && bIsMonth) {
    return 'AMBIGUOUS'
  }
  else if (aIsMonth) {
    return 'MMYY'
  }
  else if (bIsMonth) {
    return 'YYMM'
  }
  else {
    return 'NA'
  }
}

function main(input: string) {
  const a = +input.slice(0, 2)
  const b = +input.slice(2)

  console.log(check(a, b))
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 7372
#include <stdio.h>
static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
      printf("%d", A[i]);
  }
  
  printf("\n");
}

int main(){
  int n, i, j,v;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);

  for(i=2;i<=n;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
    trace(A, n);
  }
   
  return 0;
}

Measured memory_bytes: 608
#include<stdio.h>/*selection sort(選択ソート)*/
#include<stdlib.h>

int sort(int *,int);
void swap(int *,int,int);
void print(int *,int,int);

int main(void){
	int i,time,*num,count;

	scanf("%d",&time);
	
	num=malloc(sizeof(int)*time);
	
	for(i=0;i<time;i++){
		scanf("%d",num+i);
	}
	count=sort(num,time);
	print(num,count,time);
	
	return 0;
}

int sort(int *num,int time){
	int i,j,min,keep,count=0;
	
	for(i=0;i<time-1;i++){
		min=*(num+i);
		for(j=i;j<time;j++){
			if(*(num+j) < min){
				min = *(num+j);
				keep = j;
			}
		}
		if(min != *(num+i)){
			swap(num,keep,i);
			count++;
		}
	}
	return count;
}

void swap(int *num,int keep,int i){
	int temp;
	temp = *(num+i);
	*(num+i) = *(num+keep);
	*(num+keep) = temp;
}

void print(int *num,int count,int time){	
	int i;
	
	for(i = 0 ;i < time; i++){
		printf("%d",*(num + i));
		if(i != (time - 1))/*最後の数字の後にスペースを入れないようにする*/
			printf(" ");
	}
	printf("\n%d\n",count);
}

Measured memory_bytes: 604
import java.util.Arrays;

public class Main {
  private static void solve() {
    int h = ni();
    int n = ni();
    long[] a = nal(n);

    if (h > Arrays.stream(a).sum()) {
      System.out.println("No");
    } else {
      System.out.println("Yes");
    }


  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 35236
#include<bits/stdc++.h>
#include<string>
#include<cctype>
#include<cmath> 
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
 
int main(){
 
  int N;
  cin >> N;

  if(N<2){
    cout << 1 << endl;
  }else if(N<4){
    cout << 2 << endl;
  }else if(N<8){
    cout << 4 << endl;
  }else if(N<16){
    cout << 8 << endl;
  }else if(N<32){
    cout << 16 << endl;
  }else if(N<64){
    cout << 32 << endl;
  }else if(N<=100){
    cout << 64 << endl;
  }



  return 0;
}



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

using namespace std;

#define ll long long
#define ld long double

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());

ll INF = (ll) 1e20;
int iINF = (int) 1e20;
ll mod = (ll) 1e9 + 7;

signed main() {
    ll n;
    cin >> n;
    vector<ll> dp(n + 100, 0);
    if (n < 3) {
        cout << 0;
        return 0;
    }
    dp[3] = 1;
    for (int i = 4; i <= n; ++i) {
        dp[i] = 1;
        for (int j = 3; j < i; ++j) {
            if (i - j >= 3) {
                dp[i] += dp[j];
                dp[i] %= mod;
            }
        }
    }
    cout << dp[n];
}

Measured memory_bytes: 3632
/*************************************************************************
	> File Name: pyramid.cpp
	> Author: wangyifan
	> Created Time: 2019年11月07日 星期四 08时33分17秒
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
#define REP(i,a,b) for(register int i = a;i <= b;++i)
using namespace std;
const int maxn = 1e6+10;
int a[maxn],b[maxn];
int ans,n,num;
inline int read(){
	int res = 0,tmp = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-')tmp = -1;ch = getchar();}
	while(ch >= '0' && ch <= '9')res = (res<<1)+(res<<3)+(ch^48),ch = getchar();
	return res*tmp;
}
inline bool check(int x){
	REP(i,1,num)b[i] = a[i]>x;
	REP(i,0,n-1){
		if((b[n+i] && b[n+i+1]) || (b[n-i] && b[n-i-1]))return false;
		if((!b[n+i] && !b[n+i+1]) || (!b[n-i] && !b[n-i-1]))return true;
	}
	return a[1] <= x;
}
int main(){
	n = read();
	num = (n<<1)-1;
	REP(i,1,num)a[i] = read();
	int l = 1,r = num;
	while(l < r){
		int mid = (l+r)>>1;
		if(check(mid))ans = mid,r = mid;
		else l = mid+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5120
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n=getint()
a=[getints() for _ in range(n)]
a=list(sorted(a,key=lambda s: s[1]))

now=0
ok=True
for i in range(n):
    now += a[i][0]
    if now > a[i][1]:
        ok = False

print("Yes" if ok else "No")


Measured memory_bytes: 55236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0LL);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    string s;  cin >> s;
    if(s.back()=='?') s.back() = 'D';
    REP(i, s.size()-1){
        if(s[i]=='P' && s[i+1]=='?') s[i+1] = 'D';
        else if(s[i]=='?') s[i]='D';
    }


    cout << s << endl;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    long long N,A=0,W=0,T=0,R=0;
    string s;
    cin >> N;
    for (long long i = 0; i < N; i++)
    {
        cin >> s;
        if(s=="AC"){
            A++;
        }else if(s=="WA"){
            W++;
        }else if(s=="TLE"){
            T++;
        }else{
            R++;
        }
    }
    cout << "AC x " << A << endl;
    cout << "WA x " << W << endl;
    cout << "TLE x " << T << endl;
    cout << "RE x " << R << endl;

    return 0;
}


Measured memory_bytes: 3656
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
string S;
inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
inline void smax(int &x,int y) {
	x=x<y?y:x;
}
inline void smin(int &x,int y) {
	x=x>y?y:x;
}
int n;
map<int,bool> mp;
int main() {
//	freopen("in.txt","r",stdin);
	mp.clear();
	n=read();
	for (register int i=1;i<=n;++i) {
		int x=read();
		if (!mp.count(x)) mp[x]=true;
		else {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}

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

int main() {
  int K, A, B; cin >> K >> A >> B;
  for (int i = A; i <= B; i++) {
    if (i % K == 0) { cout << "OK" << endl; return 0; }
  }
  cout << "NG" << endl;
}

Measured memory_bytes: 3612
n=int(input())
slist=[input() for i in range(n)]
m=int(input())
tlist=[input() for i in range(m)]
words = set(slist) | set(tlist)
ans=0
for i in words:
  l = slist.count(i) - tlist.count(i)
  ans = max(l,ans)
print(ans)

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

// #pragma comment(linker, "/STACK:16777216")

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define int ll
#define pii pair<int, int>
const int SZ = 1e5 + 4;
const double EPS = 1e-7;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

struct custom_hash {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return x + FIXED_RANDOM;
    }
};

string s;

void read() {
    cin >> s;
}

void solve() {
    int l = 0, r = s.size() - 1;
    int ans = 0;
    while (l < r) {
        if (s[l] != s[r]) {
            ++ans;
        }
        ++l, --r;
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    read();
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	int a,b,c,d,e,k;
	cin>>a>>b>>c>>d>>e>>k;
	if(e-a>k)cout<<":("<<endl;
	else cout<<"Yay!"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define SP <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
using namespace std;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vi> Graph;

//条件式 ? 真の場合の文 : 偽の場合の文
//abs(x) = (x の絶対値)
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l)l文字目から最後まで,
///S.substr(l, r)l文字目からl+r-1文字目 n文字目から0個で空列を返せる
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//char('0'+cnt) 数字cntからcharへの変換
//int(char-'0') charからintへの変換

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) {
        int k;
        cin >> k;
        k--;
        a.at(i) = k;
    }

    int cnt = 0;
    int now = 0;
    bool ok = false;
    rep(i,n){
        if(now == 1) {
            ok = true;
            break;
        }
        now = a.at(now);
        cnt++;
    }
    if(ok) cout << cnt << endl;
    else cout << -1 << endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
ll mpower(ll a,ll b,ll c){
  int z;
  if(b==0){
    z=1;
    z%=c;
    return z;
  }
  if(b==1){
    z=a;
    z%=c;
    return z;
  }
  else{
    return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
  }
}

int main() {
  int n;
  cin>>n;
  ll vec[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  if(vec[n-1]!=2){
    cout<<-1<<endl;
    return 0;
  }
  ll p=n;
  p*=1100000000;
  ll ng=1,ok=p;
  ll a,b;
  for(int j=0;j<200;j++){
    a=(ng+ok)/2;
    b=a;
    for(int i=0;i<n;i++){
      b=(b/vec[i])*vec[i];
    }
    if(b<2){
      ng=a;
    }
    else{
      ok=a;
    }
  }
  b=ok;
  for(int i=0;i<n;i++){
    b=(b/vec[i])*vec[i];
  }
  //cout<<ng<<ok<<endl;
  if(b!=2){
    cout<<-1<<endl;
    return 0;
  }
  cout<<ng+1<<" ";
  ok=p;
  for(int j=0;j<200;j++){
    a=(ng+ok)/2;
    b=a;
    for(int i=0;i<n;i++){
      b=(b/vec[i])*vec[i];
    }
    if(b<3){
      ng=a;
    }
    else{
      ok=a;
    }
  }
  cout<<ok-1<<endl;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if (a == b && b == c) {
		puts("Yes");
	} else {
		puts("No");
	}
	return 0;
}

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

bool check(int x){
    if(x<=1)return 0;
    for(int i=2;i<x;i++){
        if(x%i==0)return 0;
    }
    return 1;
}
int main(){
    int x;cin>>x;
    while(!check(x))x++;
    cout<<x<<endl;
}


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

int a[9000000];

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, L, key = -1;
	long long int p = 0;
	cin >> N >> L;
	for (int i = 0; i < N; i++) cin >> a[i];

	for (int i = 0; i < N - 1; i++) {
		if (L <= a[i] + a[i+1]) {
			p = a[i] + a[i+1];
			key = i;
			break;
		}
	}

//	cout << "key = " << key << endl;

	if (key == -1) {
		cout << "Impossible\n";
	} else {
		cout << "Possible\n";
		for (int i = 0; i < key; i++) cout << i+1 << endl;
		for (int i = N-1; i > key + 1; i--) cout << i << endl;
		cout << key + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF 1LL<<60

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; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int N;

    cin >> N;
    vector<vector<ll>> a(N, vector<ll>(N, 0));
    for(int i=0; i<N; i++) for(int j=0; j<N; j++) {
         cin >> a[i][j];
    }
    vector<ll> scores(1<<N, 0), dp(1<<N, 0);

    for(int i=0; i<N; i++)
        for(int j=0; j<N; j++) {
            scores[(1<<i)|(1<<j)] = a[i][j];
        }

    for(int i=0; i<(1<<N); i++){
        for(int j=0; j<N; j++) {
            if(i&(1<<j)) continue;
            scores[i|(1<<j)] = scores[i];
            for(int k=0; k<N; k++) {
                if((i&(1<<k)))
                    scores[i|(1<<j)] += a[k][j];
            }   
        }
        dp[i] = max(ll(0), scores[i]);
    }

    // for(int i=0; i<(1<<N); i++) cerr << "i: " << i << " scores[i] = " << scores[i] << endl; cerr << endl;

    ll opt = 0;
    // for(int i=0; i<(1<<N); i++) {
        // dp[i] = max(ll(0), scores[i]);
    // }

    for(int i=0; i<(1<<N); i++) {
        if(__builtin_popcount(i)<=2) continue;
        for (int y = 0; ; y = (y - i) & i) {
            dp[i] = max(dp[i], dp[y] + dp[i^y]);
            if(opt < dp[i]) opt = dp[i];
            if(y==i) break;
        }
    }

    // for(int i=0; i<(1<<N); i++) cerr << "i: " << i << " dp[i] = " << dp[i] << endl; cerr << endl;
    cout << opt << endl;
    return 0;
}

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

int main() {
  int H,W,K;
  cin >> H >> W >> K;
  vector<vector<int>>data(H,vector<int>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      char a;
      cin >> a;
      if(a=='.') data.at(i).at(j)=0;
      else data.at(i).at(j)=1;
    }
  }
  int count=0;
  for(int tmp=0;tmp<(1<<H+W);tmp++){
    int ans=0;
    for(int i=0;i<H;i++){
      if(tmp&(1<<i)){
        for(int j=H;j<H+W;j++){
          if(tmp&(1<<j)) ans+=data.at(i).at(j-H);
        }
      }
    }
    if(ans==K) count++;
  }
  cout << count << endl;
}

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

int main() {
  int a,b,m;
  cin >> a >> b >> m;
  vector<int> A(a);
  rep(i, a) cin >> A[i];
  vector<int> B(b);
  rep(i, b) cin >> B[i];
  
  vector<int> sum_v;
  priority_queue<int, vector<int>, greater<int>> que;
  rep(i,m) {
    int x, y, c;
    cin >> x >> y >> c;
    que.push(A[x-1] + B[y-1] - c);
  }
  int A_min = *min_element(A.begin(), A.end());
  int B_min = *min_element(B.begin(), B.end());
  que.push(A_min + B_min);
  
  cout << que.top() << endl;
    
  return 0;
}


Measured memory_bytes: 1660
[N, M] = [int(x) for x in input().split()]
list_all = []
for i in range(M):
	list_all.append([int(x) for x in input().split()])
	
list_mid = []
for i in range(M):
	if 1 in list_all[i]:
		list_mid.append(list_all[i][1])
	if N in list_all[i]:
		list_mid.append(list_all[i][0])

if len(list_mid) == len(set(list_mid)):
	print("IMPOSSIBLE")
else:
	print("POSSIBLE")
		

Measured memory_bytes: 50140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a, b;
  cin>>a>>b;
  if(b>a)swap(a, b);
  rep(i,a)cout<<b;
  cout<<endl;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    //vector<int> res;
    int cnt_p=0;
    int cnt_n=0;
    for(int i=a;i<=b;i++){
       // res.push_back(i);
       if(i==0){
           cout << "Zero" << endl;
           return 0;
       }else if(i>0){
           cnt_p++;
       }else{
           cnt_n++;
       }
    }
    if(cnt_n%2==0){
        cout << "Positive" << endl;
    }else{
        cout << "Negative" << endl;
    }

}

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

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

int main() {
  ll k, a, b, ans = 0;
  cin >> k >> a >> b;

  for (int i = a; i <= b; ++i) {
    if (i % k == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }

  cout << "NG" << endl;
  return 0;
}


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

using namespace std;

int main(){
   string s;
   cin >> s;
   bool N=false;
   bool W=false;
   bool S=false;
   bool E=false;
   for(int i=0;i<s.size();i++){
      if(s[i] == 'N')N=true;
      if(s[i] == 'W')W=true;
      if(s[i] == 'S')S=true;
      if(s[i] == 'E')E=true;
   }
   if(N==S && W==E)cout << "Yes" << endl;
   else cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 256
import pprint
n = int(input())
dp = [{} for i in range(n + 1)]
s = "AGCT"
M = 10 ** 9 + 7

for j in range(n + 1):
  for c1 in s:
    for c2 in s:
      for c3 in s:
        dp[j][c1 + c2 + c3] = 0

dp[0]["TTT"] = 1

for l in range(n):
  for c1 in s:
    for c2 in s:
      for c3 in s:
        for p in s:
          if c2 == "A" and c3 == "G" and p == "C":
            continue
          if c1 == "A" and c3 == "G" and p == "C":
            continue
          if c1 == "A" and c2 == "G" and p == "C":
            continue
          if c2 == "G" and c3 == "A" and p == "C":
            continue
          if c2 == "A" and c3 == "C" and p == "G":
            continue
          dp[l + 1][c2 + c3 + p] = (dp[l + 1][c2 + c3 + p] + dp[l][c1 + c2 + c3]) % M
          

ans = 0
for c1 in s:
  for c2 in s:
    for c3 in s:
      ans += dp[n][c1 + c2 + c3]
      ans = ans % M
print(ans)


Measured memory_bytes: 4468
using System;

namespace ITP1_8_B
{
    class Program
    {
        static void Main()
        {
            for (; ; )
            {
                char[] x = Console.ReadLine().ToCharArray();

                if (x[0] == '0') break;

                int sum = 0;

                for (int i = 0; i < x.Length; i++) sum += (int)Char.GetNumericValue(x[i]);

                Console.WriteLine(sum);
            }
        }
    }
}

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

int main()
{
        int m, f, r, i = 0;
        char ranks[50];

        while(1) {
                cin >> m >> f >> r;

                if(m==-1&&f==-1&&r==-1) break;

                if (m==-1 || f == -1) {
                        ranks[i++] = 'F';
                } else if((m+f)>= 80) {
                        ranks[i++] = 'A';
                } else if((m+f)>= 65 && (m+f)<80) {
                        ranks[i++] = 'B';
                } else if((m+f)>= 50 && (m+f)<65) {
                        ranks[i++] = 'C';
                } else if((m+f)>= 30 && (m+f)<50) {
                        if(r >= 50) {
                                ranks[i++] = 'C';
                        } else {
                                ranks[i++] = 'D';
                        }
                } else {
                        ranks[i++] = 'F';
                }
        };

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

        return 0;
}


Measured memory_bytes: 3084
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e17
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll lens,lent;
string s,t;
ll dp[3001][3001];
ll solve(ll i,ll j)
{
	if(j==lent)
	{
		return 0;
	}
	if(i==lens)
	{
		return 0;
	}
	if(dp[i][j]!=-1) return dp[i][j];
	ll ans1=0,ans2=0,ans3=0;
	if(s[i]==t[j])
	{
		ans1=1+solve(i+1,j+1);
	}
	ans2=solve(i,j+1);
	ans3=solve(i+1,j);
	//debug3(i,j,max(ans1,max(ans2,ans3)));
	return dp[i][j]=max(ans1,max(ans2,ans3));
}
int main()
{
	boost
	memset(dp,-1,sizeof(dp));
	cin>>s>>t;
	lens=s.length();
	lent=t.length();
	solve(0,0);
	ll anslen = dp[0][0];
	ll prev=0;
	string ans;
	for(ll i=0,j=0;i<lens&&j<lent;)
	{
		if(s[i]==t[j])
		{
			ans=ans+s[i];
			i++;
			j++;
		}
		else if(dp[i][j+1]>=dp[i+1][j+1]&&dp[i][j+1]>=dp[i+1][j])
		{
			j++;
		}
		else i++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 70912
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
const int N=1e5+3,inf=0x7fffffff;
int cnt,n,a[N],maxx,fail,minn=inf;
inline int read(){
	int num=0,flag=1;
	char c=getchar();
	for(;c<'0'||c>'9';c=getchar())
	if(c=='-') flag=-1;
	for(;c>='0'&&c<='9';c=getchar())
	num=(num<<3)+(num<<1)+c-48;
	return num*flag;
}
int main(){
	n=read();
	for(int i = 1;i<=n;i++){
		a[i]=read();
		if(a[i]>maxx) maxx=a[i],fail=i;
	}
	a[fail]=0;
	int mid=maxx/2;
	for(int i = 1;i<=n;i++){
		if(abs(a[i]-mid)<minn){
			minn=abs(a[i]-mid);
			cnt=a[i];
		}
	}
	printf("%d %d",maxx,cnt);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FORR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (e), i ## __begin = (b); i -- > i ## __begin;)
#define rep(i,n) for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)
#define ALL(x) begin (x), end (x)
#define dump(x) cerr << #x " = " << boolalpha << (x) << endl;
using namespace std;
template <typename T>
inline auto input () { T a; return cin >> a ? a : throw runtime_error ("no input"); }

template <typename T>
inline constexpr auto gcd (T m, T n) noexcept -> T
{
  return n == 0 ? abs (m) : gcd (n, m % n);
}

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

  auto n = input <size_t> ();
  vector <int> a (n);
  for (auto && elem : a) cin >> elem;

  vector <int> left (n, 0), right (n, 0);
  left [0] = a [0];
  right [n - 1] = a [n - 1];

  rep (i, n)
  {
    if (i == 0) continue;
    left [i] = gcd (left [i - 1], a [i]);
    right [n - 1 - i] = gcd (a [n - 1 - i], right [n - i]);
  }

  auto ans = 0;
  rep (i, n + 1)
  {
    auto l = 0;
    if (i > 0) l = left [i - 1];
    auto r = 0;
    if (i + 1 < n) r = right [i + 1];
    cerr << "d:" << l << " " << r << endl;
    auto t = gcd (l, r);
    ans = max (ans, t);
  }
  cout << ans << endl;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    string s[3];
    cin >> s[0] >> s[1] >> s[2];

    int turn = 0;
    vint id(3, 0);
    vint l(3);
    rep(i, 3) l[i] = s[i].length();
    while(1) {
        if (id[turn] == l[turn]) {
            if (turn == 0) puts("A");
            if (turn == 1) puts("B");
            if (turn == 2) puts("C");
            return 0;
        }
        
        char n = s[turn][id[turn]];

        id[turn]++;

        if (n == 'a') turn = 0;
        if (n == 'b') turn = 1;
        if (n == 'c') turn = 2;
    }
    return 0;
}

Measured memory_bytes: 256