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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

char s[1252];
int w;

int main(){
  scanf("%s%d",s,&w);
  int n = strlen(s);
  int it = 0;
  while(it<n){
    putchar(s[it]);
    it+=w;
  }
  puts("");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string A;
  cin>>A;
  cout<<A.at(0)<<A.at(1)<<A.at(2)<<A.at(3)<<" "<<A.at(4)<<A.at(5)<<A.at(6)<<A.at(7)<<A.at(8)<<A.at(9)<<A.at(10)<<A.at(11)<<endl;
}

Measured memory_bytes: 3560
#include <iostream>

using namespace std;

int main(){
    int S, h, m, s;

    cin >> S;
    
    h = S / 3600;
    m = (S - 3600 * h) / 60;
    s = S - (3600 * h + 60 * m);

    cout << h << ":" << m << ":" << s << endl;

    return 0;
}


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

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

Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
int d[101][101]={};
int x[101];
int n;
void bfs(int);
int main(){
  int p;
  int na[100];
  int to;
  int th;
  int st,go,ttl;
  //syoki
  for(int i=0;i<n;i++){
    x[i]=10000;
  }
  //in
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> na[i] >> to;
    for(int j=0;j<to;j++){
      cin >> th;
      d[na[i]][th]=1;
    }
  
  }
  //in2
  cin >> p;
  for(int i=0;i<p;i++){
    for(int j=0;j<=n;j++){
      x[j]=10000;
    }
    
    cin>> st >> go >> ttl;
    x[st]=1;
    bfs(st);
    if(x[go]<=ttl && x[go]!=10000)cout << x[go] << endl;
    else cout << "NA" << endl;
  }
  return 0;
}

///bfs///////////////////////////////////////////
void bfs(int s){
  queue<int>q;
  int u;
  q.push(s);
  while(!q.empty()){
    u=q.front();
    q.pop();
    for(int v=0;v<=n;v++){
      if(d[u][v]==1&&x[v]==10000){
	x[v]=x[u]+1;
	q.push(v);
      }
    }
  }
  return ;
}

Measured memory_bytes: 1244
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << min({a * b , b * c, c * a}) << endl; 
    return 0;
}


Measured memory_bytes: 3572
N,k=map(int,input().split())
A=input()
ans=0
for i in range(0,N):
  if A[i]=='R' and i<N-1:
    if A[i+1]=='R':
      ans=ans+1
  if A[i]=='L' and i>0:
    if A[i-1]=='L':
      ans=ans+1
print(min(N-1,2*k+ans))



Measured memory_bytes: 3316
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int bitcnt(long bits){
	bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
	bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
	bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
	bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
	return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int H, W, K;
	cin >> H >> W >> K;

	vector<vector<char>> grid(H, vector<char>(W));
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> grid[i][j];
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) grid[i][j] -= '0';
	
	int ans = INF;
	for (int bit = 0b0; bit < (1 << (H - 1)); bit++) {

		int cnt = bitcnt(bit);

		vector<int> id(H);
		for (int i = 0; i < H - 1; i++) {
			if (bit & (1 << i)) id[i + 1] = id[i] + 1;
			else id[i + 1] = id[i];
		}
		DMP(bit, id);

		vector<int> sum(H);
		int prev = -1;
		for (int w = 0; w < W; w++) {
			for (int i = 0; i < H; i++) {
				sum[id[i]] += grid[i][w];
				if (sum[id[i]] > K) {
					cnt++;
					fill(sum.begin(), sum.end(), 0);
					i = -1;
					DMP(w, i);
					if (prev == w * W + i) {
						cnt = INF;
						break;
					}
					prev = w * W + i;
				}
			}
			DMP(sum);
		}

		if(chmin(ans, cnt)) DMP(ans, bit);

	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int H, W, i, j;
	
	while (1) {
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0) {
			break;
		}
		
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
					printf("#");
				} else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
N,MA,MB = map(int,input().split())
ABC = [tuple(map(int,input().split())) for i in range(N)]

from collections import defaultdict
from copy import copy
d = defaultdict(lambda: float('inf'))
d[(0,0)] = 0
for a,b,c in ABC:
    d2 = copy(d)
    for (pa,pb),pc in d.items():
        d2[(pa+a, pb+b)] = min(d2[(pa+a, pb+b)], pc+c)
    d = d2

ans = float('inf')
for (a,b),c in d.items():
    if a==b==0: continue
    if a*MB == b*MA:
        ans = min(ans, c)
print(-1 if ans==float('inf') else ans)

