akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//int→string
//string→int
//------------------------------------------
inline int toInt(string s) {
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}

template<class T>
inline string toString(T x) {
    ostringstream sout;
    sout << x;
    return sout.str();
}

//sqrt
//-------------------------------------------
template<class T>
inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//repetition
//------------------------------------------
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  FOR(i,0,n)
#define REPR(i, n) for(int i = n;i >= 0;i--)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main() {

    LL X; scanf("%lld", &X);
    LL Y; scanf("%lld", &Y);
    LL count = 0;

    while(true){
        count++;
        X *= 2;
        if(X <= Y){

        }else{
            break;
        }
    }

    printf("%lld", count);

    return 0;
}











































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

using namespace std;

// Function to solve the problem come here.

int main(int argc, char **argv)
{
    // The solution come here...
    // 1) 3 5 4
    int A, B, C, T;
    cin >> A >> B >> C;
    cin >> T;

    int sum;
    for (int i = 0; i < T; i++)
    {
        if (A > B && A > C)
        {
            A = 2 * A;
        }
        else if (B > C)
            B = 2 * B;
        else
            C = 2 * C;

        sum = A + B + C;
    }

    cout << sum << endl;

    return 0;
}

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

int main() {
	ll N, A, B;
	cin >> N >> A >> B;

	if (A > B) {
		cout << 0 << endl;
		return 0;
	}

	if (N == 1) {
		if (A != B) { cout << 0 << endl; }
		else { cout << 1 << endl; }
		return 0;
	}
	
	ll max_sum = B * (N - 1) + A;
	ll min_sum = A * (N - 1) + B;
	ll res = max_sum - min_sum + 1;

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
a,b=map(int,raw_input().split())
t,n,m=a-b,b,a
ans=b
while 1:
    if n<m:
        ans+=t
        t,n,m=n,t,t
    elif n%t==0:
        ans+=n*2-t
        break
    else:
        s=n+m
        n,m=n%t,m%t+t
        ans+=s-n-m
print ans

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

using namespace __gnu_pbds; 
using namespace __gnu_cxx;
using namespace std;
using ll = long long;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define precision(n) fixed<<setprecision(n)

#ifdef LOCAL
    #include "debug.h"
#else
    #define debug(...) 42
#endif

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}

template<typename T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update >;
template<typename T> using MinPriorityQueue = priority_queue <T, vector <T>, greater <T> >;
template<typename T> void done(T ans) {cout << ans << "\n"; exit(0);}


template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}
const int mod = 998244353;
const int N = 3e5 + 5;



