akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#define ll long long
#define mem(f, x) memset(f, x, sizeof(f))
#define INF 0x3f3f3f3f
using namespace std;
const int M = 15;
const int N = 10005;
char s[N];
int main( ){
    while( scanf( "%s", s ) != EOF ){
        int len = strlen( s );
        int flag = 0;
        for( int i = 1; i < len; i++ )
            if( s[i-1] != s[i] ){
                flag = 1;
                break;
            }
        if( flag )
            printf( "Yes\n" );
        else
            printf( "No\n" );
    }
    return 0;
}


Measured memory_bytes: 256
A,B,K=map(int,input().split())
if A==B:
  print(A)
  exit()
if B-A<K:
  K=B-A
l=list()
for i in range(A,A+K):
  l.append(i)
for i in range(B-K+1,B+1):
  l.append(i)
l=set(l)
l=sorted(l)
for i in range(len(l)):
  print(l[i])

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

bool check(string S){
  int N;
  N = S.size();
  //cout <<N;
  int N2;
  N2 = N/2 + N%2;
  //cout <<S <<endl;
  bool flag = true;
  for (int i=0; i<N2; i++){
    //cout <<S.substr(i,1) <<" " <<S.substr(N-i-1,1) <<endl;
    string tmp1, tmp2;
    tmp1=S.substr(i,1);
    tmp2=S.substr(N-i-1,1);
    if( tmp1 != tmp2 ){
      flag = false;
      //cout <<"not!" <<endl;
    }
  }
  return flag;
}

int main() {
  string S;
  cin >>S;
  int N;
  N = S.size();
  //cout <<S.substr((N+3)/2);
  bool flag1 = check(S);
  bool flag2 = check(S.substr(0,(N-1)/2));
  bool flag3 = check(S.substr((N+1)/2));
  
  if (flag1 && flag2 && flag3){
    cout <<"Yes" <<endl;
  }else{
    cout <<"No" <<endl;
  }
}

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

using namespace std;

bool solve(int A, int B) {
  int dist[10][10];
  for (int i = 0; i < A; i++) {
    for (int j = 0; j < B; j++) {
      cin >> dist[i][j];
    }
  }

  int T = 101;
  vector<vector<int>> data(T, vector<int>(T, -1));
  for (int x = 0; x < T; x++) {
    for (int y = 0; y < T; y++) {
      for (int i = 0; i < A; i++)
        for (int j = 0; j < B; j++) {
          int basecost = 0;
          basecost += (i + 1) * x;
          basecost += (j + 1) * y;
          int amari = dist[i][j] - basecost;
          data[x][y] = max(data[x][y], amari);
        }
    }
  }

  int cnt = 0;
  vector<vector<int>> ans(A, vector<int>(B, 200));
  for (int x = 0; x < T; x++)
    for (int y = 0; y < T; y++) {
      // cout << x << " " << y << " " << data[x][y] << endl;
      if (data[x][y] < 0) continue;
      cnt++;
      for (int i = 0; i < A; i++)
        for (int j = 0; j < B; j++) {
          int cost = (i + 1) * x + (j + 1) * y + data[x][y];
          ans[i][j] = min(ans[i][j], cost);
        }
    }
  for (int i = 0; i < A; i++)
    for (int j = 0; j < B; j++)
      if (ans[i][j] != dist[i][j]) return false;

  cout << "Possible" << endl;
  cout << 2 * T + 1 << " " << 2 * T + cnt << endl;
  for (int i = 0; i < T; i++) {
    cout << i + 1 << " " << i + 2 << " X" << endl;
  }
  for (int i = 0; i < T; i++) {
    cout << i + T + 1 << " " << i + T + 2 << " Y" << endl;
  }
  int s = 1;
  int t = T + T + 1;

  for (int x = 0; x < T; x++) {
    for (int y = 0; y < T; y++) {
      if (data[x][y] < 0) continue;
      cout << s + x << " " << t - y << " " << data[x][y] << endl;
    }
  }
  cout << s << " " << t << endl;
  return true;
}
int main() {
  int A, B;
  cin >> A >> B;
  bool ok = solve(A, B);
  if (!ok) {
    cout << "Impossible" << endl;
  }

  return 0;
}