Measured memory_bytes: 12756
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(i,arr)       for(int& i:arr)cin>>i;
#define output(i,arr)      for(int& i:arr)cout<<i<<" ";
#define for_each(arr)      for(auto& it:arr)
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx1[]={+1,-1,+0,+0};
int fy1[]={+0,+0,+1,-1};
int fx2={+0,+0,+1,-1,-1,+1,-1,+1};
int fy2={-1,+1,+0,+0,+1,+1,-1,-1};
*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
  //  #endif
    cin>>a>>b;
    cout<<(int)(floor(log(a)/log(b))+1);
    

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; ++i){
    cin >> a.at(i);
  }
  sort(a.rbegin(),a.rend());
  int count = 1;
  for(int i = 1; i < N; i++){
    if(a.at(i-1) != a.at(i)) ++count;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
    using System.Text;
    using System.Collections.Generic;
    using static System.Math;
    using System.Linq;
    using static System.Array;
    
    namespace ConsoleApp2
    {
    class Program
    {
        static string S;
        static void Main(string[] args)
        {

            //var N = long.Parse(Console.ReadLine());
            //var V = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var S = Console.ReadLine();

            if (S.Contains("AC"))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            

            
        }
    }
}


Measured memory_bytes: 11092
import java.awt.geom.*;
import java.util.*;
public class Main {
	
	//外積
	private double cross(Point2D p1, Point2D p2) {
		double res = p1.getX() * p2.getY() - p1.getY() * p2.getX();
		return res;
	}
	
	private double area(ArrayList<Point2D> polygon) {
		double res = 0.0;
		int n = polygon.size();
		for(int i = 0; i < n; i++){
			Point2D from = polygon.get(i), to = polygon.get((i+1) % n);
			res += cross(from, to);
		}
		return Math.abs(res) / 2.0;
	}

	private void doit() {
		Scanner sc = new Scanner(System.in);
		int count = 0;
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			ArrayList<Point2D> polygon = new ArrayList<Point2D>();
			for(int i = 0; i < n; i++){
				double x = sc.nextDouble();
				double y = sc.nextDouble();
				polygon.add(new Point2D.Double(x, y));
			}
			System.out.printf("%d %.1f\n",++count, area(polygon));
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read(){
    int x=0,c=getchar(),f=0;
    for(;c>'9'||c<'0';f=c=='-',c=getchar());
    for(;c>='0'&&c<='9';c=getchar())
    x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
const int maxn = 1e5 + 10;

struct qwe{
    int y , id;
};
int p[maxn] , x[maxn];
vector<qwe> g[maxn];

bool cmp(qwe q , qwe w){
    return q.y < w.y;
}
int main() {
    int n = read() , m = read();

    qwe temp;
    for (int i=1; i<=m; i++){
        p[i] = read();
        temp.id = i , temp.y = read();
        g[p[i]].push_back(temp);
    }

    for (int i=1; i<=n; i++){
        sort(g[i].begin(), g[i].end(), cmp);
        int len = g[i].size();
        for (int j=0; j<len; j++){
            x[g[i][j].id] = j + 1;
        }

    }

    for (int i=1; i<=m; i++)  printf("%06d%06d\n", p[i], x[i]);
    return 0;
}


Measured memory_bytes: 7808
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a == 2 || b == 2) {

			System.out.println("No");

		} else {
			System.out.println("Yes");
		}
	}
}


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

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

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

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

#define DEBUG

#ifndef LOCAL
#undef DEBUG
#endif

#ifdef DEBUG
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) ;
#endif

#define maxn 211111
#define maxd 20

char s[maxn];
int a[maxn];
int cnt[26][maxn];
int nxt[26][maxn];
int f[maxn];
int ff[maxd][maxn];
int n;

inline bool ok(int l,int r)
{
	for(register int i=0;i<26;i++)
	{
		if (cnt[i][r]-cnt[i][l-1]<1) return false;
	}
	return true;
}