int main() {
    io();
    int n, m, x;
    cin >> n >> m >> x;
    int cost[n];
    int a[n][m];
    for(int i = 0; i < n; i++) {
        cin >> cost[i];
        for(int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int sum = 0;
    int ans = 1e9;
    for(int i = 0; i < (1 << n); i++) {
        vector<int> req(n);
        int flag = 0;
        sum = 0;
        for(int j = 0; j < n; j++) {
            if((1 << j) & i) {
                sum += cost[j];
                for(int k = 0; k < m; k++) {
                    req[k] += a[j][k];
                }
            }
         }

         for(int k = 0; k < m; k++) {
            if(req[k] >= x)
                continue;
            else
                flag = 1;
         }
         if(flag == 0)
            ans = min(ans, sum);
    }
    if(ans == 1e9)    cout << "-1";
    else
        cout << ans;
}


Measured memory_bytes: 3692
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#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;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const ll mod = 1000000007;
ll dp[2][5005][5005],coef[5005];
int n,sub[5005];
vector<int>edge[5005];

void dfs(int v,int u){
	sub[v] = 1;
	vector<ll>t[2][2];
	rep(a,2)rep(b,2) t[a][b].resize(5005,0);
	t[0][0][1] = 1;
	int cur = 0, nxt = 1;
	rep(i,edge[v].size()){
		int to = edge[v][i]; if(to == u) continue;
		dfs(to,v);
		rep(i,2)rep(j,5005) t[nxt][i][j] = 0;
		
		rep(p,2){
			repn(x,sub[to]){
				//dp[p][to][x]
				if(dp[p][to][x] == 0) continue;
				rep(q,2){
					repn(y,sub[v]){
						//t[cur][q][y]
						if(t[cur][q][y] == 0) continue;

						//not cut
						t[nxt][(p^q)][x+y] += t[cur][q][y] * dp[p][to][x] % mod;
						if(t[nxt][(p^q)][x+y] >= mod) t[nxt][(p^q)][x+y] -= mod;
						//cut
						t[nxt][1^(p^q)][y] += t[cur][q][y] * coef[x] % mod * dp[p][to][x] % mod;
						if(t[nxt][1^(p^q)][y] >= mod) t[nxt][1^(p^q)][y]  -= mod;
					}
				}
			}
		}
		sub[v] += sub[to];
		swap(cur,nxt);
	}
	rep(i,5005) rep(j,2) dp[j][v][i] = t[cur][j][i];
}
int main(){
	cin >> n;
	rep(i,n-1){
		int a,b; cin >> a >> b;
		edge[a].pb(b);
		edge[b].pb(a);
	}
	rep(i,5005){
		if(i%2 == 0){
			if(i == 0) coef[i] = 1;
			else coef[i] = coef[i-2] * (i-1) % mod;
		}
	}
	dfs(1,-1);
	
	ll ans = 0;
	rep(i,5005){
		rep(j,2){
			if(j == 0) ans += dp[j][1][i] * coef[i] % mod;
			else ans -= dp[j][1][i] * coef[i] % mod;
		}
	}
	
	cout << (ans%mod+mod)%mod << endl;
}

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

typedef pair<int,int> PII;
const int M=2005;
vector<int> g[M];
int n,k;
int dfs(int u,int fa,int d,int md)
{
	if(d>md) return 0;
	int ans=1;
	for(int v:g[u])
	{
		if(v==fa) continue;
		ans+=dfs(v,u,d+1,md);
	}
	return ans;
}

int main()
{
	scanf("%d%d",&n,&k);
	int u,v;
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int ans=n;
	for(int i=1;i<=n;i++)
	{
		int nans=1,diff=0;
		for(int v:g[i])
		{
			int a=dfs(v,i,1,k/2);
			int b=dfs(v,i,1,(k+1)/2);
			diff=max(diff,b-a);
			nans+=a;
		}
		nans+=diff;
		ans=min(ans,n-nans);
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli d,n;

int main(){
  cin >> d >> n;
  if(n == 100) n++;
  for(lli i = 0;i < d;i++){
    n *= 100;
  }
  cout << n << endl;
}


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

using namespace std;

int main()
{
    long long int a,b,c,k,sum=0;
    cin>>a>>b>>c>>k;
    if(k>a)
    {
        sum=sum+a;    
    }
    else
    {
        sum=sum+k;
    }
    k=k-a;
    if(k>0)
    {
        k=k-b;
        if(k>0)
        {
            if(k>c)
            {
                sum=sum-c;
            }
            else
            {
                sum=sum-k;
            }
        }
    }
    cout<<sum<<endl;
    
}

Measured memory_bytes: 3632
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 2e4 + 20 ;
int n , a[N] , b[N] , part[N] ;

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

	cin >> n ;
	for (int i = 0 , p ; i < n ; i ++) cin >> p , part[--p] += i ;

	for (int i = 0 ; i < n ; i ++) a[i] = i + 1 , b[i] = n - i ;

	for (int i = 0 , cur = 0 ; i < n ; i ++) cur += part[i] , a[i] += cur ;
	for (int i = n - 1 , cur = 0 ; i >= 0 ; i --) cur += part[i] , b[i] += cur ;

	for (int i = 0 ; i < n ; i ++) cout << a[i] << ' ' ;
	cout << '\n' ;
	for (int i = 0 ; i < n ; i ++) cout << b[i] << ' ' ;
	cout << '\n' ;
}

Measured memory_bytes: 896
import java.io.PrintWriter;
import java.util.*;

public class Main {
		public static void main(String[] args) {
			Scanner stdin = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out);
			
			int A = Integer.parseInt(stdin.next());
			int B = Integer.parseInt(stdin.next());
			
			if(A%2 != B%2) {
				out.print("IMPOSSIBLE");
			}
			else {
				out.print((A+B)/2);
			}
			
			out.flush();
	}
}




Measured memory_bytes: 21844
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
int table[300000];

int main(){
  int i,j,n,x;
  for(i=7;i<=300000;i+=7){
    table[i-1]=table[i+1]=1;
  }
  for(i=7;i<=(int)::sqrt(300000);i+=7){
    if(table[x=i-1])
      for(j=x<<1;j<=300000;j+=x)table[j]=0;
    if(table[x=i+1])
      for(j=x<<1;j<=300000;j+=x)table[j]=0;
  }

  while(1){
    vector<int> v;
    scanf("%d",&n);
    if(n==1)return 0;
    printf("%d:",n);

/*
    for(i=7;i<=n+1;i+=7){
      if(table[x=i-1] && !(n%x))printf(" %d",x);
      if(table[x=i+1] && !(n%x))printf(" %d",x);
    }
*/

    for(i=7;i<(j=(int)::sqrt(n));i+=7){
      if(!(n%(x=i-1))){
        if(table[x])v.push_back(x);
        if(table[n/x]&&n!=x*x)v.push_back(n/x);
      }
      if(!(n%(x=i+1))){
        if(table[x])v.push_back(x);
        if(table[n/x]&&n!=x*x)v.push_back(n/x);
      }
    }
    if(i-j==1&&!(n%(x=i-1))){
      if(table[x])v.push_back(x);
      if(table[n/x]&&n!=x*x)v.push_back(n/x);
    }
    if(table[n])v.push_back(n);
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++)printf(" %d",v[i]);

    puts("");
  }
}

Measured memory_bytes: 2236
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<utility>
#include<string>

using namespace std;

char str[1005];
int js[1005][1005];
int os[1005][1005];
int is[1005][1005];

main(){
  int J,O,I;
  int m,n,k;
  int i,j,l;
  int a,b,c,d;
  int maxx,maxy,minx,miny;

  memset(str,0,sizeof(str));
  scanf("%d %d",&m,&n);
  scanf("%d",&k);
  for(i=1;i<=m;i++){
    scanf("%s",str);
    for(j=0;j<n;j++){
      if(str[j]=='J') js[i][j+1]++;
      if(str[j]=='O') os[i][j+1]++;
      if(str[j]=='I') is[i][j+1]++;
    }
  }
      /*
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      printf("%3d",js[i][j]);
    }
    puts("");
  }
  puts("\n\n");
      */
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      js[i][j] += js[i][j-1];
      os[i][j] += os[i][j-1];
      is[i][j] += is[i][j-1];
    }
  }
      /*
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      printf("%3d",js[i][j]);
    }
    puts("");
  }
  puts("\n\n");
      */
  for(j=1;j<=n;j++){
    for(i=1;i<=m;i++){
      js[i][j] += js[i-1][j];
      os[i][j] += os[i-1][j];
      is[i][j] += is[i-1][j];
    }
  }
      /*
  for(i=0;i<=m;i++){
    for(j=0;j<=n;j++){
      printf("%3d",js[i][j]);
    }
    puts("");
  }
      */
  for(l=0;l<k;l++){
    scanf("%d %d %d %d",&a,&b,&c,&d);
    minx=min(a,c);
    miny=min(b,d);
    maxx=max(a,c);
    maxy=max(b,d);
    minx--;
    miny--;
    J=js[maxx][maxy]-js[maxx][miny]-js[minx][maxy]+js[minx][miny];
    O=os[maxx][maxy]-os[maxx][miny]-os[minx][maxy]+os[minx][miny];
    I=is[maxx][maxy]-is[maxx][miny]-is[minx][maxy]+is[minx][miny];
    printf("%d %d %d\n",J,O,I);
  }

}