Measured memory_bytes: 384
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, L;

  cin >> N >> L;

  int sum = L * N + (N - 1) * N / 2;

  debug(sum);

  int ans = max(min(0, L + N - 1), L);

  cout << sum - ans << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		long k = long.Parse(input[1]);
		int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    int[] turns = new int[n];//それぞれの数のターン
    int a = 200001;
    List<int>[] positionList = new List<int>[a];
    for(int i = 0; i < a; i++) positionList[i] = new List<int>();
    int[] numsCount = new int[a];
    int[] numsNumber = new int[n];//それぞれの数は、何番目-1に出たものか

    for(int i = 0; i < n; i++)
    {
      positionList[nums[i]-1].Add(i);
      numsNumber[i] = numsCount[nums[i]-1];
      numsCount[nums[i]-1]++;
    }

    int lookingPosition = 0;
    int nowTurn = 1;
    while(true)
    {
      if(positionList[nums[lookingPosition]-1][positionList[nums[lookingPosition]-1].Count()-1]
        == lookingPosition)
      {
        nowTurn++;
        turns[lookingPosition] = nowTurn;
        lookingPosition = positionList[nums[lookingPosition]-1][0]+1;
        if(lookingPosition == n) break;
      }else
      {
        turns[lookingPosition] = nowTurn;
        lookingPosition 
          = positionList[nums[lookingPosition]-1][numsNumber[lookingPosition]+1]+1;
        if(lookingPosition == n) break;
      }
    }

    k %= nowTurn;
    if(k == 0) k += nowTurn;

    int leftPosition = 0;
    for(int i = 0; i < n; i++)
    {
      if(turns[i] == k)
      {
        if(numsNumber[i] != numsCount[nums[i]-1]-1)
        {
          leftPosition = Math.Max(leftPosition,positionList[nums[i]-1][numsNumber[i]+1]+1);
        }else leftPosition = Math.Max(leftPosition,positionList[nums[i]-1][0]+1);
      }
    }

    var stack = new Stack<int>();
    bool[] used = new bool[a];
    for(int i = leftPosition; i < n; i++)
    {
      if(!used[nums[i]])
      {
        stack.Push(nums[i]);
        used[nums[i]] = true;
      }else
      {
        while(true)
        {
          int topMemo = stack.Peek();
          used[topMemo] = false;
          stack.Pop();
          if(topMemo == nums[i]) break;
        }
      }
    }

    int aa = stack.Count;
    int[] answers = new int[aa];
    for(int i = 0; i < aa; i++)
    {
      int popMemo = stack.Peek();
      answers[aa-1-i] = popMemo;
      stack.Pop();
    }

    //Console.WriteLine(nowTurn+" "+turns[0]+" "+turns[1]+" "+turns[2]+" "+leftPosition);
		Console.WriteLine(string.Join(" ", answers));
	}
}

Measured memory_bytes: 58060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int INF = 2e9;
 
int main(){
    int a, p, ans=0;
    cin >> a >> p;
    ans = (a*3+p)/2;
    cout << ans << endl;
}

Measured memory_bytes: 256
A, B, K = input().split()
C = int(K)-int(A)
D = int(K)-int(B)

if(int(A)==0):
    if(int(B)==0):
        print(str(A) +" "+ str(B))
    else:
        if(D>=0):
            B = 0
        else:
            B = -D
        print(str(A) +" "+ str(B))
else:
    if(C >= 0):
        B = int(B)-C
        A = 0
        if(B<0):
            B = 0
    else:
        A = int(A)-int(K)
    print(str(A) +" "+ str(B))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }



int main(int argc, char const *argv[]) {
  ll n;
  cin >> n;
  ll ans = 0,cnt=1;
  while(n>0){
    n /= 2;
    ans += cnt;
    cnt *= 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int N, M;
vector<vector<int>> G;
vector<int> p;

void bfs() {
    queue<int> Q;
    Q.push(0);
    p[0] = 0;
    while (!Q.empty()) {
        auto q = Q.front(); Q.pop();
        for (auto g : G[q]) {
            if (p[g] != -1) continue;
            p[g] = q;
            Q.push(g);
        }
    }
}

int main() {
    cin >> N >> M;
    G.resize(N);
    REP(i, 0, M) {
        int a, b; cin >> a >> b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    p.resize(N, -1);
    bfs();
    cout << "Yes" << endl;
    REP(i, 1, N) cout << p[i] + 1 << endl;

    return 0;
}

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

int main(void)
{
    int N;
    cin >> N;

    int a[220000];
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    int A = 0;
    int x[220000]={};
    for(int i = 0; i < N; i++ ){
        A ^= a[i];
    }


    for(int i = 0; i < N; i++){
        x[i] = A ^ a[i];
    }


    for(int i = 0; i < N; i++){
        cout << x[i];
        if(i < N-1) cout << " ";
    }
    cout << endl;

}


Measured memory_bytes: 5180
import sys
sys.setrecursionlimit(100000000)
input = sys.stdin.readline

class SegmentTree():
    f = max
    unit = 0
   
    def __init__(self,array):
        self.N = len(array)
        self.tree = [self.unit] * (2*self.N)
        #self._build(array)
    
    def _build(self,array):
        for i,x in enumerate(array,self.N):
            self.tree[i] = x
        for i in range(self.N - 1,0,-1):
            self.tree[i] = self.f(self.tree[i << 1],self.tree[i << 1|1])
    
    def update(self,k,x):
        k += self.N
        self.tree[k] = x
        while k > 1:
            k >>= 1
            self.tree[k] = self.f(self.tree[k << 1],self.tree[k << 1|1])
    
    def query(self,l,r):
        l += self.N
        r += self.N
        vl = self.unit
        vr = self.unit
        while l < r:
            if l&1: 
                vl = self.f(vl,self.tree[l])
                l += 1
            if r&1:
                r -= 1
                vr = self.f(self.tree[r],vr)
            l >>= 1
            r >>= 1
        return self.f(vl,vr)
    
    def __str__(self):
        return '\n'.join(' '.join(str(v) for v in self.tree[1<<i:1<<(i + 1)]) for i in range((2*self.N).bit_length()))

N = int(input())
A = list(map(int,input().split()))
G = [[] for _ in range(N)]
for _ in range(N - 1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

B = sorted(list(set(A)))
M = len(B)
toID = {i:j for i,j  in zip(B,range(1,M + 1))}
dp = SegmentTree([0] * (M + 1))
ans = [0] * N
before = [0] * N

def dfs(v,p = -1):
    idx = toID[A[v]]
    a = dp.query(0,idx) + 1
    before[v] = dp.query(idx,idx + 1)
    flag = False
    if before[v] < a:
        flag = True
        dp.update(idx,a)
    before_max = dp.query(0,M + 1)
    ans[v] = max(before_max,a)
    for e in G[v]:
        if e == p:
            continue
        dfs(e,v)
    if flag:
        dp.update(idx,before[v])

dfs(0)
print('\n'.join(map(str,ans)))

Measured memory_bytes: 552304
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B, C; cin >> A >> B >> C;
  int res = B/A;
  int ans = min(res, C);
  cout << ans << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n;
  std::cin >> n;
  std::map<std::string, int> map;
  rep(i,n){
    std::string s;
    std::cin >> s;
    ++map[s];
  }

  int num = 0;
  for(auto it = map.begin(); it != map.end(); it++) {
    if(num < it -> second)
      num = it -> second;
  }

  for(auto it = map.begin(); it != map.end(); it++) {
      if(it -> second == num)
        std::cout << it -> first << '\n';
  }

  return 0;
}


Measured memory_bytes: 25216
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 105;

int i, n, d[N][2];

void solve()
{
    cin >> n;
    for (i = 1; i <= n; i++)
    {
        cin >> d[i][0] >> d[i][1];
    }
    for (i = 1; i + 2 <= n; i++)
    {
        if (d[i][0] == d[i][1] && d[i + 1][0] == d[i + 1][1] && d[i + 2][0] == d[i + 2][1])
        {
            cout << "Yes";
            return;
        }
    }
    cout << "No";
}

signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fastio;
    int t;
    //cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

struct info{
    int l, r, cnt;
    info(int l, int r, int cnt):l(l),r(r),cnt(cnt){}
    info(){}
};

signed main(){
    
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    a.push_back(-1);
    vector<info> v;

    int l = 0;
    for(int r = 1; r <= n; r++){
        if(a[r] == a[r - 1] || a[r] == -1){
            v.push_back(info(a[l], a[r - 1], r - l));
            //cout << a[l] << " " << a[r - 1] << " " << r - l << endl;
            l = r;
        }
    }

    int ans = 0;
    for(int i = 0; i < (int)v.size(); i++){
        if(i == 0 && i == (int)v.size() - 1) ans = v[i].cnt;
        else if(i == 0) ans = max(ans, v[i].cnt + v[i + 1].cnt);
        else if(i == (int)v.size() - 1) ans = max(ans, v[i].cnt + v[i - 1].cnt);
        else ans = max(ans, v[i].cnt + v[i + 1].cnt + v[i - 1].cnt);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5796
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;

struct edge{
	int to;
	int cost;
};

vector<edge> graph[100010];
int come[100010];
struct edge e;

int search(int x){
	int i;

	come[x]=1;

	for(i=0;i<graph[x].size();i++){
		e=graph[x][i];
		if(come[e.to]==-1){
			search(e.to);
		}
	}

	return 0;
}

int main(void)
{
	//変数の宣言
	int n,m;
	int x,y,z;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;



	//データの読み込み


	scanf("%d %d",&n,&m);
//	scanf_s("%d %d",&n,&m);

//	scanf("%s",&s);
//	scanf_s("%s",&s,5);


	for(i=0;i<m;i++){
      	scanf("%d %d %d",&x,&y,&z);
//		scanf_s("%d %d %d",&x,&y,&z);
		e.to=y;
		e.cost=z;
		graph[x].push_back(e);
		e.to=x;
		graph[y].push_back(e);
	}

	for(i=1;i<=n;i++){
		come[i]=-1;
	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	for(i=1;i<=n;i++){
		if(come[i]==-1){
			ans++;
			search(i);
		}
	}

	//	printf("計算部分終了\n");

	//出力
	printf("%d",ans);


	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 9216
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string str; cin >> str;
if(str == "Sunny") cout << "Cloudy";
else if(str == "Cloudy") cout << "Rainy";
else if(str == "Rainy") cout << "Sunny";
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    vvint ct(2,vint(n,0));
    REP(i,n+1) {
        rep(j,2) ct[j][i] = ct[j][i-1];
        if (s[i-1] == 'W') ct[0][i]++;
        if (s[i-1] == 'E') ct[1][i]++;
    }
    int ans = inf;
    rep(i,n) {
        ans = min(ans,ct[0][i]+(ct[1][n]-ct[1][i+1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4228
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif

#define forn(i,k,n) for(ll i=(k); i<(n); i++)

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

const int INF = 1e9;

/* knapsack */
void solve() {
	cini(h);
	cini(n);
	vd a(n);
	vd b(n);

	vi dp(20002, INF);	// dp[i]=min cost to reach damage i (or higher)
	vector<pii> ab(n);
	for (int i = 0; i < n; i++) {
		cin >> ab[i].second >> ab[i].first;
	}
	///sort(ab.begin(), ab.end());	// sort by cost

	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < h; j++) {
			dp[j + ab[i].second] = min(dp[j + ab[i].second], dp[j] + ab[i].first);
		}
	}
	int ans = INF;
	for (int i = h; i < dp.size(); i++)
		ans = min(ans, dp[i]);

	cout << ans << endl;
}

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



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

int main() {
    string s; cin >> s;
    cout << s.substr(0,4) << " " << s.substr(4,s.size()-4) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;

LL mod = 1000000007;

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

	vector<LL> a(n);

	bool poss = false;
	for (auto &e : a) {
		cin >> e;
		if (e == 1) {
			poss = true;
		}
	}

	if (poss) {

		LL st = 1;
		LL cnt = 0;

		for (LL i = 0; i < n; ++i) {
			if (a[i] == st) {
				cnt++;
				st++;
			}
		}
		cout << n-cnt << endl;
	}
	else {
		cout << -1 << endl;
	}

}

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

int main()
{
	int N, M;
	long long K;
	cin >> N >> M >> K;
	vector<long long> A(N), B(M);
	for (int i = 0; i < N; ++i) cin >> A[i];
	for (int i = 0; i < M; ++i) cin >> B[i];

	vector<long long> a, b;
	a.push_back(0);
	b.push_back(0);
	for (int i = 0; i < N; ++i) a.push_back(a[i] + A[i]);
	for (int i = 0; i < M; ++i) b.push_back(b[i] + B[i]);

	int maxNum = 0, num = M;
	for (int i = 0; i <= N; ++i)
	{
		if (a[i] > K) break;

		while (b[num] > K - a[i])
		{
			--num;
		}
		maxNum = max(maxNum, i + num);
	}

	cout << maxNum << endl;
}

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

#define vint vector<int>
#define vvint vector<vint>
#define sint stack<int>
#define qint queue<int>
#define rep(i, n) for(int i=0;i<(int)(n);i++) // 繰り返し処理
#define all(x) (x).begin(),(x).end() // 全体 こんな感じで使う→sort(all(a));
#define ct(a) cout << a << endl
#define iceil(a,b) (a+(b-1))/b //int ceil : 繰り上げの割り算 通常のceilではceil((7.0/2.0))のようにしなければならなかった。
vint CinLine(int N){vint v(N);for(int i=0;i<N;i++){cin >> v.at(i);}return v;}//cin line 連続でvectorに格納
void CoutLine(vint v){for(int i=0;i<v.size()-1;i++){cout<<v.at(i)<<" ";}cout << v.at(v.size()-1)<<endl;}


int main() {
    string s,t;
    cin >> s >> t;
    int l = s.size();
    if(s.substr(0,l) == t.substr(0,l)){
        ct("Yes");
    }else{
        ct("No");
    }
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<long long> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    if(i) a.at(i) += a.at(i - 1);
  }
  
  long long ans = 1e15;
  for(int i = 0; i < n; i++){
    ans = min(ans, abs(a.at(n - 1) - 2 * a.at(i)));
  }
  
  cout << ans << "\n";
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>

using namespace std;

int main(void) {
	string input;
	int s = 'a' - 'A', i;
	
	getline(cin, input);
	for(i = 0; i < (int)input.size(); i++) {
		if('a' <= input[i] && input[i] <= 'z') { input[i] -= s; }
	}
	cout << input << endl;
	
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<a.length; i++){
            a[i] = sc.nextInt();
        }

        String delimiter = "";
        for(int i=a.length-1; i>=0; i--){
           System.out.print(delimiter);
           System.out.print(a[i]);
           delimiter = " ";
        }
        System.out.println();   
      
      sc.close();
    }
}


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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
inline ll ii(){ ll x; cin >> x; return x; }
inline string is(){ string x; cin >> x; return x; }
inline ld id(){ ld x; cin >> x; return x; }
inline void oi(ll x){ cout << x; }
inline void od(ld x){ cout << fixed << setprecision(10) << x; }
inline void os(string x){ cout << x; }
inline void oe(){ cout << endl; }
inline void oie(ll x){ oi(x); oe(); }
inline void ode(ld x){ od(x); oe(); }
inline void ose(string x){ os(x); oe(); }

inline void maxin(ll &a, ll b){ a=max(a,b); }

ll m[3123][3123][5];
ll item[3123][3123];

int main(){
    ll R=ii(), C=ii(), K=ii();
    REP(i,0,K){
        ll r=ii();
        ll c=ii();
        ll v=ii();
        item[c-1][r-1]=v;
    }
    REP(y,0,R+1){
        REP(x,0,C+1){
            REP(k,0,4){
                maxin(m[x+1][y][k],m[x][y][k]);
                if(k<3) maxin(m[x+1][y][k+1],m[x][y][k]+item[x][y]);

                maxin(m[x][y+1][0],m[x][y][k]);
                if(k<3) maxin(m[x][y+1][0],m[x][y][k]+item[x][y]);
            }
        }
    }
    ll ret=0;
    REP(k,0,4){
        maxin(ret,m[C][R][k]);
    }
    oie(ret);
    return 0;
}

Measured memory_bytes: 440692
#include <vector>
#include <cstring>
#include <iostream>

using namespace std;

// ------ Variable ------ //

#define MAX_V 200

int V; vector<int> G[MAX_V];

int match[MAX_V];

bool used[MAX_V];


// ------ Bipartite_Matching ------ //

bool search(int v)
{
	used[v] = true;

	for (int i = 0; i < G[v].size(); i++)
	{
		int u = G[v][i], w = match[u];

		if (w < 0 || !used[w] && search(w))
		{
			match[v] = u;
			match[u] = v;

			return true;
		}
	}

	return false;
}

int bipartite_matching()
{
	int res = 0;

	memset(match, -1, sizeof(match));

	for (int i = 0; i < V; i++)
	{
		if (match[i] < 0)
		{
			memset(used, 0, sizeof(used));

			if (search(i))
			{
				res++;
			}
		}
	}

	return res;
}

int main()
{
	int X, Y, E, A, B;

	cin >> X >> Y >> E; V = X + Y;

	for (int i = 0; i < E; i++)
	{
		cin >> A >> B;

		G[A].push_back(X + B);
		G[X + B].push_back(A);
	}

	cout << bipartite_matching() << endl;

	return 0;
}

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

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

    int W, H, x, y;
    cin >> W >> H >> x >> y;

    cout << double(W) * double(H) / 2.0;
    cout << " ";
    cout << ((2*x == W && 2*y == H) ? 1 : 0) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  int n = 0,w = 0,s = 0,e = 0;
  cin >> str;
  for(int i = 0; i < str.size(); i++) {
    if(str.at(i) == 'N') n++;
    else if(str.at(i) == 'W') w++;
    else if(str.at(i) == 'S') s++;
    else if(str.at(i) == 'E') e++;
  }
  
  if(n+w+s+e == 0) cout << "Yes" << endl;
  else if((n>0 && s>0 && e+w==0) || (e>0 && w>0 && n+s==0)) cout << "Yes" << endl;
  else if((n>0 && s>0) && (e>0 && w>0)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 #include<math.h>
 #include<iostream>
 using namespace std;
 
 int main()
 {
 	long long int n;
 	long long int t;
 	long long int x,y;
 	while(cin>>n)
 	{
 	  bool flag=false;
 	  for(int i=0;i<n;i++)
 	  {
	   
 		cin>>t>>x>>y;
		long long int tot=x+y;
		if((tot%2)!=(t%2)) flag=true;
		else 
		{
			if(t<tot) flag=true;
		  
		  }
	    }  
	    if(!flag) cout<<"Yes"<<endl;
	    else cout<<"No"<<endl;
	 }
 	return 0;
 }
 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)

int d[100][100];
int main(){
	int n,m,s,g1,g2;
	while(cin>>n>>m>>s>>g1>>g2,n|m|s|g1|g2){
		s--;g1--;g2--;
		rep(i,n)rep(j,n)d[i][j]=INF;
		rep(i,n)d[i][i]=0;
		rep(i,m){
			int a,b,c;
			cin>>a>>b>>c;
			d[a-1][b-1]=c;
		}
		rep(k,n)rep(i,n)rep(j,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		int ans=INF;
		rep(i,n){
			ans = min(ans,d[s][i]+d[i][g1]+d[i][g2]);
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <stdio.h>

typedef struct {
    int top;
    int bottom;
    int right;
    int left;
    int front;
    int back;
} Dice;

void roll(Dice *d, char direction)
{
    int present_top = d->top;
    int present_bottom = d->bottom;
    int present_right = d->right;
    int present_left = d->left;
    int present_front = d->front;
    int present_back = d->back;

    if (direction == 'N') {
        d->top = present_front;
        d->bottom = present_back;
        d->front = present_bottom;
        d->back = present_top;
    } else if (direction == 'S') {
        d->top = present_back;
        d->bottom = present_front;
        d->front = present_top;
        d->back = present_bottom;
    } else if (direction == 'E') {
        d->top = present_left;
        d->bottom = present_right;
        d->right = present_top;
        d->left = present_bottom;
    } else {
        d->top = present_right;
        d->bottom = present_left;
        d->right = present_bottom;
        d->left = present_top;
    }
}

void revolve(Dice *d, char direction)
{
    int present_top = d->top;
    int present_bottom = d->bottom;
    int present_right = d->right;
    int present_left = d->left;
    int present_front = d->front;
    int present_back = d->back;

    if (direction == 'R') {
        d->front = present_right;
        d->back = present_left;
        d->right = present_back;
        d->left = present_front;
    } else {
        d->front = present_left;
        d->back = present_right;
        d->right = present_front;
        d->left = present_back;
    }
}

int is_same(Dice *d1, Dice *d2)
{
    int i, j;

    for (i = 0; i < 6; i++) {
        for (j = 0; j < 4; j++) {
            if (d1->top == d2->top && d1->bottom == d2->bottom &&
                d1->right == d2->right && d1->left == d2->left &&
                d1->front == d2->front && d1->back == d2->back) return 1;
            else revolve(d2, 'R');
            }
        if (i % 2 == 0) roll(d2, 'N');
        else roll(d2, 'W');
    }

    return 0;
}

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

    Dice dices[n];
    
    int flag = 0;
    int i;

    for (i = 0; i < n; i++) {
        int j;
        for (j = 0; j < 6; j++) {
            switch (j) {
                case 0 : scanf("%d", &dices[i].top); break;
                case 1 : scanf("%d", &dices[i].front); break;
                case 2 : scanf("%d", &dices[i].right); break;
                case 3 : scanf("%d", &dices[i].left); break;
                case 4 : scanf("%d", &dices[i].back); break;
                case 5 : scanf("%d", &dices[i].bottom); break;
            }
        }
        for (j = 0; j < i; j++)
            if (flag = is_same(&dices[j], &dices[i])) break;
        if (flag) break;
    }

    if (flag) puts("No");
    else puts("Yes");

    return 0;
}

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


using namespace std;


main() {
	long long n, ans;
	cin >> n;
	ans = n;
	vector<pair<long long, long long> > a(n);
	set<pair<long long, long long> > b;
	map<pair<long long, long long>, long long> m;
	for (long long i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
		m[a[i]] = 1;
		b.insert(a[i]);
	}
	sort(a.begin(), a.end());
	for (long long i = 0; i < n; i++) {
		for (long long j = i + 1; j < n; j++) {
			map<pair<long long, long long>, long long> m1;
			m1 = m;
			long long p = a[j].first - a[i].first, q = a[j].second - a[i].second, ans1 = 0;
			for (long long k = 0; k < n; k++) {
				ans1 += m1[a[k]];
				if (b.find({a[k].first + p, a[k].second + q}) != b.end()) {
					m1[{a[k].first + p, a[k].second + q}] = 0;
				}
			}
			ans = min(ans1, ans);
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,k,c,a,t1,t2,xp[100001],xn[100001],mini=2147483647;
int main()
{ cin>>n>>k;
  for(int i=1;i<=n;i++)
  { cin>>a;
    if(a>=0)
       xp[++xp[0]]=a;
    else
       xn[++xn[0]]=-a;
  }
  for(int i=0;i<=min(xp[0],k);i++)
  { if(k-i>xn[0])
       continue;
    a=0; t1=0;
    for(int j=1;j<=i;j++)
      t1+=xp[j]-a,a=xp[j];
    a=0; t2=0;
    for(int j=xn[0];j>=xn[0]-k+i+1;j--)
      t2+=xn[j]-a,a=xn[j];
    if(t1<t2)
       swap(t1,t2);
    t1+=t2*2;
    mini=min(mini,t1);
  }
  cout<<mini;
  return 0;
}


Measured memory_bytes: 768
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<bitset>
using namespace std;
int main(){
	int n;
	string str;
	cin>>n>>str;
	for(int i=0;i<str.length();i++){
		int num=str[i]-'0';
		num=num+n;
		if(num>42) num-=26;
		char ans;
		ans=num+'0';
		putchar(ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
	for (;;){
		int a;
		cin>>a;
		if (a==0) break;
		int b[a],goukei=0,m=0;
		for (int A=0;A<a;A++) cin>>b[A];
		for (int B=0;B<a;B++){
			if (b[B]>=1){
				goukei+=1;
				b[B]-=1;
			}
		}
		for (int A=0;A<a;A++){
			if (b[A]>=1){
				m=3;
				goukei+=1;
				cout<<goukei<<endl;
				break;
			}
		}
		if (m==0) cout<<"NA"<<endl;
		goukei=0;
	}
	return 0;
}
		
							
		

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

ll arr[N];
vector<int> G[N];
ll dfs(int v,int p){
  vector<ll> ze;
  int rt=0;
  REP(i,G[v].size()) if(G[v][i]!=p){
    ll po = dfs(G[v][i],v);
   // printf("g%d %lld\n",G[v][i],po);
    ze.pb(po);
    rt++;
  }

  if(!rt){
    return arr[v];
  }else{
    ll p=arr[v];
    sort(all(ze));
    reverse(all(ze));
    ll sum=0;
    REP(i,ze.size()) sum+=ze[i];
    if(sum<p){
      printf("NO\n"); exit(0);
    }
    
    ll k = (sum-p);
  //  printf("%d %lld %lld %lld\n",v,sum,p,k);
    if(k>sum-ze[0]||k>p){
      printf("NO\n"); exit(0); 
    }
    return p-k;
  }

}
int main(){
  int n; scanf("%d",&n);
  REP(i,n) scanf("%lld",&arr[i]);
  REP(i,n-1){
    int x,y; scanf("%d%d",&x,&y);x--;y--;
    G[x].pb(y); G[y].pb(x);
  }
  ll z = dfs(0,-1);
  if(G[0].size()==1) z=0;
  if(z==0) printf("YES\n"); else printf("NO\n");
  return 0;
}

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

#define rep(i, n) for(int i=0; i < (n); ++i)
#define ll long long

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

typedef pair<int, int> item;

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

    int n, t; cin >> n >> t;
    v<item> items(n);
    vv<int> dp(n+5, v<int>(t+5));
    rep(i, n) cin >> items[i].first >> items[i].second;
    sort(items.begin(), items.end());
    int ans = 0;
    rep(i, n) {
        rep(j, t) {
            chmax(dp[i+1][j], dp[i][j]);
            int nj = items[i].first + j;
            if (nj < t) {
                chmax(dp[i+1][nj], dp[i][j]+items[i].second);
            }
        }
        int now = dp[i][t-1]+items[i].second;
        chmax(ans, now);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35712
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    bool ans = true;
    repi(i, n, 0)
    {
        int t, x, y;
        cin >> t >> x >> y;
        if (x + y > t)
        {
            ans = false;
            break;
        }
        if ((x + y) % 2 != t % 2)
        {
            ans = false;
            break;
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
  
   string n,m; 
   cin >> n >> m;
  
   std::vector<char> data;
   std::vector<char> data2;
  
   for(int i=0;i<n.size();i++){
     data.push_back((char)n[i]);
   }
  
  for(int i=0;i<m.size();i++){
     data2.push_back((char)m[i]);
   }
  
  std::string buf;
  
  std::sort(data.begin(),data.end());//昇順ソート
  
	for(int i=0;i<n.size();i++) {
      
     // cout << data[i] << endl;
     
      buf = buf+data[i];
      
    }
  
  std::string buf2;
  
  //std::sort(data2.begin(),data2.end());//昇順ソート
  std::sort(data2.begin(),data2.end(),std::greater<char>());
  
	for(int i=0;i<m.size();i++) {
      
     // cout << data2[i] << endl;
      buf2 = buf2+data2[i];
    }
 
  
  std::vector<string> data3;
 
  data3.push_back(buf);
  data3.push_back(buf2);
  
   std::sort(data3.begin(),data3.end());//昇順ソート
  
  // cout << buf << buf2 << endl;
   //cout << data3[0] << data3[1] << endl;
  
  if(buf==buf2){
    cout << "No" <<endl;
  }else{
  
   if(data3[0]==buf){
     cout << "Yes" <<endl;
   }else{
     cout << "No" <<endl;
   }
    
  }
   
  return 0;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,k,c = inpm()
s = input()

saisoku = [0] * n
saioso = [0] * n

i = 0
while i < n:
    if s[i] == "x":
        i += 1
        continue
    saisoku[i] = 1
    i += c + 1

if saisoku.count(1) > k:
    exit()

i = n-1
while i >= 0:
    if s[i] == "x":
        i -= 1
        continue
    saioso[i] = 1
    i -= c + 1

for i in range(n):
    if saisoku[i] == 1 and saioso[i] == 1:
        print(i + 1)

Measured memory_bytes: 34396
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
#include <map>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    string S;
    cin>>S;
    map<string,int> A;
    A["SUN"]=7;
    A["MON"]=6;
    A["TUE"]=5;
    A["WED"]=4;
    A["THU"]=3;
    A["FRI"]=2;
    A["SAT"]=1;
    cout<<A[S]<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            int cnt = 0;
            for (int i = 0; i < 3; i++)
            {
                if (s[i] == t[i]) cnt++;
            }

            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 11092
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let kazu: usize = read();
    let mut vec= Vec::new();
    let mut lights = HashMap::new();
    //in
    for x1 in 0..kazu {
        let ans2: usize = read();
        vec.push(ans2);
    }

    //out
    let mut ppoint:usize=1;
    let mut count=0;
    for yy in 0..(kazu) {
        let nextpoint:usize = vec[yy];
        if (lights.get(&nextpoint).is_some()){
            count-=1;
            lights.remove(&nextpoint);
        }else{
            count+=1;
            lights.insert(nextpoint, 1);
        }
    }
    print!("{}",count);
}

Measured memory_bytes: 12540
open Scanf
open Printf
open Array

let () = scanf " %d" @@ fun l ->
  let a = init l (fun _ -> scanf " %d" @@ fun v -> v) in
  let dp = make_matrix (l+1) 5 max_int in
  let f typ v =
    match typ with
    | 0 | 4 -> (* zero *)
      v
    | 1 | 3 -> (* even >= 2 *)
      if v=0 then 2
      else if v mod 2 = 0 then 0 else 1
    | 2 | _ -> (* odd *)
      if v mod 2 = 1 then 0 else 1
  in
  let update i j v =
    dp.(i).(j) <- min dp.(i).(j) v
  in
  for k=0 to 4 do
    dp.(0).(k) <- 0;
  done;
  let to_ = [|
    [0;1;2];
    [1;2;4];
    [2;3;4];
    [3;4];
    [4]
  |] in
  for i=1 to l do
    for k=0 to 4 do
      List.iter (fun j ->
        update i j @@ dp.(i-1).(k) + f j a.(i-1)
      ) to_.(k)
    done
  done;
  print_int @@ fold_left min max_int dp.(l)

Measured memory_bytes: 16768
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

using namespace std;

#define ll long long
#define db double
#define clr(a, b) memset(a, b, sizeof(a))

const int maxn = 5e5 + 10;
const int inf = 0x7ffffff;
const int mod = 2019;
string s;
int a[mod + 5], b[mod + 5];

void solve()
{
    int cnt = 0;
    cin >> s;
    int tmp = 0, lst = 0, p = 1;
    a[0] = 1;
    // for (int i = 0; i < (int)s.size(); i++)
    // {
    //     tmp = s[i] - '0';
    //     lst = (lst * 10 + tmp) % mod;
    //     cout << lst << "\n";
    //     cnt += a[lst]++;
    // }
    reverse(s.begin(), s.end());
    for (int i = 0; i < s.size(); i++)
    {
        lst += (s[i] - '0') * p;
        lst %= 2019;
     //   cout << lst << " " << a[lst] << "\n";
        cnt += a[lst]++;
        p *= 10;
        p %= 2019;
        // cout << v << endl;
    }
    cout << cnt << "\n";
}

int main()
{
    // freopen("out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    //cin >> T;
    while (T-- > 0)
        solve();
}


Measured memory_bytes: 3708
program a159
      integer N

      integer s,i,j,k,cnt,unk
    
      read(*,*)N


      do s =1, N
            cnt = 0
      do i =1, N
        if (i * i + i .gt. N)then
            exit
        endif
      do j =1, N
            if (j * j + j + i * i + i .gt. N)then
                exit
            endif
      do k =1, N
                if (k * k + k + j * j + j + i * i + i .gt. N)then
                   exit
                endif
                unk =i*i + j*j + k*k + i*j + j*k + k*i
                if (unk == s)then
                    cnt = cnt+1
                    exit      
                else if (unk .gt. s)then
                    exit
                endif

     
            enddo
            enddo
            enddo
             write(*,*)cnt
            enddo

      end program a159

Measured memory_bytes: 2608
n,x = map(int,input().split())
l = [int(i) for i in input().split()] 
ct = 0
num=0
for i,item in enumerate(l):
  ct+=1
  num+=item
  if(num > x):
  	break;
  elif(i==n-1):
  	ct+=1

print(ct)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>

using namespace std;

int main(){
    int N; cin >> N;
    int ans = 0;
    for (int i = 0; i < N; i++){
        int A; cin >> A;
        ans = ans ^ A;
    }

    if (ans == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256