int getLen(int l,int r)
{
	int res=0;
	for(int d=maxd-1;d>=0;d--)
	{
		if (ff[d][l]<=n) res+=(1<<d),l=ff[d][l]+1;
	}
	return res;
}

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)
	{
		a[i]=s[i]-'a';
	}
	for(int i=0;i<26;i++)
	{
		nxt[i][n]=n+1;
	}
	nxt[a[n]][n]=n;
	for(int i=n-1;i>=1;i--)
	{
		for(int j=0;j<26;j++)
		{
			nxt[j][i]=nxt[j][i+1];
		}
		nxt[a[i]][i]=i;
	}
	for(int i=1;i<=n;i++)
	{
		cnt[a[i]][i]++;
	}
	for(int i=0;i<26;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cnt[i][j]+=cnt[i][j-1];
		}
	}
	for(int i=1;i<=n;i++)
	{
		int l=i,r=n,mid;
		while (l+5<r)
		{
			mid=(l+r)>>1;
			if (ok(i,mid))
			{
				r=mid;
			}
			else
			{
				l=mid;
			}
		}
		f[i]=n+1;
		for(int j=l;j<=r;j++)
		{
			if (ok(i,j))
			{
				f[i]=j;
				break;
			}
		}
	}
	f[n+1]=n+1;
	for(int i=1;i<=n+1;i++)
	{
		ff[0][i]=f[i];
	}
	for(int j=1;j<maxd;j++)
	{
		for(int i=1;i<=n+1;i++)
		{
			ff[j][i]=ff[j-1][min(ff[j-1][i],n)+1];
		}
	}
	
	int ans=getLen(1,n)+1;
	
	{
		int p=0;
		for(int i=1;i<ans;i++)
		{
			for(int j=0;j<26;j++)
			{
				int c_pos=nxt[j][p+1];
				if (i+getLen(c_pos+1,n)<ans)
				{
					p=c_pos;
					putchar('a'+j);
					break;
				}
			}
		}
		for(int i=0;i<26;i++)
		{
			if (nxt[i][p+1]>n)
			{
				putchar('a'+i);
				break;
			}
		}
	}
	
	putchar('\n');
	return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  set<pair<int, int>> S;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    pair<int, int> p = make_pair(a, b);
    S.insert(p);
  }
  vector<int> A(N);
  for (int i = 0; i < N; i++) A.at(i) = i + 1;
  int ans = 0;
  do {
    if (A.at(0) != 1) break;
    bool X = true;
    for (int i = 1; i < N; i++) {
      pair<int, int> p = make_pair(A.at(i), A.at(i - 1));
      pair<int, int> q = make_pair(A.at(i - 1), A.at(i));
      if (!(S.count(p)) && !(S.count(q))) X = false;
    }
    if (X) ans++;
  } while(next_permutation(A.begin(), A.end()));
  cout << ans << endl;
}

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

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

using namespace std;

int main(){
	int n; cin>>n;
	deque<int> Q;
	rep(i,n){
		int a; cin>>a;
		if(i%2==0) Q.emplace_back(a);
		else       Q.emplace_front(a);
	}

	if(n%2==0){
		rep(i,n) cout<<Q[i]<<endl;
	}
	else{
		rep(i,n) cout<<Q[n-i-1]<<endl;
	}

	return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <string>
#include <set>

#include <regex>
#include <locale>
#include <iomanip>

using namespace std;
using ll = long long;

#define OVERLOAD3(_1,_2,_3,name,...) name
#define REP(i,n) REPI(i,0,n)
#define REPI(i,a,b) for(int i=int(a),i##_Len=int(b);i<i##_Len;++i)
#define rep(...) OVERLOAD3(__VA_ARGS__,REPI,REP,)(__VA_ARGS__)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

int main () {
  char a, b;
  cin >> a >> b;
  cout << (a < b ? "<" : b < a ? ">" : "=") << endl;
}

Measured memory_bytes: 2984
#include <iostream>
#include <string>
#include <vector>
#include <sstream>

int main()
{
    int num;
    std::cin >> num;

    std::string s;
    while (std::getline(std::cin, s)) {
        if (!s.empty()) {
            break;
        }
    }

    std::stringstream ss(s);

    std::vector<int> a(num);

    int cnt = 0;
    std::string buf;

    while (std::getline(ss, buf, ' ')) {
        a[cnt++] = ::atoi(buf.c_str());
    }

    int result = 0;
    bool hasOdd = false;

    while (!hasOdd) {
        for (int i = 0; i < num; i++) {
            if ((a[i] & 0x01) == 0) {
                a[i] >>= 1;
            }
            else {
                hasOdd = true;
                break;
            }
        }
        result += (hasOdd ? 0 : 1);
    }

    std::cout << result << std::endl;

    return 0;
}

Measured memory_bytes: 504
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

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

func timesSharp(x int) string {
	b := make([]byte, x)

	for i := 0; i < x; i++ {
		b[i] = '#'
	}

	return string(b)
}

func main() {
	h, w := nextInt(), nextInt()
	input := make([]string, h)

	for i := 0; i < h; i++ {
		input[i] = next()
	}

	for i := 0; i < h+2; i++ {
		if i == 0 || i == h+1 {
			fmt.Println(timesSharp(w + 2))
		} else {
			fmt.Println("#" + input[i-1] + "#")
		}
	}
}


Measured memory_bytes: 640
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	string s; cin>>s;
	int ans=0;
	For(i,0,sz(s)/2-1){
		if(s[i]!=s[sz(s)-i-1]) ans++;
	}
	cout<<ans<<"\n";
	return 0;
}


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