/*
4 7
4
JIOJOIJ
IOJOIJO
JOIJOOI
OOJJIJO
3 5 4 7
2 2 3 6
2 2 2 2
1 1 4 7
*/

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int k,i,j,x,n,c=0;
    string s1,s2="ABC";
    cin>>n>>s1;
    for(i=0;i<n;i++)
    {
        if(s1[i]=='A')
        {
            if(s1[i+1]=='B')
            {
                if(s1[i+2]=='C')
                {
                    c++;
                    i=i+2;
                }
            }
        }
    }
    cout<<c<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool isprime(int x){
	for(int i=2;i<x;i++){
		if(x%i==0)return 0;
	}
	return 1;
}
int main(){
	int n;
	cin>>n;
	for(int i=n;;i++){
		if(isprime(i)){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
} 

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);

  ll N;
  scanf("%lld", &N);

  vector<ll> a;
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);

    if (a.size() == 0 || v != a[a.size() - 1]) {
      a.emplace_back(v);
    }
  }
  // for (ll i = 0; i < a.size(); i++) {
  //   cout << "a[i]:" << a[i] << endl;
  // }
  //
  N = a.size();
  a.emplace_back(-99999);

  //
  vector<ll> b;

  ll mode;
  if (a[0] < a[1]) {
    mode = 1;
    b.emplace_back(-a[0]);
  }
  if (a[0] > a[1]) {
    mode = -1;
  }

  for (ll i = 0; i < N; i++) {
    if (mode == 1) {
      if (a[i] > a[i + 1]) {
        // 上昇ストップ
        b.emplace_back(a[i]);
        mode = -1;
        continue;
      }
    }
    if (mode == -1) {
      if (a[i] < a[i + 1]) {
        // 下降ストップ
        b.emplace_back(-a[i]);
        mode = +1;
        continue;
      }
    }
  }

  // cout << "------------------------------" << endl;
  // for (ll i = 0; i < b.size(); i++) {
  //   cout << b[i] << endl;
  // }
  // cout << "------------------------------" << endl;

  ll stock = 0;
  ll money = 1000;
  for (ll i = 0; i < b.size(); i++) {
    if (b[i] < 0) {
      ll p = -b[i];
      stock += money / p;
      money = money % p;
    }
    if (b[i] > 0) {
      ll p = b[i];
      money += stock * p;
      stock = 0;
    }
  }

  cout << money << endl;
}


Measured memory_bytes: 3692
function permutation(n,k){
    var ret=[[]];
    var next;
    for(var i=0;i<k;i++){
        next=[];
        ret.forEach(e=>{
            for(var k=1;k<=n;k++){
                if(!e.includes(k)){
                    next.push(e.concat([k]));
                }
            }
        });
        ret=next.concat([]);
    }
    return ret;
}

function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  const K=input[0].split(' ')[1]-0;
  const R=input[1].split(' ')[0]-0;
  const S=input[1].split(' ')[1]-0;
  const P=input[1].split(' ')[2]-0;
  const T=input[2];
  var ans=0;
  var passed=new Array(N);
  passed.fill(false);
  for(var i=0;i<T.length;i++){
    if(i>=K&&T[i]===T[i-K]&&!passed[i-K]){
      passed[i]=true;
      continue;
    }
    switch(T[i]){
      case 'r':
        ans+=P;
        break;
      case 's':
        ans+=R;
        break;
      case 'p':
        ans+=S;
        break;
    }
  }
  console.log(ans);
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 33440
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long int
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pi pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define deb(x) cerr<<#x<<" : "<<x<<endl;
#define fi first
#define se second
#define mi map<int,int>
#define PI   3.141592653589
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define f(i,x,n) for(int i=x;i<n;i++)
#define rf(i,x,n) for(int i=n;i>=x;i--)
#define check(x)   cerr<<#x<<" : "<<x<<endl;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order
#define ook order_of_key
#define baar exit(0)
using namespace __gnu_pbds;
using namespace std;
int powmod(int base,int exponent)
{
	int ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base);
		base=(base*base);
		exponent/=2;
	}
	return ans;
}
signed main()
{
  fast
  int t;
  cin>>t;
  while(t--)
  {
  	cout<<"ACL";
  }
  cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
  return 0;
}
 

Measured memory_bytes: 3800
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
  int n;
  while(cin>>n){
    reep(i,1,n+1){
      int x=i;
      if(x%3==0){
        cout<<" "<<i;
      }
      else{
        do{
          if(x%10==3){
            cout<<" "<<i;
            break;
          }
          x/=10;
        }while(x);
      }
    }
  }
  cout<<endl;
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1164
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>

using namespace std;

int main() {

	int N;
	cin >> N;

	vector<int> vNum(N, 0);
	vector<int> vNumSort(N, 0);

	for (int i = 0; i < N; i++)
	{
		int setNum;
		cin >> setNum;
		vNum[i] = vNumSort[i] = setNum;
	}

	sort(vNumSort.begin(), vNumSort.end());

	int wrongNum = 0;
	for (int i = 0; i < N; i++)
	{
		if (vNum[i] != vNumSort[i])
		{
			++wrongNum;
		}
	}

	if (wrongNum == 2 || wrongNum == 0)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
 
 
int main()
{
    const int N = 5;
    while(1)
    {
        int hand[N];
        char x;
        int j;
        for(int i = 0; i < N; i++)
        {
            if(i)
                cin >> x;
            cin >> hand[i];
        }
        if(!cin)
            break;
 
        sort(hand, hand+N);
 
        if(hand[0] == hand[3] ||
            hand[1] == hand[4])
            cout << "four card" << endl;
        else if( (hand[0] == hand[1] && hand[2] == hand[4]) ||
                (hand[0] == hand[2] && hand[3] == hand[4]) )
            cout << "full house" << endl;
        else if( (hand[0] == 1 && hand[1] == 10 && hand[2] == 11 && hand[3] == 12 && hand[4] == 13) ||
            (hand[0]+1==hand[1] && hand[1]+1==hand[2] && hand[2]+1==hand[3] && hand[3]+1==hand[4]) )
            cout << "straight" << endl;
        else if( (hand[0] == hand[2] || hand[1] == hand[3] || hand[2] == hand[4]) )
            cout << "three card" << endl;
        else if( (hand[0]==hand[1] && hand[2]==hand[3]) ||
                (hand[0]==hand[1] && hand[3]==hand[4]) ||
                (hand[1]==hand[2] && hand[3]==hand[4]) )
            cout << "two pair" << endl;
        else if( hand[0]==hand[1] || hand[1]==hand[2] || hand[2]==hand[3] || hand[3]==hand[4] )
            cout << "one pair" << endl;
         else
         cout<<"null"<<endl;
       
    }
    return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define vi vector<int>
#define pi pair<int,int>
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define ll long long 

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x){
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x){
	for(auto& i:x)
		input>>i;
	return input;
}

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

const int mod=1e9+7;

int mul(int a,int b)
{
	return (a*1ll*b)%mod;
	}
	
	int add(int a,int b)
	{
		a+=b;
		if(a>=mod)return a-mod;
		return a;
		}
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
		}
		return res;
	}