int main(){
  int H, W;
  cin >> H >> W;
  string tmps;
  vector<string> Map(H+2, "");
  for (int i=0;i<H+2;i++){
    for (int j=0;j<W+2;j++){
      Map[i] = Map[i] + "#";
    }
  }
  for (int i=1;i<H+1;i++){
    cin >> tmps;
    Map[i] = "#" + tmps + "#";
  }
  vector<vector<int>> A(H, vector<int>(W, 0));
  vector<vector<int>> hl(H, vector<int>(0));
  vector<vector<int>> wl(W, vector<int>(0));
  vector<int> nhl(H);
  vector<int> nwl(W);
  int l = -1, r = -1;
  int n;
  for (int i=1;i<=H;i++){
    n = 0;
    for (int j=0;j<W+2;j++){
      if (Map[i][j] == '.' && l == -1){
        l = j - 1;
        n += 1;
      }
      else if (Map[i][j] == '#' && l != -1){
        r = j - 1;
        hl[i-1].push_back(l*(W+2)+r);
        l = -1;
      }
    }
    nhl[i-1] = n;
  }
  l = -1;
  for (int j=1;j<=W;j++){
    n = 0;
    for (int i=0;i<H+2;i++){
      if (Map[i][j] == '.' && l == -1){
        l = i - 1;
        n += 1;
      }
      else if (Map[i][j] == '#' && l != -1){
        r = i - 1;
        wl[j-1].push_back(l*(H+2)+r);
        l = -1;
      }
    }
    nwl[j-1] = n;
  }
  int s, m, d, q;
  for (int i=0;i<W;i++){
    for (int j=0;j<nwl[i];j++){
      s = wl[i][j];
      d = s % (H+2);
      q = s / (H+2);
      for (int k=q;k<d;k++){
        A[k][i] = d - q;
      }
    }
  }
  m = 0;
  for (int i=0;i<H;i++){
    for (int j=0;j<nhl[i];j++){
      s = hl[i][j];
      d = s % (W+2);
      q = s / (W+2);
      for (int k=q;k<d;k++){
        if (m < d - q + A[i][k] - 1){
          m = d - q + A[i][k] - 1;
        }
      }
    }
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 33408
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, K = MAP()
A = LIST()

G = A[0]

for i in range(1, N+1):
	G = gcd(G, A[i-1])
	if G == 1:
		break

if K%G == 0 and K <= max(A):
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Measured memory_bytes: 21640
import java.util.Scanner;

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

	int r = scan.nextInt();
	int d = scan.nextInt();
	int[] x = new int[11];
	x[0] = scan.nextInt();

	for(int i = 1; i < 11; i++){
	    x[i] = r*x[i-1]-d;
	}

	for(int i = 1; i < 11; i++){
	    System.out.println(x[i]);
	}
    }
}


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

int main() {
  int n;
  char c;
  cin >> n;
  for(int i = 0 ;i < n ;i++){
    cin >> c;
    if(c == 'Y'){
      cout << "Four" << endl;
      break;
    }
    if(i+1 == n){
      cout << "Three" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
//aclbc_a.cpp
//Sat Sep 26 21:00:08 2020

#include <bits/stdc++.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

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

	rep(i,n){
		cout << "ACL";
	}
	printf("\n");
//	printf("%.4f\n",ans);
}


Measured memory_bytes: 3636
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
int main()
{   int n;
    scanf("%d",&n);
    int a[n],ans=1;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]%2==0)ans*=2;else ans*=1;
        }
    ans=pow(3,n)-ans;
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;cin >> n >> k;
	vector<pii> a(n);
	rep(i,n) cin >> a.at(i).first >> a.at(i).second;
	sort(a.begin(),a.end());
	ll cnt=0;
	rep(i,n){
		cnt+=a.at(i).second;
		if(cnt>=k){
			cout << a.at(i).first << endl;
			return 0;
		}
	}
}

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