void solve()
{
int n;
cin>>n;
int dp[3]={0},a[3];
for(int i=0;i<n;i++)
{
	for(int j=0;j<3;j++){cin>>a[j];	}
	int cur_dp[3];
	cur_dp[0]=dp[0];cur_dp[1]=dp[1];cur_dp[2]=dp[2];
	for(int k=0;k<3;k++)
	{
		for(int j=0;j<3;j++)
		{
			if(j==k)continue;
		dp[k]=max(dp[k],cur_dp[j]+a[k]);
		}
	}
	
}
cout<<max({dp[0],dp[1],dp[2]});
}
	
	
int main()
{   ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
		}
	
	
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
const int MAX=2e5;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  string S; cin >> S;
  int l=S.size();
  int ans=l;
  rep(i,l-1){
    if(S[i]!=S[i+1]){
      chmin(ans,max(i+1,l-(i+1)));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
class Node:
    def __init__(self, id):
        self.id = id
        self.left = None
        self.right = None
        self.sibling = None
        self.parent = None

def postorder_tree_walk(root):
    result = []
    if root.left != None:
        result.extend(postorder_tree_walk(root.left))
    if root.right != None:
        result.extend(postorder_tree_walk(root.right))
    result.append(root.id)
    return result

def make_tree(root, left_ids, right_ids, tree, pre):
    if len(left_ids) == 1:
        root.left = tree[left_ids[0]]
    elif len(left_ids) > 1:
        root_id = 0
        for x in pre:
            if x in left_ids:
                root_id = x
                break
        index = left_ids.index(root_id)
        root.left = tree[root_id]
        make_tree(tree[root_id], left_ids[:index], left_ids[index + 1:], tree, pre)

    if len(right_ids) == 1:
        root.right = tree[right_ids[0]]
    elif len(right_ids) > 1:
        root_id = 0
        for x in pre:
            if x in right_ids:
                root_id = x
                break
        index = right_ids.index(root_id)
        root.right = tree[root_id]
        make_tree(tree[root_id], right_ids[:index], right_ids[index + 1:], tree, pre)

n = int(raw_input())
tree = [Node(i) for i in xrange(n+1)]
tree[0] = None
pre = map(int, raw_input().split())
inoder = map(int, raw_input().split())
root = tree[pre[0]]
index = inoder.index(root.id)
make_tree(root, inoder[:index], inoder[index + 1:], tree, pre)
result = postorder_tree_walk(root)
print ' '.join(map(str, result))

Measured memory_bytes: 6404
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int k,x; cin >> k >> x;
  for(int i = -(k-1); i < k; i++){
    cout << x+i << " ";
  }
  cout << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_dwa_a() {
	ll N, ans;
	cin >> N;

	vector<string> s(N);
	vector<ll> t(N);

	rep(i, N) {
		cin >> s[i] >> t[i];
	}

	string X;
	cin >> X;

	ans = 0;
	bool is_slept = false;
	rep(i, N) {
		if (s[i] == X) {
			is_slept = true;
		}
		else {
			if (is_slept) {
				ans += t[i];
			}
		}
	}

	cout << ans << "\n";
}

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

	solve_dwa_a();

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
#define N 105
#define M 100000005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define LL long long
int h,w;
char a[N][N];
int f[N][N];
int rd()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1; c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return f*x;
}
int main()
{
	h=rd(),w=rd();
	for(int i=1;i<=h;i++)
		scanf("%s",a[i]+1);
	memset(f,INF,sizeof(f));
	if(a[1][1]=='#') f[1][1]=1;
	else f[1][1]=0;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
		{
			if(i!=1) f[i][j]=min(f[i-1][j]+(a[i-1][j]!=a[i][j]),f[i][j]);
			if(j!=1) f[i][j]=min(f[i][j-1]+(a[i][j-1]!=a[i][j]),f[i][j]);
		}
	//
	int ans=f[h][w];//printf("%d\n",f[1][1]);
	if(ans&1) ans=ans/2+1;
	else ans=ans/2;
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

#define ll long long

const int mxN = 3003;

int n;

ll dp[mxN][mxN];
ll a[mxN];

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

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    for (int L=n; L>=1; L--) {
        dp[L][L]=a[L];
        for (int R=L+1; R<=n; R++) {
            dp[L][R]=max(a[L]-dp[L+1][R], a[R]-dp[L][R-1]);
        }
    }
    cout << dp[1][n] << endl;
}


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

#define ll long long

int main(){

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

    string Result = "Yes"; 
    
    if( x+r > W){
        Result = "No";
    }
    if( x-r < 0 ){
        Result = "No";
    }
    if( y+r > H ){
        Result = "No";
    }
    if( y-r < 0 ){
        Result = "No";
    }

    cout << Result << endl;


    return 0;
}

Measured memory_bytes: 3160
#include <stdio.h>
int main(){
	int A,i,C=0,B=0;
	for(i=0;i<5;i++){
		scanf("%d",&A);
		if(A<40){
			C=C+40;
		}
		else{
			C=C+A;
		}
	}
	C=C/5;
	printf("%d\n",C);
	return 0;
}


Measured memory_bytes: 2104
import java.util.Scanner;

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

        if(S.matches("^A[a-z]+[C]{1}+[a-z]+$")) {
        	System.out.println("AC");
        }else {
        	System.out.println("WA");
        }
	}

}


Measured memory_bytes: 21844
#include <cstdio>
using namespace std;

int emb[] = {0,0,0,0,0,0,0,1,0,0,0,1,0,1,1,1,0,0,0,1,0,1,1,1,0,1,1,1,1,2,1,1,0,0,0,1,0,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,2,1,2,1,2,2,2,1,2,1,1,0,0,0,1,0,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,2,1,2,1,2,1,1,1,1,0,1,1,1,1,2,1,2,1,2,2,2,1,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,1,2,1,1,0,0,0,1,0,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,2,1,2,1,2,1,2,2,2,1,2,2,2,1,2,2,2,1,2,1,2,1,1,1,1,0,1,1,1,1,2,1,2,1,2,2,2,1,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,1,2,1,1,0,0,0,1,0,1,1,1,0,1,1,2,1,2,1,1,0,1,1,2,1,2,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,2,1,1,1,2,1,2,2,2,1,2,1,2,1,2,1,2,1,2,1,1,1,1,1,1,0,1,1,1,1,1,1,2,1,2,1,2,1,2,2,2,1,2,2,2,1,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,1,2,2,2,1,2,1,2,1,1,1,1,0,1,1,1,1,2,1,2,1,2,2,2,1,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,3,2,3,2,2,2,3,2,3,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,3,2,3,2,2,1,2,2,3,2,3,2,2,1,2,2,2,1,2,1,1,0,0,0,1,0,1,1,1,0,1,1,2,1,2,1,1,0,1,1,2,1,2,2,1,1,2,2,2,1,2,1,1,0,1,1,2,1,2,2,2,1,1,2,2,1,2,1,2,1,1,1,2,1,2,1,1,1,2,1,1,1,1,1,1,0,1,1,1,1,1,1,2,1,1,1,2,1,2,2,2,1,2,1,2,1,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,1,2,2,2,1,2,2,2,1,2,2,2,1,2,2,2,1,2,1,2,1,2,1,1,1,1,1,1,0,1,1,1,1,1,1,2,1,2,1,2,1,2,2,2,1,2,2,2,1,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,1,2,2,2,1,2,1,2,1,1,1,1,0,1,1,1,1,2,1,2,1,2,2,2,1,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,3,2,2,2,2,1,2,2,2,2,3,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,2,2,2,3,2,3,2,2,2,3,2,2,2,2,2,2,1,2,2,2,2,2,2,3,2,2,2,3,2,3,2,2,2,3,2,3,2,3,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,3,3,2,3,3,3,2,3,2,3,2,3,3,3,2,3,3,3,2,3,2,3,2,2,2,3,2,3,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,3,2,3,2,2,2,2,2,3,2,3,3,3,2,3,3,3,2,3,2,2,1,2,2,3,2,3,3,3,2,};

int main() {
	for (int i = 2; i <= 1000; ++i ){
		emb[i] += 32 - __builtin_clz(i-1);
	}
	for (int n;scanf("%d", &n), n; printf("%d\n", emb[n])) ;
	return 0;
}

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

const int N = 1010101, M = 200;

int main() {
    vector<int> A(M + 1, 1);
    rep(_, 3) rep(i, M) A[i + 1] += A[i];
    vector<int> dp(N, N), ep(N, N);
    dp[0] = 0;
    ep[0] = 0;
    for(auto &n : A) rep(i, N) {
        if(i + n < N) {
            dp[i + n] = min(dp[i + n], dp[i] + 1);
            if(n % 2) ep[i + n] = min(ep[i + n], ep[i] + 1);
        }
    }
    int N;
    while(cin >> N) {
        if(!N) break;
        cout << dp[N] << " " << ep[N] << '\n';
    }
    return 0;
}



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

int main()
{
	int n;
	cin >> n;
	vector<int> p (n);
	for(int i = 0;i<n;i++)cin >> p[i];
	int ans = 0;
	for(int i = 0;i<n;i++)if(p[i]==i+1)
	{
		ans++;i++;
		//cout<<p[i]<<endl;
	} 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);
    ArrayList<Data> data;
    boolean debug = false;
    
    //global hensuu except for templete
    char[] lines;

    //method except for templete
    int rec(int left, int right){
	PriorityQueue<Integer> votes = new PriorityQueue<Integer>(10, new Comparator<Integer>(){
		public int compare(Integer a, Integer b){
		    return (int)(a - b);
		}
	    });

	int l = left, r = left;
	if(lines[l]-'0' >=0 && lines[l]-'0'<=9) return getNumber(left, right);

	int num = 0;
	for(int i=left; i<=right; i++){
	    r = i;
	    if(lines[i]==']') num--;
	    if(lines[i]=='[') num++;
	    if(num==0){
		votes.add(rec(l+1, r-1));
		l = i+1;
		num = 0;
	    }
	}

	int res = 0;
	int size = votes.size()/2 + 1;
	for(int i=0; i<size; i++) res += votes.poll();
	return res;
    }

    int getNumber(int left, int right){
	int res = 0;
	int ten = 1;
	for(int i=right; i>=left; i--){
	    res += (lines[i] - '0') * ten;
	    ten *= 10;
	}
	return res/2+1;
    }


    void run() {
	input();
	for(int i=0;i<data.size();i++){
	    if(debug){
		System.out.println("--------");
		data.get(i).print_line();
	    }
	    solve(i);
	    data.get(i).print_ans();
	}
    }
    
    void solve(int dataset){
	String ans = "";
	Data d = data.get(dataset);
	String line = d.line;
	lines = line.toCharArray();

	ans = Integer.toString(rec(0, lines.length-1));

	data.get(dataset).set_ans(ans);
    }

    void input(){
	data = new ArrayList<Data>();
	int n = sc.nextInt();
	for(int i=0; i<n; i++){
	    String s = sc.next();
	    data.add(new Data(s));
	}
    }
}

class Data{
    String line;
    String ans;

    Data(String line){
	this.line = line;
    }
    