int main(){
    ll d,g;
    cin >> d >> g;
    vector<pair<ll,ll>> pc(d);
    for (ll i = 0; i < d; i++){
        cin >> pc[i].first >> pc[i].second;
    }
    ll sum;
    ll solve;
    ll maxi;
    ll ans = 10000;
    ll x;
    for (ll bit = 0; bit <= (1<<d); bit++){
        sum = 0;
        maxi = 0;
        solve = 0;
        for (ll i = 0; i < d; i++){
            if (bit & (1 << i)){
                sum += pc[i].first*(i+1)*100 + pc[i].second;
                solve += pc[i].first;
            }else{
                maxi = i+1;
            }
        }
        
        if (g > sum){
            ll s = 100*maxi;
            x = (g-sum+s-1)/s;
            if (x >= pc[maxi-1].first){
                continue;
            }
            solve += x;
        }
        
        ans = min(ans,solve);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math
while True:
    n,x=list(map(int,input().split()))
    if n==x==0: break
    c=0
    for i in range(1,x//3):
        if i>n: break
        for j in range(i+1,(x-i)//2+1):
            if j>n: break
            k=x-i-j
            if not (n<k or k<=j):
                c+=1
    print(c)

Measured memory_bytes: 7708
N, Y = tmp = list(map(int,input().split()))
ans = [-1]*3
for i in range(Y // 10000 + 1):
    tmp = Y - 10000 * i
    for j in range(tmp // 5000 + 1):
        if i + j <= N:
            if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
                ans = [i, j, N - i - j]
print(ans[0], ans[1], ans[2])

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

s = {}
for _ in range(n):
    x = input()
    if x in s: s[x] += 1
    else: s[x] = 1

m = int(input())
t = {}
for _ in range(m):
    x = input()
    if x in t: t[x] += 1
    else: t[x] = 1

ans = 0
for k,v in s.items():
    ans = max(ans, v - (t[k] if k in t else 0))
print(ans)



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

#define sz(x) (int)x.size()
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define __ ios_base::sync_with_stdio(cin.tie(0) && 0);

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef double ld;

const ld pi = 3.141592653589793;
const ll inf = 1e18 + 5;
const int MOD = 1e9 + 7;
const int maxn = 1e5 + 5;

int main() {
  __;

  int h, w, k;
  cin >> h >> w >> k;

  char a[h][w];
  for(int i = 0; i < h; i++) { for(int j = 0; j < w; j++) { cin >> a[i][j]; } }

  ll ans = 0;
  for(int i = 0; i <= (1 << h) - 1; i++) {
    for(int j = 0; j <= (1 << w) - 1; j++) {

      int cnt = 0;
      for(int K = 0; K < h; K++) {
        if(((1 << K) & i) == 0) continue;
        for(int l = 0; l < w; l++) {
          if(((1 << l) & j) == 0) continue;
          if(a[K][l] == '#') cnt++;
        }
      }

      if(cnt == k) { ans++; }
    }
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3664
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        if(a>b){
            System.out.println("a > b");
        }else if(a==b){
            System.out.println("a == b");
        }else{
            System.out.println("a < b");
        }

    }

}


Measured memory_bytes: 26168
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,W;
  cin >> n >> W;
  ll dp[110][100010];
  vector<ll> weight(n);
  vector<ll> v(n);
  REP(i,n) cin >> weight[i] >> v[i];
  REP(w,W+1) dp[0][w] = 0;

  for(int i=0;i<n;i++){
    for(int w=0;w<=W;w++){
      if(w>=weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]]+v[i],dp[i][w]);
      else dp[i+1][w] = dp[i][w];
    }
  }
  cout << dp[n][W] << endl;
  return 0;
}

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

int main(){
    int N,T;
    cin >> N >> T;
    vector<pair<int,int> > vec(N);
    for (int i = 0; i < N; i++){
        cin >> vec.at(i).first;
        cin >> vec.at(i).second;
    }
    vector<int> cost(0);
    for (int i = 0; i < N; i++){
        if (vec.at(i).second <= T){
            cost.push_back(vec.at(i).first);
        }
    }
    if (cost.size() == 0){
        cout << "TLE" << endl;
    }
    else{
        int min_cost = cost.at(0);
        for (int i = 1; i < cost.size(); i++){
            min_cost = min(min_cost, cost.at(i));
        }
        cout << min_cost << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 101

int i,r[N],c[N];

int min (int a, int b)
{
  return a>b ? b : a;
}

int main()
{
  int n,j,k,l,x;
  int dp[N][N];

  scanf("%d",&n);
  for(i=1; i<=n; i++)
    {
      scanf("%d %d",&r[i],&c[i]);
    }
  c[0]=r[1];

  for(i=1; i<=n; i++) dp[i][i]=0;

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i+l-1;
      dp[i][j] = 1000000;
      for(k=i;k<=j-1;k++){
        x = dp[i][k] + dp[k+1][j] + c[i-1]*c[k]*c[j];
        dp[i][j] = min(dp[i][j],x);
      }
    }
  }

  printf("%d\n",dp[1][n]);

  return 0;
}


Measured memory_bytes: 2112
x,n = map(int,input().split())
if n != 0:
  l = list(map(int,input().split()))
else:
  l = []

m = 1e9
ans = None
for i in range(101,-2,-1):
  if i in l:
    continue
  if abs(x-i) <= m:
    m = abs(x-i)
    ans = i
print(ans)

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

vector<int> nextp(int n,vector<int> a){
  int i=n-1;
  while(i>=1&&a.at(i)<a.at(i-1)){
    i--;
  }
  if(i==0){
    vector<int> q(n);
    for(int j=0;j<n;j++){
      q.at(j)=j+1;
    }
    return q;
  }
  
  int ihold=i,mini=n,num;
  for(i=ihold;i<n;i++){
    if(a.at(ihold-1)<a.at(i)){
      mini=min(mini,a.at(i));
      num=i;
    }
  }
  swap(a.at(ihold-1),a.at(num));
  sort(a.begin()+ihold,a.end());
  return a;
}

int main(){
  int n;
  cin >> n;
  vector<int> p(n),q(n);
  int i;
  for(i=0;i<n;i++){
    cin >> p.at(i);
  }
  for(i=0;i<n;i++){
    cin >> q.at(i);
  }
  
  i=0;
  while(i<n&&p.at(i)==q.at(i)){
    i++;
  }
  
  if(i==n){
    cout << 0 << endl;
    return 0;
  }
  
  if(q.at(i)<p.at(i)){
    for(i=0;i<n;i++){
      swap(p.at(i),q.at(i));
    }
  }
  
  int x=0;
  while(p!=q){
    p=nextp(n,p);
    x++;
  }
  
  cout << x << endl;
}

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

int main(void) {
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		Deque<Integer> d = new ArrayDeque<>();

		String s ="";

		while((s = br.readLine()) !=null){
			int number = Integer.parseInt(s);

			if(number !=0){
				d.push(number);
			}else {
				System.out.println(d.pop());
			}

		}
	}



}

Measured memory_bytes: 24156
from heapq import *
N = int(input())
X,Y=[],[]
for n in range(N):
  x,y=map(int,input().split())
  X.append((x, n))
  Y.append((y, n))
X.sort()
Y.sort()
D=[[] for v in range(N)]
for n in range(N-1):
  cost = X[n+1][0]-X[n][0]
  D[X[n+1][1]].append((cost,X[n][1]))
  D[X[n][1]].append((cost,X[n+1][1]))
  cost=Y[n+1][0]-Y[n][0]
  D[Y[n+1][1]].append((cost,Y[n][1]))
  D[Y[n][1]].append((cost,Y[n+1][1]))

visited=[0]*N
pq = []
for w, t in D[0]:
  heappush(pq,(w,t))
visited[0]=1

ans = 0
while pq:
  w,t=heappop(pq)
  if visited[t]:
    continue
  visited[t]=1
  ans+=w
  for w,s in D[t]:
    if visited[s]==0:
      heappush(pq,(w,s))
print (ans)

Measured memory_bytes: 82464
#include<iostream>
#include <cstdlib>
using namespace std;
int main()
{
  int N,M;
  cin >> N >> M;

  int sum = 0;
  int a = 0;
  for(int i = 0; i < M; i++){
    cin >> a;
    sum += a;
  }

  if((N - sum) >= 0){
    cout << N - sum;
  }else{
    cout << -1;
  }
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
void solve(int st, int p, int q, int en, string &s, vector<int>&ans){
    for(int i = st; i <= p; ++i){
        if((p - i) & 1)ans[q]++;
        else ans[p]++;
    }
    for(int i = q; i <= en; ++i){
        if((en - i) & 1)ans[p]++;
        else ans[q]++;
    }
}

void input(){
    string s; cin >> s;
    int n = s.size();
    int st = 0, en = 0;
    vector<int>ans(n, 0);
    for(int i = 1; i < n; ++i){
        if(s[i] == 'L' && s[i - 1] == 'R'){
            int p = i - 1;int q = i;
            int j;
            for( j = i + 1; j < n; ++j){
                if(s[j] == 'R')break;
            }
            en = j - 1;
            solve(st, p, q, en, s, ans);
            st = j;
            i = j - 1;
        }
    }
    f(i, n)cout << ans[i] << " ";cout << "\n";
}
int main()
{
 input();
 return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  vector<int> v;
  cin>>a>>b>>k;
  int m=min(a,b);
  for(int i=1;i<=m;i++){
    if(a%i==0 && b%i==0) v.push_back(i);
  }
  sort(v.begin(),v.end(),greater<int>());
  cout<<v[k-1];

}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,K = LI()
A = LI()

for r in range(K):
    b = [0]*(N+1)
    for i in range(N):
        b[max(0,i-A[i])] += 1
        b[min(N,i+A[i]+1)] -= 1
    cb = [0]*N
    flag = True
    for i in range(N):
        cb[i] = min(cb[i-1]+b[i],N)
        if cb[i] != N:
            flag = False
    A = cb[:]
    if flag:
        break

print(*A)

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct edge {
  ll to, cost;
};

int main() {
  ll N; cin >> N;
  vector<string> S(N); REP(i, N) cin >> S[i];
  map<string, int> m;
  REP(i, N) m[S[i]]++;
  vector<string> ans; int res = 0;
  for(auto x : m) if(res < x.second) res = x.second;
  for(auto x : m) {
    if(x.second == res) ans.push_back(x.first);
  }
  sort(all(ans));
  REP(i, ans.size()) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 33452
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

ll c[111111],d[111111];

void Main() {
  ll n,x,m;
  cin >> n >> x >> m;
  memset(c,-1,sizeof(c));
  ll a=x,sum=0;
  c[a]=0;
  d[0]=a;
  sum+=a;
  REP(i,1,n) {
    ll b=a*a%m;
    a=b;
    if(c[a]!=-1) {
      n-=i;
      ll k=i-c[a];
      ll z=0;
      REP(j,c[a],i) {
        ll cnt=n/k;
        if(z<n%k) cnt++;
        sum+=d[j]*cnt;
        z++;
      }
      pr(sum);
      return;
    }
    sum+=a;
    c[a]=i;
    d[i]=a;
  }
  pr(sum);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 4792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.BitSet;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AnandOza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CYutori solver = new CYutori();
        solver.solve(1, in, out);
        out.close();
    }

    static class CYutori {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int c = in.nextInt();
            char[] sin = in.next().toCharArray();
            boolean[] s = new boolean[n];
            for (int i = 0; i < n; i++) {
                s[i] = sin[i] == 'x';
            }

            // let's say he works on the earliest possible days
            BitSet first = new BitSet(n);
            outer:
            for (int d = 0; d < n; d += c + 1) {
                while (s[d]) {
                    d++;
                    if (d >= n)
                        break outer;
                }
                first.set(d);
            }
            BitSet last = new BitSet(n);
            outer:
            for (int d = n - 1; d >= 0; d -= c + 1) {
                while (s[d]) {
                    d--;
                    if (d < 0)
                        break outer;
                }
                last.set(d);
            }

            if (first.cardinality() > k) {
                return;
            }

            first.and(last);
            for (int i = first.nextSetBit(0); i != -1; i = first.nextSetBit(i + 1)) {
                out.println(i + 1);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

#define fi first
#define se second
#define repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define repr(i, a, b) for (int i = (int)(a - 1); i >= b; i--)
#define rep(i, n) repl(i, 0, n)
#define each(itr, v) for (auto itr : v)
#define pb(s) push_back(s)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cout << #x " = " << x << endl
#define dbgv(i, a, v) \
  rep(i, a) { cout << v[i] << ((i == a - 1 ? '\n' : ' ')); }
#define maxch(x, y) x = max(x, y)
#define minch(x, y) x = min(x, y)
#define uni(x) x.erase(unique(all(x)), x.end())
#define exist(x, y) (find(all(x), y) != x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX / 3

int main() {
  cin.sync_with_stdio(false);
  int w;
  cin >> w;
  int a[w] = {}, r[w] = {}, l[w] = {};
  vector<int> in, ex, dr;
  ex.pb(-1);
  rep(i, w) {
    cin >> a[i];
    r[i] = l[i] = INF;
    if (a[i] > 0) in.pb(i);
    if (a[i] == 0) ex.pb(i);
    if (a[i] < 0) dr.pb(i);
  }
  if (ex.size() == 1) {
    cout << 0 << endl;
  } else {
    ex.pb(w);
    rep(i, ex[1]) l[i] = -1;
    repl(i, 1, ex.size() - 1) {
      l[ex[i]] = -1;
      int t = INF;
      repl(j, ex[i] + 1, ex[i + 1]) {
        if (a[j] < 0) {
          if (t >= abs(a[j])) t = abs(a[j]) - 1;
        }
        l[j] = t;
        t = max(t - 1, -1);
      }
    }
    repr(i, w, ex[ex.size() - 2] + 1) r[i] = -1;
    repr(i, ex.size() - 1, 1) {
      r[ex[i]] = -1;
      int t = INF;
      repr(j, ex[i], ex[i - 1] + 1) {
        if (a[j] < 0) {
          if (t >= abs(a[j])) t = abs(a[j]) - 1;
        }
        r[j] = t;
        t = max(t - 1, -1);
      }
    }
    int ans = 0;
    rep(i, w) {
      if (a[i] > 0) ans += min(a[i] - 1, max(r[i], l[i])) + 1;
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 4732
n = int(input())
sch = [list(map(int, input().split())) for _ in range(n)]
sch.sort(key=lambda val: val[1])

flag = True
time = 0
for elem in sch:
    need, limit = elem
    time += need
    if time > limit:
        flag = False
        break

print('Yes' if flag == True else 'No')


Measured memory_bytes: 53708
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
using namespace std;
int main()
{
    int n;
    int min = 1000000009;
    cin >> n;

    vector<int>v(n );
    int key;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        if (v[i] < min) {
            min = v[i];
            key = i;
        }
    }
    int i = 0;
    while (1) {
        
        if (key != i) {
            int a = v[i] % min;
            v[i] = a;
            if (min > a && a!=0) {
                min = a;
                key = i;
                i = 0;
                continue;
            }
            
        }
        i++;
        if (i == n)break;
    }


    cout << min<<endl;
}



Measured memory_bytes: 3740
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	llint n,i,ans=1,gen=0;cin>>n;
	string str;cin>>str;
	str.ins(str.begin(),'W');str.pub('W');
	int kri=0;
	for(i=1;i<=n+n;i++){
		int aa=0;
		if(str[i-1]!=str[i]){aa=1;}
		aa+=kri;aa%=2;
		if(aa==1){gen++;}
		else{ans*=gen;ans%=mod;gen--;}
		kri=1-aa;
	}
	if(gen!=0){ans=0;}
	for(i=1;i<=n;i++){ans*=i;ans%=mod;}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <map>
#include <cmath>



using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;

lld f(lld x,lld y)
{
	lld sol = max(floor(log10(x)+1),floor(log10(y)+1));
	return sol;
}

int main()
{
	lld n;

	cin >> n;

	lld sol = floor(log10(n)+1);

	for(lld i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			lld x = f(i,n / i);
			//cout << " i = " << i << "n / i = " << n / i << endl;
			if (x < sol )
			{
				sol = x;
			}
		}
	}

	cout << sol << endl;

	return 0;
}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int N;
ll ans;

void check_sum(string s,int x,vector<bool> &ope){
  if(x==N-1){
    ll sum=0;
    int f=0;
    for(int i=0;i<N-1;i++){
      if(ope.at(i)){
        sum += atoll(s.substr(f,i-f+1).c_str());
        f = i+1;
      }
    }
    sum += atoll(s.substr(f).c_str());
    ans += sum ;
    //puts("###");
    return ;
  }

  ope.at(x)=false;
  check_sum(s,x+1,ope);

  ope.at(x)=true;
  check_sum(s,x+1,ope);
}

int main(){
  string s;cin >> s;
  N = s.size();
  ans = 0;
  vector<bool> ope(s.size(),false);

  check_sum(s,0,ope);

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int H, W;
    cin >> H >> W;

    vector<vector<char> > C(H, vector<char>(W));

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> C[i][j];
        }
    }

    for(int i = 0; i < H * 2; i++) {
        for(int j = 0; j < W; j++) {
            cout << C[i / 2][j];
        }
        cout << endl;
    }
}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/a.in", "r", stdin);
//  freopen("../IO/a.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

void solve(std::istream &in, std::ostream &out) {
  int n, m;
  in >> n >> m;
  vector<vector<int>> graph(n);
  for (int i = 0, x, y; i < m; ++i) {
    in >> x >> y;
    --x;
    --y;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  vector<int> col(n, -1);
  col[0] = 0;
  queue<int> que;
  que.push(0);
  bool bipartite = true;
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (int v : graph[u]) {
      if (col[v] != -1) {
        bipartite &= col[v] == 1 - col[u];
      } else {
        col[v] = 1 - col[u];
        que.push(v);
      }
    }
  }
  if (bipartite) {
    int cnt = accumulate(col.begin(), col.end(), 0, std::plus<>());
    out << (int64_t) cnt * (n - cnt) - m << '\n';
  } else {
    out << (int64_t) n * (n - 1) / 2 - m << '\n';
  }
}

Measured memory_bytes: 9236