    void set_ans(String a){ans=a;}
    void print_line(){System.out.println("line = "+line);}
    void print_ans(){System.out.println(ans);}
}
    

Measured memory_bytes: 33156
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

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

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,m;
	std::cin >> n >> m;
	std::vector<std::vector<int> > g(m);
	rep(i,m) {
		int k; std::cin >> k;
		rep(j,k) {
			int x;
			std::cin >> x;
			x--;
			g[i].emplace_back(x);
		}
	}
	std::vector<int> p(m);
	rep(i,m) std::cin >> p[i];
	int count=0;
	rep(s,1<<n) {
		int off=false;
		rep(i,m) {
			int cnt=0;
			for(auto x:g[i]) if(s>>x&1) cnt++;
			if(cnt%2!=p[i]) off=true;
		}
		if(!off) count++;
	}
	print(count);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int W, H, x, y;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> W >> H >> x >> y;
  double ans = (double)W * H / 2;
  cout << fixed << setprecision(10) << ans << " ";

  if (x * 2 == W && y * 2 == H) cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    ll n;
    cin >> n;
    int input[n-1];
    for (int i = 0; i < n - 1; i++)
    {
        cin >> input[i];
    }
    ll res = 0;
    res += input[0]+input[n-2];
    for (int i = 0; i < n - 2; i++)
    {
        res += min(input[i],input[i+1]);
    }
    cout << res << endl;

}


Measured memory_bytes: 3632
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut x = vec![0; n];
    let mut ans:i64 = 0;
    for i in 0..n {
        if i+a[i]<n {
            x[i+a[i]] += 1;
        }
        if i>=a[i] {
            ans += x[i-a[i]];
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 6596
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
const ll INF = 999999999999999;

int main(){
  ll n;
  cin >> n;
  map<ll,ll> s;
  map<ll,ll> t;
  vector<ll> m;
  for(ll i=1;i<=n;++i){
    ll a;
    cin >> a;
    s[i-a]++;
    if( s[i-a] == 1 ) m.push_back(i-a);
    t[i+a]++;
  }
  ll ans = 0;
  for(ll i=0;i<(ll)s.size();++i){
    ans += ((ll)s[m.at(i)])*((ll)t[m.at(i)]);
  }
  
  cout << ans << "\n";
  
  return 0;
}


Measured memory_bytes: 38952
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,=pin()
    A=lispin()
    temp=0
    sumA=[0]*N
    sumA[0]=A[0]
    for j in range(1,N):
        sumA[j]=sumA[j-1]+A[j]
    #print(sumA)
    ans=2**32-1
    t=sumA[-1]
    for i in range(N):
        ans=min(ans,abs(t-sumA[i]*2))
        
    print(ans)
#%%submit!
resolve()


Measured memory_bytes: 82468
n, k = map(int, input().split())
ps = [tuple(map(int, input().split())) for i in range(n)]

sx = sorted(ps) #xの順にソート
nx = list(enumerate(sx)) #それぞれの点に番号をつける0〜
ans = 5e18

for l, (x1, y1) in nx[:n - k + 1]: #4つ中3つなら先頭2つまで見ればいい
    for r, (x2, y2) in nx[l + k - 1:]: #0番目を見てる時は2番目以降、
        dx = x2 - x1
        sy = sorted(y for x, y in sx[l:r + 1])

        for y3, y4 in zip(sy, sy[k - 1:]):
            if y3 <= y1 and y2 <= y4:
                ans = min(ans, dx * (y4 - y3))
print(ans)

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
typedef long long ll;
const int N=2e5+10;

int n,b[N][2];
char str[N];

void trace(){
	for(int i=1; i<=n; i++) cout<<b[i][1]<<"";
	cout<<endl;
	for(int i=1; i<=n; i++) cout<<b[i][0]<<"";
	cout<<endl;
}
int main()
{
	cin>>n>>str+1;
	for(int i=1; i<=n; i++)
	{
		if(str[i]=='R') b[i][1]=b[i-1][1]+1,b[i][0]=b[i-1][0];
		else b[i][1]=b[i-1][1],b[i][0]=b[i-1][0]+1; 
	}
	
	//trace();
	
	int r=b[n][1],w=b[n][0];
	int ans=b[r][0];
	cout<<ans;
	return 0;
}

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

using namespace std;

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

const int oo = 0x3f3f3f3f;
const double pi = acos(-1);
const double eps = 1e-9;

#define endl '\n'


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

	string s;
	cin >> s;

	if (s[0] != s[1] || s[1] != s[2])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	// int n, p;

	// cin >> n >> p;

	// string s;
	// cin >> s;

	// vector<vi> dp(n + 1, vi(p));

	// dp[n][0] = 1;

	// for (int i = n - 1; i >= 0; --i){
	// 	for (int j = 0; j < p; ++j){
	// 		dp[i][j] = dp[]
	// 	}
	// }


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
    int main() {
      string A;
      cin >> A;
      int ans = 700;
      if (A[0] == 'o') {ans+=100;}
      if (A[1] == 'o') {ans+=100;}
      if (A[2] == 'o') {ans+=100;}
      cout << ans << endl;
      
	}

Measured memory_bytes: 256
import java.util.*;

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

        long N = sc.nextLong();
        long K = sc.nextLong();
        long mod = N % K;
        long sub = Math.abs(mod - K);

        System.out.println(Math.min(sub, mod));
    }
}


Measured memory_bytes: 21588
#include <stdio.h>
 
#define N 100
 
int queue[N] = {};
int b = 0, e = 0;
int step[N] = {};

void ENQ(int);
int DEQ();
int isemp();
void clear();
void BFS(int[], int s, int n);

int main(int argc,char *argv)
{
    int n, i, j, u, k, v;
    int cnt = 0;
    int table[N*N] = {};
    scanf( "%d", &n );
 
    clear();
 
    for( i=0; i<n; ++i ) {
        scanf( "%d %d", &u, &k );
        for( j=0; j<k; ++j ) {
            scanf("%d", &v);
            table[((u-1)*N)+(v-1)] = 1;
        }
    }
 
    BFS( table, 1, n );
 
    for( i=0; i<n; ++i )
        printf("%d %d\n", i+1, step[i]);
 
    return 0;
}
void ENQ( int v ) {
    queue[b++] = v;
}
int DEQ() {
    return queue[e++];
}
int isemp() {
    return b == e;
}
 
void clear()
{
    int i;
    for( i=0; i<N; ++i ) {
        queue[i] = 0;
        step[i] = -1;
    }
    b = 0;
    e = 0;
}
 
void BFS( int table[], int s, int n )
{
    int u, v;
 
    ENQ( s - 1 );
    while( !isemp() ) {
        u = DEQ();
        if ( step[u] == -1 )
            step[u] = 0;
                     
        for( v=0; v<n; ++v ) {
            if ( table[u*N+v] == 1 && step[v] == -1 ) {
                step[v] = step[u] + 1;
                ENQ( v );
            }
        }
    }
}
 

Measured memory_bytes: 648
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    ll dp[n + 5][k + 5] = {};
    ll ans = 0;
    for (int i = 0 ; i < n ; i++) {
        int x;
        cin >> x;
        for (int j = 1 ; j <= k - x ; j++) {
            dp[i + 1][j + x] += dp[i][j];
        }
        for (int j = 1 ; j <= k ; j++) {
            dp[i + 1][j] += dp[i][j];
        }
        if (x <= k) {
            dp[i + 1][x] += i + 1;
        }
        for (int j = 1 ; j <= k ; j++) {
            dp[i + 1][j] %= mod;
        }
        ans += dp[i + 1][k];
    }
    cout << ans % mod << endl;
}


Measured memory_bytes: 70784
#include <cstdio>

int main()
{
    int c[3][3];
    int i,j;
    int flag=1;;

    for(i=0;i<3;i++)
        for(j=0;j<3;j++)
            scanf("%d",&c[i][j]);

    for(i=0;i<2;i++){
        if(flag&&((c[i][0]-c[i+1][0])!=(c[i][1]-c[i+1][1])||(c[i][2]-c[i+1][2])!=(c[i][1]-c[i+1][1])))
            flag=0;
        if(flag&&((c[0][i]-c[0][i+1])!=(c[1][i]-c[1][i+1])||(c[2][i]-c[2][i+1])!=(c[1][i]-c[1][i+1])))
            flag=0;
    }

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

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<cctype>
#include<queue>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long LL;
#define N 2010
#define INF 0x3f3f3f

int n;
int maps[N][N];
int dist[N], vis[N];

void Init(int m)
{
    for(int i=0; i<=m; i++)
        for(int j=0; j<=m; j++)
        maps[i][j]=i==j ? 0 : INF;
}

void dij(int s, int m)
{
    for(int i=0; i<=m; i++)
        dist[i]=maps[s][i];
    memset(vis, 0, sizeof(vis));
    vis[s]=1;

    for(int i=0; i<=m; i++)
    {
        int Min=INF, index=-1;
        for(int j=0; j<=m; j++)
        {
            if(!vis[j]&&dist[j]<Min)
            {
                Min=dist[j];
                index=j;
            }
        }
        if(index==-1) continue;
        vis[index]=1;
        for(int j=0; j<=m; j++)
        {
            if(!vis[j]&&dist[j]>Min+maps[index][j])
                dist[j]=Min+maps[index][j];
        }
    }
}

int main()
{
    int a, b, c, Max, index, sum;
    while(scanf("%d", &n), n)
    {
        Init(1100);
        Max=-1;
        for(int i=1; i<=n; i++)
        {
            scanf("%d%d%d", &a, &b, &c);
            maps[a][b]=maps[b][a]=min(maps[a][b], c);
            Max=max(Max, a);
            Max=max(Max, b);
        }
        int s;
        sum=INF;
        for(int i=0; i<=Max; i++)
        {
            dij(i, Max);
            s=0;
            for(int j=0; j<=Max; j++)
                s+=dist[j];
            if(s<sum)
            {
                index=i;
                sum=s;
            }
        }
        printf("%d %d\n", index, sum);
    }
    return 0;
}

Measured memory_bytes: 11420